:root {
  --ink: #18242f;
  --muted: #6c7a86;
  --line: #dfe6e9;
  --paper: #ffffff;
  --canvas: #f4f6f5;
  --navy: #19374a;
  --navy-2: #244b61;
  --teal: #1f7a6c;
  --teal-soft: #e6f3ef;
  --red: #b44b43;
  --red-soft: #f9e9e7;
  --amber: #a26815;
  --amber-soft: #fff3d8;
  --blue-soft: #eaf2f7;
  --shadow: 0 12px 34px rgba(28, 44, 54, 0.08);
  --radius: 16px;
  font-family: "Segoe UI Variable Text", "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", Arial, sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--canvas); }
body {
  min-width: 320px;
  font-family: "Segoe UI Variable Text", "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 248px 1fr; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 24px 18px 18px;
  color: #eaf1f3;
  background:
    radial-gradient(circle at 15% 8%, rgba(77, 142, 142, .26), transparent 28%),
    linear-gradient(160deg, #173446 0%, #122b3a 58%, #102632 100%);
  z-index: 30;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 26px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  color: #11303b; background: #e4c893; font-weight: 800; box-shadow: inset 0 0 0 1px rgba(255,255,255,.35);
}
.brand-mark.large { width: 56px; height: 56px; margin: 0 auto 20px; font-size: 22px; border-radius: 17px; }
.brand strong { display: block; font-size: 16px; letter-spacing: .02em; }
.brand span { display: block; margin-top: 3px; color: #95acb7; font-size: 11px; letter-spacing: .14em; }
.nav { display: grid; gap: 5px; }
.nav-item {
  position: relative; width: 100%; border: 0; border-radius: 10px; padding: 11px 12px;
  display: flex; align-items: center; gap: 11px; text-align: left; color: #b9c8cf; background: transparent;
  transition: .18s ease;
}
.nav-item:hover { color: #fff; background: rgba(255,255,255,.06); }
.nav-item.is-active { color: #fff; background: rgba(255,255,255,.105); box-shadow: inset 3px 0 #ddc184; }
.nav-icon {
  width: 25px; height: 25px; border: 1px solid rgba(255,255,255,.14); border-radius: 7px;
  display: grid; place-items: center; font-size: 12px; font-weight: 700;
}
.nav-badge { margin-left: auto; min-width: 21px; padding: 2px 6px; border-radius: 10px; text-align: center; font-size: 11px; background: #376173; color: white; }
.nav-badge.danger { background: #a94b43; }
.nav-spacer { flex: 1; }
.nav-secondary { border-top: 1px solid rgba(255,255,255,.1); padding-top: 10px; }
.sidebar-status { margin-top: 14px; padding: 12px; border-radius: 10px; display: flex; align-items: center; gap: 10px; background: rgba(255,255,255,.06); }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: #e1b85f; box-shadow: 0 0 0 4px rgba(225,184,95,.12); }
.status-dot.online { background: #6dc4a8; box-shadow: 0 0 0 4px rgba(109,196,168,.12); }
.sidebar-status strong, .sidebar-status span { display: block; }
.sidebar-status strong { font-size: 12px; }
.sidebar-status span { margin-top: 2px; color: #94aab4; font-size: 10px; }

.main { min-width: 0; }
.topbar {
  height: 96px; padding: 0 34px; display: flex; align-items: center; gap: 16px;
  background: rgba(244,246,245,.92); backdrop-filter: blur(8px); border-bottom: 1px solid rgba(201,211,214,.7);
  position: sticky; top: 0; z-index: 20;
}
.topbar h1, .modal-header h2 { margin: 2px 0 0; font-size: 25px; line-height: 1.2; font-weight: 700; letter-spacing: -.02em; }
.eyebrow { margin: 0; color: var(--teal); font-size: 10px; font-weight: 800; letter-spacing: .16em; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.date-chip { padding: 8px 12px; border: 1px solid var(--line); border-radius: 9px; color: var(--muted); background: rgba(255,255,255,.65); font-size: 12px; }
.avatar { width: 37px; height: 37px; border: 0; border-radius: 50%; color: #fff; background: var(--navy); font-weight: 700; }
.menu-button { display: none !important; }
.content { padding: 28px 34px 54px; max-width: 1600px; margin: 0 auto; }

.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.search-box { position: relative; min-width: 250px; }
.search-box::before { content: "⌕"; position: absolute; left: 11px; top: 8px; color: #839099; font-size: 18px; }
.search-box input { width: 100%; padding-left: 34px; }
input, select, textarea {
  width: 100%; border: 1px solid #d6dfe2; border-radius: 9px; padding: 9px 11px; color: var(--ink); background: #fff; outline: none;
  transition: border .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: #67a39a; box-shadow: 0 0 0 3px rgba(62,136,124,.12); }
textarea { min-height: 120px; resize: vertical; line-height: 1.65; }
.button {
  border: 1px solid transparent; border-radius: 9px; padding: 9px 14px; font-size: 13px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; transition: .16s ease;
}
.button:hover { transform: translateY(-1px); }
.button.primary { color: white; background: var(--navy); box-shadow: 0 5px 14px rgba(25,55,74,.16); }
.button.primary:hover { background: #234a60; }
.button.secondary { color: #40515d; background: #fff; border-color: #d5dfe2; }
.button.secondary:hover { border-color: #aabcc3; }
.button.danger { color: #9d3c35; background: var(--red-soft); border-color: #f2d1ce; }
.button.ghost { color: var(--teal); background: transparent; padding-inline: 7px; }
.button.small { padding: 6px 9px; font-size: 11px; }
.button.wide { width: 100%; }
.icon-button { width: 36px; height: 36px; border: 0; border-radius: 9px; display: grid; place-items: center; color: #53626c; background: transparent; font-size: 22px; }
.icon-button:hover { background: #edf1f2; }

.metric-grid { display: grid; grid-template-columns: repeat(5, minmax(150px, 1fr)); gap: 14px; }
.metric-card, .panel {
  border: 1px solid rgba(214,224,226,.9); border-radius: var(--radius); background: var(--paper); box-shadow: var(--shadow);
}
.metric-card { position: relative; min-height: 132px; padding: 19px; overflow: hidden; }
.metric-card::after { content: ""; position: absolute; right: -25px; bottom: -34px; width: 90px; height: 90px; border-radius: 50%; background: var(--blue-soft); }
.metric-card.alert::after { background: var(--red-soft); }
.metric-card.success::after { background: var(--teal-soft); }
.metric-label { color: var(--muted); font-size: 12px; }
.metric-value {
  position: relative; z-index: 1; margin: 16px 0 6px;
  font-family: "Segoe UI Variable Display", "Segoe UI", "Microsoft YaHei UI", Arial, sans-serif;
  font-size: clamp(21px, 1.75vw, 28px); line-height: 1.1; font-weight: 720; letter-spacing: -.035em;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.metric-foot { color: #8b979f; font-size: 10px; }
.dashboard-grid { margin-top: 18px; display: grid; grid-template-columns: 1.3fr .7fr; gap: 18px; }
.panel { padding: 20px; min-width: 0; }
.panel-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 17px; }
.panel-header h2 { margin: 0; font-size: 18px; line-height: 1.35; font-weight: 700; letter-spacing: -.015em; }
.panel-header p { margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.subtle { color: var(--muted); font-size: 12px; }

.channel-bars { display: grid; gap: 18px; }
.channel-row { display: grid; grid-template-columns: 62px 1fr 110px; gap: 12px; align-items: center; font-size: 12px; }
.bar-track { height: 9px; border-radius: 8px; background: #edf1f2; overflow: hidden; }
.bar-fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, #326d72, #68a79a); }
.bar-fill.offline { background: linear-gradient(90deg, #c89d51, #e5c685); }
.bar-amount { text-align: right; font-family: "Segoe UI Variable Text", "Segoe UI", Arial, sans-serif; font-weight: 650; font-variant-numeric: tabular-nums; }
.collection-ring { width: 150px; height: 150px; border-radius: 50%; display: grid; place-items: center; margin: 7px auto 13px; }
.collection-ring::before { content: ""; width: 112px; height: 112px; border-radius: 50%; background: #fff; }
.ring-value { position: absolute; text-align: center; }
.ring-value strong { display: block; font-family: "Segoe UI Variable Display", "Segoe UI", Arial, sans-serif; font-size: 28px; line-height: 1.05; font-weight: 720; letter-spacing: -.035em; font-variant-numeric: tabular-nums; }
.ring-value span { color: var(--muted); font-size: 10px; }
.quick-list { display: grid; gap: 9px; }
.quick-item { padding: 10px 12px; display: flex; align-items: center; gap: 10px; border-radius: 10px; background: #f7f9f8; }
.quick-item .quick-icon { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--blue-soft); color: var(--navy); font-weight: 700; }
.quick-item strong { display: block; font-size: 12px; }
.quick-item span { display: block; color: var(--muted); font-size: 10px; margin-top: 2px; }

.table-panel { border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: var(--shadow); overflow: hidden; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { padding: 12px 14px; color: #6c7981; background: #f7f9f8; border-bottom: 1px solid var(--line); text-align: left; font-weight: 700; white-space: nowrap; }
td { padding: 13px 14px; border-bottom: 1px solid #edf1f2; vertical-align: middle; }
tbody tr:hover { background: #fbfcfc; }
tbody tr:last-child td { border-bottom: 0; }
.money { font-family: "Segoe UI Variable Text", "Segoe UI", "Microsoft YaHei UI", Arial, sans-serif; font-variant-numeric: tabular-nums; white-space: nowrap; }
.money.strong { font-weight: 700; }
.muted { color: var(--muted); }
.cell-title { font-weight: 700; }
.cell-sub { margin-top: 3px; color: var(--muted); font-size: 10px; }
.badge { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 4px 8px; font-size: 10px; font-weight: 700; white-space: nowrap; }
.badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.badge.green { color: #24705f; background: var(--teal-soft); }
.badge.red { color: #a4443d; background: var(--red-soft); }
.badge.amber { color: #916316; background: var(--amber-soft); }
.badge.blue { color: #38667c; background: var(--blue-soft); }
.badge.gray { color: #69767e; background: #edf1f2; }
.row-actions { display: flex; gap: 4px; white-space: nowrap; }
.empty-state { padding: 56px 20px; text-align: center; }
.empty-state .empty-icon { width: 52px; height: 52px; margin: auto; border-radius: 15px; display: grid; place-items: center; background: var(--blue-soft); color: var(--navy); font-size: 20px; }
.empty-state h3 { margin: 14px 0 6px; }
.empty-state p { margin: 0 auto 18px; max-width: 400px; color: var(--muted); font-size: 12px; }

.match-grid { display: grid; gap: 14px; }
.match-card { border: 1px solid var(--line); border-radius: 14px; padding: 16px; background: #fff; box-shadow: 0 7px 20px rgba(28,44,54,.05); }
.match-head { display: flex; align-items: flex-start; gap: 16px; }
.match-payment { min-width: 230px; }
.match-arrow { align-self: center; color: #9aa7ad; font-size: 22px; }
.match-suggestion { flex: 1; padding: 12px 14px; border-radius: 11px; background: #f6f9f8; }
.confidence { margin-left: auto; text-align: right; }
.confidence strong { display: block; font-size: 17px; color: var(--teal); }
.confidence span { color: var(--muted); font-size: 10px; }

.notice-layout { display: grid; grid-template-columns: minmax(0, 1fr) 390px; gap: 18px; }
.notice-editor { position: sticky; top: 116px; align-self: start; }
.placeholder-list { margin: 10px 0 0; display: flex; gap: 6px; flex-wrap: wrap; }
.placeholder { border: 0; border-radius: 6px; padding: 4px 7px; color: #38667c; background: var(--blue-soft); font-size: 10px; }
.check { width: 16px; height: 16px; accent-color: var(--teal); }

.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 18px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 13px 0; border-bottom: 1px solid #edf1f2; }
.setting-row:last-child { border-bottom: 0; }
.setting-row strong { display: block; font-size: 12px; }
.setting-row span { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; }
.code-box { padding: 13px; border-radius: 10px; background: #172d3a; color: #c9d8de; font: 11px/1.6 Consolas, monospace; overflow-wrap: anywhere; }

.modal-backdrop { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 20px; background: rgba(15,31,40,.48); backdrop-filter: blur(4px); }
.modal { width: min(720px, 100%); max-height: 92vh; display: flex; flex-direction: column; border-radius: 18px; background: #fff; box-shadow: 0 28px 80px rgba(15,31,40,.25); overflow: hidden; }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; padding: 21px 24px 17px; border-bottom: 1px solid var(--line); }
.modal-header h2 { font-size: 21px; }
.modal-body { padding: 22px 24px; overflow: auto; }
.modal-footer { display: flex; justify-content: flex-end; gap: 9px; padding: 15px 24px; border-top: 1px solid var(--line); background: #fafbfb; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
label { display: block; color: #4c5c66; font-size: 11px; font-weight: 700; }
label input, label select, label textarea { margin-top: 6px; font-weight: 400; }
.form-help { margin: 5px 0 0; color: #8a969d; font-size: 10px; font-weight: 400; }
.form-error { min-height: 16px; color: var(--red); font-size: 11px; }

.login-layer { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; background: linear-gradient(145deg, #102b3a, #1b4656); }
.login-card { width: min(410px, 100%); padding: 38px; border-radius: 22px; text-align: center; background: #fff; box-shadow: 0 30px 90px rgba(5,18,25,.35); }
.login-card h1 { margin: 6px 0 10px; font-size: 25px; line-height: 1.25; font-weight: 700; letter-spacing: -.02em; }
.login-card > p:not(.eyebrow) { color: var(--muted); font-size: 12px; }
.login-card form { margin-top: 24px; display: grid; gap: 15px; text-align: left; }
.login-card button:disabled { cursor: wait; opacity: .68; transform: none; }

.toast-stack { position: fixed; z-index: 120; right: 20px; bottom: 20px; display: grid; gap: 9px; }
.toast { min-width: 270px; max-width: 380px; padding: 12px 14px; border-radius: 11px; color: #fff; background: #1e3b4b; box-shadow: 0 15px 40px rgba(15,31,40,.22); font-size: 12px; animation: toast-in .22s ease; }
.toast.error { background: #97443f; }
@keyframes toast-in { from { opacity: 0; transform: translateY(9px); } }

.notice-print-root { display: none; }
@media print {
  body > *:not(.notice-print-root) { display: none !important; }
  .notice-print-root { display: block !important; color: #111; background: #fff; }
  .notice-page { page-break-after: always; min-height: 260mm; padding: 14mm 16mm; font-family: "Songti SC", SimSun, serif; }
  .notice-page:last-child { page-break-after: auto; }
  .notice-page h1 { text-align: center; font-size: 22pt; margin: 0 0 15mm; }
  .notice-meta { display: flex; justify-content: space-between; font-size: 10pt; }
  .notice-body { margin-top: 10mm; font-size: 11pt; line-height: 1.9; text-indent: 2em; }
  .notice-table { margin-top: 7mm; border: 1px solid #444; }
  .notice-table td { border: 1px solid #444; padding: 8px 10px; }
  .notice-table td:first-child { width: 32mm; text-align: center; font-weight: 700; background: #f1f1f1; }
  .notice-closing { margin-top: 12mm; text-align: right; line-height: 2; }
}

@media (max-width: 1180px) {
  .metric-grid { grid-template-columns: repeat(3, 1fr); }
  .notice-layout { grid-template-columns: 1fr; }
  .notice-editor { position: static; }
}
@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: -270px; width: 248px; transition: left .2s ease; box-shadow: 20px 0 50px rgba(10,25,35,.2); }
  .sidebar.is-open { left: 0; }
  .menu-button { display: grid !important; }
  .topbar { height: 82px; padding: 0 18px; }
  .topbar h1 { font-size: 22px; }
  .content { padding: 20px 18px 44px; }
  .date-chip, #backup-button { display: none; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid, .settings-grid { grid-template-columns: 1fr; }
  .match-head { flex-wrap: wrap; }
  .match-arrow { transform: rotate(90deg); }
}
@media (max-width: 540px) {
  .metric-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .search-box { min-width: 100%; }
  .toolbar .spacer { display: none; }
  .panel { padding: 16px; }
}
