:root {
    color-scheme: light;
    --ink: #1d2723;
    --muted: #5a6861;
    --accent: #205c4b;
    --accent-strong: #174736;
    --accent-surface: #e8f0ec;
    --paper: #fff;
    --canvas: #f6f7f6;
    --line: #dde3df;
    --row-hover: #f1f4f2;
    --radius: .375rem;
    font-family: system-ui, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--canvas);
    color: var(--ink);
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font-size: 16px; line-height: 1.5; }
a { color: var(--accent); text-underline-offset: .2em; }
:where(a, button, input, select, textarea, summary):focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
img { display: block; max-width: 100%; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(1.45rem, 2.2vw, 1.875rem); line-height: 1.23; font-weight: 680; }
h2 { font-size: 1.05rem; line-height: 1.35; font-weight: 670; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.subtle, .page-heading p, .panel-heading p { color: var(--muted); }
.subtle { margin-top: .4rem; }
.skip-link {
    position: absolute;
    z-index: 5;
    inset: .6rem auto auto .6rem;
    transform: translateY(-160%);
    background: var(--paper);
    padding: .55rem .8rem;
}
.skip-link:focus { transform: none; }

.admin-shell { min-height: 100vh; display: grid; grid-template-columns: 13.75rem minmax(0, 1fr); }
.sidebar {
    position: sticky;
    top: 0;
    align-self: start;
    min-height: 100vh;
    min-height: 100dvh;
    max-height: 100dvh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    background: var(--paper);
    border-inline-end: 1px solid var(--line);
    padding: .85rem .7rem;
}
.brand {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    gap: .58rem;
    color: var(--ink);
    text-decoration: none;
}
.brand img { border-radius: var(--radius); }
.brand strong, .brand small { display: block; }
.brand strong { line-height: 1.2; font-size: .98rem; letter-spacing: .025em; font-weight: 720; }
.brand small { margin-top: .1rem; font-size: .8125rem; color: var(--muted); }
.sidebar .brand { margin: .15rem .5rem 1.3rem; }
.admin-nav, .sidebar-footer { display: grid; gap: .2rem; }
.nav-link, .sidebar-footer a {
    display: flex;
    align-items: center;
    gap: .6rem;
    min-width: 0;
    min-height: 2.55rem;
    border-radius: var(--radius);
    padding: .36rem .55rem;
    color: var(--muted);
    font-size: .9rem;
    text-decoration: none;
}
.nav-link:hover, .sidebar-footer a:hover, .button-plain:hover { background: var(--row-hover); color: var(--ink); }
.nav-link.is-current { background: var(--accent-surface); color: var(--accent); font-weight: 650; }
.admin-menu-icon, .admin-icon { flex: none; display: block; inline-size: 1.125rem; block-size: 1.125rem; }
.admin-icon { inline-size: 1rem; block-size: 1rem; }
.sidebar-footer { margin-top: auto; padding-top: .6rem; border-top: 1px solid var(--line); }
.main-shell { min-width: 0; }
.topbar, .login-topbar {
    min-height: 3.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .6rem 1rem;
    padding: .5rem clamp(1rem, 2.6vw, 2rem);
    background: var(--paper);
    border-bottom: 1px solid var(--line);
}
.admin-location, .operator { display: flex; align-items: center; min-width: 0; gap: .45rem; font-size: .875rem; color: var(--muted); }
.admin-location > a { flex: none; color: inherit; }
.admin-location > span { overflow-wrap: anywhere; }
.admin-location [aria-current] { color: var(--ink); font-weight: 600; }
.operator { flex: 0 1 auto; margin-left: auto; }
.operator > span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.operator form { flex: none; margin: 0; }
.page { padding: clamp(1rem, 2.6vw, 2rem); max-width: 89rem; margin-inline: auto; }
.page-heading { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .65rem 1rem; margin-bottom: 1.2rem; }
.page-heading p { margin-top: .35rem; font-size: .9375rem; }
.heading-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.connection-status { display: inline-flex; align-items: center; gap: .4rem; color: var(--accent); font-size: .875rem; }
.status-dot { height: .4rem; width: .4rem; border-radius: 50%; background: var(--accent); }
.connection-status.is-pending { color: var(--muted); }
.connection-status.is-pending .status-dot { background: #76847d; }

.metric-strip {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin: 0 0 1.25rem;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}
.metric-entry { display: flex; flex-direction: column; gap: .25rem; min-width: 0; padding: .75rem .9rem; }
.metric-entry + .metric-entry { border-inline-start: 1px solid var(--line); }
a.metric-entry { color: inherit; text-decoration: none; }
a.metric-entry:hover { background: var(--row-hover); }
a.metric-entry:hover .metric-value { color: var(--accent); }
.metric-entry > span, .metric-entry > dt { font-size: .875rem; color: var(--muted); }
.metric-value { margin: 0; font-size: 1.55rem; line-height: 1.2; font-weight: 670; font-variant-numeric: tabular-nums; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
.ops-trend, .ops-breakdowns { margin-bottom: 1rem; }
.ops-period { display: inline-flex; flex-wrap: wrap; gap: .15rem; padding: .15rem; border: 1px solid var(--line); border-radius: var(--radius); }
.ops-period a { padding: .3rem .65rem; color: var(--muted); border-radius: calc(var(--radius) - 2px); text-decoration: none; white-space: nowrap; font-size: .875rem; }
.ops-period a:hover, .ops-period a[aria-current] { background: var(--row-hover); color: var(--ink); }
.ops-period a[aria-current] { font-weight: 650; }
.ops-trend-body { padding: .8rem .9rem; }
.ops-trend-series { display: flex; flex-wrap: wrap; gap: .35rem 1.25rem; list-style: none; margin: 0; padding: 0; font-size: .875rem; }
.ops-trend-series li { display: flex; align-items: center; gap: .42rem; color: var(--muted); }
.ops-trend-series strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.ops-series-key { width: 1.1rem; border-top: 2px solid var(--accent); }
.ops-series-key.video-series { border-color: var(--muted); border-top-style: dashed; }
.ops-plot { display: grid; grid-template-columns: minmax(1.9rem, max-content) minmax(0, 1fr); gap: .35rem .5rem; align-items: stretch; margin: .7rem 0 .85rem; }
.ops-axis-x, .ops-axis-y { display: flex; justify-content: space-between; color: var(--muted); font-size: .74rem; font-variant-numeric: tabular-nums; }
.ops-axis-y { flex-direction: column; text-align: end; }
.ops-axis-x { grid-column: 2; gap: .2rem; }
.ops-plot svg { display: block; width: 100%; height: 7.2rem; }
.ops-plot-grid, .ops-trend-line { fill: none; vector-effect: non-scaling-stroke; }
.ops-plot-grid { stroke: var(--line); }
.ops-trend-line { stroke: var(--accent); stroke-width: 2; }
.ops-trend-line.video-series { stroke: var(--muted); stroke-dasharray: 4 3; }
.ops-trend-empty { margin: .7rem 0; color: var(--muted); }
.ops-daily { border-top: 1px solid var(--line); margin-top: .85rem; }
.ops-daily summary { cursor: pointer; width: max-content; max-width: 100%; margin: .55rem 0 .12rem; color: var(--accent); font-size: .875rem; font-weight: 650; }
.ops-daily > .table-scroll { margin-top: .65rem; }
.ops-breakdowns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; align-items: start; }
.ops-stage-list { list-style: none; padding: .25rem .9rem; margin: 0; }
.ops-stage-list li { display: grid; grid-template-columns: minmax(5.5rem, 8rem) minmax(3.5rem, 1fr) minmax(2ch, max-content); gap: .5rem; align-items: center; padding: .58rem 0; font-variant-numeric: tabular-nums; font-size: .875rem; }
.ops-stage-list li + li { border-top: 1px solid var(--line); }
.ops-stage-list meter { width: 100%; min-width: 0; height: .65rem; accent-color: var(--accent); }
.ops-stage-list meter::-webkit-meter-bar { background: var(--row-hover); border: 0; border-radius: .2rem; }
.ops-stage-list meter::-webkit-meter-optimum-value { background: var(--accent); border-radius: .2rem; }
.ops-stage-list meter::-moz-meter-bar { background: var(--accent); }
.ops-stage-list li > span { text-align: end; }
.ops-privacy-table td { font-variant-numeric: tabular-nums; }
.ops-breakdowns .empty-state { min-height: 4rem; }
@media (max-width: 57rem) {
    .ops-breakdowns { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 24rem) {
    .ops-axis-x time:nth-child(2) { display: none; }
}
.panel { min-width: 0; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); }
.panel-heading { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .6rem; padding: .76rem .9rem; border-bottom: 1px solid var(--line); }
.panel-heading p { margin-top: .2rem; font-size: .875rem; }
.text-link { font-weight: 620; font-size: .875rem; text-decoration: none; }
.text-link:hover { text-decoration: underline; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: .875rem; }
th { color: var(--muted); background: #f7f9f7; white-space: nowrap; font-weight: 630; }
th, td { padding: .6rem .72rem; border-bottom: 1px solid var(--line); }
th:first-child, td:first-child { padding-inline-start: .9rem; }
tbody tr:hover { background: #fafbf9; }
tbody tr:last-child > td { border-bottom: 0; }
td { overflow-wrap: anywhere; }
td strong { color: var(--ink); }
.nowrap { white-space: nowrap; font-variant-numeric: tabular-nums; }
.cell-subtle { display: block; color: var(--muted); font-size: .8125rem; margin-top: .1rem; }
.badge { display: inline-flex; align-items: center; padding: .1rem .43rem; border-radius: .3rem; background: #eef1ee; color: #405047; font-weight: 620; font-size: .8125rem; white-space: nowrap; }
.badge-positive { color: var(--accent-strong); background: var(--accent-surface); }
.badge-warning { color: #814a18; background: #faf0e3; }
.empty-state { padding: .95rem .9rem 1.05rem; font-size: .9rem; }
.empty-state p { margin-top: .2rem; color: var(--muted); font-size: .875rem; }
.compact-list { margin: 0; list-style: none; padding: 0 .9rem; }
.compact-list li { display: flex; justify-content: space-between; align-items: center; gap: .55rem; padding: .64rem 0; border-bottom: 1px solid var(--line); }
.compact-list li > div { min-width: 0; }
.compact-list li:last-child { border-bottom: 0; }
.compact-list small { color: var(--muted); display: block; font-size: .8125rem; }
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: .65rem; padding: .65rem .9rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .875rem; }

.button { display: inline-flex; justify-content: center; align-items: center; gap: .35rem; min-height: 2.4rem; padding: .4rem .7rem; border: 1px solid transparent; border-radius: var(--radius); font-size: .9rem; font-weight: 650; line-height: 1.35; text-decoration: none; white-space: nowrap; }
.button-primary { background: var(--accent); color: #fff; }
.button-primary:hover { background: var(--accent-strong); }
.button-outline { border-color: #c8d2cc; background: var(--paper); color: var(--ink); }
.button-outline:hover { background: var(--row-hover); }
.button-plain { color: var(--muted); background: transparent; }
.button-small { min-height: 2.15rem; padding: .3rem .52rem; font-size: .875rem; }
.field { display: grid; gap: .27rem; min-width: 0; }
.field label, .filter-form label { font-weight: 630; font-size: .875rem; }
.field input, .field select, .field textarea, .filter-form input, .filter-form select {
    min-height: 2.4rem;
    width: 100%;
    border-radius: var(--radius);
    border: 1px solid #c5d0c9;
    background: var(--paper);
    color: var(--ink);
    padding: .39rem .55rem;
    font-size: .9375rem;
}
.field textarea { min-height: 5rem; resize: vertical; }
.filter-form { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.filter-form input, .filter-form select { min-height: 2.15rem; width: auto; padding-block: .27rem; font-size: .875rem; }
.form-stack { display: grid; gap: .78rem; }
.form-stack .button { justify-self: start; }
.notice { border: 1px solid var(--line); border-left: 3px solid #89978f; border-radius: var(--radius); background: var(--paper); padding: .59rem .75rem; color: var(--ink); margin-bottom: .9rem; line-height: 1.5; overflow-wrap: anywhere; }
.notice-warning { border-left-color: #a96627; background: #fdf8f0; color: #753e16; }
.notice-positive { border-left-color: var(--accent); background: #f3f8f5; color: var(--accent-strong); }

.privacy-layout { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1.65fr) minmax(15rem, 1fr); align-items: start; }
.panel-form { padding: .9rem; }
.account-panel { max-width: 33rem; }
.request-meta { margin: 0; display: flex; flex-wrap: wrap; gap: .5rem 1.4rem; }
.request-meta dt { color: var(--muted); font-size: .875rem; }
.request-meta dd { margin: .1rem 0 0; overflow-wrap: anywhere; }
.request-message { padding: .6rem .7rem; border-radius: var(--radius); background: var(--canvas); white-space: pre-wrap; overflow-wrap: anywhere; }
.case-detail { display: grid; gap: .9rem; }
.case-filters { padding: .7rem .9rem; border-bottom: 1px solid var(--line); }
.case-filters input[type="search"] { width: min(12rem, 100%); }
.case-link { overflow-wrap: anywhere; }
.case-link strong { margin-right: .3rem; }
.case-link span { font-variant-numeric: tabular-nums; }
.case-stage { min-width: 0; margin: 0; border: 1px solid var(--line); border-radius: var(--radius); padding: .66rem; }
.case-stage legend { padding-inline: .3rem; font-weight: 650; }
.case-fields { display: grid; gap: .65rem; grid-template-columns: repeat(auto-fit, minmax(min(13rem, 100%), 1fr)); }
.case-stage .case-fields + .field { margin-top: .7rem; }
.case-hint { margin: .32rem 0 0; color: var(--muted); font-size: .875rem; overflow-wrap: anywhere; }
.case-history { list-style: none; margin: 0; padding: .18rem .9rem .5rem; }
.case-history li { display: grid; gap: .12rem; padding: .56rem 0; border-bottom: 1px solid var(--line); }
.case-history li:last-child { border-bottom: 0; }
.case-history small { font-size: .8125rem; color: var(--muted); }

.login-site-link { display: inline-flex; align-items: center; gap: .4rem; color: var(--muted); font-size: .875rem; text-decoration: none; }
.login-site-link:hover { color: var(--accent); text-decoration: underline; }
.login-layout { width: min(25rem, calc(100% - 2rem)); margin: clamp(1.75rem, 8vh, 5rem) auto; }
.login-card { padding: clamp(1.05rem, 4vw, 1.65rem); }
.login-card h1 { font-size: 1.45rem; }
.login-card .notice { margin: .85rem 0 0; }
.login-card .form-stack { margin-top: 1rem; }
.login-card .form-stack .button { justify-self: stretch; margin-top: .12rem; }

@media (max-width: 63rem) {
    .admin-shell { grid-template-columns: 12rem minmax(0, 1fr); }
    .dashboard-grid, .privacy-layout { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 44rem) {
    .admin-shell { display: block; }
    .sidebar { position: static; min-height: auto; max-height: none; overflow: visible; padding: .7rem .8rem .5rem; border-inline-end: 0; border-bottom: 1px solid var(--line); }
    .sidebar .brand { margin: 0 0 .55rem; }
    .admin-nav { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .nav-link, .sidebar-footer a { min-height: 2.3rem; gap: .42rem; padding: .3rem .42rem; }
    .sidebar-footer { display: flex; flex-wrap: wrap; gap: 0 .45rem; margin-top: .43rem; padding-top: .23rem; }
    .topbar { min-height: 3.2rem; }
    .operator > span { max-width: 8rem; }
    .table-scroll th, .table-scroll td { padding-inline: .56rem; }
}
@media (max-width: 33rem) {
    .admin-nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .admin-location .admin-icon { inline-size: .75rem; }
    .operator > span { max-width: 5.5rem; }
    .metric-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .metric-entry:nth-child(2n + 1) { border-inline-start: 0; }
    .metric-entry:nth-child(n + 3) { border-top: 1px solid var(--line); }
}
