/* ============================================================
   Lab Inventory — Stylesheet
   ============================================================ */

/* ── Custom properties ─────────────────────────────────────── */
:root {
  --sidebar-w: 220px;
  --sidebar-bg: #1e2d3d;
  --sidebar-border: #2a3f54;
  --sidebar-text: #94a8bb;
  --sidebar-active-bg: #2a3f54;
  --sidebar-active-text: #ffffff;
  --sidebar-hover-bg: #243346;
  --accent: #4a9eff;

  --content-bg: #f0f4f8;
  --card-bg: #ffffff;
  --border: #e2e8f0;
  --border-light: #f1f5f9;

  --text-primary: #1a202c;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;

  --green: #10b981;
  --green-bg: #d1fae5;
  --green-text: #065f46;
  --yellow: #f59e0b;
  --yellow-bg: #fef3c7;
  --yellow-text: #92400e;
  --red: #ef4444;
  --red-bg: #fee2e2;
  --red-text: #991b1b;
  --blue: #3b82f6;
  --blue-bg: #dbeafe;
  --blue-text: #1e40af;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.06);
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);

  --radius-sm: 4px;
  --radius: 8px;
  --radius-lg: 12px;

  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', Consolas, monospace;

  --transition: 150ms ease;
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: var(--font);
  color: var(--text-primary);
  background: var(--content-bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }
a { color: inherit; text-decoration: none; }
img, svg { display: block; }

/* ── App shell ─────────────────────────────────────────────── */
#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ───────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 100;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}
.sidebar-logo svg {
  width: 32px; height: 32px; flex-shrink: 0;
}
.sidebar-logo-text { flex: 1; min-width: 0; }
.sidebar-logo-text strong {
  display: block;
  color: #fff;
  font-size: 0.95rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-logo-text span {
  display: block;
  color: var(--sidebar-text);
  font-size: 0.72rem;
  white-space: nowrap;
}

#sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}
#sidebar-nav::-webkit-scrollbar { width: 4px; }
#sidebar-nav::-webkit-scrollbar-track { background: transparent; }
#sidebar-nav::-webkit-scrollbar-thumb { background: var(--sidebar-border); border-radius: 2px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  color: var(--sidebar-text);
  font-size: 0.88rem;
  font-weight: 500;
  border-radius: 0;
  transition: background var(--transition), color var(--transition);
  position: relative;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.nav-item:hover { background: var(--sidebar-hover-bg); color: #fff; }
.nav-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; opacity: 0.85; }
.nav-item.active svg { opacity: 1; }
.nav-badge {
  margin-left: auto;
  background: var(--red);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

.sidebar-footer {
  border-top: 1px solid var(--sidebar-border);
  padding: 12px 16px;
  flex-shrink: 0;
}
#realtime-indicator {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.75rem;
  color: var(--sidebar-text);
  margin-bottom: 10px;
}
.rt-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--text-muted);
  transition: background 0.3s;
}
.rt-dot.connected { background: var(--green); box-shadow: 0 0 0 2px rgba(16,185,129,0.25); }
.rt-dot.error { background: var(--red); }

#user-display {
  display: flex;
  align-items: center;
  gap: 8px;
}
#user-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
#user-info { flex: 1; min-width: 0; }
#current-user-name {
  display: block;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#change-user-btn {
  background: none; border: none;
  color: var(--sidebar-text);
  font-size: 0.72rem;
  padding: 0;
  cursor: pointer;
  transition: color var(--transition);
}
#change-user-btn:hover { color: #fff; }

/* ── Main content ──────────────────────────────────────────── */
#main-content {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.view { display: none; flex-direction: column; flex: 1; }
.view.active { display: flex; }

.view-header {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 18px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.view-header h1 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  flex: 1;
}
.view-body {
  padding: 20px 24px;
  flex: 1;
}

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 14px 18px 12px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 10px;
}
.card-header h2 {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
  flex: 1;
}
.card-body { padding: 16px 18px; }

/* ── Stats bar ─────────────────────────────────────────────── */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.stat-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon svg { width: 20px; height: 20px; }
.stat-icon.blue   { background: var(--blue-bg); color: var(--blue); }
.stat-icon.red    { background: var(--red-bg);  color: var(--red); }
.stat-icon.green  { background: var(--green-bg); color: var(--green); }
.stat-icon.yellow { background: var(--yellow-bg); color: var(--yellow); }
.stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1;
  color: var(--text-primary);
}
.stat-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ── Dashboard grid ────────────────────────────────────────── */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
.dashboard-grid .card.full-width { grid-column: 1 / -1; }

/* ── Alert cards ───────────────────────────────────────────── */
.alert-list { display: flex; flex-direction: column; gap: 8px; }
.alert-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
}
.alert-item.overdue  { background: var(--red-bg);    border-color: #fca5a5; }
.alert-item.due-soon { background: var(--yellow-bg); border-color: #fcd34d; }
.alert-item.low      { background: var(--red-bg);    border-color: #fca5a5; }
.alert-item.warning  { background: var(--yellow-bg); border-color: #fcd34d; }

.alert-status-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.overdue  .alert-status-dot { background: var(--red); }
.due-soon .alert-status-dot { background: var(--yellow); }
.low      .alert-status-dot { background: var(--red); }
.warning  .alert-status-dot { background: var(--yellow); }

.alert-info { flex: 1; min-width: 0; }
.alert-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.alert-sub {
  font-size: 0.75rem;
  color: var(--text-secondary);
}
.alert-days {
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}
.overdue  .alert-days { color: var(--red-text); }
.due-soon .alert-days { color: var(--yellow-text); }
.low      .alert-days { color: var(--red-text); }
.warning  .alert-days { color: var(--yellow-text); }

.empty-state {
  text-align: center;
  padding: 24px 16px;
  color: var(--text-muted);
  font-size: 0.85rem;
}
.empty-state svg {
  width: 32px; height: 32px;
  margin: 0 auto 8px;
  opacity: 0.4;
}

/* ── Activity feed ─────────────────────────────────────────── */
.activity-list { display: flex; flex-direction: column; }
.activity-item {
  display: flex;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border-light);
}
.activity-item:last-child { border-bottom: none; }
.activity-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--blue-bg);
  color: var(--blue);
  font-size: 0.68rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}
.activity-body { flex: 1; min-width: 0; }
.activity-action {
  font-size: 0.82rem;
  color: var(--text-primary);
}
.activity-action strong { font-weight: 600; }
.activity-details {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.activity-time {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 3px;
}

/* ── Toolbar (search + filters + actions) ─────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.search-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
}
.search-wrap svg {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  width: 15px; height: 15px;
  color: var(--text-muted);
  pointer-events: none;
}
.search-wrap input {
  width: 100%;
  padding: 7px 12px 7px 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  background: var(--card-bg);
  color: var(--text-primary);
  transition: border-color var(--transition);
}
.search-wrap input:focus { outline: none; border-color: var(--accent); }

select.filter-select {
  padding: 7px 28px 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  background: var(--card-bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 8px center;
  -webkit-appearance: none;
  appearance: none;
  color: var(--text-primary);
  cursor: pointer;
  transition: border-color var(--transition);
}
select.filter-select:focus { outline: none; border-color: var(--accent); }

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  line-height: 1.4;
}
.btn svg { width: 14px; height: 14px; flex-shrink: 0; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover:not(:disabled) { background: #2d87f0; border-color: #2d87f0; }

.btn-success {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}
.btn-success:hover:not(:disabled) { background: #0da271; border-color: #0da271; }

.btn-danger {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}
.btn-danger:hover:not(:disabled) { background: #dc2626; border-color: #dc2626; }

.btn-secondary {
  background: var(--card-bg);
  color: var(--text-secondary);
  border-color: var(--border);
}
.btn-secondary:hover:not(:disabled) { background: var(--border-light); color: var(--text-primary); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
  padding: 5px 8px;
}
.btn-ghost:hover:not(:disabled) { background: var(--border-light); color: var(--text-primary); }

.btn-sm {
  padding: 4px 10px;
  font-size: 0.78rem;
}

/* ── Table ─────────────────────────────────────────────────── */
.table-wrap {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
thead th {
  background: var(--border-light);
  padding: 10px 14px;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
  color: var(--text-primary);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #fafafa; }
.td-actions {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
}

/* ── Status badges ─────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}
.badge-green  { background: var(--green-bg);  color: var(--green-text); }
.badge-yellow { background: var(--yellow-bg); color: var(--yellow-text); }
.badge-red    { background: var(--red-bg);    color: var(--red-text); }
.badge-blue   { background: var(--blue-bg);   color: var(--blue-text); }
.badge-grey   { background: #f1f5f9; color: #64748b; }
.badge-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.badge-green  .badge-dot { background: var(--green); }
.badge-yellow .badge-dot { background: var(--yellow); }
.badge-red    .badge-dot { background: var(--red); }
.badge-blue   .badge-dot { background: var(--blue); }

/* ── Stock indicator ───────────────────────────────────────── */
.stock-bar-wrap { display: flex; align-items: center; gap: 8px; }
.stock-bar {
  flex: 1;
  height: 5px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  min-width: 60px;
}
.stock-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s;
}
.stock-bar-fill.ok      { background: var(--green); }
.stock-bar-fill.warning { background: var(--yellow); }
.stock-bar-fill.low     { background: var(--red); }

/* ── Forms ─────────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 5px;
}
.form-group label .required { color: var(--red); margin-left: 2px; }
.form-control {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.87rem;
  color: var(--text-primary);
  background: var(--card-bg);
  transition: border-color var(--transition), box-shadow var(--transition);
  line-height: 1.5;
}
.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(74,158,255,0.15);
}
.form-control:disabled { background: var(--border-light); opacity: 0.7; cursor: not-allowed; }
select.form-control { -webkit-appearance: none; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 28px; }
textarea.form-control { resize: vertical; min-height: 70px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row.three { grid-template-columns: 1fr 1fr 1fr; }
.form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding-top: 8px;
  border-top: 1px solid var(--border-light);
  margin-top: 4px;
}
.form-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 3px;
}

/* ── Inline stock edit ─────────────────────────────────────── */
.inline-stock-form {
  display: flex;
  align-items: center;
  gap: 6px;
}
.inline-stock-form input[type="number"] {
  width: 80px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  text-align: center;
}
.inline-stock-form input:focus { outline: none; border-color: var(--accent); }

/* ── Detail panel ──────────────────────────────────────────── */
.detail-panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 480px;
  max-width: 100vw;
  background: var(--card-bg);
  box-shadow: var(--shadow-lg);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transform: translateX(100%);
  transition: transform 0.2s ease;
}
.detail-panel.open { transform: translateX(0); }
.detail-panel-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.detail-panel-header h2 {
  font-size: 1rem;
  font-weight: 700;
  flex: 1;
  color: var(--text-primary);
}
.detail-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}
.detail-section { margin-bottom: 20px; }
.detail-section h3 {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 10px;
}
.detail-field {
  display: flex;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.85rem;
}
.detail-field:last-child { border-bottom: none; }
.detail-field-label {
  color: var(--text-secondary);
  flex-shrink: 0;
  width: 130px;
}
.detail-field-value {
  color: var(--text-primary);
  font-weight: 500;
  flex: 1;
}

/* ── Maintenance / reorder history ────────────────────────── */
.log-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
}
.log-item:last-child { border-bottom: none; }
.log-item-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.log-item-date {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
}
.log-item-by {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-left: auto;
}
.log-item-desc {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* ── Overlay backdrop ──────────────────────────────────────── */
.panel-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.25);
  z-index: 190;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.panel-backdrop.visible {
  opacity: 1;
  pointer-events: auto;
}

/* ── Modal ─────────────────────────────────────────────────── */
#modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}
#modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}
#modal-container {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 540px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  transform: scale(0.97) translateY(-8px);
  transition: transform 0.15s;
}
#modal-overlay.open #modal-container {
  transform: scale(1) translateY(0);
}
#modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
#modal-title {
  font-size: 1rem;
  font-weight: 700;
  flex: 1;
  color: var(--text-primary);
}
#modal-close {
  background: none; border: none;
  width: 28px; height: 28px;
  border-radius: var(--radius-sm);
  font-size: 1.2rem;
  color: var(--text-muted);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition), color var(--transition);
}
#modal-close:hover { background: var(--border-light); color: var(--text-primary); }
#modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

/* ── Confirm dialog ────────────────────────────────────────── */
#confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s;
}
#confirm-overlay.open { opacity: 1; pointer-events: auto; }
#confirm-box {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 380px;
  width: 100%;
  box-shadow: var(--shadow-lg);
}
#confirm-box h3 { font-size: 0.95rem; font-weight: 700; margin-bottom: 8px; }
#confirm-box p  { font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 18px; }
.confirm-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ── User selection overlay ────────────────────────────────── */
#user-select-overlay {
  position: fixed;
  inset: 0;
  background: rgba(16,25,36,0.85);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
#user-select-overlay.hidden { display: none; }
#user-select-box {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 32px;
  max-width: 380px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  text-align: center;
}
#user-select-box .select-logo {
  width: 52px; height: 52px;
  background: var(--sidebar-bg);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
}
#user-select-box h2 { font-size: 1.1rem; font-weight: 700; margin-bottom: 6px; }
#user-select-box p  { font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 20px; }
#user-select-list { display: flex; flex-direction: column; gap: 8px; }
.user-select-btn {
  width: 100%;
  padding: 11px 16px;
  background: var(--border-light);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all var(--transition);
  text-align: left;
}
.user-select-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.user-select-btn .user-initials-badge {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.75rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.user-select-btn:hover .user-initials-badge { background: rgba(255,255,255,0.25); }
.user-select-btn--last {
  border-color: var(--accent);
  background: var(--blue-bg);
}
.user-select-name { flex: 1; }
.user-select-last-tag {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--blue-text);
  background: var(--blue-bg);
  border: 1px solid var(--accent);
  border-radius: 99px;
  padding: 1px 8px;
  white-space: nowrap;
}
.user-select-btn--last:hover .user-select-last-tag {
  color: #fff;
  background: rgba(255,255,255,0.2);
  border-color: rgba(255,255,255,0.4);
}

/* ── Offline banner ────────────────────────────────────────── */
#offline-banner {
  background: #374151;
  color: #fff;
  text-align: center;
  padding: 8px 16px;
  font-size: 0.82rem;
  font-weight: 600;
  flex-shrink: 0;
  position: relative;
  z-index: 50;
}
#offline-banner.hidden { display: none; }

/* ── Toast notifications ───────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 600;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: #1e2d3d;
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 240px;
  max-width: 360px;
  pointer-events: auto;
  animation: toast-in 0.2s ease;
  border-left: 3px solid transparent;
}
.toast.success { border-left-color: var(--green); }
.toast.error   { border-left-color: var(--red); }
.toast.warning { border-left-color: var(--yellow); }
.toast.info    { border-left-color: var(--accent); }
.toast svg { width: 15px; height: 15px; flex-shrink: 0; }
.toast.success svg { color: var(--green); }
.toast.error   svg { color: var(--red); }
.toast.warning svg { color: var(--yellow); }
.toast.info    svg { color: var(--accent); }
.toast-text { flex: 1; line-height: 1.35; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes toast-out {
  from { opacity: 1; }
  to   { opacity: 0; transform: translateY(4px); }
}

/* ── Locations grid ────────────────────────────────────────── */
.locations-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}
.location-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}
.location-card-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
}
.location-type-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  background: var(--blue-bg);
  color: var(--blue);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.location-type-icon svg { width: 18px; height: 18px; }
.location-card-name { font-size: 0.9rem; font-weight: 700; color: var(--text-primary); }
.location-card-room { font-size: 0.75rem; color: var(--text-secondary); }
.location-card-stats {
  display: flex;
  gap: 12px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  border-top: 1px solid var(--border-light);
  padding-top: 10px;
  margin-top: 4px;
}
.location-card-stats span { display: flex; align-items: center; gap: 4px; }
.location-card-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  justify-content: flex-end;
}

/* ── User cards (settings) ─────────────────────────────────── */
.users-list { display: flex; flex-direction: column; gap: 8px; }
.user-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.user-avatar-lg {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.user-card-info { flex: 1; }
.user-card-name { font-size: 0.9rem; font-weight: 600; color: var(--text-primary); }
.user-card-status { font-size: 0.75rem; color: var(--text-secondary); }
.user-card.inactive .user-avatar-lg { background: var(--text-muted); }
.user-card.inactive .user-card-name { color: var(--text-muted); text-decoration: line-through; }

/* ── Sortable table headers ────────────────────────────────── */
th.sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
th.sortable:hover { background: #e8ecf1; }
.sort-indicator {
  display: inline-flex;
  flex-direction: column;
  gap: 1px;
  margin-left: 5px;
  vertical-align: middle;
  opacity: 0.35;
}
th.sort-asc  .sort-indicator,
th.sort-desc .sort-indicator { opacity: 1; }
.sort-indicator .arrow-up,
.sort-indicator .arrow-down {
  width: 0; height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
}
.sort-indicator .arrow-up   { border-bottom: 5px solid currentColor; }
.sort-indicator .arrow-down { border-top:    5px solid currentColor; }
th.sort-asc  .sort-indicator .arrow-up   { opacity: 1; }
th.sort-asc  .sort-indicator .arrow-down { opacity: 0.25; }
th.sort-desc .sort-indicator .arrow-up   { opacity: 0.25; }
th.sort-desc .sort-indicator .arrow-down { opacity: 1; }

/* ── Skeleton loading ──────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--border-light) 25%, #e8edf3 50%, var(--border-light) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ── Utility ───────────────────────────────────────────────── */
.hidden { display: none !important; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.8rem; }
.font-mono { font-family: var(--font-mono); }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.text-center { text-align: center; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-8 { gap: 8px; }
.flex-1 { flex: 1; }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 900px) {
  :root { --sidebar-w: 60px; }

  .sidebar-logo-text,
  .nav-item span,
  .nav-badge,
  .sidebar-footer #user-info,
  .sidebar-footer #change-user-btn,
  #realtime-indicator span { display: none; }

  .nav-item { padding: 12px; justify-content: center; }
  .nav-item.active::before { top: auto; bottom: 0; left: 0; right: 0; width: auto; height: 3px; border-radius: 2px 2px 0 0; }

  .sidebar-footer { padding: 8px; }
  #user-display { justify-content: center; }
  #realtime-indicator { justify-content: center; }

  .stats-bar { grid-template-columns: 1fr 1fr; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .form-row.three { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .view-body { padding: 14px 14px; }
  .view-header { padding: 14px; }
  .stats-bar { grid-template-columns: 1fr 1fr; gap: 8px; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .search-wrap { min-width: unset; }
  table { font-size: 0.8rem; }
  thead th, tbody td { padding: 8px 10px; }
  .detail-panel { width: 100%; }

  #hamburger { display: flex !important; }
  #sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 300;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }
  #sidebar.mobile-open { transform: translateX(0); }
  :root { --sidebar-w: 220px; }
  .nav-item span { display: inline; }
  .sidebar-logo-text { display: block; }
  .nav-badge { display: inline-block; }
  #user-info { display: block; }
  #change-user-btn { display: block; }
  #realtime-indicator span { display: inline; }
  .nav-item { justify-content: flex-start; padding: 9px 16px; }
  .nav-item.active::before { top: 0; bottom: 0; left: 0; right: auto; width: 3px; height: auto; border-radius: 0 2px 2px 0; }
}

/* ── Mobile header (shown only on small screens) ───────────── */
#mobile-header {
  display: none;
  background: var(--sidebar-bg);
  color: #fff;
  padding: 10px 14px;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  z-index: 50;
}
#hamburger {
  display: none;
  background: none;
  border: none;
  color: #fff;
  padding: 4px;
  cursor: pointer;
}
#hamburger svg { width: 22px; height: 22px; }
#mobile-header-title { font-size: 0.95rem; font-weight: 700; }

@media (max-width: 600px) {
  #mobile-header { display: flex; }
  #app { flex-direction: column; }
  #main-content { overflow-y: auto; }
}
