/* ============================================================
   ระบบคลังวัสดุก่อสร้าง — Design System
   Clean / minimal / professional · โทนน้ำเงินเชื่อถือได้
   ============================================================ */

:root {
  /* Neutrals — cool, subtly toned */
  --bg:          #f4f6fa;
  --bg-2:        #eef1f7;
  --surface:     #ffffff;
  --surface-2:   #fafbfd;
  --ink:         #0f1b2d;
  --ink-2:       #344256;
  --muted:       #64748b;
  --muted-2:     #94a3b8;
  --line:        #e5e9f0;
  --line-2:      #eef1f6;

  /* Primary — trustworthy blue */
  --primary:       #2563eb;
  --primary-600:   #2563eb;
  --primary-700:   #1d4ed8;
  --primary-800:   #1e40af;
  --primary-ink:   #14296b;
  --primary-soft:  #eaf1ff;
  --primary-soft2: #f3f7ff;

  /* Status */
  --green:      #0f9d58;
  --green-soft: #e6f6ee;
  --amber:      #d98a04;
  --amber-soft: #fdf3e2;
  --red:        #dc3545;
  --red-soft:   #fdecee;

  /* Geometry */
  --r-sm: 8px;
  --r:    12px;
  --r-lg: 16px;
  --r-xl: 22px;

  /* Shadow — soft, layered */
  --sh-1: 0 1px 2px rgba(15,27,45,.04), 0 1px 3px rgba(15,27,45,.06);
  --sh-2: 0 2px 4px rgba(15,27,45,.04), 0 6px 16px rgba(15,27,45,.07);
  --sh-3: 0 8px 24px rgba(15,27,45,.10), 0 24px 48px rgba(15,27,45,.10);
  --sh-pop: 0 10px 30px rgba(20,41,107,.16);

  --ink-2: #344256;

  --ease: cubic-bezier(.22,.61,.36,1);
  --ease-out: cubic-bezier(.16,1,.3,1);

  --font: "IBM Plex Sans Thai", system-ui, -apple-system, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

#root { height: 100%; }

.num { font-family: var(--mono); font-feature-settings: "tnum"; letter-spacing: -.01em; }

::selection { background: var(--primary-soft); color: var(--primary-800); }

/* Scrollbar */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: #d2dae6; border-radius: 99px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: #b9c4d4; background-clip: content-box; }
*::-webkit-scrollbar-track { background: transparent; }

/* ===================== App shell ===================== */
.app {
  display: grid;
  grid-template-columns: 256px 1fr;
  height: 100%;
  overflow: hidden;
}

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
  z-index: 40;
}
.brand {
  display: flex; align-items: center; gap: 12px;
  padding: 20px 20px 18px;
}
.brand .logo {
  width: 38px; height: 38px; border-radius: 11px;
  background: linear-gradient(150deg, var(--primary-600), var(--primary-800));
  display: grid; place-items: center; color: #fff;
  box-shadow: 0 4px 12px rgba(37,99,235,.32);
  flex: none;
}
.brand .b-name { font-weight: 600; font-size: 15.5px; line-height: 1.1; letter-spacing: -.01em; }
.brand .b-sub  { font-size: 11.5px; color: var(--muted-2); margin-top: 2px; }

.nav { padding: 6px 12px; overflow-y: auto; flex: 1; min-height: 0; }
.nav-label {
  font-size: 11px; font-weight: 600; color: var(--muted-2);
  letter-spacing: .04em; padding: 16px 12px 7px;
}
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 9.5px 12px; border-radius: 10px;
  color: var(--ink-2); font-size: 14.5px; font-weight: 500;
  cursor: pointer; position: relative;
  transition: background .16s var(--ease), color .16s var(--ease);
  user-select: none;
}
.nav-item svg { flex: none; opacity: .72; transition: opacity .16s; }
.nav-item:hover { background: var(--bg-2); }
.nav-item:hover svg { opacity: .95; }
.nav-item.active {
  background: var(--primary-soft); color: var(--primary-700); font-weight: 600;
}
.nav-item.active svg { opacity: 1; color: var(--primary-600); }
.nav-item .badge-count {
  margin-left: auto; font-size: 11.5px; font-weight: 600;
  background: var(--bg-2); color: var(--muted);
  padding: 1px 8px; border-radius: 99px;
}
.nav-item.active .badge-count { background: #fff; color: var(--primary-700); }

.side-foot {
  padding: 14px; border-top: 1px solid var(--line);
}
.user-chip {
  display: flex; align-items: center; gap: 11px;
  padding: 8px; border-radius: 12px; cursor: pointer;
  transition: background .16s;
}
.user-chip:hover { background: var(--bg-2); }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; flex: none;
  background: linear-gradient(140deg,#3b82f6,#1e40af); color: #fff;
  display: grid; place-items: center; font-weight: 600; font-size: 14px;
}

/* ---------- Main ---------- */
.main {
  min-width: 0; min-height: 0;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 0 28px; height: 66px; flex: none;
  background: rgba(255,255,255,.78);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
  z-index: 20;
}
.topbar h1 { font-size: 19px; font-weight: 600; letter-spacing: -.01em; margin: 0; white-space: nowrap; }
.topbar .crumb { font-size: 12.5px; color: var(--muted-2); margin-bottom: 1px; white-space: nowrap; }
.topbar-title { flex: none; }
.topbar-spacer { flex: 1; }

.search {
  display: flex; align-items: center; gap: 9px;
  background: var(--bg-2); border: 1px solid transparent;
  padding: 8px 13px; border-radius: 11px; width: 280px;
  color: var(--muted); transition: border .16s, background .16s, box-shadow .16s;
}
.search:focus-within { background: #fff; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.search input { border: none; background: none; outline: none; font: inherit; font-size: 14px; color: var(--ink); width: 100%; }
.search input::placeholder { color: var(--muted-2); }

.icon-btn {
  width: 40px; height: 40px; border-radius: 11px; border: 1px solid var(--line);
  background: var(--surface); color: var(--muted); cursor: pointer;
  display: grid; place-items: center; position: relative;
  transition: all .16s var(--ease);
}
.icon-btn:hover { color: var(--ink); border-color: #d6deea; box-shadow: var(--sh-1); }
.icon-btn .dot { position: absolute; top: 9px; right: 10px; width: 7px; height: 7px; border-radius: 50%; background: var(--red); border: 2px solid #fff; }

.scroll-area {
  flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden;
  scroll-behavior: smooth;
}
.page { padding: 28px; max-width: 1320px; margin: 0 auto; }
.page-head { margin-bottom: 22px; }
.page-head h2 { font-size: 24px; font-weight: 600; margin: 0 0 4px; letter-spacing: -.02em; }
.page-head p { color: var(--muted); margin: 0; font-size: 14px; }

/* ===================== Primitives ===================== */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--sh-1);
}
.card-pad { padding: 20px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 600; font-size: 14px;
  padding: 10px 16px; border-radius: 11px; cursor: pointer;
  border: 1px solid transparent; white-space: nowrap;
  transition: all .16s var(--ease); user-select: none;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn-primary { background: var(--primary-600); color: #fff; box-shadow: 0 2px 8px rgba(37,99,235,.28); }
.btn-primary:hover { background: var(--primary-700); box-shadow: 0 4px 14px rgba(37,99,235,.36); }
.btn-ghost { background: var(--surface); color: var(--ink-2); border-color: var(--line); }
.btn-ghost:hover { border-color: #ccd6e4; background: var(--surface-2); box-shadow: var(--sh-1); }
.btn-soft { background: var(--primary-soft); color: var(--primary-700); }
.btn-soft:hover { background: #dde8ff; }
.btn-danger { background: var(--red); color: #fff; }
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 9px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 99px;
  white-space: nowrap;
}
.badge .b-dot { width: 6px; height: 6px; border-radius: 50%; }
.badge-green { background: var(--green-soft); color: #0a7d44; }
.badge-amber { background: var(--amber-soft); color: #9a6300; }
.badge-red   { background: var(--red-soft);   color: #b4232f; }
.badge-blue  { background: var(--primary-soft); color: var(--primary-700); }
.badge-gray  { background: var(--bg-2); color: var(--muted); }

.chip {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 13px; font-weight: 500; padding: 7px 13px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  cursor: pointer; transition: all .15s var(--ease); white-space: nowrap;
}
.chip:hover { border-color: #ccd6e4; background: var(--surface-2); }
.chip.active { background: var(--primary-soft); border-color: transparent; color: var(--primary-700); font-weight: 600; }

/* Inputs */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field .hint { font-size: 12px; color: var(--muted-2); }
.input, .select, textarea.input {
  font: inherit; font-size: 14.5px; color: var(--ink);
  padding: 10px 13px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); outline: none; width: 100%;
  transition: border .16s, box-shadow .16s;
}
.input:focus, .select:focus, textarea.input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.input::placeholder { color: var(--muted-2); }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; cursor: pointer; }

/* ===================== Table ===================== */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tbl thead th {
  text-align: left; font-size: 11.5px; font-weight: 600; color: var(--muted);
  letter-spacing: .03em; padding: 12px 16px;
  border-bottom: 1px solid var(--line); white-space: nowrap;
  position: sticky; top: 0; background: var(--surface-2); z-index: 2;
}
table.tbl tbody td { padding: 13px 16px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.tbl tbody tr { transition: background .13s; }
table.tbl tbody tr:hover { background: var(--primary-soft2); }
table.tbl tbody tr:last-child td { border-bottom: none; }
.t-right { text-align: right; }
.t-center { text-align: center; }

/* item identity cell */
.item-id { display: flex; align-items: center; gap: 12px; }
.item-thumb {
  width: 40px; height: 40px; border-radius: 10px; flex: none;
  display: grid; place-items: center; color: #fff;
}
.item-name { font-weight: 600; font-size: 14px; line-height: 1.25; }
.item-sku { font-size: 12px; color: var(--muted-2); }

/* ===================== KPI ===================== */
.kpi-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 18px; }
.kpi {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 18px 20px; box-shadow: var(--sh-1); position: relative; overflow: hidden;
  transition: transform .2s var(--ease-out), box-shadow .2s var(--ease-out);
}
.kpi:hover { transform: translateY(-3px); box-shadow: var(--sh-2); }
.kpi .k-top { display: flex; align-items: center; justify-content: space-between; }
.kpi .k-ic { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; }
.kpi .k-label { font-size: 13px; color: var(--muted); font-weight: 500; }
.kpi .k-val { font-size: 27px; font-weight: 600; margin-top: 12px; letter-spacing: -.02em; }
.kpi .k-val small { font-size: 14px; color: var(--muted); font-weight: 500; }
.kpi .k-delta { font-size: 12.5px; font-weight: 600; margin-top: 6px; display: inline-flex; align-items: center; gap: 4px; }
.k-up { color: var(--green); } .k-down { color: var(--red); }

/* progress / fill bar */
.bar { height: 7px; background: var(--bg-2); border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 99px; transition: width .6s var(--ease-out); }

/* ===================== Drawer / Modal ===================== */
.scrim {
  position: fixed; inset: 0; background: rgba(15,27,45,.42);
  backdrop-filter: blur(2px); z-index: 100;
  opacity: 0; animation: fadeIn .22s var(--ease) forwards;
}
@keyframes fadeIn { to { opacity: 1; } }
.drawer {
  position: fixed; top: 0; right: 0; height: 100%; width: min(560px, 94vw);
  background: var(--bg); z-index: 101; box-shadow: var(--sh-3);
  display: flex; flex-direction: column;
  transform: translateX(100%); animation: slideIn .34s var(--ease-out) forwards;
}
@keyframes slideIn { to { transform: translateX(0); } }
.drawer-head { padding: 20px 24px; background: var(--surface); border-bottom: 1px solid var(--line); display: flex; align-items: flex-start; gap: 14px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 22px 24px; }
.drawer-foot { padding: 16px 24px; background: var(--surface); border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; }

.modal {
  position: fixed; z-index: 101; left: 50%; top: 50%;
  transform: translate(-50%,-46%); width: min(520px, 94vw);
  background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--sh-3);
  opacity: 0; animation: pop .28s var(--ease-out) forwards;
}
@keyframes pop { to { transform: translate(-50%,-50%); opacity: 1; } }

/* ===================== Toast ===================== */
.toast-wrap { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.toast {
  display: flex; align-items: center; gap: 12px;
  background: var(--ink); color: #fff; padding: 13px 18px; border-radius: 13px;
  box-shadow: var(--sh-pop); font-size: 14px; font-weight: 500;
  animation: toastIn .35s var(--ease-out);
}
.toast .t-ic { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; flex: none; }
@keyframes toastIn { from { transform: translateY(16px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ===================== Location grid ===================== */
.zone-grid { display: grid; gap: 12px; }
.bin {
  aspect-ratio: 1.15; border-radius: 12px; border: 1.5px solid var(--line);
  background: var(--surface); padding: 11px 12px; cursor: pointer; position: relative;
  display: flex; flex-direction: column; justify-content: space-between;
  transition: transform .18s var(--ease-out), box-shadow .18s, border-color .18s;
  overflow: hidden;
}
.bin:hover { transform: translateY(-3px); box-shadow: var(--sh-2); border-color: #cdd8e8; z-index: 3; }
.bin .bin-code { font-size: 12.5px; font-weight: 600; color: var(--ink-2); font-family: var(--mono); }
.bin .bin-fill-label { font-size: 11px; color: var(--muted); }
.bin .bin-bar { position: absolute; left: 0; bottom: 0; width: 100%; height: 5px; background: var(--line-2); }
.bin .bin-bar > span { display: block; height: 100%; transition: width .5s var(--ease-out); }
.bin .bin-count { font-size: 22px; font-weight: 600; letter-spacing: -.02em; }
.bin .bin-count small { font-size: 12px; color: var(--muted); font-weight: 500; }
.bin.empty { background: repeating-linear-gradient(45deg,#fafbfd,#fafbfd 7px,#f2f5f9 7px,#f2f5f9 14px); border-style: dashed; }
.bin.empty .bin-count { color: var(--muted-2); }
.bin.sel { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

/* ===================== Charts ===================== */
.chart-bars { display: flex; align-items: flex-end; gap: 10px; height: 180px; }
.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; justify-content: flex-end; height: 100%; }
.chart-stack { width: 100%; display: flex; flex-direction: column; justify-content: flex-end; gap: 3px; height: 100%; }
.chart-seg { width: 100%; border-radius: 5px; transition: height .6s var(--ease-out); min-height: 2px; }
.chart-x { font-size: 11.5px; color: var(--muted-2); }

/* line list */
.line-row { display: grid; grid-template-columns: 1fr 120px 150px 40px; gap: 12px; align-items: center; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }

/* timeline */
.tl-item { display: flex; gap: 14px; padding-bottom: 4px; }
.tl-rail { display: flex; flex-direction: column; align-items: center; flex: none; }
.tl-dot { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; flex: none; z-index: 1; }
.tl-line { width: 2px; flex: 1; background: var(--line); margin: 4px 0; }

/* segmented */
.seg { display: inline-flex; background: var(--bg-2); border-radius: 11px; padding: 3px; gap: 2px; }
.seg button { font: inherit; font-size: 13.5px; font-weight: 600; color: var(--muted); border: none; background: none; padding: 7px 15px; border-radius: 8px; cursor: pointer; transition: all .16s var(--ease); }
.seg button.on { background: var(--surface); color: var(--primary-700); box-shadow: var(--sh-1); }

/* loading spinner */
.spin { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* entrance for page content */
.fade-up { animation: fadeUp .42s var(--ease-out) both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
.stagger > * { animation: fadeUp .5s var(--ease-out) both; }
.stagger > *:nth-child(1){animation-delay:.02s}
.stagger > *:nth-child(2){animation-delay:.07s}
.stagger > *:nth-child(3){animation-delay:.12s}
.stagger > *:nth-child(4){animation-delay:.17s}
.stagger > *:nth-child(5){animation-delay:.22s}
.stagger > *:nth-child(6){animation-delay:.27s}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ===================== Quotation document ===================== */
.quote-stage { display: flex; justify-content: center; }
.quote-paper {
  width: 794px; max-width: 100%; background: #fff; color: #1a2233;
  border: 1px solid var(--line); border-radius: 6px; box-shadow: var(--sh-2);
  padding: 44px 48px; font-size: 13.5px; line-height: 1.5;
}
.q-head { display: flex; justify-content: space-between; gap: 24px; padding-bottom: 20px; border-bottom: 2px solid var(--primary-700); }
.q-company { display: flex; gap: 16px; align-items: flex-start; }
.q-logo { width: 64px; height: 64px; object-fit: contain; flex: none; border-radius: 8px; }
.q-logo-ph { background: linear-gradient(150deg, var(--primary-600), var(--primary-800)); color: #fff; display: grid; place-items: center; }
.q-cname { font-size: 18px; font-weight: 700; letter-spacing: -.01em; color: #14213d; margin-bottom: 4px; }
.q-cmeta { font-size: 12px; color: #5a6b82; line-height: 1.55; }
.q-title { text-align: right; flex: none; }
.q-title-th { font-size: 26px; font-weight: 700; color: var(--primary-700); letter-spacing: -.01em; }
.q-title-en { font-size: 12px; color: var(--muted-2); letter-spacing: .22em; margin-bottom: 12px; }
.q-meta-tbl { margin-left: auto; font-size: 12.5px; border-collapse: collapse; }
.q-meta-tbl td { padding: 2px 0; }
.q-meta-tbl td:first-child { color: #5a6b82; padding-right: 16px; text-align: right; }
.q-meta-tbl td:last-child { font-weight: 600; text-align: right; }
.q-cust { margin: 22px 0 18px; padding: 14px 16px; background: var(--primary-soft2); border-radius: 10px; border: 1px solid #e4edfb; }
.q-cust-label { font-size: 11px; color: var(--primary-700); font-weight: 600; letter-spacing: .03em; }
.q-cust-name { font-size: 16px; font-weight: 700; margin: 2px 0 4px; }
.q-cust-meta { display: flex; gap: 20px; font-size: 12.5px; color: #5a6b82; flex-wrap: wrap; }
table.q-items { width: 100%; border-collapse: collapse; margin-bottom: 18px; }
table.q-items thead th { background: #14213d; color: #fff; font-size: 12px; font-weight: 600; padding: 10px 12px; text-align: left; }
table.q-items thead th:first-child { border-radius: 6px 0 0 0; }
table.q-items thead th:last-child { border-radius: 0 6px 0 0; }
table.q-items tbody td { padding: 10px 12px; border-bottom: 1px solid #eef1f6; vertical-align: top; }
table.q-items .q-empty-row td { height: 34px; border-bottom: 1px solid #f4f6fa; }
.q-foot { display: flex; justify-content: space-between; gap: 28px; align-items: flex-start; }
.q-note { flex: 1; font-size: 12.5px; color: #5a6b82; }
.q-note-label { font-weight: 600; color: #1a2233; margin-bottom: 3px; }
.q-baht { margin-top: 14px; padding: 9px 13px; background: var(--surface-2); border: 1px dashed var(--line); border-radius: 8px; color: #1a2233; font-weight: 600; }
table.q-totals { width: 280px; flex: none; border-collapse: collapse; font-size: 13.5px; }
table.q-totals td { padding: 7px 4px; }
table.q-totals td:first-child { color: #5a6b82; }
table.q-totals td:last-child { text-align: right; font-weight: 600; }
table.q-totals .q-grand td { border-top: 2px solid #14213d; padding-top: 11px; font-size: 17px; font-weight: 700; }
table.q-totals .q-grand td:last-child { color: var(--primary-700); }
.q-sign { display: flex; gap: 40px; margin-top: 40px; }
.q-sign-box { flex: 1; text-align: center; font-size: 13px; font-weight: 600; }
.q-sign-line { border-top: 1px dotted #9aa7ba; margin-bottom: 8px; height: 38px; }
.q-sign-sub { font-size: 11px; color: var(--muted-2); font-weight: 400; margin-top: 4px; }

@media (max-width: 560px) {
  .quote-paper { padding: 24px 18px; }
  .q-head { flex-direction: column; gap: 16px; }
  .q-title { text-align: left; } .q-meta-tbl { margin-left: 0; }
  .q-foot { flex-direction: column; } table.q-totals { width: 100%; }
}

/* ===================== Print ===================== */
@media print {
  body { background: #fff; }
  .sidebar, .topbar, .mobile-tabbar, .sidebar-scrim, .no-print, .toast-wrap { display: none !important; }
  .app { display: block !important; height: auto !important; overflow: visible !important; }
  .main, .scroll-area { overflow: visible !important; height: auto !important; display: block !important; }
  .page { padding: 0 !important; max-width: none !important; }
  .quote-stage { display: block !important; }
  .quote-paper { width: 100% !important; max-width: none !important; border: none !important; box-shadow: none !important; border-radius: 0 !important; padding: 0 !important; }
  @page { margin: 14mm; size: A4 portrait; }
}

/* ===================== Auth screen ===================== */
.auth-wrap { display: grid; grid-template-columns: 1.05fr 1fr; height: 100%; background: var(--bg); }
.auth-brand { position: relative; overflow: hidden; background: linear-gradient(155deg, #1e40af 0%, #2563eb 60%, #1d4ed8 100%); color: #fff; display: flex; align-items: center; padding: 48px; }
.auth-brand-inner { position: relative; z-index: 2; max-width: 440px; }
.auth-logo { width: 56px; height: 56px; border-radius: 16px; background: rgba(255,255,255,.16); backdrop-filter: blur(6px); display: grid; place-items: center; margin-bottom: 28px; border: 1px solid rgba(255,255,255,.25); }
.auth-brand h1 { font-size: 32px; font-weight: 600; line-height: 1.18; letter-spacing: -.02em; margin: 0 0 14px; }
.auth-brand p { font-size: 15.5px; color: rgba(255,255,255,.82); line-height: 1.6; margin: 0 0 30px; }
.auth-feats { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 14px; }
.auth-feats li { display: flex; align-items: center; gap: 12px; font-size: 14.5px; color: rgba(255,255,255,.92); }
.auth-feat-ic { width: 32px; height: 32px; border-radius: 10px; background: rgba(255,255,255,.16); display: grid; place-items: center; flex: none; }
.auth-pattern { position: absolute; inset: 0; z-index: 1; opacity: .5;
  background-image: radial-gradient(circle at 1px 1px, rgba(255,255,255,.18) 1.5px, transparent 0);
  background-size: 26px 26px; mask-image: radial-gradient(120% 90% at 85% 15%, #000, transparent 70%); }
.auth-panel { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-h { font-size: 24px; font-weight: 600; letter-spacing: -.02em; margin-bottom: 4px; }
.auth-sub { font-size: 14px; color: var(--muted); margin-bottom: 26px; }
.auth-switch { text-align: center; font-size: 13.5px; color: var(--muted); margin-top: 20px; }
.auth-switch button { background: none; border: none; font: inherit; font-weight: 600; color: var(--primary-600); cursor: pointer; padding: 0; }
.auth-switch button:hover { text-decoration: underline; }
.auth-demo { display: flex; align-items: center; gap: 8px; justify-content: center; margin-top: 22px; padding: 11px; border-radius: 11px; background: var(--primary-soft2); color: var(--primary-700); font-size: 12.5px; border: 1px dashed #c7d8f7; }
.auth-foot { font-size: 12px; color: var(--muted-2); margin-top: 26px; }
@media (max-width: 820px) {
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
}

/* mobile menu button hidden on desktop */
.menu-btn { display: none; }
.mobile-tabbar { display: none; }
.sidebar-scrim { display: none; }

/* ===================== Responsive ===================== */
@media (max-width: 980px) {
  .kpi-grid { grid-template-columns: repeat(2,1fr); }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100%; width: 260px;
    transform: translateX(-100%); transition: transform .3s var(--ease-out);
    box-shadow: var(--sh-3);
  }
  .app.nav-open .sidebar { transform: translateX(0); }
  .sidebar-scrim { display: block; position: fixed; inset: 0; background: rgba(15,27,45,.4); z-index: 39; opacity: 0; pointer-events: none; transition: opacity .25s; }
  .app.nav-open .sidebar-scrim { opacity: 1; pointer-events: auto; }
  .menu-btn { display: grid; }
  .topbar { padding: 0 16px; height: 60px; }
  .search { display: none; }
  .page { padding: 18px 16px 90px; }
  .page-head h2 { font-size: 21px; }
  .scroll-area { padding-bottom: env(safe-area-inset-bottom); }

  /* bottom tab bar for mobile */
  .mobile-tabbar {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
    background: rgba(255,255,255,.92); backdrop-filter: blur(12px);
    border-top: 1px solid var(--line); padding: 7px 6px calc(7px + env(safe-area-inset-bottom));
    justify-content: space-around;
  }
  .mtab { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 4px 10px; border-radius: 10px; color: var(--muted); font-size: 10.5px; font-weight: 600; cursor: pointer; flex: 1; }
  .mtab.active { color: var(--primary-700); }
  .mtab svg { opacity: .8; }
  .mtab.active svg { opacity: 1; }
}
@media (max-width: 560px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .kpi .k-val { font-size: 22px; }
  .drawer { width: 100vw; }
}
