/* ============================================================
   NEXUS ERP — design tokens & shell
   ============================================================ */
:root {
  --ink: #12161f;
  --ink-soft: #1a202c;
  --canvas: #f4f5f7;
  --paper: #ffffff;

  --line: #e4e7ec;
  --line-strong: #d0d5dd;

  --text: #1a1f29;
  --muted: #667085;
  --faint: #98a2b3;

  --brand: #0f766e;
  --brand-strong: #0b5d57;
  --brand-soft: #e7f4f1;

  --amber: #b54708;
  --amber-soft: #fef0c7;
  --green: #067647;
  --green-soft: #ecfdf3;
  --red: #b42318;
  --red-soft: #fef3f2;

  --radius: 10px;
  --radius-sm: 7px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-lg: 0 24px 48px -12px rgba(16, 24, 40, .28);
  --sidebar-w: 236px;
  --font: "Segoe UI Variable", "Segoe UI", "PingFang SC", "Hiragino Sans GB",
          "Microsoft YaHei", ui-sans-serif, sans-serif;
}

* { box-sizing: border-box; }

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

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, p { margin: 0; }
button { font-family: inherit; font-size: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
svg { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- shell ---------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 22px 14px 16px;
  background:
    radial-gradient(120% 60% at 0% 0%, #1e2a33 0%, transparent 60%),
    linear-gradient(180deg, #12161f 0%, #10141c 100%);
  color: #cbd5df;
  border-right: 1px solid #000;
}

.sidebar::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: repeating-linear-gradient(135deg, rgba(255,255,255,.022) 0 1px, transparent 1px 7px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 4px 8px 22px;
  position: relative;
  z-index: 1;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: linear-gradient(150deg, #14b8a6, #0f766e);
  color: #03231f;
  font-weight: 800;
  font-size: 17px;
  letter-spacing: -.02em;
  box-shadow: 0 6px 16px -6px rgba(20, 184, 166, .8);
}

.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { color: #f2f5f8; font-size: 15px; letter-spacing: .16em; font-weight: 700; }
.brand-text span { font-size: 9px; letter-spacing: .22em; color: #64748b; margin-top: 3px; }

.nav { position: relative; z-index: 1; flex: 1; }
.nav-label {
  font-size: 10px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: #5a6878;
  padding: 16px 12px 7px;
}

.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  margin-bottom: 2px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #aab6c4;
  text-align: left;
  transition: background .16s, color .16s;
}
.nav-item svg { width: 17px; height: 17px; opacity: .85; }
.nav-item:hover { background: rgba(255,255,255,.055); color: #eaeef2; }
.nav-item.is-active {
  background: linear-gradient(90deg, rgba(20,184,166,.18), rgba(20,184,166,.04));
  color: #eafffb;
  box-shadow: inset 2px 0 0 #14b8a6;
}
.nav-item.is-active svg { stroke: #2dd4bf; opacity: 1; }

.sidebar-foot {
  position: relative;
  z-index: 1;
  border-top: 1px solid rgba(255,255,255,.07);
  padding: 14px 12px 2px;
  font-size: 11px;
  color: #5f6d7d;
}
.storage-line { display: flex; align-items: center; gap: 7px; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: #2dd4bf; box-shadow: 0 0 0 3px rgba(45,212,191,.15); }
.version { margin-top: 6px; font-size: 10px; letter-spacing: .06em; color: #47535f; }

/* ---------- main ---------- */
.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 28px;
  background: rgba(244,245,247,.86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-title h1 { font-size: 19px; font-weight: 650; letter-spacing: -.015em; }
.topbar-title p { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.topbar-actions { display: flex; align-items: center; gap: 9px; }

.content { padding: 24px 28px 56px; }
.view { display: none; }
.view.is-active { display: block; animation: rise .22s ease-out; }

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--paper);
  color: #344054;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .06s;
  box-shadow: var(--shadow-sm);
}
.btn:hover { background: #f9fafb; border-color: #b9c1cb; }
.btn:active { transform: translateY(.5px); }
.btn svg { width: 15px; height: 15px; }

.btn.primary {
  background: linear-gradient(180deg, #12897f, var(--brand));
  border-color: #0b6d64;
  color: #fff;
  box-shadow: 0 1px 2px rgba(16,24,40,.12), inset 0 1px 0 rgba(255,255,255,.14);
}
.btn.primary:hover { background: linear-gradient(180deg, #14a094, #0c8078); }

.btn.ghost { border-color: transparent; background: transparent; box-shadow: none; color: var(--muted); }
.btn.ghost:hover { background: #edeff2; color: var(--text); }

.btn.danger { color: var(--red); border-color: #f3c3bd; background: #fff; }
.btn.danger:hover { background: var(--red-soft); }
.btn.solid-danger { background: #b42318; border-color: #9a1c12; color: #fff; }
.btn.solid-danger:hover { background: #97190f; }

.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.icon-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: #edeff2; color: var(--text); }
.icon-btn svg { width: 17px; height: 17px; }

.link-btn {
  border: 0;
  background: none;
  padding: 0;
  color: var(--brand);
  font-size: 12.5px;
  font-weight: 500;
}
.link-btn:hover { text-decoration: underline; }
.link-btn.danger { color: var(--red); }

/* ============================================================
   Cards / KPI
   ============================================================ */
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
}
.card-head h3 { font-size: 13.5px; font-weight: 600; letter-spacing: -.01em; }
.card-head .sub { font-size: 12px; color: var(--faint); margin-top: 2px; }
.card-body { padding: 18px; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.kpi {
  position: relative;
  padding: 16px 18px 15px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.kpi::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--brand);
  opacity: .75;
}
.kpi.is-warn::before { background: #d97706; }
.kpi.is-muted::before { background: #98a2b3; }
.kpi-label { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.kpi-value {
  margin-top: 8px;
  font-size: 25px;
  font-weight: 650;
  letter-spacing: -.03em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.kpi-value small { font-size: 14px; font-weight: 500; color: var(--faint); margin-right: 3px; }
.kpi-foot { margin-top: 7px; font-size: 11.5px; color: var(--faint); }
.kpi-foot b { color: var(--green); font-weight: 600; }
.kpi-foot b.warn { color: var(--amber); }

.dash-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.stack { display: flex; flex-direction: column; gap: 16px; }

/* mini bar chart */
.chart {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  height: 132px;
  padding: 4px 2px 0;
}
.chart-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 7px; height: 100%; }
.chart-bar-wrap { width: 100%; flex: 1; display: flex; align-items: flex-end; }
.chart-bar {
  width: 100%;
  min-height: 3px;
  border-radius: 4px 4px 2px 2px;
  background: linear-gradient(180deg, #2dd4bf, #0f766e);
  transition: filter .15s;
  position: relative;
}
.chart-col:hover .chart-bar { filter: brightness(1.12); }
.chart-day { font-size: 10.5px; color: var(--faint); letter-spacing: .02em; }
.chart-val { font-size: 10.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ============================================================
   Toolbar / filters
   ============================================================ */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius) var(--radius) 0 0;
  border-bottom: 0;
}
.search-field {
  position: relative;
  flex: 0 1 268px;
  min-width: 190px;
}
.search-field svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px; height: 15px;
  color: var(--faint);
}
.search-field input { padding-left: 32px; }

.field-inline { display: flex; align-items: center; gap: 7px; }
.field-inline > label { font-size: 12px; color: var(--muted); white-space: nowrap; }
.toolbar-sep { width: 1px; height: 22px; background: var(--line); margin: 0 2px; }
.toolbar-spacer { flex: 1; }

/* ============================================================
   Inputs
   ============================================================ */
input[type="text"], input[type="number"], input[type="date"],
input[type="tel"], input[type="search"], select, textarea {
  width: 100%;
  height: 36px;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
textarea { height: auto; min-height: 68px; padding: 8px 11px; resize: vertical; line-height: 1.55; }
input::placeholder, textarea::placeholder { color: #b0b8c4; }
input:hover, select:hover, textarea:hover { border-color: #b9c1cb; }
input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(15,118,110,.13);
}
select {
  appearance: none;
  padding-right: 30px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5' fill='none' stroke='%23667085' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
input.compact, select.compact { height: 32px; font-size: 13px; }

/* form layout */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label { font-size: 12.5px; font-weight: 500; color: #344054; display: flex; align-items: center; gap: 5px; }
.field > label .req { color: var(--red); font-weight: 600; }
.field .hint { font-size: 11.5px; color: var(--faint); }
.field .err { font-size: 11.5px; color: var(--red); display: none; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: #e38b82; background: #fffbfa; }
.field.has-error .err { display: block; }

.input-group { display: flex; align-items: stretch; }
.input-group .prefix {
  display: grid;
  place-items: center;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-right: 0;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  background: #f9fafb;
  color: var(--muted);
  font-size: 12.5px;
}
.input-group input { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

.form-section { margin-bottom: 22px; }
.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--line);
}
.section-title .idx {
  width: 18px; height: 18px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 10px;
  letter-spacing: 0;
}

/* switch */
.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
  width: 40px; height: 22px;
  border-radius: 999px;
  background: #d7dce3;
  position: relative;
  transition: background .18s;
  flex: none;
}
.switch .track::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,.2);
  transition: transform .18s;
}
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px rgba(15,118,110,.2); }
.switch .switch-label { font-size: 13px; color: #344054; }

/* ============================================================
   Table
   ============================================================ */
.table-wrap {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 0 0 var(--radius) var(--radius);
  overflow: auto;
}
table.data { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
table.data th {
  position: sticky;
  top: 0;
  z-index: 2;
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--muted);
  text-transform: uppercase;
  background: #fafbfc;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.data th.sortable { cursor: pointer; user-select: none; }
table.data th.sortable:hover { color: var(--text); }
table.data th .arrow { font-size: 9px; margin-left: 4px; color: var(--brand); }
table.data td {
  padding: 11px 14px;
  border-bottom: 1px solid #f1f3f5;
  vertical-align: middle;
}
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr { transition: background .12s; }
table.data tbody tr:hover { background: #fafcfb; }
table.data .right { text-align: right; }
table.data .center { text-align: center; }
table.data .nowrap { white-space: nowrap; }
td .cell-strong { font-weight: 550; color: var(--text); }
td .cell-sub { font-size: 11.5px; color: var(--faint); margin-top: 2px; }
td .money { font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
td .muted { color: var(--faint); }
.row-actions { display: flex; gap: 12px; justify-content: flex-end; }

.order-no { font-variant-numeric: tabular-nums; font-size: 12.5px; color: var(--muted); letter-spacing: .01em; }

/* badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
}
.badge .bdot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.badge.shipped { background: var(--green-soft); color: var(--green); }
.badge.pending { background: var(--amber-soft); color: var(--amber); }
.badge.low { background: var(--red-soft); color: var(--red); }
.badge.ok { background: var(--brand-soft); color: var(--brand); }
.badge.neutral { background: #f2f4f7; color: #475467; }

/* pagination */
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 14px;
  border-top: 1px solid var(--line);
  background: var(--paper);
  border-radius: 0 0 var(--radius) var(--radius);
  font-size: 12.5px;
  color: var(--muted);
}
.pager-btns { display: flex; align-items: center; gap: 6px; }
.pager-btn {
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: #475467;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}
.pager-btn:hover:not(:disabled) { background: #f9fafb; border-color: var(--line-strong); }
.pager-btn.is-active { background: var(--brand); border-color: var(--brand); color: #fff; }
.pager-btn:disabled { opacity: .45; cursor: not-allowed; }

/* empty state */
.empty {
  padding: 54px 20px;
  text-align: center;
  color: var(--muted);
}
.empty .glyph {
  width: 46px; height: 46px;
  margin: 0 auto 14px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: #f2f4f7;
  color: #98a2b3;
}
.empty .glyph svg { width: 22px; height: 22px; }
.empty h4 { font-size: 13.5px; font-weight: 600; color: #344054; margin-bottom: 5px; }
.empty p { font-size: 12.5px; color: var(--faint); margin-bottom: 14px; }

/* ============================================================
   Drawer (side panel)
   ============================================================ */
.drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  justify-content: flex-end;
  background: rgba(16, 24, 40, .38);
  backdrop-filter: blur(2px);
  animation: fade .18s ease-out;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.drawer {
  width: min(760px, 96vw);
  height: 100%;
  display: flex;
  flex-direction: column;
  background: #fbfbfc;
  box-shadow: var(--shadow-lg);
  animation: slide-in .26s cubic-bezier(.22,.8,.3,1);
}
.drawer.narrow { width: min(440px, 96vw); }
@keyframes slide-in { from { transform: translateX(28px); opacity: .6; } to { transform: none; opacity: 1; } }

.drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 18px 22px 15px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.drawer-head .eyebrow {
  font-size: 10.5px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--brand);
  font-weight: 600;
  margin-bottom: 4px;
}
.drawer-head h2 { font-size: 17px; font-weight: 650; letter-spacing: -.015em; }
.drawer-head .meta { font-size: 12px; color: var(--faint); margin-top: 3px; }

.drawer-body { flex: 1; overflow-y: auto; padding: 20px 22px 28px; }
.drawer-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 22px;
  background: #fff;
  border-top: 1px solid var(--line);
  box-shadow: 0 -4px 16px -12px rgba(16,24,40,.3);
}
.foot-total { display: flex; flex-direction: column; line-height: 1.25; }
.foot-total .lbl { font-size: 11px; color: var(--faint); letter-spacing: .04em; }
.foot-total .val { font-size: 20px; font-weight: 700; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.foot-total .val small { font-size: 13px; font-weight: 600; margin-right: 2px; color: var(--muted); }
.foot-actions { display: flex; gap: 9px; }

/* item editor */
.items-box { border: 1px solid var(--line); border-radius: 9px; background: #fff; overflow: hidden; }
.items-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.items-table th {
  background: #fafbfc;
  font-size: 11px;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}
.items-table td { padding: 7px 8px; border-bottom: 1px solid #f4f5f7; vertical-align: top; }
.items-table tr:last-child td { border-bottom: 0; }
.items-table input { height: 34px; font-size: 13px; }
.items-table .col-idx { width: 30px; text-align: center; color: var(--faint); font-size: 11.5px; padding-top: 16px; }
.items-table .col-qty { width: 86px; }
.items-table .col-price { width: 110px; }
.items-table .col-sub { width: 112px; text-align: right; padding-top: 16px; }
.items-table .col-del { width: 38px; padding-top: 12px; }
.items-table .subtotal { font-weight: 550; font-variant-numeric: tabular-nums; }
.items-table .sku-hint { font-size: 11px; color: var(--faint); margin-top: 3px; padding-left: 2px; }
.items-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 10px;
  background: #fafbfc;
  border-top: 1px solid var(--line);
}
.items-foot .sum { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.items-foot .sum b { color: var(--text); font-weight: 600; }
.add-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 10px;
  border: 1px dashed var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--brand);
  font-size: 12.5px;
  font-weight: 500;
}
.add-row:hover { background: var(--brand-soft); border-color: #86c9c0; }
.add-row svg { width: 13px; height: 13px; }

/* ============================================================
   Dialog (confirm)
   ============================================================ */
.dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(16,24,40,.45);
  animation: fade .15s ease-out;
}
.dialog {
  width: min(420px, 100%);
  background: #fff;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 22px;
  animation: pop .18s cubic-bezier(.22,.8,.3,1);
}
@keyframes pop { from { transform: scale(.97); opacity: .7; } to { transform: none; opacity: 1; } }
.dialog h3 { font-size: 15.5px; font-weight: 650; margin-bottom: 7px; }
.dialog p { font-size: 13px; color: var(--muted); line-height: 1.6; }
.dialog .dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 20px; }

/* ============================================================
   Toast
   ============================================================ */
.toast-root {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 9px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 210px;
  max-width: 380px;
  padding: 11px 14px;
  border-radius: 9px;
  background: #101828;
  color: #f2f5f8;
  font-size: 13px;
  box-shadow: 0 12px 28px -8px rgba(16,24,40,.45);
  animation: toast-in .22s cubic-bezier(.22,.8,.3,1);
}
.toast.out { animation: toast-out .18s ease-in forwards; }
.toast svg { width: 15px; height: 15px; flex: none; }
.toast.success svg { stroke: #2dd4bf; }
.toast.error svg { stroke: #fda29b; }
.toast.warn svg { stroke: #fdb022; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px); } }

/* ============================================================
   Misc blocks
   ============================================================ */
.mini-list { display: flex; flex-direction: column; }
.mini-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 18px;
  border-bottom: 1px solid #f4f5f7;
  font-size: 13px;
}
.mini-row:last-child { border-bottom: 0; }
.mini-row .who { font-weight: 500; }
.mini-row .when { font-size: 11.5px; color: var(--faint); margin-top: 2px; }
.mini-row .amt { font-variant-numeric: tabular-nums; font-weight: 600; }

.data-tools { display: flex; flex-wrap: wrap; gap: 8px; }
.note-box {
  display: flex;
  gap: 9px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #fffaeb;
  border: 1px solid #fedf89;
  color: #93370d;
  font-size: 12.5px;
  line-height: 1.55;
}
.note-box svg { width: 15px; height: 15px; flex: none; margin-top: 1px; }

.kbd {
  display: inline-block;
  padding: 1px 5px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: #fff;
  font-size: 10.5px;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  color: var(--muted);
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1180px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 232px;
    transform: translateX(-100%);
    transition: transform .22s ease;
    z-index: 70;
  }
  .app.nav-open .sidebar { transform: none; }
  .nav-toggle { display: grid !important; }
  .content { padding: 18px 16px 48px; }
  .topbar { padding: 14px 16px; }
  .form-grid { grid-template-columns: 1fr; }
}
.nav-toggle { display: none; width: 34px; height: 34px; place-items: center; border: 1px solid var(--line); border-radius: 7px; background: #fff; }
@media (max-width: 620px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .search-field { flex: 1 1 100%; }
  .drawer { width: 100vw; }
  .drawer-foot { flex-direction: column; align-items: stretch; }
  .foot-actions { justify-content: flex-end; }
}

/* ============================================================
   Layout helpers used by views
   ============================================================ */
body.no-scroll { overflow: hidden; }

.table-wrap { overflow: hidden; }
.table-scroll { overflow: auto; max-height: calc(100vh - 340px); min-height: 180px; }
.orders-table { min-width: 1020px; }
.inventory-table { min-width: 900px; }

.tracking {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 11.5px;
  color: #475467;
  background: #f5f6f8;
  border: 1px solid #eaecf0;
  border-radius: 4px;
  padding: 1px 5px;
  letter-spacing: -.01em;
}

.range-sep { color: var(--faint); font-size: 12px; }
.field-inline input[type="date"] { width: 138px; }
.field-inline input[type="date"].compact { padding: 0 8px; }

.filter-count { font-size: 12px; color: var(--muted); }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fafbfc;
  font-size: 11.5px;
  color: #475467;
}
.chip.quiet { border-color: transparent; background: transparent; color: var(--faint); padding-left: 0; }
button.chip { cursor: pointer; }
.chip.warn {
  background: var(--amber-soft);
  border-color: #fedf89;
  color: var(--amber);
  font-weight: 500;
}
.chip.warn:hover { background: #fde9b0; }

.check { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: #475467; cursor: pointer; }
.check input { width: 15px; height: 15px; accent-color: var(--brand); cursor: pointer; }

.stock-num { font-weight: 600; color: var(--text); }
.stock-num.is-low { color: var(--red); }

.chart-empty { margin-top: 10px; font-size: 12px; color: var(--faint); text-align: center; }
.storage-meta { margin-top: 10px; font-size: 11.5px; color: var(--faint); }

.mini-row[data-order] { cursor: pointer; transition: background .12s; }
.mini-row[data-order]:hover { background: #fafcfb; }
.mini-row[data-order]:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }

/* items validation */
.items-error {
  display: none;
  margin-top: 7px;
  font-size: 12px;
  color: var(--red);
  line-height: 1.5;
}
.items-error.show { display: block; }
.is-invalid { border-color: #e38b82 !important; background: #fffbfa !important; }

/* pager */
.pager-info { font-size: 12.5px; color: var(--muted); }
.pager-info b { color: var(--text); font-weight: 600; }
.pager-info b.money { font-variant-numeric: tabular-nums; }
.pager-range { margin-left: 8px; color: var(--faint); font-size: 11.5px; }
.pager-gap { color: var(--faint); padding: 0 4px; font-size: 12px; }

/* tabs / utility */
.hint { font-weight: 400; color: var(--faint); }

@media (max-width: 900px) {
  .table-scroll { max-height: none; }
  .filter-count { display: none; }
}

/* fix: 搜索框图标与输入文字重叠（提高优先级并置于最后） */
.search-field input,
.search-field input[type="search"] { padding-left: 33px; }
.search-field input::-webkit-search-cancel-button { margin-right: 2px; }

/* ============================================================
   Polish: fixed column widths, text truncation, drawer overflow
   ============================================================ */
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }

.drawer-body { overflow-x: hidden; }
.drawer { overflow-x: hidden; }

.orders-table { table-layout: fixed; }
.orders-table th:nth-child(1) { width: 148px; }
.orders-table th:nth-child(2) { width: 188px; }
.orders-table th:nth-child(3) { width: 156px; }
.orders-table th:nth-child(4) { width: auto; min-width: 200px; }
.orders-table th:nth-child(5) { width: 72px; }
.orders-table th:nth-child(6) { width: 118px; }
.orders-table th:nth-child(7) { width: 112px; }
.orders-table th:nth-child(8) { width: 96px; }
.orders-table th:nth-child(9) { width: 150px; }
.orders-table th:nth-child(10) { width: 104px; }

.inventory-table { table-layout: fixed; }
.inventory-table th:nth-child(1) { width: auto; min-width: 230px; }
.inventory-table th:nth-child(2) { width: 108px; }
.inventory-table th:nth-child(3) { width: 112px; }
.inventory-table th:nth-child(4) { width: 84px; }
.inventory-table th:nth-child(5) { width: 96px; }
.inventory-table th:nth-child(6) { width: 122px; }
.inventory-table th:nth-child(7) { width: 142px; }
.inventory-table th:nth-child(8) { width: 132px; }

td .cell-sub.ellipsis { max-width: 180px; }

/* 明细表在窄屏下自身滚动，避免列被裁切 */
.items-box { overflow-x: auto; overflow-y: hidden; }
.items-table { min-width: 540px; }

/* ============================================================
   发货库存扣减预览
   ============================================================ */
.ship-preview {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafbfc;
}
.ship-title {
  font-size: 10.5px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 8px;
}
.ship-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 76px 116px;
  gap: 8px;
  align-items: center;
  padding: 3px 0;
  font-size: 12.5px;
}
.ship-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ship-qty { text-align: right; color: var(--red); font-weight: 600; font-variant-numeric: tabular-nums; }
.ship-stock { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; }
.ship-stock.is-negative { color: var(--red); font-weight: 600; }
.ship-empty { font-size: 12.5px; color: var(--faint); line-height: 1.5; }

/* 覆盖 fixed 布局：改为自动布局 + 文本截断，避免列被压成 0 宽 */
.orders-table,
.inventory-table { table-layout: auto; min-width: 0; }

.orders-table th,
.orders-table td { padding-left: 12px; padding-right: 12px; }

.orders-table th:nth-child(1) { width: 126px; }
.orders-table th:nth-child(2) { width: 168px; }
.orders-table th:nth-child(3) { width: 138px; }
.orders-table th:nth-child(4) { width: 176px; }
.orders-table th:nth-child(5) { width: 62px; }
.orders-table th:nth-child(6) { width: 108px; }
.orders-table th:nth-child(7) { width: 98px; }
.orders-table th:nth-child(8) { width: 92px; }
.orders-table th:nth-child(9) { width: 132px; }
.orders-table th:nth-child(10) { width: 96px; }

.orders-table td:nth-child(2) .cell-strong { max-width: 150px; }
.orders-table td:nth-child(2) .cell-sub { max-width: 150px; }
.orders-table td:nth-child(3) { max-width: 138px; }
.orders-table td:nth-child(3) .muted,
.orders-table td:nth-child(3) .ellipsis { display: block; max-width: 132px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.orders-table td:nth-child(4) .ellipsis { max-width: 170px; }
.orders-table td:nth-child(9) { max-width: 132px; }

.inventory-table th,
.inventory-table td { padding-left: 12px; padding-right: 12px; }
.inventory-table td:first-child .cell-strong,
.inventory-table td:first-child .cell-sub { max-width: 260px; }


/* 兜底：明细列不被压缩、次级文本不竖排 */
.orders-table th:nth-child(4) { width: 176px; min-width: 128px; }
.orders-table td .cell-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ============================================================
   移动端可用性修正（覆盖前序规则）
   ============================================================ */
@media (max-width: 900px) {
  .topbar { flex-wrap: wrap; row-gap: 10px; }
  .topbar-title { flex: 1 1 auto; min-width: 0; }
  .topbar-title h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 18px; }
  .topbar-title p { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar-actions { flex: 0 0 auto; }
}

@media (max-width: 620px) {
  .topbar { padding: 12px 14px 14px; }
  .topbar-actions { flex: 1 1 100%; }
  .topbar-actions .btn { flex: 1 1 0; }

  .toolbar { padding: 10px; gap: 8px; }
  .search-field { flex: 1 1 100%; min-width: 0; }
  .field-inline { flex: 1 1 100%; }
  .field-inline input[type="date"] { width: 112px; }
  .field-inline label { min-width: 52px; }

  .pager { flex-direction: column; align-items: stretch; gap: 9px; }
  .pager-btns { justify-content: space-between; }
  .pager-btn { white-space: nowrap; }
  .pager-range { display: none; }
  .pager-info { line-height: 1.6; }
}

/* 明细表：收窄固定列，保证「商品名称」有可用宽度 */
.items-table { min-width: 640px; }
.items-table th:nth-child(2) { min-width: 150px; }
.items-table .col-spec { width: 150px; }
.items-table .col-qty { width: 72px; }
.items-table .col-price { width: 96px; }
.items-table .col-sub { width: 100px; }

/* ============================================================
   结款状态与结算方式
   ============================================================ */
.settle-tag {
  margin-top: 3px;
  font-size: 11px;
  line-height: 1.4;
  font-weight: 500;
  letter-spacing: .01em;
}
.settle-tag.is-settled { color: var(--green); }
.settle-tag.is-unsettled { color: var(--amber); }

.orders-table td .settle-tag { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 两个开关并排时保持顶部对齐 */
.form-grid > .field > .switch { height: 36px; }

/* 抽屉打开时提示条上移，避免遮住底部主按钮 */
body.no-scroll .toast-root { bottom: 86px; }
@media (max-width: 620px) {
  body.no-scroll .toast-root { bottom: 118px; left: 16px; right: 16px; }
  body.no-scroll .toast { min-width: 0; }
}

/* ============================================================
   五项 KPI 与结款快捷操作
   ============================================================ */
.kpi-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }

@media (max-width: 1400px) {
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1180px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 620px) {
  .kpi-grid { grid-template-columns: 1fr; }
}

/* 操作列容纳「结款/发货/编辑/删除」 */
.orders-table th:nth-child(10) { width: 138px; }
.orders-table .row-actions { gap: 10px; }

.unsettled-sum { color: var(--amber); }

.dialog .field .err { display: none; }
.dialog .field.has-error .err { display: block; }

/* 最终列宽：10 列在 1440 下完整可见，操作列不裁切 */
.orders-table th:nth-child(1) { width: 118px; }
.orders-table th:nth-child(2) { width: 150px; }
.orders-table th:nth-child(3) { width: 118px; }
.orders-table th:nth-child(4) { width: 150px; min-width: 120px; }
.orders-table th:nth-child(5) { width: 60px; }
.orders-table th:nth-child(6) { width: 116px; }
.orders-table th:nth-child(7) { width: 96px; }
.orders-table th:nth-child(8) { width: 90px; }
.orders-table th:nth-child(9) { width: 118px; }
.orders-table th:nth-child(10) { width: 130px; }

.orders-table .row-actions { gap: 8px; }
.orders-table .row-actions .link-btn { font-size: 12px; }
.orders-table td:nth-child(2) .cell-strong,
.orders-table td:nth-child(2) .cell-sub { max-width: 132px; }
.orders-table td:nth-child(3) .muted,
.orders-table td:nth-child(3) .ellipsis { max-width: 110px; }
.orders-table td:nth-child(4) .ellipsis { max-width: 144px; }
.orders-table td .settle-tag { max-width: 108px; }

/* ============================================================
   业务员列 / 客户管理表
   ============================================================ */
.orders-table th:nth-child(1) { width: 118px; min-width: 0; }
.orders-table th:nth-child(2) { width: 178px; min-width: 0; }
.orders-table th:nth-child(3) { width: 150px; min-width: 0; }
.orders-table th:nth-child(4) { width: 58px; min-width: 0; }
.orders-table th:nth-child(5) { width: 116px; min-width: 0; }
.orders-table th:nth-child(6) { width: 96px; min-width: 0; }
.orders-table th:nth-child(7) { width: 90px; min-width: 0; }
.orders-table th:nth-child(8) { width: 118px; min-width: 0; }
.orders-table th:nth-child(9) { width: 90px; min-width: 0; }
.orders-table th:nth-child(10) { width: 130px; min-width: 0; }

.orders-table td:nth-child(2) .cell-strong,
.orders-table td:nth-child(2) .cell-sub { max-width: 168px; }
.orders-table td:nth-child(3) .ellipsis { max-width: 144px; }
.orders-table td:nth-child(3) .muted { max-width: 144px; }
.orders-table td:nth-child(5) .settle-tag { max-width: 108px; }

.sales-tag {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: #f2f4f7;
  color: #344054;
  font-size: 11.5px;
  font-weight: 500;
  max-width: 82px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.customers-table th:nth-child(1) { width: 230px; }
.customers-table th:nth-child(2) { width: 150px; }
.customers-table th:nth-child(3) { width: 190px; }
.customers-table th:nth-child(4) { width: 76px; }
.customers-table th:nth-child(5) { width: 120px; }
.customers-table th:nth-child(6) { width: 110px; }
.customers-table th:nth-child(7) { width: 104px; }
.customers-table th:nth-child(8) { width: 140px; }
.customers-table td .row-actions { gap: 10px; }

/* 筛选栏收紧：1440 下一行放得下 5 个筛选控件 */
.search-field { flex: 0 1 230px; }
.field-inline input[type="date"] { width: 124px; }
.filter-count .chip { white-space: nowrap; }

/* ============================================================
   登录页 / 账号区
   ============================================================ */
body.is-locked { overflow: hidden; }
body.is-locked .app { display: none; }

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(90% 60% at 15% 0%, #1c2b33 0%, transparent 55%),
    radial-gradient(70% 50% at 100% 100%, #123c39 0%, transparent 60%),
    #0d1117;
}

.login-card {
  width: min(388px, 100%);
  background: #fff;
  border-radius: 14px;
  padding: 30px 28px 26px;
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .55);
}

.login-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 24px; }
.login-brand .brand-text strong { color: var(--ink); }
.login-brand .brand-text span { color: var(--faint); }

.login-card h1 { font-size: 22px; font-weight: 650; letter-spacing: -.02em; }
.login-sub { font-size: 13px; color: var(--muted); margin: 5px 0 22px; }

.login-card .field { margin-bottom: 14px; }
.login-submit { width: 100%; height: 40px; margin-top: 8px; font-size: 14px; }

.login-error {
  display: none;
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--red);
  line-height: 1.5;
}
.login-error.show { display: block; }

.login-hint {
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--faint);
  line-height: 1.7;
}
.login-hint code {
  background: #f2f4f7;
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 11px;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
}

.account-line { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; }
.logout-btn {
  height: 24px;
  padding: 0 9px;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 6px;
  background: transparent;
  color: #8b98a8;
  font-size: 11px;
  transition: color .15s, border-color .15s;
}
.logout-btn:hover { color: #e6edf3; border-color: rgba(255, 255, 255, .32); }

/* 登录遮罩：display 会覆盖 hidden 属性，需显式声明 */
.login-screen[hidden] { display: none !important; }

/* 对公账户输入组合 + hidden 全局兜底 */
[hidden] { display: none !important; }

.input-with-action { display: flex; align-items: center; gap: 8px; }
.input-with-action select { flex: 1 1 auto; min-width: 0; }
.input-with-action .btn { flex: none; height: 36px; }

/* 结算标签变长后重平衡列宽（10 列总宽 ≤1106，容器 1148） */
.orders-table th:nth-child(1) { width: 116px; }
.orders-table th:nth-child(2) { width: 168px; }
.orders-table th:nth-child(3) { width: 144px; }
.orders-table th:nth-child(4) { width: 56px; }
.orders-table th:nth-child(5) { width: 114px; }
.orders-table th:nth-child(6) { width: 94px; }
.orders-table th:nth-child(7) { width: 88px; }
.orders-table th:nth-child(8) { width: 112px; }
.orders-table th:nth-child(9) { width: 86px; }
.orders-table th:nth-child(10) { width: 128px; }

.orders-table td .settle-tag { max-width: 88px; }
.orders-table td:nth-child(2) .cell-strong,
.orders-table td:nth-child(2) .cell-sub { max-width: 156px; }
.orders-table td:nth-child(3) .ellipsis { max-width: 138px; }
.sales-tag { max-width: 78px; }

/* 订单表：固定布局，列宽不受内容最小宽度影响，避免整体超出容器 */
.orders-table { table-layout: fixed; width: 100%; min-width: 0; }
.orders-table th,
.orders-table td { overflow: hidden; }

.orders-table th:nth-child(1) { width: 118px; }
.orders-table th:nth-child(2) { width: 170px; }
.orders-table th:nth-child(3) { width: 146px; }
.orders-table th:nth-child(4) { width: 54px; }
.orders-table th:nth-child(5) { width: 112px; }
.orders-table th:nth-child(6) { width: 96px; }
.orders-table th:nth-child(7) { width: 88px; }
.orders-table th:nth-child(8) { width: 122px; }
.orders-table th:nth-child(9) { width: 88px; }
.orders-table th:nth-child(10) { width: 144px; }

.orders-table td .tracking {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}

/* 快递单号列加宽，保证 14 位单号完整显示 */
.orders-table th:nth-child(2) { width: 160px; }
.orders-table th:nth-child(3) { width: 140px; }
.orders-table th:nth-child(8) { width: 140px; }

/* 金额列略加宽，让「已结款 · 私人账户」完整显示（总额不变） */
.orders-table th:nth-child(2) { width: 152px; }
.orders-table th:nth-child(5) { width: 120px; }
.orders-table td .settle-tag { max-width: 96px; }

/* 客户列恢复 160，商品明细让出 8px（总宽不变） */
.orders-table th:nth-child(2) { width: 160px; }
.orders-table th:nth-child(3) { width: 132px; }

/* 账号管理表 */
.users-table th:nth-child(1) { width: 200px; }
.users-table th:nth-child(2) { width: 170px; }
.users-table th:nth-child(3) { width: 120px; }
.users-table th:nth-child(4) { width: 160px; }
.users-table th:nth-child(5) { width: 170px; }
.users-table th:nth-child(6) { width: 130px; }
