:root {
  color-scheme: light;
  --paper: #fafaf8;
  --card: #fff;
  --ink: #0b1120;
  --muted: #526073;
  --line: #e1e5ea;
  --blue: #005bff;
  --teal: #0f766e;
  --amber: #b45309;
  --red: #dc2626;
  --blue-wash: #edf3ff;
  --text: "Avenir Next", "PingFang SC", "Microsoft YaHei", sans-serif;
  --display: "Iowan Old Style", "Songti SC", "Noto Serif CJK SC", Georgia, serif;
  font: 15px/1.5 var(--text);
  color: var(--ink);
  background: var(--paper);
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
button, select { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .58; }
h1, h2, h3, p, dl, dd { margin: 0; }
h1, h2 { font-family: var(--display); letter-spacing: -.045em; line-height: 1.15; }
h1 { font-size: clamp(2.25rem, 4.4vw, 4.1rem); }
h2 { font-size: clamp(1.6rem, 3vw, 2.25rem); }
h3 { font-size: 1.15rem; overflow-wrap: anywhere; }
.muted { color: var(--muted); }
.brand { display: flex; align-items: center; gap: 12px; font-size: 1.1rem; letter-spacing: .045em; }
.brand small { display: block; color: var(--muted); font-size: .7rem; font-weight: 600; letter-spacing: .08em; }
.brand-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--blue); color: white; font-family: var(--display); font-size: 1.75rem; }
.shell { display: grid; grid-template-columns: 228px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: #f1f2ef; position: sticky; top: 0; height: 100vh; padding: 29px 17px; display: flex; flex-direction: column; gap: 35px; border-right: 1px solid var(--line); }
.sidebar .brand { margin-inline: 8px; }
.navigation { display: grid; gap: 5px; }
.navigation a { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 43px; padding: 8px 11px; font-weight: 600; border-radius: 5px; }
.navigation a:hover { background: #e8ebee; }
.navigation a[aria-current="page"] { background: var(--blue-wash); color: #0046c6; box-shadow: inset 3px 0 var(--blue); }
.navigation small { color: var(--muted); font-size: .7rem; font-weight: 500; }
.sidebar-foot { display: flex; gap: 9px; align-items: baseline; margin-top: auto; padding: 15px 8px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: .81rem; overflow-wrap: anywhere; }
.scope-dot { width: 8px; height: 8px; flex: none; background: var(--blue); border-radius: 50%; }
.workspace { max-width: 1580px; width: 100%; padding: 0 clamp(18px, 3vw, 52px) 46px; min-width: 0; }
.toolbar { min-height: 79px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 10px 16px; flex-wrap: wrap; padding-block: 14px; }
.workspace-label { color: var(--muted); font-size: .78rem; font-weight: 700; letter-spacing: .06em; }
.toolbar-actions, .site-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 37px; padding: 6px 11px; border: 1px solid var(--line); border-radius: 5px; background: var(--card); color: var(--ink); font-size: .82rem; font-weight: 650; }
.button:hover:not(:disabled) { border-color: #9cb8f0; color: #0046c6; }
.button.primary { border-color: var(--blue); background: var(--blue); color: white; }
.button.primary:hover:not(:disabled) { background: #004ae0; color: white; }
.logout { color: var(--muted); background: transparent; }
.heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-block: 36px 22px; }
.heading.compact { margin-block: 34px 14px; }
.heading p { margin-top: 9px; color: var(--muted); }
.metrics { display: grid; grid-template-columns: 1fr 1.32fr 1fr 1fr 1fr; gap: 10px; }
.metrics > div { min-width: 0; border: 1px solid var(--line); border-top: 2px solid var(--blue); background: var(--card); padding: 14px 13px 12px; border-radius: 0 0 6px 6px; }
.metrics dt { color: var(--muted); font-size: .81rem; }
.metrics dt span { color: #758496; }
.metrics dd { margin-top: 12px; font: 600 clamp(1.65rem, 3vw, 2.85rem)/1 var(--display); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.pill, .chip { display: inline-flex; align-items: center; gap: 5px; max-width: 100%; border-radius: 4px; padding: 3px 7px; font-size: .74rem; font-weight: 600; background: #eef0f3; color: #485568; overflow-wrap: anywhere; }
.pill.success, .chip.success { background: #def3ee; color: var(--teal); }
.pill.warning, .chip.warning { background: #fff2db; color: var(--amber); }
.pill.error, .chip.error { background: #ffebeb; color: #b91c1c; }
.pill.managed { background: var(--blue-wash); color: #0046c6; }
.matrix { display: grid; gap: 8px; }
.site { display: grid; grid-template-columns: minmax(155px, .65fr) minmax(240px, 1.85fr) minmax(160px, 1fr); align-items: center; gap: 12px 20px; padding: 15px 16px; border: 1px solid var(--line); border-radius: 6px; background: var(--card); min-width: 0; }
.site-name p { margin: 2px 0 6px; overflow-wrap: anywhere; font-size: .78rem; }
.channels { display: flex; flex-wrap: wrap; gap: 5px; }
.quotas { margin-top: 6px; color: var(--muted); font-size: .76rem; }
.readonly-note { margin-top: 6px; font-size: .74rem; color: var(--muted); }
.empty, .notice { background: var(--card); padding: 12px 14px; border: 1px solid var(--line); border-radius: 5px; color: var(--muted); overflow-wrap: anywhere; }
.notice { margin-top: 14px; border-left: 3px solid var(--blue); color: var(--ink); }
.notice.error { border-left-color: var(--red); color: #a61b1b; }
.filters { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; margin-bottom: 14px; }
.filters label { flex: 1 1 145px; max-width: 240px; }
label { display: block; color: var(--ink); font-size: .86rem; font-weight: 650; }
input, select { display: block; width: 100%; min-width: 0; min-height: 39px; margin-top: 5px; border: 1px solid #c9d0d8; border-radius: 5px; background: var(--card); color: var(--ink); padding: 7px 9px; }
.table-list, .traffic-grid { display: grid; gap: 8px; min-width: 0; }
.ledger-row, .traffic-row { background: var(--card); border: 1px solid var(--line); border-radius: 5px; padding: 11px 13px; overflow-wrap: anywhere; }
.ledger-row { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 5px 14px; }
.ledger-row p, .traffic-row p { color: var(--muted); font-size: .8rem; }
.traffic-block { padding: 13px; background: #f1f2ef; border-radius: 6px; }
.traffic-block h3 { margin-bottom: 8px; }
.traffic-row + .traffic-row { margin-top: 6px; }
.traffic-metrics, .facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 7px; }
.traffic-metrics dt, .facts dt { color: var(--muted); font-size: .76rem; }
.traffic-metrics dd, .facts dd { font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.drawer { margin: 0 0 0 auto; width: min(100%, 635px); max-width: 100%; height: 100%; max-height: 100%; padding: 20px clamp(16px, 4vw, 31px) 25px; border: 0; border-left: 1px solid var(--line); background: var(--paper); color: var(--ink); }
.drawer::backdrop { background: #0b112066; }
.drawer-head { display: flex; justify-content: space-between; align-items: start; gap: 10px; padding-bottom: 15px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.drawer-head h2 { margin-top: 4px; }
.drawer section { margin-block: 17px; }
.drawer section h3 { margin-bottom: 8px; }
.drawer .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.channel-detail { display: grid; grid-template-columns: minmax(73px, .8fr) minmax(70px, .7fr) minmax(120px, 1.3fr); gap: 6px 10px; padding-block: 5px; border-bottom: 1px solid var(--line); font-size: .8rem; overflow-wrap: anywhere; }
pre { white-space: pre-wrap; overflow-wrap: anywhere; padding: 12px; background: #f1f2ef; border: 1px solid var(--line); border-radius: 5px; font-size: .8rem; }
.login-page { display: grid; place-items: center; min-height: 100vh; padding: 24px 16px; background: linear-gradient(147deg, #edf3ff, var(--paper) 46%); }
.login-card { width: min(100%, 440px); background: var(--card); border: 1px solid var(--line); border-top: 3px solid var(--blue); border-radius: 0 0 8px 8px; padding: clamp(21px, 5vw, 42px); box-shadow: 0 13px 35px #0b112009; }
.login-card h1 { margin: 25px 0 9px; }
.login-card .muted { font-size: .84rem; overflow-wrap: anywhere; }
.login-card form { margin-top: 23px; }
.login-card label { margin-top: 13px; }
.login-card input { min-height: 46px; }
.login-card button { width: 100%; margin-top: 19px; min-height: 46px; justify-content: space-between; }

@media (max-width: 1060px) {
  .site { grid-template-columns: minmax(130px, 1fr) minmax(180px, 1.7fr); }
  .site > :last-child { grid-column: 1 / -1; }
}
@media (max-width: 760px) {
  .shell { display: block; }
  .sidebar { position: static; height: auto; padding: 14px 15px 10px; gap: 12px; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar .brand { margin: 0; }
  .sidebar-foot { display: none; }
  .navigation { display: flex; flex-wrap: wrap; gap: 3px 4px; }
  .navigation a { min-height: 32px; padding: 4px 7px; font-size: .76rem; }
  .navigation small { font-size: .62rem; }
  .toolbar { min-height: 0; }
  .heading { margin-top: 24px; }
  .metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 480px) {
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metrics > div { padding: 10px; }
  .site { grid-template-columns: minmax(0, 1fr); gap: 9px; padding: 12px; }
  .site > :last-child { grid-column: auto; }
  .ledger-row, .traffic-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
