:root {
  --bg: #eef2f4;
  --surface: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --primary: #0f766e;
  --primary-2: #14b8a6;
  --danger: #e11d48;
  --warn: #f59e0b;
  --ok: #10b981;
  --sidebar: #0b1220;
  --sidebar-2: #111827;
  --shadow: 0 10px 30px rgba(15, 23, 42, .08);
  --radius: 16px;
  --font: "IBM Plex Sans", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", "Noto Sans CJK SC", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: var(--font); color: var(--ink); background:
  radial-gradient(900px 420px at 0% 0%, rgba(20,184,166,.12), transparent 55%),
  radial-gradient(700px 380px at 100% 0%, rgba(14,165,233,.10), transparent 50%),
  var(--bg);
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
img { max-width: 100%; }

.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 248px; background: linear-gradient(180deg, var(--sidebar), var(--sidebar-2));
  color: #cbd5e1; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
  transition: width .25s ease; z-index: 30;
}
.brand, .sidebar .brand {
  padding: 22px 18px 16px; display: flex; gap: 12px; align-items: center; border-bottom: 1px solid rgba(255,255,255,.06);
}
.brand-mark, .brand-mark {
  width: 38px; height: 38px; border-radius: 12px;
  background: linear-gradient(135deg, var(--primary-2), var(--primary));
  display: grid; place-items: center; color: #fff; font-weight: 700; flex: none;
}
.brand-text { line-height: 1.15; }
.brand-text strong { display: block; color: #fff; font-size: 1.05rem; }
.brand-text span { font-size: .75rem; color: #94a3b8; }
.sidebar.collapsed { width: 248px; }
.brand-text { min-width: 0; }
.brand-text strong { font-size: .92rem; }

.nav { padding: 12px 10px; overflow: auto; flex: 1; }
.nav-group { margin-bottom: 6px; }
.nav-group-title, .nav-link {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; color: #cbd5e1;
}
.nav-link:hover, .nav-link.active { background: rgba(20,184,166,.16); color: #5eead4; }
.nav-children { padding-left: 8px; }
.nav-children .nav-link { padding: 8px 12px; font-size: .92rem; color: #94a3b8; }
.nav-ico { width: 18px; text-align: center; opacity: .9; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 12px 18px; background: rgba(255,255,255,.86);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.tab {
  padding: 8px 12px; border-radius: 999px; background: #f1f5f9; color: var(--muted); font-size: .9rem;
  border: 1px solid transparent;
}
.tab.active { background: #ecfeff; color: var(--primary); border-color: #99f6e4; font-weight: 600; }
.top-search { flex: 1; min-width: 140px; max-width: 360px; }
.top-search input {
  width: 100%; border: 1px solid var(--line); border-radius: 999px; padding: 9px 14px; background: #fff;
}
.icon-btn {
  border: 1px solid var(--line); background: #fff; border-radius: 12px; width: 40px; height: 40px; cursor: pointer;
}
.user-chip { display: flex; align-items: center; gap: 10px; padding: 6px 12px; border-radius: 999px; background: #fff; border: 1px solid var(--line); white-space: nowrap; }
.user-chip a { color: var(--muted); font-size: .88rem; }
.content { padding: 18px; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 1.6rem; letter-spacing: -.02em; }
.page-head .sub { color: var(--muted); margin-top: 4px; }

.grid { display: grid; gap: 14px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }

.card {
  background: var(--surface); border: 1px solid rgba(226,232,240,.9); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px;
}
.num { font-weight: 700; letter-spacing: -.02em; }
.muted { color: var(--muted); }
.panel-title { font-weight: 700; margin: 0 0 12px; }
.pre-wrap { white-space: pre-wrap; line-height: 1.55; }
.remark-cell { white-space: pre-wrap; max-width: 280px; font-size: .86rem; }
.tfoot-row { background: #f8fafc; font-weight: 700; }
.row-warn td { background: #fff1f2; }
.empty-state { text-align: center; color: var(--muted); padding: 28px 12px; }

.table-wrap { overflow: auto; }
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; font-size: .92rem; }
table.data th { color: var(--muted); font-weight: 600; background: var(--table-head, #f8fafc); }
body.zebra-on table.data > tbody > tr:nth-child(even):not(.row-warn):not(.is-disabled):not(.row-converted) > td { background: var(--row-alt, #f0fdfa); }
table.data > tbody > tr.is-disabled > td { background: var(--goods-off-bg, #f1f5f9); color: var(--goods-off-ink, #64748b); }
.state-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; vertical-align: middle; }
.state-toggle button { border: 0; background: #fff; padding: 2px 8px; cursor: pointer; color: var(--muted); }
.state-toggle button.on { background: var(--primary); color: #fff; }
.style-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.style-card { text-align: left; border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 12px; cursor: pointer; }
.style-card.on { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.style-swatch { display: flex; height: 28px; border-radius: 8px; overflow: hidden; margin-bottom: 8px; }
.count-cats { display: flex; flex-wrap: wrap; gap: 8px 14px; margin: 8px 0 12px; }
.count-group { margin-bottom: 10px; }
.count-group summary { cursor: pointer; font-weight: 600; padding: 8px 0; }
.ver-log { max-width: 880px; }
.ver-title { margin: 0 0 8px; font-size: 1.15rem; }
.ver-list { margin: 0; padding-left: 1.25em; }
.ver-list li { margin: 7px 0; line-height: 1.65; }
.ver-entry { margin-bottom: 14px; }
.ver-entry-head { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; margin-bottom: 8px; }
.ver-entry-head .muted { color: var(--muted); }
.ver-check { display: inline-flex; gap: 6px; align-items: center; }
.ver-public { padding: 18px 20px 8px; }
.ver-badge {
  display: inline-flex; align-items: center; height: 26px; padding: 0 10px;
  border-radius: 999px; background: #f0fdfa; color: var(--primary); font-weight: 700; font-size: .86rem;
}
.ver-public .ver-title { margin-bottom: 4px; }
.ver-public .ver-list { padding-left: 0; list-style: none; counter-reset: ver; }
.ver-public .ver-list li {
  counter-increment: ver;
  display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 10px; align-items: start;
  margin: 0; padding: 10px 0; border-top: 1px solid var(--line);
}
.ver-public .ver-list li::before {
  content: counter(ver);
  width: 22px; height: 22px; margin-top: 1px; border-radius: 999px;
  display: grid; place-items: center; background: #f1f5f9; color: var(--muted);
  font-size: .75rem; font-weight: 700;
}

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 999px; font-size: .78rem; background: #f1f5f9; }
.pill.ok { background: #ecfdf5; color: #047857; }
.pill.warn { background: #fff7ed; color: #c2410c; }
.pill.bad { background: #fff1f2; color: #be123c; }
tr.row-converted { background: #f0fdfa; }
tr.row-converted td:first-child { box-shadow: inset 3px 0 0 #0f766e; }
a.pill { text-decoration: none; }
.doc-links a:not(.btn):not(.pill),
a.doc-link,
.doc-link {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.doc-links a:not(.btn):not(.pill):hover,
a.doc-link:hover { color: #115e59; }
button.doc-link { background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }
.role-member-list { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; }
.role-member-list .who { display: inline-flex; gap: 6px; align-items: center; }
.attach-thumb-cell { width: 64px; }
.attach-thumb {
  width: 52px;
  height: 52px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.attach-thumb a { display: flex; width: 100%; height: 100%; }
.attach-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.attach-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 12px; }
.attach-tile {
  display: flex; flex-direction: column; gap: 8px; min-width: 0; padding: 8px;
  border: 1px solid var(--line); border-radius: 14px; background: linear-gradient(180deg, #fff, #f8fafc);
  box-shadow: 0 8px 20px rgba(15, 23, 42, .05); color: inherit; text-align: left;
}
.attach-tile-open {
  display: block; width: 100%; padding: 0; border: 0; background: transparent;
  color: inherit; font: inherit; text-align: inherit; cursor: pointer; text-decoration: none;
}
.attach-tile-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.attach-del {
  flex: none; margin: 0; padding: 0; border: 0; background: none; color: var(--danger);
  cursor: pointer; font: inherit; font-size: .78rem; line-height: 1.2;
}
.attach-del:hover { text-decoration: underline; }
#linesTable .line-del { width: 52px; white-space: nowrap; }
#linesTable input[type="date"] { min-width: 168px; color-scheme: light; }
#linesTable input[type="date"]::-webkit-calendar-picker-indicator { opacity: 1; cursor: pointer; }
.attach-tile:hover { border-color: #99f6e4; box-shadow: 0 12px 28px rgba(15, 118, 110, .14); }
.attach-tile-pic, .attach-tile-badge {
  aspect-ratio: 1; border-radius: 10px; overflow: hidden;
}
.attach-tile-pic { background: #0b1220; }
.attach-tile-pic img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .25s ease; }
.attach-tile:hover .attach-tile-pic img { transform: scale(1.05); }
.attach-tile-badge {
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #0f172a, #115e59); color: #99f6e4;
  font-weight: 700; letter-spacing: .08em; font-size: .92rem;
}
.attach-tile-name { display: block; font-size: .82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attach-tile-meta .muted { font-size: .75rem; }
.attach-tile.is-missing { opacity: .72; cursor: default; }
.attach-lite {
  position: fixed; inset: 0; z-index: 80; background: rgba(8, 15, 28, .84);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.attach-lite[hidden] { display: none; }
.attach-lite-frame { max-width: min(980px, 94vw); display: flex; flex-direction: column; gap: 12px; align-items: center; }
.attach-lite img {
  max-width: min(980px, 94vw); max-height: 68vh; object-fit: contain;
  border-radius: 14px; background: #0b1220; box-shadow: 0 24px 70px rgba(0, 0, 0, .4);
}
.attach-lite-bar {
  width: min(980px, 94vw); display: flex; justify-content: space-between; gap: 12px; align-items: center;
  color: #e2e8f0; background: rgba(15, 23, 42, .92); border-radius: 999px; padding: 8px 10px 8px 16px;
}
.attach-lite-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-lite-actions { display: flex; gap: 8px; flex: none; }
.attach-lite-actions button, .attach-lite-actions a {
  background: rgba(255,255,255,.08); color: #fff; border: 1px solid rgba(255,255,255,.18);
  border-radius: 999px; padding: 6px 12px; cursor: pointer; text-decoration: none;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; border-radius: 12px; padding: 10px 14px; cursor: pointer; font-weight: 600;
}
.btn-primary { background: linear-gradient(135deg, var(--primary-2), var(--primary)); color: #fff; }
.btn-ghost { background: #fff; border: 1px solid var(--line); color: var(--ink); }
.btn-danger { background: #fff1f2; color: var(--danger); }
.btn-ok { background: #ecfdf5; color: #047857; }
.btn-sm { padding: 6px 10px; font-size: .85rem; }
.link-btn { background: none; border: none; color: var(--danger); cursor: pointer; padding: 0; font: inherit; }
.row-actions { display: flex; gap: 10px; align-items: center; }
.row-actions form { display: inline; margin: 0; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.filters .input { min-width: 140px; }
.input {
  border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: #fff; min-width: 160px; width: 100%;
}
.alert { padding: 12px 14px; border-radius: 12px; margin-bottom: 12px; }
.alert-ok { background: #ecfdf5; color: #065f46; }
.alert-err { background: #fff1f2; color: #9f1239; }

.form-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px;
}
.field label { display: block; margin-bottom: 6px; font-size: .9rem; color: var(--muted); }
.field-span { grid-column: 1 / -1; }
.sticky-actions {
  position: sticky; bottom: 12px; background: rgba(255,255,255,.92); backdrop-filter: blur(8px);
  padding: 10px; border-radius: 12px; border: 1px solid var(--line); z-index: 5;
}

.mobile-list { display: none; }
.mobile-item {
  display: block; background: #fff; border: 1px solid var(--line); border-radius: 14px;
  padding: 12px 14px; margin-bottom: 10px; box-shadow: var(--shadow);
}
.mi-top, .mi-bot { display: flex; justify-content: space-between; gap: 8px; }
.mi-mid { color: var(--muted); font-size: .88rem; margin: 6px 0; }

.report-card {
  display: flex; flex-direction: column; gap: 6px; min-height: 110px;
}
.report-card strong { font-size: 1.1rem; }
.search-list, .attach-list { margin: 0; padding-left: 18px; line-height: 1.85; }

.stat-card { position: relative; overflow: hidden; min-height: 110px; display: block; }
.stat-card .num { font-size: 2rem; font-weight: 700; }
.stat-card .label { color: var(--muted); margin-top: 4px; }
.stat-orange { background: linear-gradient(160deg, #fff7ed, #ffedd5); color: #c2410c; }
.stat-blue { background: linear-gradient(160deg, #eff6ff, #dbeafe); color: #1d4ed8; }
.stat-rose { background: linear-gradient(160deg, #fff1f2, #ffe4e6); color: #be123c; }
.stat-green { background: linear-gradient(160deg, #ecfdf5, #d1fae5); color: #047857; }
.ring {
  position: absolute; right: 14px; top: 18px; width: 52px; height: 52px; border-radius: 50%;
  background: conic-gradient(currentColor calc(var(--p, 0) * 1%), rgba(255,255,255,.55) 0);
  mask: radial-gradient(circle at center, transparent 56%, #000 58%);
  -webkit-mask: radial-gradient(circle at center, transparent 56%, #000 58%);
  opacity: .85;
}
.kpi-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.kpi-row .v { font-size: 1.25rem; font-weight: 700; }
.kpi-row .k { color: var(--muted); font-size: .85rem; margin-top: 2px; }
.profit { color: #0f766e; }

.desktop-only { display: block; }
.mobile-only { display: none !important; }

.bottom-nav {
  display: none;
  position: fixed; left: 0; right: 0; bottom: 0; background: rgba(255,255,255,.94); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line); grid-template-columns: repeat(7, 1fr);
  padding: 8px 4px calc(8px + env(safe-area-inset-bottom)); z-index: 40;
}
.bottom-nav a { text-align: center; font-size: .68rem; color: var(--muted); padding: 4px 0; }
.bottom-nav a.active { color: var(--primary); font-weight: 700; }
.bottom-nav .ico { display: block; font-size: 1.1rem; margin-bottom: 2px; }

.login-page {
  min-height: 100vh; display: grid; place-items: center;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(20,184,166,.25), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(14,165,233,.18), transparent 55%),
    linear-gradient(160deg, #f8fafc, #e2e8f0);
}
.login-card {
  width: min(460px, 94vw); background: rgba(255,255,255,.9); backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,.7); border-radius: 24px; padding: 32px; box-shadow: var(--shadow);
}
.login-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.login-tabs button { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 12px; cursor: pointer; font: inherit; }
.login-tabs button.on { background: var(--primary); color: #fff; border-color: var(--primary); }
.login-pane { display: none; }
.login-pane.on { display: block; }
.login-qr { width: 220px; height: 220px; object-fit: contain; background: #fff; border-radius: 12px; }
.sms-row { display: flex; gap: 8px; }
.sms-row .input { flex: 1; }
.login-card h1 { margin: 0 0 6px; font-size: 1.8rem; }
.login-card p { margin: 0 0 22px; color: var(--muted); }
.field { margin-bottom: 14px; }
.field label { display: block; margin-bottom: 6px; font-size: .9rem; color: var(--muted); }

/* filter bars: desktop 4-up, phone 2-up */
.toolbar.filters, form.filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  align-items: end;
}
.toolbar.filters .input, form.filters .input { min-width: 0; width: 100%; }
.toolbar.filters .btn, form.filters .btn { width: 100%; }
.toolbar.filters .filter-span, form.filters .filter-span { grid-column: 1 / -1; }
.toolbar.filters .filter-grow, form.filters .filter-grow { grid-column: span 3; }
.stat-card { min-height: 96px; }

@media (max-width: 960px) {
  .sidebar, .tabs, .desktop-only, .desktop-table { display: none !important; }
  .mobile-only { display: grid !important; }
  .bottom-nav.mobile-only { display: grid !important; }
  .mobile-list { display: block; }
  .content { padding: 14px 14px 84px; }
  /* 色块：窄屏每行 2 个，避免单列过长 */
  .grid.grid-4, .grid.grid-3,
  .grid-4, .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 10px; }
  .grid.grid-2, .grid-2 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .stat-card { min-height: 84px; padding: 12px; }
  .stat-card .num { font-size: 1.45rem; }
  .toolbar.filters, form.filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .toolbar.filters .filter-grow, form.filters .filter-grow { grid-column: 1 / -1; }
  .page-head h1 { font-size: 1.4rem; }
  .app-shell { display: block; }
  .topbar { padding: 10px 12px; }
  .top-search { max-width: none; }
  .user-chip strong { display: none; }
}
@media (max-width: 640px) {
  .kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* aliases used by older/newer views */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 1.6rem; }
.page-head .sub, .sub { color: var(--muted); margin-top: 4px; }
.btn-ghost { background: #fff; border: 1px solid var(--line); color: var(--ink); }
.panel-title { font-weight: 700; margin: 0 0 12px; }
.kpi-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.kpi-row .v { font-size: 1.25rem; font-weight: 700; }
.kpi-row .k { color: var(--muted); font-size: .85rem; margin-top: 2px; }
.table-wrap { overflow: auto; }
.brand-mark { width: 38px; height: 38px; border-radius: 12px; background: linear-gradient(135deg, var(--primary-2), var(--primary)); display: grid; place-items: center; color: #fff; font-weight: 700; flex: none; }
.nav-label { flex: 1; min-width: 0; color: inherit; }

.pick-inline { display: flex; gap: 4px; align-items: center; }
.pick-inline > .input, .pick-inline > select.input { flex: 1; min-width: 0; }
.pick-btn {
  flex: none; width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; cursor: pointer; font-weight: 700; letter-spacing: 1px; color: var(--ink);
}
.pick-btn:hover { border-color: var(--primary); color: var(--primary); }
.picker-mask {
  position: fixed; inset: 0; z-index: 90; background: rgba(8, 15, 28, .45);
  display: flex; align-items: center; justify-content: center; padding: 18px;
}
.picker-mask[hidden] { display: none; }
.picker-panel {
  width: min(980px, 96vw); max-height: min(86vh, 820px); background: #fff; border-radius: 16px;
  display: flex; flex-direction: column; box-shadow: 0 24px 70px rgba(0,0,0,.25); overflow: hidden;
}
.picker-head, .picker-foot { display: flex; align-items: center; gap: 8px; padding: 12px 14px; }
.picker-head { border-bottom: 1px solid var(--line); }
.picker-title { flex: 1; font-size: 1.05rem; }
.picker-filters { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 14px 0; align-items: center; }
.picker-filters .input { width: auto; min-width: 140px; flex: 1; }
.picker-stock { display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; }
.picker-table-wrap { overflow: auto; margin: 12px 14px; border: 1px solid var(--line); border-radius: 12px; min-height: 220px; }
.picker-table-wrap table.data { margin: 0; }
.picker-table-wrap tbody tr { cursor: pointer; }
.picker-table-wrap tbody tr:hover td { background: #f8fafc; }
.picker-foot { border-top: 1px solid var(--line); justify-content: flex-end; }
.picker-meta { margin-right: auto; }
.picker-pager { color: var(--muted); }
