/* =========================================================
   TradeFlow · 设计系统 (Light Theme)
   ========================================================= */

[hidden] { display: none !important; }

:root {
  --ease-out: cubic-bezier(.23, 1, .32, 1);
  /* surfaces */
  --bg:            #f5f7fa;
  --surface:       #ffffff;
  --surface-2:     #f7f9fc;
  --surface-3:     #eef2f8;
  --border:        #e3e8f0;
  --border-strong: #d3dae6;

  /* text */
  --text:          #0f172a;
  --text-2:        #475569;
  --muted:         #64748b;

  /* brand */
  --primary:       #2563eb;
  --primary-600:   #1d4ed8;
  --primary-weak:  #e8f0fe;
  --primary-ring:  rgba(37, 99, 235, .18);

  --teal:          #0d9488;
  --teal-weak:     #e0f5f2;
  --amber:         #b45309;
  --amber-weak:    #fdf2dd;
  --rose:          #dc2626;
  --rose-weak:     #fdeaea;
  --violet:        #7c3aed;
  --violet-weak:   #f1e9fe;
  --green:         #16a34a;
  --green-weak:    #e5f6ea;

  /* geometry */
  --r-sm: 8px;
  --r:    12px;
  --r-lg: 14px;
  --r-xl: 18px;
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .035);
  --shadow-md: 0 4px 14px -4px rgba(16, 24, 40, .12), 0 2px 6px -2px rgba(16, 24, 40, .06);
  --shadow-lg: 0 22px 48px -20px rgba(16, 24, 40, .3), 0 4px 12px -6px rgba(16, 24, 40, .1);

  --sidebar-w: 244px;
  --topbar-h:  68px;

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", sans-serif;
  --mono: "SFMono-Regular", "JetBrains Mono", Consolas, "Courier New", monospace;
}

* { box-sizing: border-box; }

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

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

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ic { display: inline-block; vertical-align: middle; flex: none; }

h1, h2, h3, h4, p { margin: 0; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #cfd8e5; border-radius: 20px; border: 3px solid transparent; background-clip: content-box; }
@media (hover: hover) and (pointer: fine) { ::-webkit-scrollbar-thumb:hover { background: #b6c2d4; background-clip: content-box; } }
::-webkit-scrollbar-track { background: transparent; }

/* =========================================================
   LAYOUT
   ========================================================= */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: none;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 60;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 18px 16px 16px;
  border-bottom: 1px solid var(--border);
}

.brand-mark {
  width: 38px; height: 38px;
  flex: none;
  border-radius: 11px;
  display: grid; place-items: center;
  color: #fff;
  background: linear-gradient(140deg, #3b82f6, #1d4ed8 60%, #1e40af);
  box-shadow: 0 6px 16px -6px rgba(37, 99, 235, .7);
}

.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-text strong { font-size: 15.5px; letter-spacing: -.2px; }
.brand-text span { font-size: 11px; color: var(--muted); margin-top: 3px; }

.icon-btn.sidebar-close { display: none; margin-left: auto; }

.nav { flex: 1; overflow-y: auto; padding: 14px 10px 20px; }

.nav-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 12px 10px 6px;
}
.nav-label:first-child { padding-top: 2px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9.5px 11px;
  border-radius: 10px;
  color: var(--text-2);
  font-weight: 500;
  font-size: 13.5px;
  position: relative;
  transition: background .16s, color .16s;
  margin-bottom: 2px;
  cursor: pointer;
}
@media (hover: hover) and (pointer: fine) { .nav-item:hover { background: var(--surface-2); color: var(--text); } }
.nav-item.on { background: var(--primary-weak); color: var(--primary-600); font-weight: 600; }
.nav-item.on::before {
  content: "";
  position: absolute; left: -10px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 20px; border-radius: 0 3px 3px 0; background: var(--primary);
}
.nav-item.locked { opacity: .42; }
.nav-item.locked::after {
  content: "";
  width: 5px; height: 5px; border-radius: 50%; background: var(--border-strong);
  margin-left: auto;
}

.sidebar-foot { padding: 12px; border-top: 1px solid var(--border); }

.role-card {
  display: flex; align-items: center; gap: 10px;
  padding: 10px;
  border-radius: var(--r);
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.role-avatar {
  width: 34px; height: 34px; flex: none; border-radius: 10px;
  display: grid; place-items: center;
  font-weight: 700; font-size: 13px; color: #fff;
  background: linear-gradient(140deg, #6366f1, #4338ca);
}
.role-meta { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.role-meta strong { font-size: 13px; }
.role-meta span { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.scrim {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .42);
  backdrop-filter: blur(2px);
  z-index: 55; opacity: 0; pointer-events: none; transition: opacity .22s;
}
.scrim.on { opacity: 1; pointer-events: auto; }

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

.topbar {
  height: var(--topbar-h);
  flex: none;
  position: sticky; top: 0; z-index: 40;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px;
  padding: 0 20px;
}

.icon-btn.menu-btn { display: none; }

.crumb { min-width: 0; }
.crumb h1 { font-size: 17px; font-weight: 700; letter-spacing: -.3px; white-space: nowrap; }
.crumb p { font-size: 11.5px; color: var(--muted); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.topbar-tools { margin-left: auto; display: flex; align-items: center; gap: 9px; }

/* 未登录时顶栏不该出现搜索框：人还没进系统，搜也搜不出东西 */
body.is-locked .search-mini { display: none; }
body.is-locked .sidebar,
body.is-locked .topbar,
body.is-locked #drawerRoot,
body.is-locked #modalRoot { display: none; }
body.is-locked .main { width: 100%; margin-left: 0; }
body.is-locked .content { min-height: 100dvh; display: grid; place-items: center; }
body.is-locked .content > .card { width: min(100%, 520px); }

.search-mini {
  position: relative; isolation: isolate;
  display: flex; align-items: center;
  border-radius: 10px; margin-inline: 4px 8px;
  height: 40px; color: #e9dfea;
}
/* Adapted from Lakshay-art / Uiverse curvy-earwig-22 (MIT).
   License: assets/uiverse-search-LICENSE.txt. */
.search-glow, .search-border, .search-highlight {
  position: absolute; pointer-events: none; z-index: -1;
  inset: -2px; overflow: hidden; border-radius: 12px;
}
.search-glow { inset: -5px; filter: blur(10px); opacity: .5; }
.search-highlight { inset: -1px; filter: blur(1px); }
.search-glow::before, .search-border::before, .search-highlight::before {
  content: ''; position: absolute; left: 50%; top: 50%;
  width: 600px; height: 600px;
  transform: translate(-50%, -50%) rotate(70deg);
  background: conic-gradient(#1c191c, #402fb5 5%, #1c191c 14%, #1c191c 50%, #cf30aa 60%, #1c191c 64%);
  transition: transform 2s ease;
}
.search-highlight::before {
  transform: translate(-50%, -50%) rotate(83deg);
  background: conic-gradient(transparent, #a099d8, transparent 8%, transparent 50%, #dfa2da, transparent 58%);
}
.search-mini:hover .search-glow::before,
.search-mini:hover .search-border::before,
.search-mini:hover .search-highlight::before { transform: translate(-50%, -50%) rotate(250deg); }
.search-mini:focus-within .search-glow::before,
.search-mini:focus-within .search-border::before,
.search-mini:focus-within .search-highlight::before { transform: translate(-50%, -50%) rotate(430deg); }
.search-mini:focus-within { outline: 2px solid #a099d8; outline-offset: 3px; }
.search-leading { position: absolute; left: 13px; pointer-events: none; }
.search-mini input {
  border: 0; outline: 0; border-radius: 10px; background: #010201;
  padding: 0 43px 0 39px;
  height: 100%; font-size: 12px; width: 272px; color: #fff; font-family: inherit;
  color-scheme: dark;
}
.search-mini input::placeholder { color: #c0b9c0; }
.search-submit {
  position: absolute; right: 5px; top: 5px; width: 30px; height: 30px;
  display: grid; place-items: center; cursor: pointer;
  border: 1px solid #625578; border-radius: 8px; color: #e5deed;
  background: linear-gradient(180deg, #161329, #08070d 55%, #1d1b4b);
  transition: border-color .2s, color .2s;
}
.search-submit:hover { border-color: #dfa2da; color: #fff; }
.search-submit:focus-visible { outline: 2px solid #dfa2da; outline-offset: 1px; }
.search-submit:active { transform: translateY(1px); }
@media (prefers-reduced-motion: reduce) {
  .search-glow::before, .search-border::before, .search-highlight::before,
  .search-submit { transition: none; }
}

.seg {
  display: flex; background: var(--surface-3); border-radius: 9px; padding: 3px; gap: 2px;
}
.seg button {
  border: 0; background: transparent; cursor: pointer;
  font-size: 12px; font-weight: 600; color: var(--muted);
  padding: 5px 11px; border-radius: 7px; transition: transform 140ms var(--ease-out), background-color 140ms ease, border-color 140ms ease, color 140ms ease, box-shadow 140ms ease;
}
.seg button.on { background: #fff; color: var(--primary-600); box-shadow: var(--shadow-xs); }

.select {
  height: 36px; border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-family: inherit; font-size: 12.5px; font-weight: 600;
  color: var(--text-2);
  padding: 0 8px; cursor: pointer; outline: 0;
}
.select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }

.icon-btn {
  width: 36px; height: 36px; flex: none;
  border-radius: 10px; border: 1px solid transparent;
  background: transparent; color: var(--text-2);
  display: grid; place-items: center; cursor: pointer;
  transition: transform 140ms var(--ease-out), background-color 140ms ease, border-color 140ms ease, color 140ms ease, box-shadow 140ms ease; position: relative;
}
@media (hover: hover) and (pointer: fine) { .icon-btn:hover { background: var(--surface-3); color: var(--text); } }
.icon-btn.bell { border-color: var(--border); background: var(--surface-2); }
.icon-btn .dot {
  position: absolute; top: 7px; right: 8px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--rose); border: 2px solid var(--surface-2);
}

.content { padding: 22px 24px 60px; flex: 1; }

/* =========================================================
   PRIMITIVES
   ========================================================= */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 18px; }

.card-head {
  display: flex; align-items: center; gap: 12px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
}
.card-head h3 { font-size: 14px; font-weight: 700; letter-spacing: -.15px; }
.card-head p { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.card-head .spacer { flex: 1; }

.section-title {
  display: flex; align-items: center; gap: 10px;
  margin: 4px 0 14px;
}
.section-title h2 { font-size: 15px; font-weight: 700; letter-spacing: -.2px; }
.section-title .spacer { flex: 1; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 15px;
  border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  font-size: 13px; font-weight: 600; font-family: inherit;
  cursor: pointer; white-space: nowrap;
  transition: transform 140ms var(--ease-out), background-color 140ms ease, border-color 140ms ease, color 140ms ease, box-shadow 140ms ease;
}
@media (hover: hover) and (pointer: fine) { .btn:hover { background: var(--surface-2); border-color: var(--border-strong); } }
.btn:active { transform: scale(.97); }
.btn-primary {
  background: var(--primary); border-color: var(--primary); color: #fff;
  box-shadow: 0 6px 16px -8px rgba(37, 99, 235, .8);
}
@media (hover: hover) and (pointer: fine) { .btn-primary:hover { background: var(--primary-600); border-color: var(--primary-600); } }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
@media (hover: hover) and (pointer: fine) { .btn-ghost:hover { background: var(--surface-3); color: var(--text); } }
.btn-sm { height: 32px; padding: 0 11px; font-size: 12.5px; border-radius: 8px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; pointer-events: none; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; line-height: 1.5;
  background: var(--surface-3); color: var(--text-2);
  white-space: nowrap;
}
.badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge.no-dot::before { display: none; }
.badge.b-blue   { background: var(--primary-weak); color: #1d4ed8; }
.badge.b-teal   { background: var(--teal-weak);    color: #0f766e; }
.badge.b-amber  { background: var(--amber-weak);   color: #b45309; }
.badge.b-rose   { background: var(--rose-weak);    color: #b91c1c; }
.badge.b-violet { background: var(--violet-weak);  color: #6d28d9; }
.badge.b-green  { background: var(--green-weak);   color: #15803d; }
.badge.b-gray   { background: var(--surface-3);    color: var(--text-2); }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 7px;
  font-size: 11.5px; font-weight: 600;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2);
}

.mono { font-family: var(--mono); font-size: 12.5px; letter-spacing: -.2px; }
.muted { color: var(--muted); }
.dim { color: var(--text-2); }
.nowrap { white-space: nowrap; }

/* Toolbar */
.toolbar {
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap; margin-bottom: 16px;
}
.toolbar .grow { flex: 1; }

.field-search {
  display: flex; align-items: center; gap: 8px;
  height: 38px; padding: 0 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; min-width: 240px; color: var(--muted);
  transition: transform 140ms var(--ease-out), background-color 140ms ease, border-color 140ms ease, color 140ms ease, box-shadow 140ms ease;
}
.field-search:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
.field-search input {
  border: 0; outline: 0; background: transparent; flex: 1;
  font-size: 13px; font-family: inherit; color: var(--text); min-width: 0;
}

/* Segmented filter pills */
.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pill {
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-2); font-size: 12.5px; font-weight: 600;
  padding: 7px 13px; border-radius: 999px; cursor: pointer;
  transition: transform 140ms var(--ease-out), background-color 140ms ease, border-color 140ms ease, color 140ms ease, box-shadow 140ms ease; font-family: inherit;
}
@media (hover: hover) and (pointer: fine) { .pill:hover { border-color: var(--border-strong); background: var(--surface-2); } }
.pill.on { background: var(--text); border-color: var(--text); color: #fff; }

/* =========================================================
   TABLES
   ========================================================= */
.table-wrap { overflow-x: auto; border-radius: 0 0 var(--r-lg) var(--r-lg); }
table.tbl { width: 100%; border-collapse: collapse; min-width: 720px; }
.tbl th {
  text-align: left; font-size: 11px; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); padding: 11px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.tbl td {
  padding: 13px 14px; border-bottom: 1px solid var(--border);
  font-size: 13px; vertical-align: middle;
}
.tbl tbody tr { transition: background .13s; cursor: pointer; }
@media (hover: hover) and (pointer: fine) { .tbl tbody tr:hover { background: #f8fafd; } }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .actions { text-align: right; white-space: nowrap; }

.cell-main { display: flex; align-items: center; gap: 11px; }
.thumb {
  width: 36px; height: 36px; flex: none; border-radius: 9px;
  display: grid; place-items: center; font-size: 17px;
  background: var(--surface-3); border: 1px solid var(--border);
}
.cell-main .t1 { font-weight: 600; font-size: 13px; }
.cell-main .t2 { font-size: 11.5px; color: var(--muted); margin-top: 1px; }

.avatar-sm {
  width: 34px; height: 34px; flex: none; border-radius: 9px;
  display: grid; place-items: center;
  font-size: 11.5px; font-weight: 700; color: #fff;
  background: linear-gradient(140deg, #64748b, #475569);
}

/* =========================================================
   KPI / STATS
   ========================================================= */
.grid { display: grid; gap: 16px; }
.g-kpi  { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-2    { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3    { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-2-1  { grid-template-columns: 1.55fr 1fr; }
.g-1-2  { grid-template-columns: 1fr 1.55fr; }

.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px 17px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.kpi-top { display: flex; align-items: center; gap: 9px; margin-bottom: 11px; }
.kpi-ic {
  width: 32px; height: 32px; border-radius: 9px;
  display: grid; place-items: center; flex: none;
}
.kpi-ic.i-blue   { background: var(--primary-weak); color: var(--primary-600); }
.kpi-ic.i-teal   { background: var(--teal-weak);    color: #0f766e; }
.kpi-ic.i-violet { background: var(--violet-weak);  color: #6d28d9; }
.kpi-ic.i-amber  { background: var(--amber-weak);   color: #b45309; }
.kpi-ic.i-rose   { background: var(--rose-weak);    color: #b91c1c; }
.kpi-ic.i-green  { background: var(--green-weak);   color: #15803d; }
.kpi-ic.i-gray   { background: var(--surface-3);    color: var(--text-2); }
.kpi-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.kpi-val {
  font-size: 28px; font-weight: 700; letter-spacing: -.9px;
  font-variant-numeric: tabular-nums; line-height: 1.15;
}
.kpi-val small { font-size: 13px; font-weight: 600; color: var(--muted); margin-left: 3px; }
.kpi-foot { display: flex; align-items: center; gap: 7px; margin-top: 9px; font-size: 11.5px; }
.trend { display: inline-flex; align-items: center; gap: 3px; font-weight: 700; }
.trend.up { color: var(--green); }
.trend.down { color: var(--rose); }

/* =========================================================
   CHARTS
   ========================================================= */
.chart-box { padding: 6px 10px 12px; }
.chart-box svg { display: block; width: 100%; height: auto; overflow: visible; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; padding: 0 18px 16px; }
.legend-item { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text-2); font-weight: 500; }
.legend-dot { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.legend-val { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }

/* =========================================================
   LISTS / TIMELINE
   ========================================================= */
.list { display: flex; flex-direction: column; }
.list-row {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 18px; border-bottom: 1px solid var(--border);
  transition: background .13s;
}
.list-row:last-child { border-bottom: 0; }
.list-row.clickable { cursor: pointer; }
@media (hover: hover) and (pointer: fine) { .list-row.clickable:hover { background: #f8fafd; } }
.list-row .grow { flex: 1; min-width: 0; }

.timeline { padding: 4px 0; }
.tl-item { display: flex; gap: 13px; padding: 0 0 20px; position: relative; }
.tl-item:last-child { padding-bottom: 4px; }
.tl-rail { width: 26px; flex: none; display: flex; flex-direction: column; align-items: center; }
.tl-node {
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; flex: none;
  background: var(--surface-3); color: var(--muted);
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1.5px var(--border);
  z-index: 1;
}
.tl-node.done { background: var(--teal); color: #fff; box-shadow: 0 0 0 1.5px var(--teal); }
.tl-node.active { background: var(--primary); color: #fff; box-shadow: 0 0 0 3.5px var(--primary-ring); }
.tl-line { flex: 1; width: 2px; background: var(--border); margin-top: 2px; border-radius: 2px; }
.tl-line.done { background: var(--teal); }
.tl-body { flex: 1; min-width: 0; padding-top: 2px; }
.tl-title { font-size: 13px; font-weight: 600; }
.tl-meta { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

/* =========================================================
   PROGRESS
   ========================================================= */
.bar { height: 7px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 999px; background: var(--primary);  }
.bar.thin { height: 5px; }

/* =========================================================
   DRAWER
   ========================================================= */
.drawer-scrim {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .38);
  backdrop-filter: blur(2px); z-index: 90;
  opacity: 0; transition: opacity .22s;
}
.drawer-scrim.on { opacity: 1; }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(560px, 94vw);
  background: var(--surface);
  z-index: 95;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
  transform: translateX(102%);
  transition: transform .3s cubic-bezier(.32, .72, 0, 1);
}
.drawer.on { transform: translateX(0); }
.drawer-head {
  padding: 18px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: flex-start; gap: 14px; flex: none;
}
.drawer-head .grow { flex: 1; min-width: 0; }
.drawer-head h2 { font-size: 17px; font-weight: 700; letter-spacing: -.3px; }
.drawer-head p { font-size: 12px; color: var(--muted); margin-top: 3px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px; }
.drawer-foot {
  padding: 14px 20px; border-top: 1px solid var(--border);
  display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; flex: none;
  background: var(--surface-2);
}

/* =========================================================
   MODAL
   ========================================================= */
.modal-scrim {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15, 23, 42, .45);
  backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: 20px;
  opacity: 0; transition: opacity .2s;
}
.modal-scrim.on { opacity: 1; }
.modal {
  background: var(--surface); border-radius: var(--r-xl);
  width: min(520px, 100%); max-height: 90vh; overflow: auto;
  box-shadow: var(--shadow-lg);
  transform: scale(.96) translateY(8px); transition: transform .24s cubic-bezier(.32,.72,0,1);
}
.modal-scrim.on .modal { transform: scale(1) translateY(0); }
.modal.wide { width: min(720px, 100%); }
.modal-head { padding: 20px 22px 14px; }
.modal-head h2 { font-size: 18px; font-weight: 700; letter-spacing: -.3px; }
.modal-head p { font-size: 12.5px; color: var(--muted); margin-top: 5px; }
.modal-body { padding: 4px 22px 20px; }
.modal-foot {
  padding: 14px 22px; border-top: 1px solid var(--border);
  display: flex; gap: 10px; justify-content: flex-end;
  background: var(--surface-2); border-radius: 0 0 var(--r-xl) var(--r-xl);
}

/* Role picker cards */
.role-grid { display: grid; gap: 11px; }
.role-opt {
  display: flex; gap: 13px; align-items: flex-start;
  padding: 15px; border-radius: var(--r);
  border: 1.5px solid var(--border); background: var(--surface);
  cursor: pointer; transition: transform 140ms var(--ease-out), background-color 140ms ease, border-color 140ms ease, color 140ms ease, box-shadow 140ms ease; text-align: left; font-family: inherit; width: 100%;
}
@media (hover: hover) and (pointer: fine) { .role-opt:not(.role-summary):hover { border-color: var(--primary); background: #f7faff; } }
.role-summary { cursor: default; }
.drawer-foot:empty { display: none; }
.role-opt.on { border-color: var(--primary); background: var(--primary-weak); box-shadow: 0 0 0 3px var(--primary-ring); }
.role-opt .ro-ic {
  width: 40px; height: 40px; border-radius: 11px; flex: none;
  display: grid; place-items: center; color: #fff;
}
.role-opt .ro-t { font-size: 14px; font-weight: 700; color: var(--text); }
.role-opt .ro-d { font-size: 12px; color: var(--muted); margin-top: 3px; line-height: 1.5; }

/* =========================================================
   FORMS
   ========================================================= */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row { display: flex; flex-direction: column; gap: 6px; }
.form-row.full { grid-column: 1 / -1; }
.form-row label { font-size: 12px; font-weight: 600; color: var(--text-2); }
.input, .textarea {
  height: 38px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface);
  padding: 0 12px; font-size: 13px; font-family: inherit; color: var(--text);
  outline: 0; transition: transform 140ms var(--ease-out), background-color 140ms ease, border-color 140ms ease, color 140ms ease, box-shadow 140ms ease; width: 100%;
}
.textarea { height: auto; padding: 10px 12px; resize: vertical; min-height: 84px; line-height: 1.6; }
.input:focus, .textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }

/* Permission matrix */
.matrix { width: 100%; border-collapse: collapse; min-width: 620px; }
.matrix th, .matrix td { padding: 11px 14px; border-bottom: 1px solid var(--border); font-size: 12.5px; text-align: center; }
.matrix th:first-child, .matrix td:first-child { text-align: left; font-weight: 600; }
.matrix thead th {
  background: var(--surface-2); font-size: 11px; text-transform: uppercase;
  letter-spacing: .05em; color: var(--muted); font-weight: 700;
}
@media (hover: hover) and (pointer: fine) { .matrix tbody tr:hover { background: #f8fafd; } }
.matrix .yes { color: var(--green); }
.matrix .no  { color: #cbd5e1; }
.matrix .ro  { color: var(--amber); }

/* Empty state */
.empty {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 54px 20px; text-align: center; color: var(--muted);
}
.empty .em-ic {
  width: 52px; height: 52px; border-radius: 15px;
  display: grid; place-items: center; background: var(--surface-3); color: var(--muted);
  margin-bottom: 4px;
}
.empty strong { color: var(--text); font-size: 14px; }
.empty span { font-size: 12.5px; max-width: 320px; }

/* Locked notice */
.locked-box {
  display: flex; align-items: center; gap: 14px;
  padding: 22px; border-radius: var(--r-lg);
  background: var(--surface); border: 1px dashed var(--border-strong);
}
.locked-box .lb-ic {
  width: 44px; height: 44px; border-radius: 13px; flex: none;
  display: grid; place-items: center; background: var(--amber-weak); color: #b45309;
}
.locked-box strong { display: block; font-size: 14px; }
.locked-box span { font-size: 12.5px; color: var(--muted); }

/* =========================================================
   TOAST
   ========================================================= */
.toast-root {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  z-index: 200; display: flex; flex-direction: column; gap: 9px; align-items: center;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  background: #0f172a; color: #fff;
  padding: 11px 17px; border-radius: 12px;
  font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(8px) scale(.97);
  transition: opacity 180ms var(--ease-out), transform 180ms var(--ease-out);
}
.toast.on { opacity: 1; transform: translateY(0) scale(1); }
.toast.out { opacity: 0; transform: translateY(8px) scale(.97); transition-duration: 120ms; }
.toast .t-ic { display: grid; place-items: center; }
.toast.ok .t-ic { color: #4ade80; }
.toast.warn .t-ic { color: #fbbf24; }
.toast.err .t-ic { color: #f87171; }


/* =========================================================
   MISC
   ========================================================= */
.kv { display: grid; grid-template-columns: 106px 1fr; gap: 9px 14px; font-size: 13px; }
.kv dt { color: var(--muted); font-size: 12.5px; }
.kv dd { margin: 0; font-weight: 500; }

.sub-head {
  font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--muted); margin: 20px 0 11px;
}
.sub-head:first-child { margin-top: 0; }

.stat-inline { display: flex; gap: 26px; flex-wrap: wrap; }
.stat-inline > div { display: flex; flex-direction: column; }
.stat-inline b { font-size: 18px; font-weight: 700; letter-spacing: -.4px; font-variant-numeric: tabular-nums; }
.stat-inline span { font-size: 11.5px; color: var(--muted); }

.dot-sep { width: 3px; height: 3px; border-radius: 50%; background: #cbd5e1; flex: none; }

/* =========================================================
   STEPPER（订单流程）
   ========================================================= */
.stepper {
  display: flex;
  align-items: flex-start;
  padding: 8px 0 4px;
  overflow-x: auto;
  gap: 0;
}
.stepper::-webkit-scrollbar { height: 5px; }
.step {
  flex: 1 0 74px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  position: relative;
}
.step i {
  width: 27px; height: 27px; border-radius: 50%;
  background: var(--surface-3); color: var(--muted);
  display: grid; place-items: center;
  font-size: 11.5px; font-weight: 700; font-style: normal;
  border: 2px solid var(--surface);
  z-index: 1;
}
.step::before {
  content: "";
  position: absolute; top: 13px; left: -50%;
  width: 100%; height: 2px; background: var(--border);
}
.step:first-child::before { display: none; }
.step.done i { background: var(--teal); color: #fff; }
.step.done::before { background: var(--teal); }
.step.active i { background: var(--primary); color: #fff; box-shadow: 0 0 0 4px var(--primary-ring); }
.step.active::before { background: var(--teal); }
.step span { font-size: 11px; color: var(--muted); font-weight: 600; text-align: center; white-space: nowrap; }
.step.done span, .step.active span { color: var(--text); }

.card.clickable { cursor: pointer; transition: transform .18s, box-shadow .18s, border-color .18s; }
@media (hover: hover) and (pointer: fine) { .card.clickable:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--border-strong); } }

/* 列表内 chip 无圆点 */
.chip.no-dot::before { display: none; }

/* =========================================================
   CHAT（智能助手）
   ========================================================= */
.chat {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 200px);
  min-height: 440px;
  overflow: hidden;
}
.chat-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.msg { display: flex; gap: 10px; max-width: 86%; min-width: 0; }
.msg.user { align-self: flex-end; flex-direction: row-reverse; }
.msg-avatar {
  width: 30px; height: 30px; flex: none;
  border-radius: 9px; display: grid; place-items: center;
  font-size: 11px; font-weight: 700; color: #fff;
}
.msg.user .msg-avatar { background: linear-gradient(140deg, #64748b, #475569); }
.msg.bot  .msg-avatar { background: linear-gradient(140deg, #6366f1, #4338ca); }
.msg-stack { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.msg.user .msg-stack { align-items: flex-end; }
.msg.bot { width: 100%; max-width: 100%; }
.msg.bot .msg-stack { flex: 1; align-items: flex-start; }
.msg.bot .ans-card { align-self: stretch; }
.msg-name { font-size: 11px; color: var(--muted); font-weight: 600; padding: 0 3px; }
.bubble {
  padding: 11px 15px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.7;
  word-break: break-word;
}
.msg.user .bubble { background: var(--primary); color: #fff; border-bottom-right-radius: 5px; }
.msg.bot  .bubble { background: var(--surface-2); border: 1px solid var(--border); border-bottom-left-radius: 5px; }

.ans-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  overflow: hidden;
  min-width: 0;
  box-shadow: var(--shadow-xs);
}
.ans-head {
  padding: 13px 15px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 9px;
  background: var(--surface-2);
}
.ans-head strong { font-size: 13.5px; }
.ans-head .grow { flex: 1; min-width: 0; }
.ans-body { padding: 4px 0; }
.ans-row {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 15px;
  border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background .13s;
}
.ans-row:last-child { border-bottom: 0; }
@media (hover: hover) and (pointer: fine) { .ans-row:hover { background: #f8fafd; } }
.ans-row .grow { flex: 1; min-width: 0; }
.ans-row .t1 { font-size: 13px; font-weight: 600; }
.ans-row .t2 { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.ans-foot {
  padding: 10px 15px; border-top: 1px solid var(--border);
  font-size: 12px; color: var(--muted); background: var(--surface-2);
}

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.qchip {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 12.5px; font-weight: 500;
  font-family: inherit; cursor: pointer;
  transition: transform 140ms var(--ease-out), background-color 140ms ease, border-color 140ms ease, color 140ms ease, box-shadow 140ms ease; text-align: left;
}
@media (hover: hover) and (pointer: fine) { .qchip:hover { border-color: var(--primary); color: var(--primary-600); background: #f7faff; } }

.chat-input-bar {
  flex: none;
  padding: 13px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  display: flex; gap: 9px; align-items: center;
}
.chat-input {
  flex: 1; height: 42px;
  border-radius: 11px; border: 1px solid var(--border);
  background: var(--surface); padding: 0 14px;
  font-size: 13.5px; font-family: inherit; color: var(--text);
  outline: 0; transition: transform 140ms var(--ease-out), background-color 140ms ease, border-color 140ms ease, color 140ms ease, box-shadow 140ms ease; min-width: 0;
}
.chat-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }

.typing { display: inline-flex; gap: 4px; align-items: center; }
.typing i {
  width: 6px; height: 6px; border-radius: 50%;
  background: #9aa8bd; animation: blink 1.2s infinite;
}
.typing i:nth-child(2) { animation-delay: .18s; }
.typing i:nth-child(3) { animation-delay: .36s; }
@keyframes blink { 0%, 60%, 100% { opacity: .3; } 30% { opacity: 1; } }

/* 答案卡片内部构件 */
.ans-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  background: var(--border);
}
.ans-kpi { background: var(--surface); padding: 13px 15px; min-width: 0; }
.ans-kpi .l {
  font-size: 11.5px; color: var(--muted); margin-bottom: 5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ans-kpi .v { font-size: 17px; font-weight: 700; letter-spacing: -.4px; }
.ans-kpi .d { font-size: 11px; margin-top: 3px; color: var(--muted); }

.ans-rank {
  width: 21px; height: 21px; flex: none; border-radius: 6px;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700; color: #fff; background: #94a3b8;
}
.ans-rank.r1 { background: linear-gradient(140deg, #f59e0b, #b45309); }
.ans-rank.r2 { background: linear-gradient(140deg, #94a3b8, #64748b); }
.ans-rank.r3 { background: linear-gradient(140deg, #c2804f, #8a5a2c); }

.ans-bar {
  display: block;
  width: 88px; flex: none; height: 6px;
  border-radius: 999px; background: var(--surface-2); overflow: hidden;
}
.ans-bar i { display: block; height: 100%; border-radius: 999px; background: var(--primary); }
.ans-val { font-size: 13px; font-weight: 700; flex: none; }
.ans-note { padding: 11px 15px; font-size: 12.5px; color: var(--text-2); line-height: 1.75; }
.ans-tags { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 15px 12px; }

@media (max-width: 760px) {
  .chat { height: calc(100vh - 150px); min-height: 380px; }
  .chat-scroll { padding: 14px; gap: 14px; }
  .msg { max-width: 96%; }
  .ans-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ans-bar { display: none; }
}

/* Responsive */
@media (max-width: 1180px) {
  .g-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-2-1, .g-1-2 { grid-template-columns: 1fr; }
  .search-mini input { width: 220px; }
}

@media (max-width: 1024px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    transform: translateX(-102%);
    transition: transform .3s cubic-bezier(.32,.72,0,1);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.on { transform: translateX(0); }
  .icon-btn.sidebar-close { display: grid; }
  .icon-btn.menu-btn { display: grid; }
  .content { padding: 18px 16px 60px; }
  .g-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .g-kpi, .g-3, .g-2, .g-2-1, .g-1-2 { grid-template-columns: minmax(0, 1fr); }
  .demo-chip { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .topbar { padding: 0 12px; gap: 10px; }
  .crumb p { display: none; }
  .search-mini { display: none; }
  .select-currency { display: none; }
  .content { padding: 14px 12px 60px; }
  .card-head { padding: 13px 14px; }
  .list-row { padding: 12px 14px; }
  .drawer-body { padding: 16px; }
  .kv { grid-template-columns: 92px 1fr; }
  .crumb h1 { font-size: 15.5px; }
}

/* Interaction polish: frequent navigation stays immediate; overlays give context. */
:where(button, a, summary, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
}
:where(.icon-btn, .pill, .seg button, .qchip, .role-opt):active:not(:disabled) { transform: scale(.97); }
.nav-item { transition: none; }
.card.clickable { transition: border-color 140ms ease, box-shadow 140ms ease; }
@media (hover: hover) and (pointer: fine) {
  .card.clickable:hover { transform: none; }
}
.drawer, .sidebar { overscroll-behavior: contain; }
.drawer { transition-duration: 180ms; }
.drawer.on { transition-duration: 260ms; }
.modal { transition: transform 140ms var(--ease-out); transform-origin: center; }
.modal-scrim.on .modal { transition-duration: 220ms; }
.modal-scrim { transition-duration: 140ms; }
.modal-scrim.on { transition-duration: 200ms; }
.toast-root { width: max-content; max-width: calc(100vw - 32px); bottom: max(22px, env(safe-area-inset-bottom)); }
.toast { max-width: 100%; overflow-wrap: anywhere; }
.tbl th { font-size: 12px; letter-spacing: .02em; }
.card-head p, .crumb p { line-height: 1.6; }
.kpi-label { color: var(--text-2); }
body.is-locked .content { padding: 32px 20px; }
.login-card { border-radius: 20px; box-shadow: var(--shadow-lg); }
.login-card > h2 { font-size: 24px; letter-spacing: -.6px; margin-bottom: 8px; }
.login-card > p:first-of-type { color: var(--text-2); font-size: 13px; margin-bottom: 24px; }
.login-card label { font-size: 13px; font-weight: 600; }
.login-card .input, .login-card .btn { min-height: 42px; }
.login-card details { padding-top: 14px; border-top: 1px solid var(--border); }
.login-card summary { padding-block: 3px; }
#authMessage:empty { display: none; }
#authMessage:not(:empty) { padding: 10px 12px; border-radius: 8px; background: var(--rose-weak); }
html[data-input="keyboard"] *, html[data-input="keyboard"] *::before,
html[data-input="keyboard"] *::after { transition: none !important; animation: none !important; }
html[data-input="keyboard"] :where(button, .btn, .pill, .qchip):active { transform: none; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
  .modal, .modal-scrim.on .modal, .toast, .toast.on, .toast.out { transform: none; }
  :where(button, .btn, .pill, .qchip):active { transform: none !important; }
}
@media (max-width: 760px) {
  .modal-scrim { padding: 12px; }
  .modal { max-height: calc(100dvh - 24px); }
  .field-search { min-width: 0; width: 100%; }
  .btn, .select, .pill, .icon-btn { min-height: 40px; }
  .login-card .input { font-size: 16px; }
}
.login-card > details + form { margin-top: 18px; }
.login-card > p:last-of-type { margin-top: 16px; line-height: 1.7; }
