:root {
  color-scheme: light;
  --canvas: #edf1ee;
  --surface: #f8faf8;
  --surface-strong: #ffffff;
  --ink: #18211e;
  --muted: #66726d;
  --faint: #909b96;
  --line: #d4ddd8;
  --line-strong: #bbc8c1;
  --jade: #2e6c60;
  --jade-soft: #dcebe6;
  --blue: #567a8b;
  --coral: #bd684c;
  --coral-soft: #f3e2dc;
  --amber: #a8792d;
  --danger: #a7423b;
  --danger-soft: #f4dfdc;
  --sidebar: #1b2522;
  --sidebar-muted: #9eaaa5;
  --radius: 6px;
  --shadow: 0 18px 50px rgba(27, 48, 40, 0.08);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--canvas); }
body { margin: 0; min-height: 100vh; color: var(--ink); background: var(--canvas); font-size: 14px; letter-spacing: 0; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button, select { min-height: 44px; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.5; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(46, 108, 96, 0.28); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.eyebrow { margin: 0 0 7px; color: var(--jade); font-size: 11px; font-weight: 750; letter-spacing: 0.12em; text-transform: uppercase; }
.muted { color: var(--muted); }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 32px 20px; background: linear-gradient(115deg, #e7eeea 0 48%, #f5f7f5 48% 100%); }
.login-panel { width: min(420px, 100%); padding: 40px; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(255,255,255,0.82); box-shadow: var(--shadow); backdrop-filter: blur(18px); }
.brand-mark { display: grid; place-items: center; width: 52px; height: 52px; margin-bottom: 26px; border: 1px solid var(--line-strong); border-radius: 50%; color: var(--jade); background: var(--surface-strong); font-family: "STKaiti", "Kaiti SC", serif; font-size: 29px; }
.brand-mark.small { width: 40px; height: 40px; margin: 0; border-color: #4a5b55; color: #dbe8e3; background: transparent; font-size: 23px; }
.login-panel h1 { margin: 0; font-size: 30px; line-height: 1.2; }
.login-copy { margin: 10px 0 30px; color: var(--muted); line-height: 1.7; }
.login-panel form { display: grid; gap: 9px; }
.login-panel label { margin-top: 7px; color: var(--muted); font-weight: 650; }
input, select, textarea { width: 100%; border: 1px solid var(--line-strong); border-radius: 4px; color: var(--ink); background: var(--surface-strong); }
input, select { height: 44px; padding: 0 13px; }
textarea { padding: 12px 13px; resize: vertical; line-height: 1.6; }
.login-panel .primary-button { margin-top: 15px; width: 100%; }
.form-message { min-height: 20px; margin: 14px 0 0; color: var(--danger); }
.security-note { margin: 24px 0 0; padding-top: 18px; border-top: 1px solid var(--line); color: var(--faint); font-size: 12px; line-height: 1.7; }

.primary-button, .secondary-button, .danger-button, .text-button, .icon-button { border-radius: 4px; font-weight: 700; }
.primary-button { padding: 0 18px; border: 1px solid var(--jade); color: white; background: var(--jade); }
.primary-button:hover { background: #245c51; }
.secondary-button { padding: 0 16px; border: 1px solid var(--line-strong); color: var(--ink); background: var(--surface-strong); }
.secondary-button:hover { border-color: var(--jade); color: var(--jade); }
.danger-button { padding: 0 16px; border: 1px solid var(--danger); color: var(--danger); background: var(--danger-soft); }
.danger-button:hover { color: white; background: var(--danger); }
.text-button { min-height: 44px; padding: 0; border: 0; color: #c2d0ca; background: transparent; text-align: left; }
.icon-button { width: 44px; height: 44px; padding: 0; border: 1px solid var(--line); color: var(--muted); background: transparent; font-size: 25px; line-height: 1; }

.admin-shell { min-height: 100vh; display: grid; grid-template-columns: 232px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 26px 18px 20px; color: #f0f4f2; background: var(--sidebar); }
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 26px; border-bottom: 1px solid #34423d; }
.sidebar-brand strong, .sidebar-brand span { display: block; }
.sidebar-brand strong { font-size: 17px; }
.sidebar-brand span { margin-top: 4px; color: var(--sidebar-muted); font-size: 11px; }
.sidebar-nav { display: grid; gap: 4px; margin-top: 24px; }
.nav-item { width: 100%; padding: 0 13px; border: 1px solid transparent; border-radius: 4px; color: #b8c3bf; background: transparent; font-weight: 650; text-align: left; }
.nav-item:hover { color: white; background: #25322e; }
.nav-item.active { border-color: #44564f; color: white; background: #2c3a35; }
.nav-count { float: right; min-width: 22px; height: 22px; padding: 2px 6px; border-radius: 11px; color: white; background: var(--coral); text-align: center; }
.sidebar-account { margin-top: auto; padding: 18px 9px 0; border-top: 1px solid #34423d; }
.sidebar-account span, .sidebar-account small { display: block; overflow: hidden; text-overflow: ellipsis; }
.sidebar-account small { margin-top: 5px; color: var(--sidebar-muted); }

.workspace { min-width: 0; padding: 0 34px 60px; }
.workspace-header { position: sticky; z-index: 5; top: 0; display: flex; align-items: center; justify-content: space-between; min-height: 112px; padding: 22px 0 18px; border-bottom: 1px solid var(--line); background: rgba(237, 241, 238, 0.9); backdrop-filter: blur(14px); }
.workspace-header h1 { margin: 0; font-size: 27px; line-height: 1.2; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.segmented { display: flex; padding: 3px; border: 1px solid var(--line-strong); border-radius: 5px; background: rgba(255,255,255,0.5); }
.segmented button { min-height: 36px; padding: 0 14px; border: 0; border-radius: 3px; color: var(--muted); background: transparent; }
.segmented button.active { color: var(--ink); background: white; box-shadow: 0 1px 4px rgba(20,36,30,0.08); }
.view { padding-top: 24px; }

.status-ribbon { min-height: 50px; display: flex; align-items: center; gap: 10px; padding: 0 16px; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(255,255,255,0.55); }
.status-ribbon > span:not(.status-dot) { color: var(--muted); }
.status-ribbon time { margin-left: auto; color: var(--faint); font-variant-numeric: tabular-nums; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--faint); }
.status-dot.ok { background: var(--jade); box-shadow: 0 0 0 5px rgba(46,108,96,0.12); }
.status-dot.warning { background: var(--amber); box-shadow: 0 0 0 5px rgba(168,121,45,0.12); }
.status-dot.error { background: var(--danger); box-shadow: 0 0 0 5px rgba(167,66,59,0.12); }
.status-dot.checking { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }

.metric-band { display: grid; grid-template-columns: repeat(6, minmax(120px, 1fr)); margin-top: 20px; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: rgba(255,255,255,0.58); }
.metric-band article { min-height: 126px; padding: 20px; border-right: 1px solid var(--line); }
.metric-band article:last-child { border-right: 0; }
.metric-band span, .metric-band small { display: block; color: var(--muted); }
.metric-band strong { display: block; margin: 12px 0 8px; font-size: 29px; font-weight: 650; font-variant-numeric: tabular-nums; }
.metric-band strong.attention { color: var(--coral); }
.metric-band small { font-size: 11px; }

.overview-grid { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(260px, 0.8fr); gap: 20px; margin-top: 20px; }
.data-section { border: 1px solid var(--line); border-radius: var(--radius); background: rgba(255,255,255,0.58); }
.section-heading { min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.section-heading h2, .section-toolbar h2 { margin: 0; font-size: 18px; }
.section-heading > p, .section-toolbar > p { margin: 0; color: var(--muted); }
.legend { display: flex; gap: 15px; color: var(--muted); font-size: 12px; }
.legend span::before { content: ""; display: inline-block; width: 14px; height: 2px; margin: 0 7px 3px 0; background: currentColor; }
.legend .letters { color: var(--jade); }
.legend .replies { color: var(--coral); }
.trend-chart { display: block; width: 100%; height: 270px; padding: 15px 10px 4px; overflow: visible; }
.trend-grid { stroke: #dbe2de; stroke-width: 1; }
.trend-label { fill: var(--faint); font-size: 11px; }
.trend-line { fill: none; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.trend-line.letters { stroke: var(--jade); }
.trend-line.replies { stroke: var(--coral); }
.trend-point { stroke: white; stroke-width: 2; }
.trend-point.letters { fill: var(--jade); }
.trend-point.replies { fill: var(--coral); }
.category-list { display: grid; gap: 17px; padding: 22px 20px 25px; }
.category-row { display: grid; grid-template-columns: 58px 1fr 30px; align-items: center; gap: 10px; }
.category-row span:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.category-track { height: 7px; border-radius: 4px; background: #dce3df; overflow: hidden; }
.category-fill { height: 100%; border-radius: inherit; background: var(--blue); }
.category-row:nth-child(1) .category-fill { background: var(--coral); }
.category-row:nth-child(2) .category-fill { background: var(--jade); }
.activity-section { margin-top: 20px; }
.activity-list { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 0; padding: 0; list-style: none; }
.activity-list li { min-height: 88px; padding: 18px 20px; border-right: 1px solid var(--line); }
.activity-list li:nth-child(4n) { border-right: 0; }
.activity-list li:nth-child(n+5) { border-top: 1px solid var(--line); }
.activity-list strong, .activity-list time { display: block; }
.activity-list time { margin-top: 9px; color: var(--faint); font-size: 11px; }

.section-toolbar { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 16px; }
.section-toolbar label { display: flex; align-items: center; gap: 9px; color: var(--muted); }
.section-toolbar select { width: 140px; }
.content-filters { display: flex; gap: 8px; }
.content-filters input { width: 240px; }
.content-filters select { width: 132px; }
.privacy-boundary { margin: 0 0 14px; padding: 12px 14px; border-left: 3px solid var(--jade); color: var(--muted); background: rgba(220,235,230,0.55); }
.table-wrap { border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; background: rgba(255,255,255,0.62); }
table { width: 100%; border-collapse: collapse; min-width: 820px; }
th, td { padding: 14px 16px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { height: 48px; color: var(--muted); background: rgba(226,233,229,0.45); font-size: 11px; font-weight: 750; }
td { line-height: 1.5; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(255,255,255,0.72); }
.table-link { min-height: 44px; padding: 0; border: 0; color: var(--jade); background: transparent; font-weight: 750; text-decoration: underline; text-decoration-color: transparent; text-underline-offset: 3px; }
.table-link:hover { text-decoration-color: currentColor; }
.content-excerpt { max-width: 520px; overflow-wrap: anywhere; }
.content-excerpt small { display: block; margin-top: 4px; color: var(--faint); }
.status-pill { display: inline-flex; align-items: center; min-height: 28px; padding: 2px 9px; border-radius: 14px; color: var(--muted); background: #e6ece8; font-size: 11px; font-weight: 750; }
.status-pill.open { color: var(--coral); background: var(--coral-soft); }
.status-pill.reviewing { color: var(--amber); background: #f3ead8; }
.status-pill.resolved { color: var(--jade); background: var(--jade-soft); }
.status-pill.dismissed { color: var(--muted); }
.sla-breached { color: var(--danger); font-weight: 750; }
.empty-state { margin: 0; padding: 60px 20px; color: var(--muted); text-align: center; }

.service-list { border-top: 1px solid var(--line); }
.service-list article { min-height: 84px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 15px 4px; border-bottom: 1px solid var(--line); }
.service-list strong, .service-list span { display: block; }
.service-list div > span { margin-top: 6px; color: var(--muted); }
.health-badge { min-width: 74px; min-height: 32px; display: inline-flex; align-items: center; justify-content: center; padding: 4px 11px; border-radius: 16px; font-size: 11px; font-weight: 750; }
.health-badge.ok { color: var(--jade); background: var(--jade-soft); }
.health-badge.warning { color: var(--amber); background: #f3ead8; }
.health-badge.error { color: var(--danger); background: var(--danger-soft); }
.health-badge.neutral, .health-badge.checking { color: var(--muted); background: #e2e8e4; }

dialog { max-width: none; padding: 0; border: 0; color: var(--ink); background: transparent; }
dialog::backdrop { background: rgba(18,28,24,0.56); backdrop-filter: blur(3px); }
.report-dialog { width: min(760px, calc(100vw - 32px)); }
.confirm-dialog { width: min(480px, calc(100vw - 32px)); }
.dialog-frame { margin: 0; padding: 26px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 26px 80px rgba(12,24,19,0.28); }
.dialog-frame.compact { padding: 26px; }
.dialog-frame > header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding-bottom: 17px; border-bottom: 1px solid var(--line); }
.dialog-frame h2, .dialog-frame h3 { margin: 0; }
.dialog-frame h2 { font-size: 21px; }
.dialog-frame h3 { font-size: 14px; }
.dialog-frame.compact > p { color: var(--muted); line-height: 1.7; }
.report-meta { display: grid; grid-template-columns: repeat(3, 1fr); margin: 18px 0; border: 1px solid var(--line); }
.report-meta div { padding: 13px; border-right: 1px solid var(--line); }
.report-meta div:nth-child(3n) { border-right: 0; }
.report-meta div:nth-child(n+4) { border-top: 1px solid var(--line); }
.report-meta dt { color: var(--faint); font-size: 11px; }
.report-meta dd { margin: 5px 0 0; overflow-wrap: anywhere; }
.snapshot-section { margin-bottom: 18px; }
.snapshot-section > p { margin: 6px 0 12px; color: var(--muted); font-size: 12px; }
.snapshot-section pre { max-height: 240px; margin: 0; padding: 16px; overflow: auto; border-left: 3px solid var(--coral); color: var(--ink); background: white; font-family: inherit; line-height: 1.75; white-space: pre-wrap; overflow-wrap: anywhere; }
.dialog-frame > label { display: block; margin: 0 0 8px; color: var(--muted); font-weight: 700; }
.dialog-actions { display: flex; align-items: center; gap: 8px; margin-top: 18px; }
.action-spacer { flex: 1; }
.toast { position: fixed; z-index: 20; right: 24px; bottom: 24px; max-width: 380px; padding: 14px 17px; border: 1px solid #50615b; border-radius: 4px; color: white; background: #26332e; box-shadow: var(--shadow); }

@media (max-width: 1080px) {
  .metric-band { grid-template-columns: repeat(3, 1fr); }
  .metric-band article:nth-child(3) { border-right: 0; }
  .metric-band article:nth-child(n+4) { border-top: 1px solid var(--line); }
  .overview-grid { grid-template-columns: 1fr; }
  .activity-list { grid-template-columns: repeat(2, 1fr); }
  .activity-list li:nth-child(2n) { border-right: 0; }
  .activity-list li:nth-child(n+3) { border-top: 1px solid var(--line); }
}

@media (max-width: 760px) {
  .admin-shell { width: 100%; grid-template-columns: minmax(0, 1fr); overflow-x: hidden; }
  .sidebar { position: static; width: 100%; min-width: 0; height: auto; padding: 16px; overflow: hidden; }
  .sidebar-brand { padding-bottom: 14px; }
  .sidebar-nav { width: 100%; min-width: 0; grid-template-columns: repeat(5, minmax(92px, 1fr)); margin-top: 12px; overflow-x: auto; overscroll-behavior-x: contain; }
  .sidebar-account { display: none; }
  .workspace { width: 100%; min-width: 0; padding: 0 16px 44px; }
  .workspace-header { min-height: 126px; align-items: flex-start; flex-direction: column; justify-content: center; gap: 13px; }
  .header-actions { width: 100%; align-items: center; flex-direction: row; justify-content: space-between; }
  .metric-band { grid-template-columns: repeat(2, 1fr); }
  .metric-band article:nth-child(2n) { border-right: 0; }
  .metric-band article:nth-child(3) { border-right: 1px solid var(--line); }
  .metric-band article:nth-child(n+3) { border-top: 1px solid var(--line); }
  .activity-list { grid-template-columns: 1fr; }
  .activity-list li { border-right: 0; border-top: 1px solid var(--line); }
  .activity-list li:first-child { border-top: 0; }
  .section-toolbar { align-items: flex-start; flex-direction: column; }
  .content-filters { width: 100%; flex-wrap: wrap; }
  .content-filters input { flex: 1 1 100%; width: 100%; }
  .dialog-actions { align-items: stretch; flex-direction: column; }
  .action-spacer { display: none; }
  .report-meta { grid-template-columns: repeat(2, 1fr); }
  .report-meta div:nth-child(3n) { border-right: 1px solid var(--line); }
  .report-meta div:nth-child(2n) { border-right: 0; }
  .report-meta div:nth-child(n+3) { border-top: 1px solid var(--line); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
