/* ============================================================
   WeaveTrack — Textile ERP design system
   ============================================================ */

:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #f1f5f9;
  --border: #e2e8f0;
  --border-2: #cbd5e1;
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #64748b;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eff6ff;
  --primary-border: #bfdbfe;
  --sidebar-bg: #0b1220;
  --sidebar-text: #94a3b8;
  --sidebar-text-active: #ffffff;
  --sidebar-hover: #16203a;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --danger-border: #fecaca;
  --success: #16a34a;
  --success-soft: #f0fdf4;
  --success-border: #bbf7d0;
  --warning: #d97706;
  --warning-soft: #fffbeb;
  --warning-border: #fde68a;
  --info: #0891b2;
  --info-soft: #ecfeff;
  --info-border: #a5f3fc;
  --purple: #7c3aed;
  --purple-soft: #f5f3ff;
  --purple-border: #ddd6fe;
  --amber: #b45309;
  --amber-soft: #fffbeb;
  --red: #dc2626;
  --red-soft: #fef2f2;
  --teal: #0d9488;
  --teal-soft: #f0fdfa;
  --teal-border: #99f6e4;
  --orange: #ea580c;
  --orange-soft: #fff7ed;
  --orange-border: #fed7aa;
  --slate: #64748b;
  --slate-soft: #f8fafc;
  --slate-border: #e2e8f0;

  --radius: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 14px rgba(15, 23, 42, .035);
  --shadow: 0 2px 8px rgba(15, 23, 42, .06), 0 10px 24px rgba(15, 23, 42, .035);
  --shadow-md: 0 10px 28px rgba(15, 23, 42, .10);
  --shadow-lg: 0 24px 56px rgba(15, 23, 42, .18);
  --sidebar-w: 248px;
  --sidebar-w-collapsed: 68px;
  --topbar-h: 60px;
  --font: 'Segoe UI Variable', 'Segoe UI', -apple-system, BlinkMacSystemFont, Arial, sans-serif;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f172a;
  --surface: #111c30;
  --surface-2: #17243a;
  --surface-3: #1e2d45;
  --border: #2b3a52;
  --border-2: #40506a;
  --text: #e5edf8;
  --text-2: #b7c3d6;
  --text-3: #8190a8;
  --primary-soft: #172d5b;
  --primary-border: #2857a8;
  --danger-soft: #391b24;
  --success-soft: #143223;
  --warning-soft: #362912;
  --info-soft: #12313b;
  --purple-soft: #271d46;
  --amber-soft: #342712;
  --red-soft: #391b24;
  --teal-soft: #12342f;
  --orange-soft: #3b2418;
  --slate-soft: #17243a;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

::selection { background: #bfdbfe; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; border: 2px solid transparent; background-clip: content-box; }

/* ============================================================
   App shell layout
   ============================================================ */

.app-shell { min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 60;
  transition: width .18s ease, transform .2s ease;
}

.app-shell.sidebar-collapsed .sidebar { width: var(--sidebar-w-collapsed); }

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--topbar-h);
  padding: 0 14px;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
  flex-shrink: 0;
}

.brand-mark {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: #fff;
  font-weight: 800;
  font-size: 17px;
  display: grid; place-items: center;
  flex-shrink: 0;
  box-shadow: 0 3px 10px rgba(37, 99, 235, .4);
}

.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-name { color: #fff; font-weight: 700; font-size: 15px; white-space: nowrap; }
.brand-sub { color: #64748b; font-size: 11px; font-weight: 500; white-space: nowrap; }

.sidebar-collapse { margin-left: auto; color: #64748b; font-size: 15px; }
.sidebar-collapse:hover { color: #e2e8f0; background: rgba(255,255,255,.06); }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px 16px;
}

.nav-group-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #475569;
  padding: 14px 10px 6px;
  white-space: nowrap;
}

.sidebar-collapsed .nav-group-label { font-size: 0; padding: 12px 0 4px; text-align: center; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 11px;
  margin-bottom: 2px;
  border-radius: 7px;
  color: var(--sidebar-text);
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  border: none;
  width: 100%;
  text-align: left;
  position: relative;
}
.nav-item:hover { background: var(--sidebar-hover); color: #e2e8f0; text-decoration: none; }
.nav-item.active { background: rgba(37, 99, 235, .18); color: #fff; }
.nav-item.active::before {
  content: ""; position: absolute; left: 0; top: 20%; bottom: 20%;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--primary);
}
.nav-item svg { flex-shrink: 0; }
.nav-item .nav-text { overflow: hidden; text-overflow: ellipsis; }

.sidebar-collapsed .nav-item { justify-content: center; padding: 10px 0; }
.sidebar-collapsed .nav-text, .sidebar-collapsed .brand-text, .sidebar-collapsed .sidebar-foot .demo-chip { display: none; }

.sidebar-collapsed .sidebar-collapse { margin-left: 0; }
.sidebar-collapsed .sidebar-brand { justify-content: center; padding: 0; gap: 0; }
.sidebar-collapsed .sidebar-brand .brand-mark { margin: 0 auto; }

.sidebar-foot { padding: 12px 14px; border-top: 1px solid rgba(255,255,255,.06); flex-shrink: 0; }

.demo-chip {
  display: inline-flex; align-items: center; gap: 7px;
  color: #93c5fd; font-size: 11.5px; font-weight: 600;
  background: rgba(37, 99, 235, .14);
  padding: 6px 10px; border-radius: 999px;
  border: 1px solid rgba(59, 130, 246, .25);
  white-space: nowrap;
}
.demo-chip .dot { width: 7px; height: 7px; border-radius: 50%; background: #22c55e; animation: pulse-dot 1.8s infinite; }

@keyframes pulse-dot { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(2, 6, 23, .5);
  z-index: 55;
}

.app-main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  min-width: 0;
  display: flex;
  flex-direction: column;
  transition: margin-left .18s ease;
}

.app-shell.sidebar-collapsed .app-main { margin-left: var(--sidebar-w-collapsed); }

/* ============================================================
   Topbar
   ============================================================ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 18px;
}

.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }

.mobile-menu-btn { display: none; }

.search-trigger {
  display: flex; align-items: center; gap: 9px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 12px;
  color: var(--text-3);
  font-size: 13px;
  width: 300px;
  max-width: 40vw;
  transition: border-color .15s, box-shadow .15s;
}
.search-trigger:hover { border-color: var(--border-2); color: var(--text-2); }
.search-trigger:focus-within, .search-trigger:focus { outline: 2px solid var(--primary-border); }
.search-trigger kbd {
  margin-left: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 6px;
  font-size: 10.5px;
  font-family: inherit;
  color: var(--text-3);
}

.breadcrumbs { display: flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--text-3); min-width: 0; }
.breadcrumbs a { color: var(--text-3); font-weight: 500; }
.breadcrumbs a:hover { color: var(--primary); text-decoration: none; }
.breadcrumbs .sep { color: var(--text-3); opacity: .6; }
.breadcrumbs .crumb-current { color: var(--text-2); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.topbar-right { display: flex; align-items: center; gap: 6px; position: relative; }

.icon-btn {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: 8px;
  color: var(--text-2);
  border: 1px solid transparent;
  position: relative;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }

.notif-btn { position: relative; }
.notif-dot {
  position: absolute; top: 7px; right: 7px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--danger);
  border: 2px solid var(--surface);
}

.profile-btn {
  display: flex; align-items: center; gap: 9px;
  padding: 4px 8px 4px 4px;
  border-radius: 10px;
  border: 1px solid transparent;
  transition: background .15s;
}
.profile-btn:hover { background: var(--surface-3); }

.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #4338ca);
  color: #fff;
  font-size: 12px; font-weight: 700;
  display: grid; place-items: center;
  flex-shrink: 0;
}

.profile-meta { display: flex; flex-direction: column; line-height: 1.2; text-align: left; }
.profile-name { font-size: 12.5px; font-weight: 600; color: var(--text); }
.profile-role { font-size: 11px; color: var(--text-3); }

@keyframes pop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* Notification panel — also the shared floating-panel treatment for the
   Quick Actions and Profile ("Admin Singh") menus, so all three topbar
   dropdowns share one visual language. */

.notif-panel, .quick-menu, .profile-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 340px;
  max-width: calc(100vw - 24px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  z-index: 70;
  overflow: hidden;
  animation: pop .14s ease;
}

.notif-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.notif-head h4 { font-size: 13.5px; font-weight: 700; }
.notif-head button { font-size: 11.5px; color: var(--primary); font-weight: 600; }

.notif-list { max-height: 380px; overflow-y: auto; }
.notif-item {
  display: flex; gap: 10px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--surface-3);
  cursor: pointer;
  transition: background .12s;
}
.notif-item:hover { background: var(--surface-2); }
.notif-item.unread { background: var(--primary-soft); }
.notif-item.unread:hover { background: #e0edff; }
.notif-dot-s { width: 7px; height: 7px; border-radius: 50%; margin-top: 6px; flex-shrink: 0; }
.notif-item .notif-title { font-size: 13px; font-weight: 600; }
.notif-item .notif-text { font-size: 12.5px; color: var(--text-2); }
.notif-item .notif-time { font-size: 11px; color: var(--text-3); margin-top: 2px; }

.notif-empty { padding: 26px; text-align: center; color: var(--text-3); font-size: 13px; }

/* Quick Actions / Profile menu items — same list rhythm as .notif-item
   (padding, hover, separators) but single-line, icon-led rows. */
.panel-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 11px 14px;
  border-bottom: 1px solid var(--surface-3);
  font-size: 13px; font-weight: 500;
  color: var(--text-2);
  text-align: left;
  cursor: pointer;
  transition: background .12s;
}
.panel-item:last-child { border-bottom: none; }
.panel-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.panel-item svg { color: var(--text-3); flex-shrink: 0; }
.panel-item.danger { color: var(--danger); }
.panel-item.danger svg { color: var(--danger); }

.profile-menu-head { gap: 10px; }
.profile-menu-head .profile-menu-name { font-size: 13.5px; font-weight: 700; color: var(--text); }
.profile-menu-head .profile-menu-role { font-size: 11.5px; color: var(--text-3); margin-top: 1px; }

/* ============================================================
   Page
   ============================================================ */

.page { padding: 22px 26px 90px; width: 100%; max-width: 1600px; min-width: 0; margin: 0 auto; flex: 1; }
.page:focus { outline: none; }

.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  margin-bottom: 18px;
}
.page-title { font-size: 21px; font-weight: 800; letter-spacing: -.01em; }
.page-sub { font-size: 13px; color: var(--text-3); margin-top: 3px; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.section { margin-bottom: 22px; }
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; flex-wrap: wrap;
  margin-bottom: 12px;
}
.section-title { font-size: 14.5px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.section-title .count-pill {
  background: var(--surface-3); color: var(--text-2);
  font-size: 11px; font-weight: 600;
  padding: 2px 8px; border-radius: 999px;
}
.section-link { font-size: 12.5px; font-weight: 600; }

/* ============================================================
   Buttons
   ============================================================ */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px; font-weight: 600;
  border: 1px solid transparent;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
  white-space: nowrap;
  line-height: 1.4;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }

.btn-secondary { background: var(--surface); color: var(--text-2); border-color: var(--border-2); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }

.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }

.btn-danger-ghost { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-border); }
.btn-danger-ghost:hover:not(:disabled) { background: #fee2e2; }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: #15803d; }

.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
.btn-lg { padding: 11px 20px; font-size: 14px; }
.btn-block { width: 100%; }
.btn-icon { padding: 7px; }

.btn svg { flex-shrink: 0; }

/* ============================================================
   Cards
   ============================================================ */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.card-pad { padding: 18px; }

.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; flex-wrap: wrap;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.card-head h3 { font-size: 14px; font-weight: 700; }

.card-body { padding: 18px; }

/* ============================================================
   KPI stat cards
   ============================================================ */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .1s;
  position: relative;
  overflow: hidden;
}
.stat-card:hover { border-color: var(--primary-border); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat-card .stat-icon {
  width: 34px; height: 34px;
  border-radius: 9px;
  display: grid; place-items: center;
  margin-bottom: 10px;
}
.stat-card .stat-label { font-size: 11.5px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; }
.stat-card .stat-value { font-size: 22px; font-weight: 800; letter-spacing: -.02em; margin-top: 2px; }
.stat-card .stat-sub { font-size: 11.5px; color: var(--text-3); margin-top: 3px; }
.stat-card .stat-arrow { position: absolute; top: 14px; right: 14px; color: var(--text-3); opacity: 0; transition: opacity .15s; }
.stat-card:hover .stat-arrow { opacity: 1; }

/* ============================================================
   Tables
   ============================================================ */

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.table-scroll { overflow-x: auto; }

table.data-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 560px; }

.data-table thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-3);
  background: var(--surface-2);
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  cursor: default;
  user-select: none;
}
.data-table thead th.sortable { cursor: pointer; }
.data-table thead th.sortable:hover { color: var(--text-2); }
.data-table thead th .sort-arrow { font-size: 9px; margin-left: 4px; }

.data-table tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--surface-3);
  vertical-align: middle;
  color: var(--text-2);
}
.data-table tbody tr { transition: background .1s; }
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table tbody tr.clickable { cursor: pointer; }
.data-table tbody tr:last-child td { border-bottom: none; }

.compact-ui .data-table thead th,
.compact-ui .data-table tbody td { padding-top: 7px; padding-bottom: 7px; }
.compact-ui .card-body, .compact-ui .card-pad { padding: 13px; }

.data-table td .cell-main { font-weight: 600; color: var(--text); }
.data-table td .cell-sub { font-size: 11.5px; color: var(--text-3); margin-top: 1px; }
.data-table td.num, .data-table th.num { text-align: right; font-variant-numeric: tabular-nums; }

.table-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-3);
}

.pager { display: flex; align-items: center; gap: 4px; }
.pager button {
  min-width: 30px; height: 30px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 12.5px; font-weight: 600;
  color: var(--text-2);
  border: 1px solid transparent;
  display: grid; place-items: center;
}
.pager button:hover:not(:disabled) { background: var(--surface-3); }
.pager button.active { background: var(--primary); color: #fff; }
.pager button:disabled { opacity: .4; cursor: not-allowed; }
.pager .page-info { margin-right: 8px; }

/* Mobile card list (replaces tables) */

.mobile-cards { display: none; }

@media (max-width: 768px) {
  .table-desktop { display: none; }
  .mobile-cards { display: block; }
  .table-wrap { background: transparent; border: none; box-shadow: none; }
  .data-table { display: none; }
}

.record-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: border-color .15s;
}
.record-card:hover { border-color: var(--primary-border); }
.record-card .rc-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.record-card .rc-title { font-size: 14px; font-weight: 700; }
.record-card .rc-sub { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }
.record-card .rc-body { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; font-size: 12.5px; color: var(--text-2); }
.record-card .rc-foot { display: flex; gap: 8px; margin-top: 12px; }
.record-card .rc-foot .btn { flex: 1; }

/* ============================================================
   Badges
   ============================================================ */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
  white-space: nowrap;
  border: 1px solid transparent;
  line-height: 1.5;
}
.badge .b-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-lg { font-size: 12.5px; padding: 5px 12px; }

.b-gray   { color: var(--slate); background: var(--slate-soft); border-color: var(--slate-border); }
.b-blue   { color: var(--primary-dark); background: var(--primary-soft); border-color: var(--primary-border); }
.b-green  { color: #15803d; background: var(--success-soft); border-color: var(--success-border); }
.b-red    { color: var(--red); background: var(--red-soft); border-color: var(--danger-border); }
.b-amber  { color: var(--amber); background: var(--amber-soft); border-color: var(--warning-border); }
.b-purple { color: var(--purple); background: var(--purple-soft); border-color: var(--purple-border); }
.b-cyan   { color: var(--info); background: var(--info-soft); border-color: var(--info-border); }
.b-teal   { color: var(--teal); background: var(--teal-soft); border-color: var(--teal-border); }
.b-orange { color: var(--orange); background: var(--orange-soft); border-color: var(--orange-border); }

/* ============================================================
   Forms
   ============================================================ */

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px 16px;
}

.form-field { display: flex; flex-direction: column; gap: 5px; }
.form-field.full { grid-column: 1 / -1; }

.form-label { font-size: 12.5px; font-weight: 600; color: var(--text-2); display: flex; align-items: center; gap: 4px; }
.form-label .req { color: var(--danger); }
.form-hint { font-size: 11.5px; color: var(--text-3); }

.input, .select, .textarea {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--border-2);
  border-radius: 8px;
  background: var(--surface);
  font-size: 13.5px;
  transition: border-color .15s, box-shadow .15s;
  color: var(--text);
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:disabled, .select:disabled, .textarea:disabled { background: var(--surface-3); color: var(--text-3); cursor: not-allowed; }

.textarea { resize: vertical; min-height: 80px; }

.input.invalid, .select.invalid, .textarea.invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, .1);
}

.field-error { font-size: 11.5px; color: var(--danger); font-weight: 500; display: none; }
.form-field.invalid .field-error { display: block; }

.password-input-wrap { position: relative; width: 100%; }
.password-input-wrap .input { width: 100%; padding-right: 58px; }
.password-toggle {
  position: absolute;
  right: 7px;
  top: 50%;
  transform: translateY(-50%);
  min-width: 44px;
  padding: 5px 7px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--primary);
  font: 700 11px/1 var(--font);
  cursor: pointer;
}
.password-toggle:hover, .password-toggle:focus-visible { background: var(--primary-soft); outline: none; }

.input-group { display: flex; }
.input-group .input { border-radius: 8px 0 0 8px; }
.input-group .input-append {
  background: var(--surface-3);
  border: 1px solid var(--border-2); border-left: none;
  border-radius: 0 8px 8px 0;
  padding: 8px 12px;
  font-size: 13px; color: var(--text-3);
  display: flex; align-items: center;
  white-space: nowrap;
}

.search-field { position: relative; }
.search-field .input { padding-left: 34px; }
.search-field .sf-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--text-3);
  pointer-events: none;
}

.check-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); cursor: pointer; }
.check-row input { width: 16px; height: 16px; accent-color: var(--primary); }

.radio-row { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.radio-row input { accent-color: var(--primary); width: 15px; height: 15px; }

/* Selectable record list (worker picker, vendor picker) */

.option-list {
  display: flex; flex-direction: column; gap: 6px;
  max-height: 300px; overflow-y: auto;
  padding: 2px;
}

.option-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.option-row:hover { border-color: var(--primary-border); background: var(--surface-2); }
.option-row.selected { border-color: var(--primary); background: var(--primary-soft); }
.option-row input { accent-color: var(--primary); width: 15px; height: 15px; flex-shrink: 0; }
.option-row .opt-text { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.3; }
.option-row .opt-name { font-size: 13px; font-weight: 600; color: var(--text); }
.option-row .opt-sub { font-size: 11.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; }
.option-row .badge { flex-shrink: 0; }


.filter-bar {
  display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}
.filter-bar .form-field { min-width: 150px; flex: 0 1 180px; }
.filter-bar .form-field.grow { flex: 1 1 220px; min-width: 200px; }
.filter-bar .filter-actions { display: flex; gap: 8px; margin-left: auto; }

/* Scan-or-search entry row (Finishing, Product Scan) */

.finish-scan-row { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.finish-scan-row .form-field { min-width: 200px; }
.finish-scan-row .form-field.grow { flex: 1 1 260px; }

/* Active filter chips */

.filter-chips { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: -4px 0 14px; }
.filter-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--primary-soft);
  border: 1px solid var(--primary-border);
  color: var(--text-2);
  border-radius: 999px;
  padding: 4px 6px 4px 11px;
  font-size: 12px; font-weight: 500;
}
.filter-chip b { color: var(--text); font-weight: 600; }
.filter-chip .fc-x {
  display: grid; place-items: center;
  width: 18px; height: 18px;
  border-radius: 50%;
  color: var(--text-3); font-size: 15px; line-height: 1;
  background: transparent;
}
.filter-chip .fc-x:hover { background: var(--surface); color: var(--danger); }

/* Barcode display */

.barcode-display {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: grid; place-items: center;
}
.barcode-display .barcode-svg { width: 100%; max-width: 320px; height: auto; }

/* Order wizard: design picker + task list (Tasks step) */

.design-pick { cursor: pointer; }
.design-pick.selected { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary); }
.step-item:not(.done) { cursor: default; }
.step-item.done { cursor: pointer; }

.task-list { display: flex; flex-direction: column; gap: 8px; }
.task-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
}
.task-item .ti-icon { width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; flex-shrink: 0; }
.task-item .ti-text { flex: 1; min-width: 0; }
.task-item .ti-title { font-size: 13.5px; font-weight: 600; color: var(--text); }
.task-item .ti-sub { font-size: 12px; color: var(--text-3); margin-top: 1px; }

/* Sticky form action bar */

.form-actions-sticky {
  position: sticky;
  bottom: 0;
  z-index: 30;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 12px 18px;
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  flex-wrap: wrap;
  margin: 0;
  border-radius: 0 0 calc(var(--radius-lg) - 1px) calc(var(--radius-lg) - 1px);
  box-shadow: 0 -4px 12px rgba(15,23,42,.05);
}

/* Full-width entity forms. The previous inline max-width values left a large
   unused strip on desktop, while the negative footer margin pushed actions
   outside the card boundary. */
.card.page-form-card {
  width: 100%;
  max-width: none;
  overflow: visible;
}

.page-form-card > .card-body {
  padding: clamp(18px, 2vw, 26px);
}

.design-form-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px 20px;
}

.design-form-card .upload-zone,
.design-form-card .img-preview {
  width: 100%;
  max-width: 220px;
  min-height: 140px;
}

.design-form-card .textarea { min-height: 110px; }

@media (max-width: 1024px) {
  .design-form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ============================================================
   Tabs
   ============================================================ */

.tabs {
  display: flex; align-items: center; gap: 2px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab-btn {
  padding: 10px 14px;
  font-size: 13px; font-weight: 600;
  color: var(--text-3);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  display: flex; align-items: center; gap: 7px;
  transition: color .15s;
}
.tab-btn:hover { color: var(--text-2); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-btn .tab-count {
  background: var(--surface-3);
  font-size: 10.5px; font-weight: 700;
  padding: 1px 7px; border-radius: 999px;
  color: var(--text-3);
}
.tab-btn.active .tab-count { background: var(--primary-soft); color: var(--primary); }

.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fade-in .18s ease; }

@keyframes fade-in { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

/* ============================================================
   Pipeline / stepper / timeline
   ============================================================ */

.pipeline {
  display: flex; align-items: flex-start; gap: 0;
  overflow-x: auto;
  padding-bottom: 6px;
}
.pipeline-step {
  display: flex; align-items: center; gap: 10px;
  flex: 1 0 auto;
  min-width: 118px;
}
.pipeline-step .ps-node {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 2px solid var(--border-2);
  background: var(--surface);
  display: grid; place-items: center;
  color: var(--text-3);
  font-size: 11px; font-weight: 700;
  flex-shrink: 0;
  position: relative;
}
.pipeline-step.done .ps-node { background: var(--success); border-color: var(--success); color: #fff; }
.pipeline-step.current .ps-node { border-color: var(--primary); color: var(--primary); box-shadow: 0 0 0 4px rgba(37,99,235,.15); }
.pipeline-step .ps-label { font-size: 11.5px; font-weight: 600; color: var(--text-3); white-space: nowrap; }
.pipeline-step.done .ps-label, .pipeline-step.current .ps-label { color: var(--text); }
.pipeline-step .ps-info { font-size: 10.5px; color: var(--text-3); white-space: nowrap; }
.pipeline-link {
  width: 26px; height: 2px;
  background: var(--border-2);
  margin: 14px 4px 0;
  flex-shrink: 0;
  position: relative;
}
.pipeline-link.done { background: var(--success); }

/* Stepper (multi-step forms) */

.stepper { display: flex; align-items: center; margin-bottom: 22px; overflow-x: auto; padding-bottom: 4px; }
.step-item { display: flex; align-items: center; gap: 9px; flex-shrink: 0; cursor: pointer; }
.step-num {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 2px solid var(--border-2);
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700;
  color: var(--text-3);
  background: var(--surface);
  transition: all .15s;
}
.step-item.active .step-num { border-color: var(--primary); color: var(--primary); box-shadow: 0 0 0 4px rgba(37,99,235,.12); }
.step-item.done .step-num { background: var(--success); border-color: var(--success); color: #fff; }
.step-label { font-size: 12.5px; font-weight: 600; color: var(--text-3); white-space: nowrap; }
.step-item.active .step-label { color: var(--primary); }
.step-item.done .step-label { color: var(--text-2); }
.step-line { width: 30px; height: 2px; background: var(--border-2); margin: 0 8px; flex-shrink: 0; }
.step-line.done { background: var(--success); }

/* Vertical timeline */

.timeline { position: relative; padding-left: 22px; }
.timeline::before {
  content: ""; position: absolute; left: 6px; top: 4px; bottom: 4px;
  width: 2px; background: var(--border);
}
.tl-item { position: relative; padding-bottom: 16px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before {
  content: ""; position: absolute; left: -21px; top: 4px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--border-2);
}
.tl-item.done::before { background: var(--success); border-color: var(--success); }
.tl-item.current::before { background: var(--primary); border-color: var(--primary); box-shadow: 0 0 0 4px rgba(37,99,235,.15); }
.tl-item.failed::before { background: var(--danger); border-color: var(--danger); }
.tl-item .tl-title { font-size: 13px; font-weight: 600; }
.tl-item .tl-date { font-size: 11.5px; color: var(--text-3); margin-top: 1px; }
.tl-item .tl-note { font-size: 12.5px; color: var(--text-2); margin-top: 3px; }

/* ============================================================
   Modals & drawers
   ============================================================ */

.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(2, 6, 23, .55);
  z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  animation: fade-in .15s ease;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 40px);
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: pop .16s ease;
}

.modal-lg { max-width: 760px; }
.modal-sm { max-width: 400px; }

.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-head h3 { font-size: 15px; font-weight: 700; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-foot {
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  padding: 13px 18px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.drawer-overlay {
  position: fixed; inset: 0;
  background: rgba(2, 6, 23, .45);
  z-index: 100;
  animation: fade-in .15s ease;
}

.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 440px;
  max-width: 100vw;
  background: var(--surface);
  z-index: 101;
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  animation: slide-in .2s ease;
}

@keyframes slide-in { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }

.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.drawer-head h3 { font-size: 15px; font-weight: 700; }
.drawer-body { padding: 18px; overflow-y: auto; flex: 1; }
.drawer-foot {
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  padding: 13px 18px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* ============================================================
   Toasts
   ============================================================ */

.toast-root {
  position: fixed;
  top: 16px; right: 16px;
  z-index: 200;
  display: flex; flex-direction: column; gap: 8px;
  width: min(360px, calc(100vw - 32px));
}

.toast {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: 10px;
  padding: 12px 14px;
  box-shadow: var(--shadow-md);
  font-size: 13px;
  animation: toast-in .22s ease;
}
.toast.out { animation: toast-out .2s ease forwards; }

@keyframes toast-in { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(24px); } }

.toast-success { border-left-color: var(--success); }
.toast-error { border-left-color: var(--danger); }
.toast-info { border-left-color: var(--info); }
.toast-warning { border-left-color: var(--warning); }

.toast .toast-ic { margin-top: 1px; flex-shrink: 0; }
.toast .toast-title { font-weight: 700; font-size: 13px; }
.toast .toast-msg { color: var(--text-2); font-size: 12.5px; margin-top: 1px; }
.toast .toast-close { margin-left: auto; color: var(--text-3); font-size: 14px; padding: 0 2px; line-height: 1; }
.toast .toast-close:hover { color: var(--text); }

/* ============================================================
   Empty / error / loading
   ============================================================ */

.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px;
  padding: 48px 20px;
  text-align: center;
  color: var(--text-3);
}
.empty-state .es-icon { color: var(--border-2); margin-bottom: 4px; }
.empty-state .es-title { font-size: 14.5px; font-weight: 700; color: var(--text-2); }
.empty-state .es-text { font-size: 13px; max-width: 340px; }
.empty-state .es-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; justify-content: center; }

.error-state {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 44px 20px;
  text-align: center;
}
.error-state .es-title { font-size: 15px; font-weight: 700; color: var(--danger); }
.error-state .es-text { font-size: 13px; color: var(--text-3); max-width: 360px; }
.error-state .es-actions { display: flex; gap: 8px; margin-top: 10px; }

/* Skeletons */

.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--surface-3);
  border-radius: 6px;
}
.skeleton::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.7), transparent);
  transform: translateX(-100%);
  animation: shimmer 1.2s infinite;
}
@keyframes shimmer { 100% { transform: translateX(100%); } }

.skeleton-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px; }
.skeleton-line { height: 12px; margin-bottom: 10px; }
.skeleton-line.w60 { width: 60%; }
.skeleton-line.w40 { width: 40%; }
.skeleton-line.w80 { width: 80%; }
.skeleton-block { height: 90px; margin-bottom: 12px; }

/* ============================================================
   Global search overlay
   ============================================================ */

.search-overlay {
  position: fixed; inset: 0;
  background: rgba(2, 6, 23, .5);
  z-index: 150;
  padding: 8vh 16px 16px;
  animation: fade-in .12s ease;
  display: flex; justify-content: center;
  overflow-y: auto;
}

.search-box {
  width: 100%;
  max-width: 620px;
  height: fit-content;
  background: var(--surface);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: pop .15s ease;
}

.search-box .sb-input-row {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.search-box .sb-input-row input {
  flex: 1;
  border: none; outline: none;
  font-size: 15px;
  background: transparent;
}
.search-box .sb-input-row input::placeholder { color: var(--text-3); }

.sb-group { padding: 10px 8px 6px; }
.sb-group-label {
  font-size: 10.5px; font-weight: 700;
  letter-spacing: .07em; text-transform: uppercase;
  color: var(--text-3);
  padding: 0 10px 6px;
}
.sb-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}
.sb-item:hover { background: var(--surface-2); }
.sb-item .sb-ic {
  width: 30px; height: 30px;
  border-radius: 7px;
  background: var(--surface-3);
  display: grid; place-items: center;
  color: var(--text-3);
  flex-shrink: 0;
}
.sb-item .sb-main { font-weight: 600; color: var(--text); }
.sb-item .sb-sub { color: var(--text-3); font-size: 12px; }

.sb-empty { padding: 30px; text-align: center; color: var(--text-3); font-size: 13px; }
.sb-foot { padding: 9px 16px; border-top: 1px solid var(--border); font-size: 11.5px; color: var(--text-3); display: flex; gap: 14px; }

/* ============================================================
   Barcode scanner
   ============================================================ */

.scanner-area {
  background: #0b1220;
  border-radius: 12px;
  padding: 26px 16px;
  text-align: center;
  color: #94a3b8;
  position: relative;
  overflow: hidden;
}
.scanner-frame {
  width: 200px; height: 130px;
  margin: 0 auto 18px;
  border: 2px solid rgba(96, 165, 250, .6);
  border-radius: 10px;
  position: relative;
  display: grid; place-items: center;
}
.scanner-frame::before {
  content: ""; position: absolute; left: 8px; right: 8px; top: 0;
  height: 2px; background: #3b82f6;
  box-shadow: 0 0 12px #3b82f6;
  animation: scan-line 1.4s ease-in-out infinite;
}
@keyframes scan-line {
  0%, 100% { top: 8px; }
  50% { top: calc(100% - 8px); }
}
.scanner-frame .barcode-ic { width: 120px; opacity: .9; }
.scanner-status { font-size: 13px; font-weight: 600; }
.scanner-hint { font-size: 12px; margin-top: 4px; }

/* ============================================================
   Images / design previews
   ============================================================ */

.design-thumb {
  width: 54px; height: 54px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--border);
  background: var(--surface-3);
}

.img-preview {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface-3);
  overflow: hidden;
  display: grid; place-items: center;
}

.design-detail-img { width: 100%; border-radius: var(--radius-lg); border: 1px solid var(--border); }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.gallery .img-preview { aspect-ratio: 3/4; }
.gallery .img-preview img { width: 100%; height: 100%; object-fit: cover; }

.upload-zone {
  border: 2px dashed var(--border-2);
  border-radius: var(--radius-lg);
  padding: 22px;
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.upload-zone:hover { border-color: var(--primary); background: var(--primary-soft); }

/* ============================================================
   Product / order cards, misc
   ============================================================ */

.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.detail-grid > * { min-width: 0; }
@media (max-width: 900px) { .detail-grid { grid-template-columns: 1fr; } }

.info-list { display: grid; gap: 11px; }
.info-item { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.info-item .il-label { color: var(--text-3); font-weight: 500; }
.info-item .il-value { font-weight: 600; text-align: right; }

.meta-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 4px 9px;
  font-size: 12px; font-weight: 600;
  color: var(--text-2);
}
.meta-chip svg { color: var(--text-3); }

.doc-id { font-weight: 800; font-size: 15px; color: var(--text); font-variant-numeric: tabular-nums; }

.progress-track { height: 6px; background: var(--surface-3); border-radius: 999px; overflow: hidden; min-width: 80px; }
.progress-fill { height: 100%; background: var(--primary); border-radius: 999px; transition: width .3s ease; }
.progress-fill.green { background: var(--success); }
.progress-fill.amber { background: var(--warning); }
.progress-fill.purple { background: var(--purple); }

.chart-bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.chart-bar-label { width: 130px; font-size: 12px; font-weight: 600; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex-shrink: 0; }
.chart-bar-track { flex: 1; height: 22px; background: var(--surface-3); border-radius: 6px; overflow: hidden; display: flex; }
.chart-bar-seg { height: 100%; }
.chart-bar-val { width: 52px; font-size: 12px; font-weight: 700; color: var(--text-2); text-align: right; flex-shrink: 0; font-variant-numeric: tabular-nums; }

.chart-legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; }
.chart-legend .lg-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); }
.chart-legend .lg-swatch { width: 10px; height: 10px; border-radius: 3px; }

.avatar-sm {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 10.5px; font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.avatar-row { display: flex; align-items: center; gap: 8px; }

.amount { font-variant-numeric: tabular-nums; }
.amount.pos { color: var(--success); }
.amount.neg { color: var(--danger); }

/* Invoice / job card print preview */

.doc-preview { max-width: 760px; margin: 0 auto; }
.doc-preview .dp-head { display: flex; justify-content: space-between; gap: 14px; padding-bottom: 14px; border-bottom: 2px solid var(--text); margin-bottom: 14px; flex-wrap: wrap; }
.doc-preview .dp-brand { font-size: 20px; font-weight: 800; }
.doc-preview .dp-docno { font-size: 14px; font-weight: 700; }

.kv-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 26px; font-size: 13px; margin-bottom: 14px; }
.kv-2col .kv { display: flex; gap: 8px; }
.kv-2col .kv .k { color: var(--text-3); min-width: 84px; }
.kv-2col .kv .v { font-weight: 600; }

/* ============================================================
   Bottom navigation (mobile)
   ============================================================ */

.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 50;
  padding: 4px 6px calc(4px + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 12px rgba(15,23,42,.06);
}

.bottom-nav .bn-item {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 2px;
  font-size: 10px; font-weight: 600;
  color: var(--text-3);
  border-radius: 8px;
}
.bottom-nav .bn-item.active { color: var(--primary); }
.bottom-nav .bn-item svg { width: 20px; height: 20px; }

/* ============================================================
   Status highlight box (business UX principle)
   ============================================================ */

.status-banner {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 18px;
}
.status-banner .sb-cell { background: var(--surface); padding: 12px 16px; }
.status-banner .sb-cell .sb-label { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); margin-bottom: 3px; }
.status-banner .sb-cell .sb-value { font-size: 13.5px; font-weight: 700; }
.status-banner .sb-cell .sb-note { font-size: 12px; color: var(--text-3); margin-top: 2px; }
@media (max-width: 640px) { .status-banner { grid-template-columns: 1fr; } }

/* ============================================================
   Status and action banner
   ============================================================ */

.status-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: linear-gradient(90deg, #1e3a8a, #2563eb);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  color: #fff;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.status-bar .status-bar-title { font-weight: 700; font-size: 13.5px; }
.status-bar .status-bar-text { font-size: 12px; opacity: .85; }
.status-bar .btn { background: rgba(255,255,255,.14); color: #fff; border: 1px solid rgba(255,255,255,.25); }
.status-bar .btn:hover { background: rgba(255,255,255,.24); }
.status-bar .status-bar-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ============================================================
   Tooltips
   ============================================================ */

[data-tip] { position: relative; }
[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%; bottom: calc(100% + 8px);
  transform: translateX(-50%);
  background: #0f172a;
  color: #e2e8f0;
  font-size: 11px; font-weight: 500;
  padding: 4px 9px;
  border-radius: 6px;
  white-space: nowrap;
  z-index: 80;
  pointer-events: none;
  box-shadow: var(--shadow-md);
}
.sidebar-collapsed .nav-item[data-tip]::after { left: calc(100% + 6px); bottom: auto; top: 50%; transform: translateY(-50%); }
.sidebar-collapsed .nav-item[data-tip]::before {
  content: ""; position: absolute;
  left: calc(100% - 2px); top: 50%;
  border: 5px solid transparent; border-right-color: #0f172a;
  transform: translateY(-50%);
  z-index: 81;
}

/* ============================================================
   Login-less demo, misc utility
   ============================================================ */

.money-table td { text-align: right; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.muted { color: var(--text-3); }
.small { font-size: 12px; }
.bold { font-weight: 700; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 6px; } .mt-2 { margin-top: 12px; } .mt-3 { margin-top: 18px; }
.mb-1 { margin-bottom: 6px; } .mb-2 { margin-bottom: 12px; } .mb-3 { margin-bottom: 18px; }
.flex { display: flex; align-items: center; gap: 8px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.flex-wrap { flex-wrap: wrap; }
.gap-1 { gap: 6px; } .gap-2 { gap: 12px; } .gap-3 { gap: 18px; }
.hidden { display: none !important; }
.w-100 { width: 100%; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

kbd {
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 6px;
  font-size: 11px;
  font-family: inherit;
  color: var(--text-2);
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 1180px) {
  .search-trigger { width: 210px; }
  .profile-meta { display: none; }
}

@media (max-width: 1024px) {
  .search-label { display: none; }
  .search-trigger { width: 150px; }
}

@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); box-shadow: none; }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .app-main { margin-left: 0 !important; }
  .sidebar-backdrop.show { display: block; }
  .mobile-menu-btn { display: grid; }
  .sidebar-collapse { display: none; }
  .breadcrumbs { display: none; }
}

@media (max-width: 640px) {
  html { font-size: 14px; }
  .page { padding: 16px 14px 84px; }
  .topbar { padding: 0 10px; }
  .search-trigger { width: 40px; justify-content: center; padding: 7px; border-color: transparent; background: transparent; }
  .search-trigger kbd { display: none; }
  .profile-btn svg { display: none; }
  .profile-btn { padding: 4px; }
  .profile-meta { display: none; }
  .bottom-nav { display: flex; }
  .page-title { font-size: 18px; }
  .page-header { margin-bottom: 14px; }
  .btn { padding: 8px 12px; }
  .modal { max-height: calc(100vh - 24px); }
  .filter-bar .form-field { flex: 1 1 100%; }
  .form-actions-sticky { position: static; margin: 0; padding: 12px 14px; box-shadow: none; }
  .form-actions-sticky .btn { flex: 1 1 0; }
  .page-form-card > .card-body { padding: 14px; }
  .design-form-grid { grid-template-columns: 1fr; }
  .design-form-card .upload-zone,
  .design-form-card .img-preview { width: 100%; max-width: none !important; min-height: 150px; aspect-ratio: auto !important; }
  .kpi-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}

/* ============================================================
   Print
   ============================================================ */

@media print {
  .sidebar, .topbar, .bottom-nav, .toast-root, .modal-overlay, .drawer-overlay, .btn, .no-print, .form-actions-sticky { display: none !important; }
  .app-main { margin: 0 !important; }
  .page { padding: 0; }
  body { background: #fff; }
  .print-area { border: none; box-shadow: none; }
  .print-area .doc-preview { max-width: 100%; }
}

/* ============================================================
   Boot loading (initial fetch from the MySQL-backed API)
   ============================================================ */

.boot-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-height: 60vh;
  color: var(--text-3);
  font-size: 13px;
}

.boot-loading .spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   Public authentication pages
   ============================================================ */
.auth-page-body{margin:0;min-height:100vh;background:#f3f5fb;color:#172033}.auth-page-shell{min-height:100vh;display:grid;grid-template-columns:minmax(0,1.05fr) minmax(420px,.95fr)}.auth-brand-panel{position:relative;display:flex;flex-direction:column;justify-content:space-between;padding:clamp(28px,6vw,88px);overflow:hidden;background:linear-gradient(145deg,#111a35 0%,#1d2d62 58%,#304c9b 100%);color:#fff}.auth-brand-panel:after{content:"";position:absolute;width:420px;height:420px;border-radius:50%;right:-170px;bottom:-180px;background:rgba(255,255,255,.08);box-shadow:0 0 0 70px rgba(255,255,255,.04),0 0 0 140px rgba(255,255,255,.025)}.auth-brand-lockup{display:flex;align-items:center;gap:12px;position:relative;z-index:1}.auth-brand-lockup .brand-mark,.auth-mobile-mark{display:grid;place-items:center;width:42px;height:42px;border-radius:12px;background:#4f72e9;color:#fff;font-weight:800;font-size:20px;box-shadow:0 8px 18px rgba(0,0,0,.18)}.auth-brand-lockup .brand-name{font-size:18px;font-weight:800;letter-spacing:-.02em}.auth-brand-lockup .brand-sub{color:#b7c7ff}.auth-brand-copy{position:relative;z-index:1;max-width:560px;margin:auto 0}.auth-eyebrow,.auth-kicker{margin:0 0 14px;color:#8da9ff;font-size:12px;font-weight:800;letter-spacing:.12em;text-transform:uppercase}.auth-brand-copy h1{max-width:560px;margin:0;font-size:clamp(36px,5vw,68px);line-height:1.03;letter-spacing:-.055em}.auth-brand-copy p{max-width:470px;margin:24px 0 0;color:#ced8f7;font-size:17px;line-height:1.7}.auth-brand-points{display:grid;gap:12px;position:relative;z-index:1;color:#cad5f7;font-size:13px}.auth-brand-points span{display:flex;align-items:center;gap:14px}.auth-brand-points b{color:#8da9ff;letter-spacing:.12em}.auth-card-wrap{display:flex;flex-direction:column;justify-content:center;padding:clamp(24px,6vw,92px);background:#f3f5fb}.auth-card{width:100%;max-width:540px;margin:0 auto;padding:clamp(24px,4vw,42px);border:1px solid #e0e5f1;border-radius:22px;background:#fff;box-shadow:0 18px 50px rgba(28,44,82,.10)}.auth-card-head{display:flex;gap:12px;align-items:center}.auth-mobile-mark{display:none}.auth-card h2{margin:0;color:#18213b;font-size:clamp(24px,3vw,32px);letter-spacing:-.04em}.auth-subtitle{margin:10px 0 24px;color:#69748d;font-size:14px;line-height:1.6}.auth-tabs{display:flex;gap:6px;padding:4px;margin-bottom:22px;border-radius:10px;background:#f1f4fa}.auth-tab{flex:1;border:0;border-radius:8px;padding:10px 12px;background:transparent;color:#74809a;font:600 13px inherit;cursor:pointer}.auth-tab.active{background:#fff;color:#2450cf;box-shadow:0 2px 8px rgba(27,45,87,.10)}.auth-form{display:grid;gap:16px}.auth-form-grid{display:grid;grid-template-columns:1fr 1fr;gap:14px}.auth-form-grid .full{grid-column:1/-1}.auth-submit{width:100%;justify-content:center;min-height:46px;margin-top:4px}.auth-submit span{margin-left:auto}.auth-status{padding:11px 12px;margin:0 0 16px;border-radius:9px;font-size:13px;line-height:1.45}.auth-status.info{background:#eef4ff;color:#2854bb}.auth-status.success{background:#eaf8ef;color:#187342}.auth-status.error{background:#fff0f0;color:#b42318}.auth-help{margin:0;color:#7b8497;font-size:12px;line-height:1.55}.auth-footer{margin:22px 0 0;text-align:center;color:#778198;font-size:13px}.auth-link{border:0;padding:0;background:transparent;color:#2450cf;font:600 13px inherit;cursor:pointer}.auth-legal{margin:18px auto 0;color:#8b94a7;font-size:11px;text-align:center}.auth-page-body .form-label{color:#3b4760}.auth-page-body .input,.auth-page-body .textarea{background:#fbfcff}.auth-page-body .input:focus,.auth-page-body .textarea:focus{border-color:#4c6fe5;box-shadow:0 0 0 3px rgba(76,111,229,.12)}@media(max-width:900px){.auth-page-shell{grid-template-columns:1fr}.auth-brand-panel{display:none}.auth-card-wrap{min-height:100vh;padding:22px 16px}.auth-card{max-width:560px}.auth-mobile-mark{display:grid;flex:0 0 42px}}@media(max-width:520px){.auth-card{padding:22px 18px;border-radius:16px}.auth-form-grid{grid-template-columns:1fr}.auth-form-grid .full{grid-column:auto}.auth-card h2{font-size:24px}.auth-tabs{margin-bottom:18px}.auth-page-body .auth-subtitle{margin-bottom:18px}}

/* Auth view toggle: the inactive form must not render or occupy card space. */
.auth-form[hidden] { display: none !important; }
.auth-form[aria-hidden="true"] { display: none !important; }

/* Narrow detail cards: keep invoice/job-card metadata inside the viewport. */
@media (max-width: 640px) {
  .kv-2col { grid-template-columns: 1fr; gap: 9px; }
  .kv-2col .kv { min-width: 0; align-items: flex-start; }
  .kv-2col .kv .k { flex: 0 0 84px; min-width: 0; }
  .kv-2col .kv .v { min-width: 0; overflow-wrap: anywhere; }
}

/* Mobile tabs: wrap long Settings/order tab sets instead of forcing horizontal clipping. */
@media (max-width: 640px) {
  .tabs { flex-wrap: wrap; overflow-x: visible; gap: 4px; padding-bottom: 4px; }
  .tab-btn { flex: 1 1 calc(50% - 4px); min-width: 0; text-align: center; padding: 9px 8px; margin-bottom: 0; border: 1px solid var(--border); border-radius: 8px; }
  .tab-btn.active { border-color: var(--primary); background: var(--primary-soft); }
}

/* Tablet tab sets: keep Settings and detail tabs inside the content column. */
@media (max-width: 1180px) {
  .tabs { flex-wrap: wrap; overflow-x: visible; gap: 4px; padding-bottom: 4px; }
  .tab-btn { flex: 1 1 calc(25% - 4px); min-width: 120px; text-align: center; padding: 9px 8px; margin-bottom: 0; border: 1px solid var(--border); border-radius: 8px; }
  .tab-btn.active { border-color: var(--primary); background: var(--primary-soft); }
}
@media (max-width: 640px) {
  .tab-btn { flex-basis: calc(50% - 4px); min-width: 0; }
}

/* ============================================================
   Modern responsive polish
   ============================================================ */

body {
  min-width: 0;
  background:
    radial-gradient(circle at 78% -20%, rgba(37, 99, 235, .07), transparent 34rem),
    var(--bg);
}

[data-theme="dark"] body {
  background:
    radial-gradient(circle at 78% -20%, rgba(59, 130, 246, .12), transparent 34rem),
    var(--bg);
}

.sidebar {
  background: linear-gradient(180deg, #08101f 0%, var(--sidebar-bg) 54%, #0d1729 100%);
  border-right: 1px solid rgba(148, 163, 184, .10);
}

.sidebar-brand { border-bottom-color: rgba(255, 255, 255, .08); }
.brand-mark { box-shadow: 0 10px 24px rgba(37, 99, 235, .28); }
.nav-item { border: 1px solid transparent; }
.nav-item.active {
  border-color: rgba(96, 165, 250, .13);
  box-shadow: inset 0 0 0 1px rgba(96, 165, 250, .04), 0 8px 24px rgba(0, 0, 0, .12);
}

.topbar {
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border-bottom-color: color-mix(in srgb, var(--border) 82%, transparent);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
}

.page { padding: 28px clamp(18px, 2.4vw, 38px) 96px; max-width: 1540px; }
.page-header { margin-bottom: 22px; }
.page-title { font-size: clamp(22px, 2vw, 28px); letter-spacing: -.035em; line-height: 1.2; }
.page-sub { color: var(--text-2); line-height: 1.55; }
.section-head { margin-top: 4px; }
.section-title { font-size: 15px; }

.card,
.table-wrap,
.filter-bar,
.record-card,
.stat-card {
  border-color: color-mix(in srgb, var(--border) 90%, transparent);
  box-shadow: var(--shadow-sm);
}

.card,
.table-wrap,
.filter-bar { overflow: clip; }
.card-head { background: color-mix(in srgb, var(--surface-2) 42%, transparent); }

.stat-card {
  min-height: 128px;
  padding: 17px 18px;
  isolation: isolate;
}
.stat-card::after {
  content: "";
  position: absolute;
  z-index: -1;
  width: 84px;
  height: 84px;
  right: -34px;
  bottom: -42px;
  border-radius: 50%;
  background: var(--primary-soft);
  opacity: .45;
}
.stat-card .stat-icon { border: 1px solid rgba(148, 163, 184, .10); box-shadow: 0 5px 14px rgba(15, 23, 42, .06); }
.stat-card .stat-label { color: var(--text-2); font-size: 11px; }
.stat-card .stat-value { font-size: 24px; }
.stat-card .stat-sub { color: var(--text-3); }

.btn {
  min-height: 38px;
  border-radius: 10px;
  transition: transform .14s ease, background .16s ease, border-color .16s ease, color .16s ease, box-shadow .16s ease;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn-primary { box-shadow: 0 7px 16px rgba(37, 99, 235, .18); }
.btn-success { box-shadow: 0 7px 16px rgba(22, 163, 74, .15); }
.btn-sm { min-height: 32px; border-radius: 8px; }
.icon-btn { transition: transform .14s ease, background .16s ease, color .16s ease; }
.icon-btn:hover { transform: translateY(-1px); }

.input, .select, .textarea {
  min-height: 40px;
  border-color: var(--border);
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface) 96%, var(--surface-2));
}
.textarea { min-height: 92px; }
.form-label { color: var(--text-2); }
.form-hint, .cell-sub, .muted { color: var(--text-3); }

.data-table thead th { position: sticky; top: 0; z-index: 1; color: var(--text-2); }
.data-table tbody td { color: var(--text-2); }
.data-table tbody tr.clickable:focus-within,
.data-table tbody tr:hover { background: color-mix(in srgb, var(--primary-soft) 45%, var(--surface)); }

.modal-overlay, .drawer-overlay { backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.modal { border-radius: 18px; box-shadow: var(--shadow-lg); }
.modal-head, .modal-foot { background: color-mix(in srgb, var(--surface-2) 60%, var(--surface)); }
.drawer { box-shadow: var(--shadow-lg); }

.scan-launch-panel {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 150px;
  padding: 22px;
  border: 1px dashed var(--primary-border);
  border-radius: 14px;
  color: var(--primary);
  background: linear-gradient(145deg, var(--primary-soft), color-mix(in srgb, var(--surface) 88%, var(--primary-soft)));
}
.scan-launch-panel > div { color: var(--text); }
.scan-launch-panel .muted { margin-top: 5px; line-height: 1.55; }

.scanner-live { padding: 12px; background: #07111f; }
.scanner-video-wrap {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  max-height: 360px;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border: 1px solid rgba(96, 165, 250, .34);
  border-radius: 14px;
  background: radial-gradient(circle at 50% 32%, #172a45, #07111f 72%);
}
.scanner-video-wrap video { display: none; width: 100%; height: 100%; object-fit: cover; }
.scanner-video-wrap.is-live video { display: block; }
.scanner-placeholder { display: flex; flex-direction: column; align-items: center; gap: 7px; padding: 20px; color: #dbeafe; }
.scanner-placeholder svg { color: #60a5fa; }
.scanner-placeholder strong { font-size: 14px; }
.scanner-placeholder span { color: #94a3b8; font-size: 12px; }
.scanner-video-wrap.is-live .scanner-placeholder { display: none; }
.scanner-reticle {
  position: absolute;
  inset: 22% 12%;
  border: 2px solid rgba(96, 165, 250, .84);
  border-radius: 14px;
  box-shadow: 0 0 0 999px rgba(2, 6, 23, .18), 0 0 22px rgba(59, 130, 246, .24);
  pointer-events: none;
}
.scanner-reticle::after {
  content: "";
  position: absolute;
  left: 7%; right: 7%; top: 50%;
  height: 2px;
  background: #60a5fa;
  box-shadow: 0 0 12px #3b82f6;
  animation: scan-line-live 1.55s ease-in-out infinite;
}
@keyframes scan-line-live { 0%, 100% { transform: translateY(-42px); } 50% { transform: translateY(42px); } }
.scanner-status { margin-top: 12px; color: #cbd5e1; }
.scanner-status.is-success { color: #86efac; }
.scanner-status.is-warning { color: #fde68a; }
.scanner-status.is-error { color: #fca5a5; }
.scanner-status.is-camera { color: #93c5fd; }
.scan-code-input { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .035em; }
.scan-highlight { animation: scan-highlight 1.8s ease; }
@keyframes scan-highlight { 0%, 100% { box-shadow: var(--shadow-sm); } 30% { border-color: var(--primary); box-shadow: 0 0 0 5px rgba(37, 99, 235, .16), var(--shadow-md); } }
.sale-rate-input { min-width: 118px; max-width: 142px; margin-left: auto; text-align: right; }

@media (max-width: 860px) {
  .page { padding-left: 20px; padding-right: 20px; }
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stat-card { min-height: 118px; }
}

@media (max-width: 640px) {
  body { background: var(--bg); }
  .topbar { height: 58px; padding: 0 8px; }
  .topbar-left, .topbar-right { gap: 3px; }
  .topbar .icon-btn { width: 38px; height: 38px; }
  .page { padding: 18px 12px calc(88px + env(safe-area-inset-bottom)); }
  .page-header { gap: 12px; }
  .page-header > div:first-child { min-width: 0; width: 100%; }
  .page-title { font-size: 22px; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1 1 auto; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .stat-card { min-height: 112px; padding: 13px; }
  .stat-card .stat-icon { width: 31px; height: 31px; margin-bottom: 8px; }
  .stat-card .stat-label { font-size: 9.8px; line-height: 1.35; }
  .stat-card .stat-value { font-size: 21px; }
  .stat-card .stat-sub { font-size: 10.5px; }
  .card-pad, .card-body { padding: 14px; }
  .card-head { padding: 12px 14px; }
  .filter-bar { padding: 12px; }
  .filter-bar .filter-actions { width: 100%; margin-left: 0; }
  .filter-bar .filter-actions .btn { flex: 1; }
  .form-grid, .auth-form-grid { grid-template-columns: 1fr !important; }
  .form-field.full { grid-column: auto; }
  .finish-scan-row > .btn { flex: 1 1 100%; }
  .info-item { align-items: flex-start; }
  .info-item .il-value { min-width: 0; overflow-wrap: anywhere; }
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal { width: 100%; max-width: none; max-height: 92dvh; border-radius: 20px 20px 0 0; }
  .modal-foot { flex-wrap: wrap; }
  .modal-foot .btn { flex: 1 1 auto; }
  .drawer { width: min(100%, 420px); }
  .scanner-reticle { inset: 24% 8%; }
  .scan-launch-panel { min-height: 132px; padding: 18px; align-items: flex-start; }
  .bottom-nav .bn-item { min-width: 0; }
}

@media (max-width: 390px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .topbar-right #quickAddBtn { display: none; }
  .page-actions { display: grid; grid-template-columns: 1fr; }
  .page-actions .btn, .page-actions a.btn { width: 100%; }
  .record-card .rc-foot { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
