:root {
  color-scheme: light;
  --paper: #f4f6f3;
  --surface: #fff;
  --ink: #162923;
  --muted: #556b62;
  --line: #dce5de;
  --brand: #17654e;
  --brand-dark: #104635;
  --brand-soft: #e8f3ed;
  --warning: #80500d;
  --warning-soft: #fff3d8;
  --danger: #a32b3b;
  --danger-soft: #fcebef;
  --info: #245c82;
  --info-soft: #eaf3fc;
  --shadow: 0 1px 2px #14251c08;
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--paper); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button[disabled] { opacity: .55; cursor: wait; }
:focus-visible { outline: 2px solid #087e66; outline-offset: 3px; }
strong, th, button { font-weight: 650; }
a { color: inherit; }
h1, h2, h3, p { margin: 0; }

.boot { min-height: 100dvh; display: grid; place-content: center; color: var(--muted); padding: 2rem; text-align: center; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark { flex: 0 0 43px; height: 43px; display: grid; place-content: center; border-radius: 12px; background: var(--brand); color: white; font: 700 23px/1 "Songti SC", STSong, serif; }
.brand strong, .brand small { display: block; line-height: 1.45; }
.brand strong { overflow-wrap: anywhere; font-size: 16px; letter-spacing: .03em; }
.brand small { color: var(--muted); font-size: 12px; }

.auth { min-height: 100dvh; display: grid; grid-template-columns: minmax(300px, 43%) minmax(0, 1fr); }
.auth-cover { min-height: 100%; display: flex; flex-direction: column; justify-content: space-between; gap: 70px; padding: clamp(28px, 6vw, 100px); background: radial-gradient(ellipse at 80% 67%, #3f7d66, transparent 52%), radial-gradient(ellipse at 95% 100%, #73937a 0%, transparent 62%), linear-gradient(135deg, #102d24, #184a3c); color: #f8f9ef; }
.brand-light .brand-mark { background: #d6e8d9; color: #164c3b; }
.brand-light small { color: #d1e7d8; }
.auth-intro { max-width: 490px; }
.auth-intro h1 { margin: 14px 0 18px; font-family: "Songti SC", STSong, serif; font-weight: 700; font-size: clamp(36px, 5.2vw, 76px); line-height: 1.2; letter-spacing: .01em; }
.auth-intro p { color: #e0eee6; font-size: clamp(14px, 1.4vw, 18px); }
.eyebrow { color: var(--brand); font-size: 12px; font-weight: 700; letter-spacing: .12em; }
.auth-intro .eyebrow { color: #d3ead9; }
.auth-tag { display: flex; align-items: center; gap: 8px; color: #d7e9db; font-size: 13px; }
.auth-tag .status-dot { background: #b9ebc2; }
.auth-main { display: grid; place-items: center; padding: clamp(24px, 6vw, 80px); }
.auth-card { width: min(100%, 395px); }
.auth-card h2 { margin: 10px 0 6px; font-size: 32px; line-height: 1.3; }
.auth-card p { margin-bottom: 22px; color: var(--muted); }
.auth-card form { display: grid; gap: 16px; }
.auth-card .form-error { margin: 0; color: var(--danger); }
.auth-card form > button { margin-top: 4px; }

.workspace { min-height: 100dvh; display: grid; grid-template-columns: 222px minmax(0, 1fr); }
.sidebar-scrim { display: none; }
.sidebar { position: sticky; top: 0; height: 100dvh; overflow: auto; display: flex; flex-direction: column; padding: 24px 16px 15px; border-right: 1px solid var(--line); background: var(--surface); }
.sidebar .brand { margin: 0 5px 37px; }
.workspace-label { margin: 0 10px 9px; color: var(--muted); font-size: 12px; letter-spacing: .10em; }
.navigation { display: grid; gap: 3px; }
.nav-group { margin-top: 7px; min-width: 0; }
.nav-group summary { padding: 7px 10px; color: var(--muted); font-size: 12px; font-weight: 650; cursor: pointer; }
.nav-group-links { display: grid; gap: 2px; padding-left: 6px; }
.nav-group-links .nav-link { min-height: 37px; padding-block: 6px; }
.nav-link { display: flex; align-items: center; gap: 12px; min-height: 43px; padding: 8px 12px; border-radius: 8px; color: #3e584e; font-weight: 560; text-decoration: none; }
.nav-link:hover, .nav-link[aria-current="page"] { background: var(--brand-soft); color: var(--brand-dark); }
.nav-link[aria-current="page"] { font-weight: 700; }
.icon { flex: 0 0 auto; display: inline-block; width: 18px; height: 18px; vertical-align: -.2em; }
.sidebar-footer { margin-top: auto; padding: 20px 6px 0; }
.system-label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; padding: 4px 4px 8px; }
.status-dot { display: inline-block; flex: 0 0 7px; width: 7px; height: 7px; border-radius: 50%; background: #2f8a60; }
.logout { width: 100%; }
.workarea { min-width: 0; }
.topbar { min-height: 68px; display: flex; align-items: center; gap: 12px; padding: 9px clamp(16px, 3.2vw, 48px); border-bottom: 1px solid var(--line); background: var(--surface); }
.breadcrumb { display: flex; align-items: center; gap: 9px; flex: 1; color: var(--muted); font-size: 13px; }
.breadcrumb strong { color: var(--ink); }
.account { display: flex; align-items: center; gap: 9px; text-align: left; }
.account strong, .account small { display: block; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.4; }
.account strong { font-size: 13px; }
.account small { color: var(--muted); font-size: 11px; }
.avatar { display: grid; place-content: center; width: 36px; height: 36px; background: var(--brand-soft); color: var(--brand-dark); border-radius: 50%; font-weight: 700; }
.mobile-only { display: none !important; }

.page { max-width: 1560px; margin: 0 auto; padding: 28px clamp(16px, 3.2vw, 48px) 54px; }
.page-heading { display: flex; align-items: end; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 22px; }
.page-heading h1 { font-size: clamp(25px, 3vw, 34px); line-height: 1.22; letter-spacing: -.025em; }
.page-heading p { color: var(--muted); margin-top: 6px; }
.page-actions, .form-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.channel-tabs { margin-bottom: 15px; }
.panel { min-width: 0; padding: 20px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); box-shadow: var(--shadow); }
.panel + .panel { margin-top: 15px; }
.panel-heading { display: flex; align-items: start; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.panel h2, .section-heading { font-size: 17px; line-height: 1.35; }
.panel-heading p { color: var(--muted); font-size: 13px; margin-top: 4px; }
.dashboard-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; margin-bottom: 15px; }
.dashboard-grid .panel { margin: 0; }
.dashboard-detail { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 13px; margin-block: 15px; }
.dashboard-detail .panel { margin: 0; }
.stat-label { display: flex; justify-content: space-between; align-items: center; gap: 4px; color: var(--muted); font-size: 13px; }
.stat-label .icon { width: 19px; height: 19px; color: var(--brand); }
.stat-value { font-size: clamp(21px, 3.1vw, 34px); margin-top: 8px; font-weight: 710; line-height: 1.2; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.chart { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(32px, 1fr); align-items: end; gap: 12px; height: 174px; overflow-x: auto; }
.chart-item { display: grid; grid-template-rows: 20px 120px 22px; gap: 2px; text-align: center; min-width: 0; color: var(--muted); font-size: 11px; }
.chart-track { align-self: end; position: relative; height: 100%; border-radius: 6px; background: #f2f5f2; }

.button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 39px; padding: 7px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); text-decoration: none; white-space: nowrap; }
.button:hover { background: #f2f6f3; }
.button.primary { border-color: var(--brand); background: var(--brand); color: white; }
.button.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.button.ghost { background: transparent; color: var(--muted); }
.button.ghost:hover { background: var(--paper); color: var(--ink); }
.button.danger { color: var(--danger); }
.button.icon-button { width: 39px; padding: 0; font-size: 20px; }
.button.small { min-height: 31px; padding: 4px 9px; font-size: 12px; }
.button[aria-pressed="true"] { border-color: #b3cebe; background: var(--brand-soft); color: var(--brand-dark); }

.filter-bar { display: flex; align-items: end; flex-wrap: wrap; gap: 11px; margin-bottom: 17px; }
.filter-bar .field { width: auto; min-width: 145px; }
.filter-bar .search-field { flex: 1 1 190px; max-width: 330px; }
.field { display: grid; gap: 5px; min-width: 0; color: #324b41; font-size: 13px; font-weight: 630; }
.field small { color: var(--muted); font-size: 12px; font-weight: 400; }
input:not([type="checkbox"]), select, textarea { width: 100%; min-width: 0; min-height: 39px; padding: 8px 10px; border: 1px solid #cbd8d0; border-radius: 7px; background: white; color: var(--ink); font-size: 14px; font-weight: 440; }
input:not([type="checkbox"]):focus, select:focus, textarea:focus { outline: 2px solid #86bda9; outline-offset: 1px; }
input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--brand); }
textarea { min-height: 78px; resize: vertical; }
.field.check { display: flex; align-items: center; flex-wrap: wrap; min-height: 39px; gap: 8px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.form-grid .wide { grid-column: 1 / -1; }
.settings-form { max-width: 740px; }
.settings-form .form-actions { margin-top: 17px; }
.form-error { color: var(--danger); font-size: 13px; }
.form-help { color: var(--muted); font-size: 13px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: 13px; }
th, td { padding: 11px 12px; border-bottom: 1px solid #e9eee9; vertical-align: middle; }
th { background: #f4f7f4; color: var(--muted); font-size: 12px; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfcfa; }
td .subline { display: block; color: var(--muted); font-size: 12px; }
.table-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; min-width: max-content; }
.nowrap { white-space: nowrap; }
.badge { display: inline-flex; align-items: center; border-radius: 20px; padding: 3px 8px; background: var(--paper); color: var(--muted); font-size: 12px; font-weight: 630; white-space: nowrap; }
.badge.success { background: var(--brand-soft); color: var(--brand-dark); }
.badge.warn { background: var(--warning-soft); color: var(--warning); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.empty-state { text-align: center; padding: 27px 12px; color: var(--muted); font-size: 14px; }
.page-error { background: var(--danger-soft); border-color: #f4cbd2; color: var(--danger); }
.detail-list { display: grid; grid-template-columns: minmax(90px, 135px) minmax(0, 1fr); gap: 7px 12px; margin: 0; }
.detail-list dt { color: var(--muted); }
.detail-list dd { margin: 0; overflow-wrap: anywhere; }
.code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-variant-numeric: tabular-nums; }

dialog { width: min(calc(100% - 32px), 565px); max-height: calc(100dvh - 32px); padding: 0; border: 1px solid var(--line); border-radius: 14px; background: white; color: var(--ink); box-shadow: 0 22px 85px #132e2540; }
dialog::backdrop { background: #183b3160; }
.modal-header { display: flex; justify-content: space-between; align-items: start; gap: 16px; padding: 19px 22px 16px; border-bottom: 1px solid var(--line); }
.modal-header h2 { font-size: 21px; line-height: 1.35; }
.modal-header p { color: var(--muted); font-size: 13px; margin-top: 5px; }
.modal-fields { display: grid; gap: 14px; padding: 18px 22px; }
#modal-error { margin: 0 22px 14px; }
.modal-actions { display: flex; justify-content: end; gap: 8px; padding: 13px 22px; border-top: 1px solid var(--line); background: #f8faf8; }
.toast { position: fixed; bottom: 22px; right: 22px; z-index: 4; max-width: min(450px, calc(100% - 44px)); padding: 10px 15px; border-radius: 9px; background: var(--brand-dark); color: white; box-shadow: 0 5px 22px #183c2a25; }
.toast.is-error { background: var(--danger); }

@media (max-width: 1020px) {
  .workspace { grid-template-columns: 184px minmax(0, 1fr); }
  .dashboard-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 680px) {
  .auth { grid-template-columns: 1fr; }
  .auth-cover { padding: 22px; gap: 24px; }
  .auth-intro h1 { font-size: 33px; margin: 6px 0; }
  .auth-intro h1 br { display: none; }
  .auth-tag { display: none; }
  .auth-main { place-items: start center; }
  .workspace { grid-template-columns: 1fr; }
  .sidebar { display: none; position: fixed; z-index: 3; top: 0; bottom: 0; left: 0; width: 220px; max-width: 85vw; height: 100dvh; box-shadow: 10px 0 45px #183b3150; }
  .sidebar.is-open { display: flex; }
  .sidebar-scrim { display: block; position: fixed; inset: 0; z-index: 2; border: 0; background: #183b3160; }
  .mobile-only { display: inline-flex !important; }
  .topbar { min-height: 56px; }
  .page { padding-top: 20px; }
  .panel { padding: 15px; }
  .form-grid { grid-template-columns: 1fr; }
  .breadcrumb span { display: none; }
  .account strong { max-width: 86px; }
}
