:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --ink: #172033;
  --muted: #6b7890;
  --line: #e4eaf2;
  --brand: #1c5fd4;
  --brand-dark: #12479f;
  --brand-soft: #e9f1ff;
  --green: #16865b;
  --green-soft: #e8f8f1;
  --amber: #b76a00;
  --amber-soft: #fff5e5;
  --red: #c53a4a;
  --red-soft: #fff0f1;
  --violet: #6d4bd1;
  --violet-soft: #f1edff;
  --shadow: 0 12px 30px rgba(28, 45, 75, .08);
  --radius: 18px;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background:
    radial-gradient(circle at 10% 0%, rgba(28, 95, 212, .12), transparent 28%),
    radial-gradient(circle at 92% 8%, rgba(109, 75, 209, .09), transparent 23%),
    var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", sans-serif;
  font-size: 14px;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 236px; flex: 0 0 236px; background: #101a2d; color: #fff;
  padding: 22px 14px 16px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 22px; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center;
  background: linear-gradient(135deg, #4d8bff, #1c5fd4); font-size: 20px; font-weight: 700;
  box-shadow: 0 8px 18px rgba(28,95,212,.35);
}
.brand-title { font-size: 16px; font-weight: 700; letter-spacing: .3px; }
.brand-sub { color: #91a0b9; font-size: 11px; margin-top: 4px; }
.nav { display: flex; flex-direction: column; gap: 4px; overflow: auto; padding-right: 2px; }
.nav-item {
  border: 0; background: transparent; color: #aebbd0; padding: 11px 12px; border-radius: 11px;
  display: flex; align-items: center; gap: 10px; text-align: left; transition: .18s ease;
}
.nav-item span {
  width: 26px; height: 26px; display: grid; place-items: center; border-radius: 8px;
  background: rgba(255,255,255,.07); font-size: 12px; color: #d7e3f8;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: linear-gradient(90deg, rgba(77,139,255,.28), rgba(77,139,255,.08)); color: #fff; }
.nav-item.active span { background: #2e6fe2; color: #fff; }
.sidebar-foot { margin-top: auto; display: flex; gap: 10px; align-items: center; padding: 16px 8px 2px; border-top: 1px solid rgba(255,255,255,.08); }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: #49d69a; box-shadow: 0 0 0 5px rgba(73,214,154,.12); }
.foot-title { font-size: 12px; color: #dbe6f7; }
.foot-sub { font-size: 10px; color: #8090aa; margin-top: 3px; }
.main { flex: 1; min-width: 0; padding: 28px 32px 44px; }
.topbar { display: flex; justify-content: space-between; gap: 20px; align-items: flex-end; margin-bottom: 24px; }
.page-kicker { color: var(--brand); font-weight: 700; font-size: 12px; letter-spacing: .12em; text-transform: uppercase; }
h1 { margin: 6px 0 0; font-size: 28px; letter-spacing: -.04em; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.operator-field { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.operator-field input {
  width: 94px; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: #fff; color: var(--ink);
}
.content { max-width: 1500px; }
.loading { padding: 80px; text-align: center; color: var(--muted); }
.btn {
  border: 0; border-radius: 10px; padding: 10px 15px; font-weight: 700; font-size: 13px;
  transition: .16s ease; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 8px 17px rgba(28,95,212,.2); }
.btn-primary:hover { background: var(--brand-dark); }
.btn-ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn-soft { background: var(--brand-soft); color: var(--brand-dark); }
.btn-danger-soft { background: var(--red-soft); color: var(--red); }
.btn-green { background: var(--green); color: #fff; }
.btn-sm { padding: 7px 10px; border-radius: 8px; font-size: 12px; }
.card {
  background: rgba(255,255,255,.94); border: 1px solid rgba(228,234,242,.9); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px;
}
.card + .card { margin-top: 18px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 16px; }
.card-title { font-size: 16px; font-weight: 800; letter-spacing: -.02em; }
.card-sub { color: var(--muted); font-size: 12px; margin-top: 5px; line-height: 1.6; }
.metric-grid { display: grid; grid-template-columns: repeat(6, minmax(150px, 1fr)); gap: 13px; margin-bottom: 18px; }
.metric {
  position: relative; overflow: hidden; min-height: 120px; padding: 18px; border-radius: 16px;
  background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.metric::after { content: ""; position: absolute; width: 95px; height: 95px; border-radius: 50%; right: -32px; bottom: -38px; opacity: .7; }
.metric.blue::after { background: #dceaff; }
.metric.green::after { background: #d9f6ea; }
.metric.amber::after { background: #ffefd1; }
.metric.red::after { background: #ffe1e5; }
.metric.violet::after { background: #e9e1ff; }
.metric-label { color: var(--muted); font-size: 12px; font-weight: 700; }
.metric-value { font-size: 34px; line-height: 1; margin-top: 15px; font-weight: 800; letter-spacing: -.05em; position: relative; z-index: 1; }
.metric-note { color: var(--muted); font-size: 11px; margin-top: 9px; position: relative; z-index: 1; }
.blue .metric-value { color: var(--brand); }
.green .metric-value { color: var(--green); }
.amber .metric-value { color: var(--amber); }
.red .metric-value { color: var(--red); }
.violet .metric-value { color: var(--violet); }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(320px, .65fr); gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.table-wrap { overflow: auto; border-radius: 12px; border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; background: #fff; min-width: 640px; }
th { background: var(--panel-soft); color: var(--muted); font-size: 11px; font-weight: 800; text-align: left; padding: 11px 13px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px 13px; border-bottom: 1px solid #edf1f6; font-size: 13px; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tr:hover td { background: #fbfcff; }
.num { font-variant-numeric: tabular-nums; font-weight: 700; }
tr.summary-row td, tr.summary-row:hover td { background: #eef4ff; border-top: 2px solid #c9d9f5; border-bottom: 0; }
tr.summary-row td:first-child { color: var(--brand-dark); }
.muted { color: var(--muted); }
.small { font-size: 11px; }
.tag { display: inline-flex; align-items: center; border-radius: 999px; padding: 4px 8px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.tag-blue { background: var(--brand-soft); color: var(--brand-dark); }
.tag-green { background: var(--green-soft); color: var(--green); }
.tag-amber { background: var(--amber-soft); color: var(--amber); }
.tag-red { background: var(--red-soft); color: var(--red); }
.tag-violet { background: var(--violet-soft); color: var(--violet); }
.tag-gray { background: #eef2f7; color: #64718a; }
.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.form-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { display: flex; flex-direction: column; gap: 7px; }
.field label { color: var(--muted); font-size: 11px; font-weight: 800; }
.field input, .field select, .field textarea {
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 11px; background: #fff; color: var(--ink); min-width: 0;
}
.field textarea { min-height: 70px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid rgba(28,95,212,.15); border-color: #9cbcf5; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.item-editor { margin-top: 16px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.item-editor-head, .item-row { display: grid; grid-template-columns: minmax(210px, 1fr) 100px 40px; gap: 10px; align-items: center; padding: 10px 12px; }
.item-editor-head { background: var(--panel-soft); color: var(--muted); font-size: 11px; font-weight: 800; }
.item-row { border-top: 1px solid #edf1f6; }
.item-row select, .item-row input { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; background: #fff; }
.item-row .remove-row { border: 0; width: 32px; height: 32px; border-radius: 8px; background: var(--red-soft); color: var(--red); font-weight: 800; }
.add-row { margin-top: 10px; }
.list { display: flex; flex-direction: column; gap: 10px; }
.list-item { padding: 13px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-soft); }
.list-row { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.list-title { font-weight: 800; }
.list-meta { color: var(--muted); font-size: 11px; margin-top: 5px; line-height: 1.6; }
.list-actions { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 10px; }
.empty { padding: 28px 14px; text-align: center; color: var(--muted); border: 1px dashed #d6deea; border-radius: 12px; background: #fbfcff; }
.info-box { padding: 13px 15px; background: var(--brand-soft); border: 1px solid #d6e4ff; color: #28538f; border-radius: 12px; font-size: 12px; line-height: 1.8; }
.warn-box { padding: 13px 15px; background: var(--amber-soft); border: 1px solid #f7ddb0; color: #82520a; border-radius: 12px; font-size: 12px; line-height: 1.8; }
.pill-switch { display: inline-flex; background: #eef2f7; border-radius: 10px; padding: 3px; gap: 2px; }
.pill-switch button { border: 0; background: transparent; padding: 8px 12px; border-radius: 8px; color: var(--muted); font-weight: 700; font-size: 12px; }
.pill-switch button.active { background: #fff; color: var(--brand); box-shadow: 0 2px 8px rgba(20,40,80,.08); }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.toolbar-group { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; }
.input-search { min-width: 220px; border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; background: #fff; }
.import-drop { border: 1px dashed #b9c8dd; background: #fbfdff; border-radius: 14px; padding: 26px; text-align: center; }
.import-drop input { width: 100%; }
.preview-box { max-height: 320px; overflow: auto; margin-top: 14px; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(12,22,40,.45); display: grid; place-items: center; padding: 20px; z-index: 50; }
.modal { width: min(760px, 100%); max-height: calc(100vh - 40px); overflow: auto; background: #fff; border-radius: 18px; box-shadow: 0 25px 70px rgba(8,20,40,.28); }
.modal-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; padding: 20px 22px 14px; border-bottom: 1px solid var(--line); }
.modal-title { font-size: 18px; font-weight: 800; }
.modal-sub { color: var(--muted); font-size: 12px; margin-top: 5px; }
.modal-body { padding: 18px 22px 22px; }
.modal-close { border: 0; background: #f0f3f8; color: #6c7890; width: 32px; height: 32px; border-radius: 9px; font-size: 20px; line-height: 1; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 70; min-width: 260px; max-width: 420px; padding: 13px 16px; border-radius: 12px; background: #15233b; color: #fff; box-shadow: 0 15px 40px rgba(10,25,50,.25); opacity: 0; transform: translateY(12px); pointer-events: none; transition: .2s ease; font-size: 13px; line-height: 1.55; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #a72d3b; }
.toast.success { background: #176f51; }
.empty-cell { color: #a5b0c1; }
.split-line { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.mono { font-family: Consolas, "SFMono-Regular", monospace; font-size: 12px; }
@media (max-width: 1280px) {
  .metric-grid { grid-template-columns: repeat(3, minmax(150px, 1fr)); }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 980px) {
  .sidebar { width: 78px; flex-basis: 78px; padding: 16px 8px; }
  .brand { justify-content: center; padding: 0 0 18px; }
  .brand > div:last-child, .nav-item:not(.active) span, .nav-item { font-size: 0; }
  .nav-item { justify-content: center; padding: 10px; }
  .nav-item span { font-size: 12px; }
  .sidebar-foot { justify-content: center; }
  .sidebar-foot > div:last-child { display: none; }
  .main { padding: 22px 18px 32px; }
  .operator-field { display: none; }
  .grid-3 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .topbar { align-items: flex-start; }
  h1 { font-size: 23px; }
  .metric-grid { grid-template-columns: repeat(2, minmax(130px, 1fr)); }
  .metric { min-height: 105px; padding: 14px; }
  .metric-value { font-size: 28px; }
  .form-grid, .form-grid.cols-2, .form-grid.cols-3 { grid-template-columns: 1fr; }
  .card { padding: 15px; border-radius: 14px; }
  .item-editor-head { display: none; }
  .item-row { grid-template-columns: 1fr 76px 34px; }
  .top-actions .btn-ghost { display: none; }
}
.item-row.with-result { grid-template-columns: minmax(210px, 1fr) 90px 170px 40px; }
.item-row.with-reason { grid-template-columns: minmax(210px, 1fr) 90px minmax(130px, .8fr) 40px; }
.user-chip { display:flex; flex-direction:column; gap:2px; padding:6px 11px; border:1px solid var(--line); background:#fff; border-radius:10px; line-height:1.15; }
.user-label { color:var(--muted); font-size:10px; }
.user-chip strong { font-size:12px; color:var(--ink); }
.login-mode .sidebar, .login-mode .topbar { display:none; }
.login-mode .main { display:grid; place-items:center; min-height:100vh; padding:20px; }
.login-mode .content { width:min(430px,100%); }
.login-card { padding:32px; }
.login-brand { width:54px; height:54px; border-radius:17px; display:grid; place-items:center; color:#fff; font-weight:800; font-size:24px; background:linear-gradient(135deg,#4d8bff,#1c5fd4); box-shadow:0 10px 24px rgba(28,95,212,.3); margin-bottom:20px; }
.login-title { font-size:26px; font-weight:800; letter-spacing:-.04em; }
.login-sub { color:var(--muted); line-height:1.7; font-size:12px; margin:8px 0 22px; }
.login-card .field { margin-bottom:13px; }
.login-card .btn-primary { width:100%; margin-top:8px; padding:12px; }
@media (max-width: 640px) { .user-chip { display:none; } #change-password-btn { display:none; } }
.day-group { margin-bottom: 12px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff; }
.day-summary { cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; background: var(--panel-soft); font-weight: 800; }
.day-summary::-webkit-details-marker { display: none; }
.day-summary::before { content: "▸"; color: var(--brand); font-size: 12px; margin-right: 2px; }
.day-group[open] .day-summary::before { content: "▾"; }
.day-title { flex: 1; }
.day-meta { color: var(--muted); font-size: 11px; font-weight: 700; white-space: nowrap; }
.day-body { padding: 10px; }
.day-body .list { gap: 8px; }
.stock-pager { margin-top: 14px; padding: 12px 2px 0; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.pager-meta { color: var(--muted); font-size: 12px; }
.pager-actions { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.pager-page { color: var(--muted); font-size: 12px; padding: 0 4px; white-space: nowrap; }
