
:root {
  --bg: #F4F6F9;
  --surface: #FFFFFF;
  --surface-soft: #F8FAFC;
  --navy: #18283E;
  --navy-hover: #223855;
  --gold: #8C6523;
  --gold-bg: #FBF4E6;
  --ok: #126A46;
  --ok-bg: #E7F6EE;
  --warn: #A24A0B;
  --warn-bg: #FFF3E5;
  --danger: #B42318;
  --danger-bg: #FEECEB;
  --text: #122033;
  --muted: #5B6B80;
  --border: #E2E8F0;
  --shadow: 0 6px 24px rgba(18, 32, 51, 0.06);
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 13px; line-height: 1.5; -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button {
  cursor: pointer; border-radius: 8px; border: 1px solid transparent;
  padding: 7px 14px; font-weight: 600; transition: all .15s ease;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
button:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--navy); color: #FFF; }
.btn-primary:hover:not(:disabled) { background: var(--navy-hover); }
.btn-sub { background: #FFF; color: var(--navy); border-color: #CBD5E1; }
.btn-sub:hover:not(:disabled) { background: #F1F5F9; }
.btn-gold { background: var(--gold-bg); color: var(--gold); border-color: #EBD5A7; }
.btn-gold:hover:not(:disabled) { background: #F5E7C8; }
.btn-danger { background: var(--danger-bg); color: var(--danger); border-color: #F7C6C2; }
.btn-danger:hover:not(:disabled) { background: #FCD7D4; }
.btn-sm { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.btn-link { background: transparent; color: var(--navy); padding: 4px 6px; }
.btn-link:hover { text-decoration: underline; }

input[type="text"], input[type="password"], input[type="number"], input[type="date"], select, textarea {
  background: #FFF; border: 1px solid #CBD5E1; border-radius: 8px; padding: 7px 10px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--navy); box-shadow: 0 0 0 3px rgba(24, 40, 62, 0.1); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.strong { font-weight: 700; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* Login Screen */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: radial-gradient(circle at top right, #E7EEF8, #F4F6F9 55%);
}
.login-card {
  width: 400px; max-width: 100%; background: #FFF; border: 1px solid var(--border);
  border-radius: 16px; padding: 32px; box-shadow: 0 20px 50px rgba(18, 32, 51, 0.1);
}
.login-kicker { color: var(--gold); font-weight: 700; font-size: 11px; letter-spacing: 2px; text-transform: uppercase; }
.login-title { font-size: 24px; font-weight: 800; margin: 6px 0 6px; color: var(--navy); }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
.field input, .field select, .field textarea { width: 100%; }

/* App Shell */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 224px; flex: none; background: var(--navy); color: #E2E8F0;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand-box { padding: 22px 18px 18px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.brand-kicker { font-size: 10px; letter-spacing: 2px; color: #E8C98E; font-weight: 700; }
.brand-name { font-size: 17px; font-weight: 800; color: #FFF; margin-top: 4px; }
.brand-sub { font-size: 11px; color: #94A3B8; margin-top: 2px; }
.nav-list { padding: 14px 10px; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  width: 100%; justify-content: flex-start; padding: 10px 12px; border-radius: 9px;
  background: transparent; color: #CBD5E1; font-weight: 600; font-size: 13px; border: none;
}
.nav-item:hover { background: rgba(255,255,255,0.07); color: #FFF; }
.nav-item.active { background: #FFF; color: var(--navy); }
.nav-badge {
  margin-left: auto; background: #B42318; color: #FFF; border-radius: 99px;
  padding: 1px 7px; font-size: 11px; font-weight: 700;
}
.sidebar-foot { padding: 14px 16px; border-top: 1px solid rgba(255,255,255,0.08); font-size: 12px; }
.sidebar-user { color: #FFF; font-weight: 700; margin-bottom: 8px; }

.main-area { flex: 1; min-width: 0; padding: 20px 24px 64px; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px;
}
.page-title { font-size: 21px; font-weight: 800; color: var(--navy); margin: 0; }
.page-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* KPI Strip */
.kpi-grid {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px;
}
@media (max-width: 1280px) { .kpi-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.kpi-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; cursor: pointer; transition: all .15s ease;
}
.kpi-card:hover { border-color: var(--navy); transform: translateY(-1px); box-shadow: var(--shadow); }
.kpi-card.active { border-color: var(--navy); background: #F0F5FC; }
.kpi-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.kpi-val { font-size: 22px; font-weight: 800; color: var(--navy); margin-top: 4px; }
.kpi-card.danger .kpi-val { color: var(--danger); }
.kpi-card.gold .kpi-val { color: var(--gold); }

/* Cards & Toolbar */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px;
}
.filter-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.pill-group { display: flex; gap: 6px; flex-wrap: wrap; }
.pill {
  padding: 6px 12px; border-radius: 99px; background: #EFF3F8; color: var(--muted);
  border: 1px solid transparent; font-size: 12px; font-weight: 600;
}
.pill.active { background: var(--navy); color: #FFF; }
.spacer { flex: 1; }

/* Sticky Batch Action Bar */
.batch-bar {
  position: sticky; top: 10px; z-index: 30;
  background: var(--navy); color: #FFF; border-radius: 12px;
  padding: 10px 14px; margin-bottom: 12px;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  box-shadow: 0 12px 30px rgba(24, 40, 62, 0.25);
}
.batch-count { font-weight: 700; margin-right: 6px; color: #F3D9A4; }
.batch-bar .btn-sub { background: rgba(255,255,255,0.12); color: #FFF; border-color: rgba(255,255,255,0.25); }
.batch-bar .btn-sub:hover:not(:disabled) { background: rgba(255,255,255,0.22); }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; background: #FFF; }
table { width: 100%; border-collapse: collapse; min-width: 1060px; }
th {
  background: #F8FAFC; color: var(--muted); font-size: 12px; font-weight: 700;
  text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
td { padding: 10px 10px; border-bottom: 1px solid #EEF2F7; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #F8FBFF; }
tbody tr.selected { background: #EEF4FC; }
tbody tr.cancelled { opacity: .6; }

.badge {
  display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 99px;
  font-size: 11px; font-weight: 700; background: #EDF2F7; color: var(--navy); white-space: nowrap;
}
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.danger { background: var(--danger-bg); color: var(--danger); }
.badge.gold { background: var(--gold-bg); color: var(--gold); }

/* 7-File Matrix Pills */
.doc-matrix { display: flex; gap: 4px; flex-wrap: nowrap; }
.doc-chip {
  width: 24px; height: 24px; padding: 0; border-radius: 6px; font-size: 11px; font-weight: 700;
  border: 1px solid #CBD5E1; background: #F8FAFC; color: #94A3B8;
}
.doc-chip.has { background: var(--ok-bg); color: var(--ok); border-color: #A7DFC5; }
.doc-chip.has:hover { background: #D1F0E0; }
.doc-chip:not(.has):hover { border-color: var(--navy); color: var(--navy); }

.pagination {
  display: flex; align-items: center; justify-content: space-between; margin-top: 12px; font-size: 12px; color: var(--muted);
}

/* Right Slide-over Drawer */
.drawer-mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45); z-index: 60;
  display: flex; justify-content: flex-end;
}
.drawer {
  width: 720px; max-width: 96vw; height: 100vh; background: #F8FAFC;
  display: flex; flex-direction: column; box-shadow: -12px 0 40px rgba(15, 23, 42, 0.2);
}
.drawer-head {
  background: #FFF; padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.drawer-body { flex: 1; overflow-y: auto; padding: 18px 20px 36px; }
.drawer-section {
  background: #FFF; border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; margin-bottom: 14px;
}
.section-h { font-size: 14px; font-weight: 800; color: var(--navy); margin: 0 0 10px; display: flex; align-items: center; justify-content: space-between; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }

/* Drag & Drop Upload Zones */
.dropzone {
  border: 1.5px dashed #CBD5E1; border-radius: 10px; padding: 10px; background: #F8FAFC;
  transition: all .15s ease; display: flex; flex-direction: column; gap: 6px;
}
.dropzone.has { border-style: solid; border-color: #A7DFC5; background: #F3FBF7; }
.dropzone.dragover { border-color: var(--navy); background: #EAF2FC; transform: scale(1.01); }
.dropzone-title { font-size: 12px; font-weight: 700; color: var(--navy); display: flex; justify-content: space-between; align-items: center; }
.dropzone-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.big-dropzone {
  border: 2px dashed #94A3B8; border-radius: 12px; padding: 20px; text-align: center;
  background: #F8FAFC; cursor: pointer; transition: all .15s ease;
}
.big-dropzone.dragover { border-color: var(--navy); background: #EAF2FC; }

/* Modals & Lightbox */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.55); z-index: 80;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-box {
  width: 520px; max-width: 96vw; max-height: 90vh; overflow-y: auto;
  background: #FFF; border-radius: 14px; padding: 22px; box-shadow: 0 24px 60px rgba(0,0,0,0.25);
}
.modal-box.wide { width: 960px; }
.modal-title { font-size: 17px; font-weight: 800; color: var(--navy); margin: 0 0 12px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.lightbox-grid { display: grid; grid-template-columns: 1.45fr 1fr; gap: 16px; min-height: 480px; }
.lightbox-stage {
  background: #0F172A; border-radius: 10px; display: flex; align-items: center; justify-content: center;
  overflow: hidden; min-height: 460px; position: relative;
}
.lightbox-stage img { max-width: 100%; max-height: 68vh; object-fit: contain; }
.lightbox-stage iframe { width: 100%; height: 68vh; border: none; background: #FFF; }

/* Toast & Banner */
.toast-stack { position: fixed; top: 18px; right: 20px; z-index: 120; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--navy); color: #FFF; padding: 10px 16px; border-radius: 10px;
  font-weight: 600; box-shadow: 0 10px 28px rgba(0,0,0,0.2); max-width: 420px;
}
.toast.ok { background: var(--ok); }
.toast.err { background: var(--danger); }
.alert-box { padding: 10px 12px; border-radius: 8px; font-size: 12px; margin-bottom: 10px; }
.alert-box.err { background: var(--danger-bg); color: var(--danger); }
.alert-box.ok { background: var(--ok-bg); color: var(--ok); }
.alert-box.gold { background: var(--gold-bg); color: var(--gold); }
.list-row { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid #EEF2F7; gap: 8px; }
.list-row:last-child { border-bottom: none; }

/* Login Tabs & WeChat QR Box */
.login-tabs {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 4px;
  background: #EFF3F8; border-radius: 10px; margin-bottom: 16px;
}
.login-tab {
  border-radius: 8px; padding: 7px 10px; background: transparent; color: var(--muted); font-size: 12px; font-weight: 700;
}
.login-tab.active { background: #FFF; color: var(--navy); box-shadow: 0 2px 6px rgba(18, 32, 51, 0.08); }
.qr-box {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 18px 14px; border: 1px solid var(--border); border-radius: 12px; background: #F8FAFC; text-align: center;
}
.qr-img { width: 204px; height: 204px; border-radius: 10px; border: 1px solid #E2E8F0; background: #FFF; padding: 6px; object-fit: contain; }
.qr-status { margin-top: 10px; font-size: 12px; font-weight: 600; color: var(--navy); }
.portal-links {
  margin-top: 16px; padding-top: 12px; border-top: 1px solid #EEF2F7;
  display: flex; justify-content: center; gap: 14px; font-size: 12px;
}
.portal-links a { color: var(--muted); text-decoration: none; font-weight: 600; }
.portal-links a:hover { color: var(--navy); text-decoration: underline; }

/* Analytics Trend Chart & Summary Banner */
.summary-strip {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: linear-gradient(135deg, #18283E 0%, #243B5A 100%); color: #FFF;
  border-radius: 12px; padding: 12px 16px; margin-bottom: 14px;
}
.summary-metrics { display: flex; gap: 22px; flex-wrap: wrap; align-items: center; }
.summary-metric-label { font-size: 11px; color: #CBD5E1; }
.summary-metric-val { font-size: 17px; font-weight: 800; color: #FFF; }
.summary-metric-val.gold { color: #F3D9A4; }

.trend-chart {
  display: grid; grid-template-columns: repeat(14, minmax(0, 1fr)); gap: 8px;
  align-items: end; height: 188px; padding: 14px 8px 6px; border-top: 1px solid #EEF2F7;
}
.trend-col { display: flex; flex-direction: column; align-items: center; height: 100%; justify-content: flex-end; gap: 4px; }
.trend-bars { display: flex; align-items: flex-end; gap: 3px; height: 132px; width: 100%; justify-content: center; }
.trend-bar {
  width: 11px; min-height: 3px; border-radius: 4px 4px 0 0; background: var(--navy);
  transition: height .2s ease;
}
.trend-bar.done { background: #16A34A; }
.trend-num { font-size: 10px; font-weight: 700; color: var(--navy); min-height: 14px; }
.trend-day { font-size: 10px; color: var(--muted); white-space: nowrap; }

.delta-up { color: var(--ok); font-size: 11px; font-weight: 700; margin-left: 4px; }
.delta-down { color: var(--danger); font-size: 11px; font-weight: 700; margin-left: 4px; }
.sidebar.upstream-theme { background: #10322E; }
.sidebar.upstream-theme .brand-kicker { color: #7EE2C8; }
.sidebar.partner-theme { background: #22293F; }
.sidebar.partner-theme .brand-kicker { color: #F2C97D; }
