@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Outfit:wght@500;600;700&display=swap');

:root {
  color-scheme: light;
  --bg: #f3f5f7;
  --surface: #ffffff;
  --surface-soft: #f7f9fa;
  --ink: #18212b;
  --muted: #6c7885;
  --line: #e2e7eb;
  --primary: #176f62;
  --primary-soft: #e5f2ef;
  --blue: #477ed5;
  --purple: #8067c9;
  --orange: #d19332;
  --red: #c85e68;
  --green: #138a70;
  --gray: #aab2bc;
  --shadow: 0 12px 32px rgba(31, 45, 61, 0.06);
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; color: var(--ink); background: var(--bg); font-family: Inter, "PingFang SC", "Microsoft YaHei", sans-serif; }
button, input, select { font: inherit; }
button, select { cursor: pointer; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
h1 { font: 600 26px/1.3 Outfit, Inter, sans-serif; letter-spacing: -0.02em; }
h2 { font-size: 17px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; }
.muted { color: var(--muted); }
.eyebrow { margin-bottom: 5px; color: var(--primary); font-size: 11px; font-weight: 700; letter-spacing: .12em; }
.error { min-height: 20px; color: var(--red); font-size: 13px; }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 50% 0%, #e7f3f0 0, var(--bg) 45%); }
.login-card { width: min(420px, 100%); padding: 36px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: var(--shadow); }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; margin-bottom: 18px; border-radius: 11px; color: #fff; background: var(--primary); font: 700 13px Outfit, sans-serif; }
.brand-mark.small { width: 31px; height: 31px; margin: 0; border-radius: 8px; font-size: 10px; }
.login-card .muted { margin: 7px 0 26px; }
label { color: var(--muted); font-size: 12px; font-weight: 500; }
input, select { min-height: 39px; padding: 0 11px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: var(--surface); outline: none; }
textarea { padding: 9px 11px; resize: vertical; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: var(--surface); font: inherit; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
input[readonly] { color: var(--muted); background: var(--surface-soft); }
.login-card label { display: grid; gap: 7px; margin: 17px 0; }
button, .button { min-height: 38px; padding: 0 14px; border: 0; border-radius: 8px; color: #fff; background: var(--primary); font-weight: 600; text-decoration: none; }
button:hover, .button:hover { filter: brightness(.97); }
.login-card button { width: 100%; margin-top: 8px; min-height: 46px; }
.login-divider { display: flex; align-items: center; gap: 12px; margin: 22px 0 16px; color: var(--muted); font-size: 11px; }
.login-divider::before, .login-divider::after { content: ''; height: 1px; flex: 1; background: var(--line); }
.feishu-login { min-height: 46px; display: flex; align-items: center; justify-content: center; background: #3370ff; }
.wecom-login { min-height: 46px; display: flex; align-items: center; justify-content: center; background: #07a858; }
.secondary { border: 1px solid var(--line); color: var(--ink); background: var(--surface); }
.ghost { color: var(--muted); background: transparent; }
.text-button { min-height: auto; padding: 0; color: var(--primary); background: transparent; font-size: 12px; }

.workbench { min-height: 100vh; }
.app-header { min-height: 68px; display: flex; align-items: center; gap: 18px; position: sticky; top: 0; z-index: 20; padding: 0 22px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.96); backdrop-filter: blur(12px); }
.app-brand { min-width: 184px; display: flex; align-items: center; gap: 10px; }
.header-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; white-space: nowrap; }
.header-actions .muted { margin-right: 4px; font-size: 11px; }
.header-actions button, .header-actions .button { min-height: 34px; padding: 0 11px; font-size: 12px; }
.app-layout { display: grid; grid-template-columns: 205px minmax(0, 1fr); }
.sidebar { min-height: calc(100vh - 68px); padding: 23px 12px; position: sticky; top: 68px; align-self: start; border-right: 1px solid var(--line); background: var(--surface); }
.sidebar-label { margin: 0 11px 10px; color: #8b95a0; font-size: 10px; letter-spacing: .12em; }
.nav-item { width: 100%; min-height: 43px; display: flex; align-items: center; gap: 10px; margin: 3px 0; padding: 0 11px; color: var(--muted); background: transparent; text-align: left; font-size: 13px; font-weight: 500; }
.nav-item span { width: 18px; text-align: center; font-size: 15px; }
.nav-item.active { color: var(--primary); background: var(--primary-soft); }
.sidebar-state { margin: 28px 10px 0; padding-top: 16px; display: grid; gap: 5px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; line-height: 1.5; }
.sidebar-state strong { color: var(--ink); font-size: 12px; }
.workspace { min-width: 0; padding: 26px; }
.page-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 18px; }
.page-heading .muted { margin-top: 5px; font-size: 13px; }
.date-caption { color: var(--muted); font-size: 12px; }
.date-control { display: flex; align-items: center; gap: 8px; }
.date-control input { min-height: 37px; }
.scope-control { min-width: 190px; display: grid; gap: 5px; text-align: left; }
.scope-control select { width: 100%; }
.heading-controls { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 10px; }
.heading-date-control { min-width: 145px; display: grid; gap: 5px; }
.heading-date-control input { width: 100%; min-height: 39px; }

.summary-strip { display: grid; grid-template-columns: 1.25fr repeat(4, 1fr); gap: 1px; margin-bottom: 13px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--line); }
.summary-strip article { min-width: 0; padding: 16px; background: var(--surface); }
.summary-strip span, .summary-strip small { display: block; color: var(--muted); font-size: 11px; }
.summary-strip strong { display: block; margin: 7px 0 4px; font: 600 21px/1 Outfit, Inter, sans-serif; }
.summary-strip .primary-stat strong { color: var(--primary); font-size: 28px; }
.data-note { min-height: 17px; margin: -3px 1px 11px; color: var(--muted); font-size: 11px; text-align: right; }
.panel { min-width: 0; padding: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 4px 16px rgba(31,45,61,.03); }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; margin-bottom: 17px; }
.panel-heading .muted { margin-top: 4px; font-size: 11px; }
.panel-actions { display: flex; align-items: center; gap: 9px; }
.overview-grid { display: grid; grid-template-columns: 1.35fr .9fr; gap: 13px; }
.trend-panel { grid-row: span 2; }
.task-overview-panel { grid-column: 1 / -1; }
.usage-chart { display: block; width: 100%; min-height: 260px; overflow: visible; }
.usage-chart.large { min-height: 300px; }
.chart-grid { stroke: var(--line); stroke-width: 1; }
.chart-axis-label { fill: var(--muted); font-size: 10px; font-family: Inter, sans-serif; }
.chart-total-label { fill: var(--ink); font-size: 8px; font-weight: 600; font-family: Inter, sans-serif; }
.chart-bar { fill: var(--primary); rx: 4; }
.chart-bar:hover { filter: brightness(1.08); }
.chart-day-link { cursor: pointer; outline: none; }
.chart-day-link rect { transition: filter .15s ease, opacity .15s ease; }
.chart-day-link:hover rect, .chart-day-link:focus rect { filter: brightness(1.12); opacity: .9; }
.chart-day-link:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
.chart-area { fill: rgba(23,111,98,.08); }
.chart-line { fill: none; stroke: var(--primary); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.chart-dot { fill: var(--surface); stroke: var(--primary); stroke-width: 2; }
.chart-message { min-height: 20px; color: var(--muted); font-size: 12px; }
.chart-summary { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 10px; color: var(--muted); font-size: 11px; }
.chart-summary strong { color: var(--ink); }
.bar-list, .ranking, .task-mix, .model-breakdown { display: grid; gap: 13px; }
.rank-row, .bar-row, .task-row { display: grid; align-items: center; gap: 9px; font-size: 12px; }
.rank-row { grid-template-columns: 24px minmax(75px, 1fr) minmax(90px, 1.4fr) 105px; }
.bar-row { grid-template-columns: minmax(75px, 1fr) minmax(90px, 1.4fr) 105px; }
.task-row { grid-template-columns: 10px minmax(90px, 1fr) minmax(90px, 1.5fr) 58px 72px; }
.rank-number { width: 22px; height: 22px; display: grid; place-items: center; border-radius: 6px; color: var(--primary); background: var(--primary-soft); font-size: 10px; }
.rank-name, .bar-name, .legend-name, .model-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-label { min-width: 0; display: flex; align-items: center; gap: 8px; }
.ratio-track { display: block; width: 100%; height: 8px; overflow: hidden; }
.ratio-background { fill: var(--line); }
.value { color: var(--muted); font-variant-numeric: tabular-nums; }
.rank-row > .value, .bar-row > .value, .task-row > span:nth-last-child(-n+2) { text-align: right; }
.pie-layout { display: grid; grid-template-columns: 130px minmax(0, 1fr); align-items: center; gap: 16px; }
.pie-wrap { width: 126px; height: 126px; position: relative; }
.pie-chart { width: 126px; height: 126px; transform: rotate(-90deg); }
.pie-background, .pie-segment { fill: none; stroke-width: 22; }
.pie-background { stroke: var(--line); }
.pie-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; pointer-events: none; }
.pie-center strong { font: 600 18px Outfit, sans-serif; }
.pie-center span { margin-top: 3px; color: var(--muted); font-size: 9px; }
.pie-legend { min-width: 0; display: grid; gap: 9px; }
.legend-row { display: grid; grid-template-columns: 8px minmax(60px, 1fr) auto auto; align-items: center; gap: 8px; font-size: 11px; }
.legend-swatch { width: 10px; height: 10px; flex: 0 0 10px; }
.legend-title { grid-column: 1 / -1; margin-bottom: 2px; color: var(--ink); font-size: 10px; font-weight: 600; }
.empty, .empty-cell { padding: 30px 0; color: var(--muted); text-align: center; }

.terminals-panel, .archived-panel, .detail-panel { margin-top: 13px; }
.compact-button { min-height: 31px; padding: 0 10px; font-size: 11px; }
.status-pill { padding: 5px 9px; border-radius: 99px; color: var(--green); background: #e8f5f1; font-size: 11px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; font-size: 12px; }
th { color: var(--muted); font-size: 10px; font-weight: 600; letter-spacing: .04em; }
.dot { display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: var(--green); }
.dot.offline { background: var(--red); }
.device-link, .rename-device, .archive-device, .restore-device, .delete-device { min-height: auto; padding: 3px 7px; color: var(--primary); background: transparent; font-size: 11px; }
.rename-device { margin-left: 5px; color: var(--muted); }
.delete-device { color: var(--red); }
.device-meta { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; }
.detail-heading { align-items: flex-end; }
.detail-controls { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 9px; }
.detail-controls label, .subpanel-title label { display: grid; gap: 5px; }
.detail-grid { display: grid; grid-template-columns: minmax(280px, .8fr) minmax(440px, 1.2fr); gap: 13px; }
.subpanel { min-width: 0; padding: 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-soft); }
.subpanel-title { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 15px; }
.component-strip { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.component-strip article { min-width: 0; padding: 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.component-strip span, .component-strip small { display: block; color: var(--muted); font-size: 9px; }
.component-strip strong { display: block; margin: 5px 0 3px; font: 600 15px Outfit, sans-serif; }
.component-strip.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 14px; }
.tool-group { display: grid; gap: 8px; }
.tool-heading { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; font-weight: 600; }
.model-row { display: grid; grid-template-columns: minmax(100px, 1fr) minmax(80px, 1fr) auto; align-items: center; gap: 8px; padding-left: 8px; font-size: 11px; }

.period-grid { display: grid; grid-template-columns: 1.35fr .85fr; gap: 13px; }
.period-chart-panel { grid-row: span 3; }
.filter-bar { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 10px; margin-bottom: 13px; padding: 13px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.filter-bar label { display: grid; gap: 5px; }
.quick-ranges { display: flex; flex-wrap: wrap; gap: 5px; }
.quick-ranges button { min-height: 39px; padding: 0 10px; border: 1px solid var(--line); color: var(--muted); background: var(--surface); font-size: 11px; }
.quick-ranges button.active { border-color: #cbe4de; color: var(--primary); background: var(--primary-soft); }
.task-analysis-grid { display: grid; grid-template-columns: minmax(260px, .75fr) minmax(480px, 1.25fr); gap: 13px; }
.unclassified-panel { grid-column: 1 / -1; }
.unclassified-panel .task-row { grid-template-columns: 10px minmax(120px, .7fr) minmax(120px, 1.2fr) minmax(220px, 1fr) 90px; }
.task-legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 9px; color: var(--muted); font-size: 10px; }
.task-legend span { display: flex; align-items: center; gap: 5px; }
.task-legend .legend-title { margin-right: 2px; }
.coverage-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; margin-bottom: 13px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--line); }
.coverage-strip article { padding: 13px 15px; background: var(--surface); }
.coverage-strip span { display: block; color: var(--muted); font-size: 10px; }
.coverage-strip strong { display: block; margin-top: 6px; font: 600 18px Outfit, sans-serif; }
.coverage-note { margin-top: 14px; color: var(--muted); font-size: 11px; line-height: 1.6; }
.privacy-note { margin-top: 11px; color: var(--muted); font-size: 10px; text-align: right; }
.workspace-error { margin-top: 12px; }
.modal-backdrop { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; background: rgba(24,33,43,.42); backdrop-filter: blur(4px); }
.modal-card { width: min(430px, 100%); display: grid; gap: 18px; padding: 24px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: 0 24px 70px rgba(24,33,43,.2); }
.modal-card .muted { margin-top: 5px; font-size: 11px; }
.modal-card label { display: grid; gap: 7px; }
.field-hint { color: var(--muted); font-size: 10px; font-weight: 400; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.settings-card { width: min(620px, 100%); max-height: calc(100vh - 40px); overflow-y: auto; }
.settings-status { padding: 10px 12px; border-radius: 8px; color: var(--muted); background: var(--surface-soft); font-size: 11px; line-height: 1.6; }
.settings-status.verified { color: var(--green); background: #e8f5f1; }
.check-row { display: flex !important; grid-template-columns: auto 1fr; align-items: center; justify-content: flex-start; }
.check-row input { min-height: auto; }
.settings-actions { flex-wrap: wrap; }
body[data-role="viewer"] .rename-device,
body[data-role="viewer"] .archive-device,
body[data-role="viewer"] .restore-device,
body[data-role="viewer"] .delete-device { display: none; }

@media (max-width: 1120px) {
  .header-actions #lastUpdated { display: none; }
  .summary-strip { grid-template-columns: repeat(3, 1fr); }
  .overview-grid, .period-grid { grid-template-columns: 1fr; }
  .trend-panel, .period-chart-panel, .task-overview-panel { grid-column: auto; grid-row: auto; }
  .task-analysis-grid, .detail-grid { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .app-header { flex-wrap: wrap; padding: 11px 14px; gap: 9px; }
  .app-brand { width: 100%; }
  .header-actions { margin-left: auto; }
  .app-layout { grid-template-columns: 1fr; }
  .sidebar { min-height: 0; display: flex; gap: 4px; overflow-x: auto; position: static; padding: 8px; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar-label, .sidebar-state { display: none; }
  .nav-item { width: auto; min-width: max-content; margin: 0; }
  .workspace { padding: 16px; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .scope-control, .heading-controls { width: 100%; }
  .heading-controls .scope-control { flex: 1 1 190px; }
  .heading-date-control { flex: 1 1 145px; }
}
@media (max-width: 560px) {
  .header-actions .button, .header-actions .secondary { display: none; }
  .summary-strip { grid-template-columns: repeat(2, 1fr); }
  .summary-strip .primary-stat { grid-column: span 2; }
  .pie-layout { grid-template-columns: 1fr; justify-items: center; }
  .pie-legend { width: 100%; }
  .component-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .coverage-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rank-row { grid-template-columns: 24px minmax(72px, 1fr) minmax(82px, 1.2fr) 94px; }
  .bar-row { grid-template-columns: minmax(72px, 1fr) minmax(82px, 1.2fr) 94px; }
  .task-row { grid-template-columns: 10px minmax(76px, 1fr) minmax(74px, 1fr) 52px 64px; }
  .unclassified-panel .task-row { grid-template-columns: 10px minmax(105px, 1fr) minmax(90px, 1fr) 82px; }
  .unclassified-panel .task-row > span:nth-last-child(2) { grid-column: 2 / -1; grid-row: 2; text-align: left; }
}
