/* ============================================================
   TISMA — Mobile-first Stylesheet
   ============================================================ */

/* ── Variables ──────────────────────────────────────────── */
:root {
  --sidebar-w: 256px;
  --sidebar-bg: #0f172a;
  --sidebar-border: rgba(255,255,255,.07);
  --nav-hover: rgba(255,255,255,.06);
  --nav-active-bg: rgba(37,99,235,.18);

  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --border-light: #f1f5f9;

  --text: #0f172a;
  --text-2: #475569;
  --text-3: #94a3b8;

  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #dbeafe;

  --success: #10b981;
  --success-light: #d1fae5;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --info: #06b6d4;
  --info-light: #cffafe;

  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.07);
  --shadow: 0 4px 12px rgba(0,0,0,.1);
  --shadow-lg: 0 16px 40px rgba(0,0,0,.16);

  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --t: 160ms cubic-bezier(.4,0,.2,1);

  --topbar-h: 56px;
  --bottomnav-h: 62px;
}

/* ── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font); background: var(--bg);
  color: var(--text); line-height: 1.5;
  overscroll-behavior: none;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; border: none; background: none; }
input, select, textarea { font-family: inherit; }
ul { list-style: none; }

/* ── Utils ──────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ══════════════════════════════════════════════════════════
   LOGIN
══════════════════════════════════════════════════════════ */
.login-screen {
  min-height: 100vh; min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #0f172a 0%, #1e3a5f 55%, #1e293b 100%);
  padding: 20px;
}
.login-card {
  background: var(--surface); border-radius: var(--radius-xl);
  padding: 36px 28px; width: 100%; max-width: 400px;
  box-shadow: var(--shadow-lg);
}
.login-logo {
  display: flex; align-items: center; gap: 12px;
  font-size: 22px; font-weight: 800; margin-bottom: 28px;
}
.logo-mark {
  width: 44px; height: 44px; flex-shrink: 0;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 20px;
  box-shadow: 0 4px 12px rgba(37,99,235,.35);
}
.login-card h2 { font-size: 22px; font-weight: 800; margin-bottom: 6px; }
.login-card > p { color: var(--text-2); font-size: 14px; margin-bottom: 24px; }
.login-card form { display: flex; flex-direction: column; gap: 14px; }
.form-error {
  background: var(--danger-light); color: var(--danger);
  padding: 12px 14px; border-radius: var(--radius);
  font-size: 13px; border-left: 3px solid var(--danger);
}
.btn-full { width: 100%; margin-top: 4px; }

/* ══════════════════════════════════════════════════════════
   APP SHELL  ←  the key layout fix
   sidebar (fixed/sticky) + app-body (flex-col, flex:1)
══════════════════════════════════════════════════════════ */
.app-shell {
  display: flex;
  height: 100vh; height: 100dvh;
  overflow: hidden;
}

/* ── SIDEBAR ────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--sidebar-bg);
  display: flex; flex-direction: column;
  height: 100%; overflow-y: auto;
  z-index: 200;
  /* desktop: in-flow sticky column */
}
.sidebar-header {
  display: flex; align-items: center; gap: 12px;
  padding: 22px 18px 18px; border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}
.logo-text { color: #fff; font-weight: 800; font-size: 17px; }
.sidebar-nav { flex: 1; padding: 10px 8px; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: var(--radius);
  color: #94a3b8; font-size: 14px; font-weight: 500;
  transition: background var(--t), color var(--t);
  -webkit-tap-highlight-color: transparent;
}
.nav-item:hover { background: var(--nav-hover); color: #e2e8f0; }
.nav-item.active { background: var(--nav-active-bg); color: #fff; }
.nav-item i { width: 19px; height: 19px; flex-shrink: 0; }
.nav-separator {
  padding: 14px 14px 4px; color: #475569;
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em;
}
.sidebar-footer {
  padding: 12px; border-top: 1px solid var(--sidebar-border);
  display: flex; align-items: center; gap: 8px; flex-shrink: 0;
}
.user-info { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.user-avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
}
.user-details { min-width: 0; }
.user-name { display: block; color: #e2e8f0; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { display: block; color: #64748b; font-size: 11px; text-transform: capitalize; }
.logout-btn { color: #64748b !important; }

/* ── SIDEBAR OVERLAY ────────────────────────────────────── */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.55); z-index: 190;
  backdrop-filter: blur(3px);
}
.sidebar-overlay.open { display: block; }

/* ── APP BODY ───────────────────────────────────────────── */
.app-body {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
  height: 100%; overflow: hidden;
}

/* ── TOP BAR (hidden on desktop) ───────────────────────── */
.top-bar {
  display: none;
  height: var(--topbar-h); flex-shrink: 0;
  align-items: center; gap: 4px;
  padding: 0 8px 0 4px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.hamburger {
  width: 48px; height: 48px; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-2); flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.hamburger i { width: 22px; height: 22px; }
.top-bar-title {
  flex: 1; font-size: 17px; font-weight: 800;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  padding: 0 4px;
}
.top-bar-right { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }

/* ── MAIN CONTENT ───────────────────────────────────────── */
.main-content {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}
#view-container {
  padding: 24px;
  width: 100%;
  max-width: 1400px;
}

/* ── BOTTOM NAV (hidden on desktop) ────────────────────── */
.bottom-nav {
  display: none;
  height: var(--bottomnav-h);
  flex-shrink: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 0 4px;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.bottom-nav { /* flex set in mobile media query */ }
.bnav-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 3px; padding: 6px 4px;
  color: var(--text-3); border-radius: var(--radius);
  margin: 4px 2px;
  transition: background var(--t), color var(--t);
  -webkit-tap-highlight-color: transparent;
  text-decoration: none;
}
.bnav-item i { width: 22px; height: 22px; }
.bnav-item span { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.bnav-item.active { color: var(--primary); background: var(--primary-light); }

/* ── FAB (hidden on desktop) ────────────────────────────── */
.fab {
  display: none;
  position: fixed;
  right: 16px;
  bottom: calc(var(--bottomnav-h) + 16px + env(safe-area-inset-bottom, 0px));
  width: 56px; height: 56px; border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff; border: none;
  align-items: center; justify-content: center;
  box-shadow: 0 4px 20px rgba(37,99,235,.45);
  z-index: 80;
  transition: transform var(--t), box-shadow var(--t);
  -webkit-tap-highlight-color: transparent;
}
.fab:active { transform: scale(.92); box-shadow: 0 2px 10px rgba(37,99,235,.35); }
.fab i { width: 26px; height: 26px; }

/* ══════════════════════════════════════════════════════════
   PAGE HEADER
══════════════════════════════════════════════════════════ */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; gap: 12px;
}
.page-header h1 { font-size: 22px; font-weight: 800; }
.page-header .actions { display: flex; align-items: center; gap: 8px; }

/* ══════════════════════════════════════════════════════════
   BUTTONS
══════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 18px; border-radius: var(--radius);
  font-size: 14px; font-weight: 600;
  border: 1.5px solid transparent; white-space: nowrap; min-height: 42px;
  transition: all var(--t); -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}
.btn-sm { padding: 6px 13px; font-size: 13px; min-height: 34px; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-primary:active { transform: scale(.97); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #dc2626; }
.btn-ghost { color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-icon {
  width: 38px; height: 38px; min-height: unset;
  border-radius: var(--radius); padding: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-2); transition: background var(--t), color var(--t);
  -webkit-tap-highlight-color: transparent;
}
.btn-icon:hover { background: var(--surface-2); color: var(--text); }
.btn-icon i { width: 17px; height: 17px; }
.table-link-btn {
  color: var(--primary);
  font: inherit;
  text-align: left;
  padding: 0;
}
.table-link-btn:hover { text-decoration: underline; }
.machine-row-clickable { cursor: pointer; }
.machine-row-clickable:hover { background: var(--surface-2); }
.btn i { width: 16px; height: 16px; }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn-full { width: 100%; }

/* ══════════════════════════════════════════════════════════
   CARDS
══════════════════════════════════════════════════════════ */
.card {
  background: var(--surface); border-radius: var(--radius-lg);
  border: 1px solid var(--border); box-shadow: var(--shadow-sm); overflow: hidden;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.card-header h3 { font-size: 15px; font-weight: 700; }
.card-body { padding: 18px; }

/* ── Stats ──────────────────────────────────────────────── */
.stats-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 12px; margin-bottom: 20px;
}
.stat-card {
  background: var(--surface); border-radius: var(--radius-lg);
  border: 1px solid var(--border); box-shadow: var(--shadow-sm);
  padding: 16px; display: flex; flex-direction: column; gap: 10px;
}
.stat-icon {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
}
.stat-icon i { width: 20px; height: 20px; }
.stat-value { font-size: 28px; font-weight: 900; line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-2); font-weight: 500; }
.stat-icon.blue  { background: var(--primary-light); color: var(--primary); }
.stat-icon.green { background: var(--success-light); color: var(--success); }
.stat-icon.orange{ background: var(--warning-light); color: var(--warning); }
.stat-icon.red   { background: var(--danger-light);  color: var(--danger); }
.stat-icon.cyan  { background: var(--info-light);    color: var(--info); }

/* ══════════════════════════════════════════════════════════
   TABLES
══════════════════════════════════════════════════════════ */
.table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left; padding: 10px 14px;
  font-size: 11px; font-weight: 700; color: var(--text-2);
  text-transform: uppercase; letter-spacing: .06em;
  background: var(--surface-2); border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td { padding: 12px 14px; border-bottom: 1px solid var(--border-light); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
tbody tr { transition: background var(--t); }
.actions-col { width: 1px; white-space: nowrap; }
.row-actions { display: flex; align-items: center; gap: 2px; justify-content: flex-end; }

/* ══════════════════════════════════════════════════════════
   BADGES
══════════════════════════════════════════════════════════ */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 700; white-space: nowrap;
}
.badge-blue   { background: var(--primary-light); color: var(--primary); }
.badge-green  { background: var(--success-light); color: var(--success); }
.badge-orange { background: var(--warning-light); color: var(--warning); }
.badge-red    { background: var(--danger-light);  color: var(--danger); }
.badge-gray   { background: #f1f5f9; color: #475569; }
.badge-cyan   { background: var(--info-light);    color: var(--info); }

/* ══════════════════════════════════════════════════════════
   FORMS
══════════════════════════════════════════════════════════ */
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field input:not([type="checkbox"]):not([type="radio"]), .field select, .field textarea {
  padding: 10px 12px; border: 1.5px solid var(--border);
  border-radius: var(--radius); background: var(--surface); color: var(--text);
  font-size: 15px; width: 100%; min-height: 44px;
  transition: border-color var(--t), box-shadow var(--t);
  -webkit-appearance: none; appearance: none;
}
.field input:not([type="checkbox"]):not([type="radio"]):focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.field textarea { resize: vertical; min-height: 80px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1/-1; }

.search-bar { position: relative; display: flex; align-items: center; }
.search-bar i { position: absolute; left: 11px; width: 16px; height: 16px; color: var(--text-3); pointer-events: none; }
.search-bar input {
  padding: 10px 12px 10px 36px; border: 1.5px solid var(--border);
  border-radius: var(--radius); background: var(--surface);
  color: var(--text); font-size: 14px; width: 100%; min-height: 44px;
  -webkit-appearance: none; appearance: none;
  transition: border-color var(--t);
}
.search-bar input:focus { outline: none; border-color: var(--primary); }

.toolbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px; gap: 10px;
}
.toolbar-left, .toolbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ── Tabs ───────────────────────────────────────────────── */
.tabs {
  display: flex; border-bottom: 2px solid var(--border);
  margin-bottom: 20px; overflow-x: auto;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab-btn {
  padding: 10px 16px; font-size: 13.5px; font-weight: 600;
  color: var(--text-2); white-space: nowrap; min-height: 44px;
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  transition: all var(--t); -webkit-tap-highlight-color: transparent;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ══════════════════════════════════════════════════════════
   MODAL (bottom sheet on all screens)
══════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15,23,42,.55);
  display: flex; align-items: flex-end;
  z-index: 1000; backdrop-filter: blur(4px);
}
.modal {
  background: var(--surface);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  width: 100%; max-height: 92vh; max-height: 92dvh;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: sheetUp .22s cubic-bezier(.25,.46,.45,.94);
}
.modal-handle {
  width: 40px; height: 4px; background: var(--border);
  border-radius: 99px; margin: 10px auto 0; flex-shrink: 0;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px 10px; flex-shrink: 0;
}
.modal-header h3 { font-size: 17px; font-weight: 800; }
.modal-body {
  padding: 4px 20px 20px; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex; flex-direction: column; gap: 14px; flex: 1;
}
.modal-footer {
  display: flex; gap: 10px;
  padding: 12px 20px calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border); flex-shrink: 0;
}
.modal-footer .btn { flex: 1; }
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: none; } }

/* ══════════════════════════════════════════════════════════
   TOAST
══════════════════════════════════════════════════════════ */
.toast-container {
  position: fixed; left: 12px; right: 12px;
  bottom: calc(var(--bottomnav-h) + 10px + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; gap: 8px; z-index: 2000;
}
.toast {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px; border-radius: var(--radius-lg);
  background: var(--surface); box-shadow: var(--shadow-lg);
  border: 1px solid var(--border); border-left: 4px solid var(--primary);
  font-size: 14px; font-weight: 500;
  animation: toastIn .2s ease;
}
.toast.success { border-left-color: var(--success); }
.toast.error   { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
.toast i { width: 20px; height: 20px; flex-shrink: 0; }
.toast.success i { color: var(--success); }
.toast.error   i { color: var(--danger); }
.toast.warning i { color: var(--warning); }
.toast.info    i { color: var(--primary); }
.toast-msg { flex: 1; }
.toast-close { color: var(--text-3); padding: 4px; cursor: pointer; }
@keyframes toastIn { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ══════════════════════════════════════════════════════════
   MISC
══════════════════════════════════════════════════════════ */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 52px 20px; color: var(--text-3); gap: 12px;
}
.empty-state i { width: 48px; height: 48px; }
.empty-state p { font-size: 14px; font-weight: 500; }
.loading {
  display: flex; align-items: center; justify-content: center;
  padding: 40px; color: var(--text-3); gap: 10px;
}
.spinner {
  width: 22px; height: 22px; border: 2.5px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin .7s linear infinite; flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

.back-btn {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--text-2); font-size: 13px; font-weight: 600;
  margin-bottom: 12px; padding: 4px 0;
  -webkit-tap-highlight-color: transparent;
}
.back-btn:hover { color: var(--text); }
.back-btn i { width: 16px; height: 16px; }

.alert {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-radius: var(--radius);
  font-size: 13.5px; margin-bottom: 14px;
}
.alert-warning { background: var(--warning-light); color: #92400e; border: 1px solid #fcd34d; }
.alert i { width: 18px; height: 18px; flex-shrink: 0; }

.stock-bar-wrap { display: flex; align-items: center; gap: 8px; }
.stock-bar { height: 6px; flex: 1; min-width: 40px; background: var(--border); border-radius: 99px; overflow: hidden; }
.stock-bar-fill { height: 100%; border-radius: 99px; }
.stock-bar-fill.ok      { background: var(--success); }
.stock-bar-fill.warning { background: var(--warning); }
.stock-bar-fill.danger  { background: var(--danger); }

.doc-item {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px; border-bottom: 1px solid var(--border-light);
}
.doc-item:last-child { border-bottom: none; }
.doc-icon {
  width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0;
  background: var(--danger-light); color: var(--danger);
  display: flex; align-items: center; justify-content: center;
}
.doc-icon i { width: 19px; height: 19px; }
.doc-info { flex: 1; min-width: 0; }
.doc-name { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-meta { font-size: 11px; color: var(--text-3); margin-top: 2px; }

.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px,1fr)); gap: 16px; }
.info-label { font-size: 11px; color: var(--text-3); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 4px; }
.info-value { font-size: 14px; font-weight: 500; }

.pagination { display: flex; align-items: center; gap: 6px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.page-btn {
  padding: 7px 13px; border-radius: var(--radius); font-size: 13px;
  font-weight: 600; color: var(--text-2); min-width: 38px; min-height: 38px;
  display: flex; align-items: center; justify-content: center;
}
.page-btn:hover { background: var(--surface-2); }
.page-btn.active { background: var(--primary); color: #fff; }

/* Calendar */
.fc { font-family: var(--font) !important; }
.fc .fc-toolbar-title { font-size: 15px !important; font-weight: 800 !important; }
.fc .fc-toolbar { flex-wrap: wrap; gap: 8px; }
.fc .fc-button {
  background: var(--primary) !important; border-color: var(--primary) !important;
  font-size: 13px !important;
}
.fc .fc-daygrid-event { border-radius: 5px !important; font-size: 11px !important; }

.client-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.client-chip {
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13px;
  min-height: 38px;
  transition: all var(--t);
}
.client-chip:hover { border-color: var(--primary); color: var(--primary); }
.client-chip.selected {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
  font-weight: 600;
}

/* ══════════════════════════════════════════════════════════
   RESPONSIVE — TABLET ≤1024px
══════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
  :root { --sidebar-w: 220px; }
  #view-container { padding: 20px; }
  .stats-grid { grid-template-columns: repeat(3,1fr); }
}

/* ══════════════════════════════════════════════════════════
   RESPONSIVE — MOBILE ≤768px
══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {

  /* ── Sidebar → fixed off-screen drawer ─────────────────── */
  .sidebar {
    position: fixed;
    top: 0; bottom: 0; left: 0;
    width: min(var(--sidebar-w), 80vw);
    transform: translateX(-110%);
    transition: transform .25s cubic-bezier(.25,.46,.45,.94);
    box-shadow: none;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  /* ── Show mobile chrome ─────────────────────────────────── */
  .top-bar { display: flex; }
  .bottom-nav { display: flex; }
  .fab { display: flex; }

  /* ── Content padding ────────────────────────────────────── */
  #view-container {
    padding: 14px;
    padding-bottom: calc(var(--bottomnav-h) + 72px + env(safe-area-inset-bottom, 0px));
  }

  /* ── Page header on mobile ──────────────────────────────── */
  .page-header { margin-bottom: 14px; }
  /* Hide desktop h1 — title shown in top-bar instead */
  .page-header h1 { display: none; }
  /* But show it if no top-bar (fallback) */

  /* ── Stats: 2 columns ───────────────────────────────────── */
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
  .stat-card { padding: 14px; gap: 8px; }
  .stat-value { font-size: 24px !important; }
  .stat-label { font-size: 11px; }

  /* ── Table → stacked card layout ───────────────────────── */
  .table-wrapper { border-radius: var(--radius-lg); overflow: hidden; }
  .table-wrapper table { display: block; }
  .table-wrapper thead { display: none; }
  .table-wrapper tbody { display: block; }
  .table-wrapper tbody tr {
    display: block;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    position: relative;
  }
  .table-wrapper tbody tr:last-child { border-bottom: none; }
  .table-wrapper tbody td {
    display: flex; align-items: baseline;
    padding: 3px 0; border: none; font-size: 14px;
    gap: 8px;
    width: 100%;
    box-sizing: border-box;
    min-width: 0;
  }
  .table-wrapper tbody td::before {
    content: attr(data-label);
    font-size: 10px; font-weight: 700; color: var(--text-3);
    text-transform: uppercase; letter-spacing: .05em;
    min-width: 80px; flex-shrink: 0;
  }
  /* Actions row: right-aligned, no label */
  .table-wrapper td.actions-col {
    display: flex;
    width: 100%;
    justify-content: flex-end;
    padding-top: 8px;
  }
  .table-wrapper td.actions-col::before { display: none; }
  .table-wrapper td.actions-col .row-actions {
    width: 100%;
    justify-content: flex-end;
    margin-left: auto;
    gap: 6px;
  }
  .table-wrapper td.actions-col > .btn-icon,
  .table-wrapper td.actions-col > a.btn-icon {
    margin-left: auto;
  }

  /* ── Forms ──────────────────────────────────────────────── */
  .form-grid { grid-template-columns: 1fr; gap: 12px; }

  /* ── Toolbar ────────────────────────────────────────────── */
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar-left, .toolbar-right { width: 100%; }
  .toolbar select, .toolbar-left select {
    width: 100%; padding: 10px 12px; border: 1.5px solid var(--border);
    border-radius: var(--radius); font-size: 14px; min-height: 44px;
    background: var(--surface); -webkit-appearance: none; appearance: none;
  }

  /* ── Dashboard cards ────────────────────────────────────── */
  .dashboard-2col { grid-template-columns: 1fr !important; }

  /* ── Tabs ───────────────────────────────────────────────── */
  .tab-btn { padding: 10px 12px; font-size: 13px; }

  /* ── Toast above bottom nav ─────────────────────────────── */
  .toast-container {
    bottom: calc(var(--bottomnav-h) + 10px + env(safe-area-inset-bottom, 0px));
  }

  /* ── Info grid ──────────────────────────────────────────── */
  .info-grid { grid-template-columns: 1fr 1fr; }

  /* ── Card body ──────────────────────────────────────────── */
  .card-body { padding: 16px; }
  .card-header { padding: 12px 16px; }
}

/* ── Extra small ≤390px ─────────────────────────────────── */
@media (max-width: 390px) {
  .bnav-item span { display: none; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
