:root {
  color-scheme: light;
  --sidebar-width: 210px;
  --canvas: #d8dad5;
  --surface: #f4f5f1;
  --surface-alt: #eef0eb;
  --surface-strong: #e4e8e2;
  --sidebar: #191e1a;
  --sidebar-hover: #252c27;
  --sidebar-selected: #2a3932;
  --text: #17211c;
  --muted: #667169;
  --quiet: #899189;
  --line: #c9cec7;
  --line-strong: #b7beb7;
  --primary: #39735d;
  --primary-hover: #2d604c;
  --primary-soft: #dcebe4;
  --success: #21845f;
  --success-soft: #e7f4ee;
  --warning: #98631a;
  --warning-soft: #faf0df;
  --danger: #b44848;
  --danger-soft: #faeaea;
  --info: #376bd6;
  --info-soft: #eaf0fc;
  --focus: #5c9589;
  --radius: 7px;
  --z-nav: 30;
  --z-toast: 70;
  --z-popover: 80;
  font-family: "Noto Sans SC", "Microsoft YaHei UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; min-height: 100%; background: var(--canvas); }
body { min-width: 320px; min-height: 100vh; margin: 0; color: var(--text); background: var(--canvas); font-size: 0.875rem; line-height: 1.5; }
button, input, select, textarea { color: inherit; font: inherit; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.48; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
[hidden] { display: none !important; }
svg { display: block; width: 1.125rem; height: 1.125rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.skip-link { position: fixed; top: 0.5rem; left: 0.5rem; z-index: 100; padding: 0.625rem 0.875rem; color: #fff; background: var(--primary); transform: translateY(-140%); }
.skip-link:focus { transform: translateY(0); }

.app-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: var(--z-nav);
  width: var(--sidebar-width);
  padding: 0 0.75rem 0.875rem;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: #eef0f2;
  background: var(--sidebar);
  border-right: 1px solid #101316;
}

.brand {
  min-height: 4rem;
  padding: 0 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.625rem;
  color: inherit;
  text-decoration: none;
}
.brand-mark {
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  flex: 0 0 2rem;
  border-radius: var(--radius);
  color: #fff;
  background: #a9d0be;
  color: #15372a;
  font-size: 0.75rem;
  font-weight: 800;
}
.brand > span:last-child { display: grid; }
.brand strong { font-size: 0.875rem; }
.brand small { color: #969ea6; font-size: 0.6875rem; }

.primary-nav {
  min-height: 0;
  margin-top: 0;
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 0.1875rem;
  overflow-y: auto;
}
.primary-nav a {
  min-height: 2.75rem;
  padding: 0 0.75rem;
  display: grid;
  grid-template-columns: 1.125rem 1fr auto;
  align-items: center;
  gap: 0.625rem;
  border-radius: 6px;
  color: #b2b9c0;
  text-decoration: none;
  font-size: 0.8125rem;
  font-weight: 650;
}
.primary-nav a:hover { color: #fff; background: var(--sidebar-hover); }
.primary-nav a.selected { color: #fff; background: var(--sidebar-selected); }
.primary-nav a.selected svg { color: #85c8b7; }
.primary-nav b { color: #8f98a0; font-size: 0.6875rem; font-variant-numeric: tabular-nums; }
.nav-section-label {
  min-height: 2rem;
  padding: 0.75rem 0.75rem 0;
  display: block;
  color: #667169;
  font-size: 0.625rem;
  font-weight: 750;
}
.nav-section-label.secondary { margin-top: 0.5rem; border-top: 1px solid #303631; }

.service-health {
  margin-top: 0.75rem;
  padding: 0.875rem 0.5rem;
  border-top: 1px solid #34393e;
  border-bottom: 1px solid #34393e;
}
.service-health header { display: flex; align-items: center; gap: 0.5rem; font-size: 0.75rem; }
.live-dot { width: 0.5rem; height: 0.5rem; flex: 0 0 0.5rem; border-radius: 50%; background: #43b889; box-shadow: 0 0 0 3px rgb(67 184 137 / 12%); }
.service-health.is-degraded .live-dot { background: var(--warning); }
.service-health dl { margin: 0.625rem 0 0 1rem; display: grid; gap: 0.375rem; }
.service-health dl div { display: flex; justify-content: space-between; gap: 0.5rem; color: #929aa2; font-size: 0.6875rem; }
.service-health dt, .service-health dd { margin: 0; }
.service-health dd { color: #b9c0c6; text-align: right; }

.operator-profile {
  min-height: 3.25rem;
  padding: 0.625rem 0.5rem 0;
  display: grid;
  grid-template-columns: 2rem 1fr;
  align-items: center;
  gap: 0.625rem;
}
.operator-avatar { width: 2rem; height: 2rem; display: grid; place-items: center; border-radius: 50%; color: #225247; background: #b4ded4; font-size: 0.6875rem; font-weight: 800; }
.operator-profile > span:last-child { display: grid; }
.operator-profile strong { font-size: 0.75rem; }
.operator-profile small { color: #8f979f; font-size: 0.6875rem; }

.app-main { min-height: 100vh; margin-left: var(--sidebar-width); }
.page-header {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 4rem;
  padding: 0.75rem 1.375rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: #1c211d;
  border-bottom: 1px solid var(--line);
}
.page-header .page-heading h1 { color: #f1f4f1; font-size: 0.875rem; }
.page-header .page-heading p { color: #748078; font-size: 0.625rem; }
.page-header .icon-button, .page-header .button.secondary { color: #dce3de; border-color: #424a43; background: #262c27; }
.page-heading { min-width: 0; }
.page-heading h1 { margin: 0; font-size: 1.375rem; line-height: 1.25; letter-spacing: 0; text-wrap: balance; }
.page-heading p { max-width: 70ch; margin: 0.25rem 0 0; overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; font-size: 0.75rem; }
.header-actions { position: relative; display: flex; align-items: center; gap: 0.5rem; }

.button, .icon-button {
  min-height: 2.25rem;
  padding: 0 0.875rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--text);
  background: var(--surface);
  font-size: 0.75rem;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}
.button:hover, .icon-button:hover { background: var(--surface-strong); }
.button.primary { color: #fff; border-color: var(--primary); background: var(--primary); }
.button.primary:hover { border-color: var(--primary-hover); background: var(--primary-hover); }
.button.danger { color: var(--danger); border-color: #e3bbbb; background: #fff; }
.button.quiet { border-color: transparent; background: transparent; }
.icon-button { width: 2.25rem; padding: 0; }

.top-menu {
  width: 13rem;
  margin: 0.375rem 0 0;
  padding: 0.375rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 8px 16px rgb(25 29 33 / 16%);
}
.top-menu:popover-open { position: fixed; inset: 4.25rem 1.5rem auto auto; z-index: var(--z-popover); }
.top-menu button, .top-menu a {
  width: 100%;
  min-height: 2.375rem;
  padding: 0 0.625rem;
  display: flex;
  align-items: center;
  border: 0;
  border-radius: 5px;
  color: var(--text);
  background: transparent;
  text-align: left;
  text-decoration: none;
  font-size: 0.75rem;
}
.top-menu button:hover, .top-menu a:hover { background: var(--surface-strong); }

.app-notice {
  position: fixed;
  top: 5.25rem;
  right: 1.5rem;
  z-index: var(--z-toast);
  max-width: min(32rem, calc(100vw - 2rem));
  padding: 0.75rem 0.875rem;
  border: 1px solid #b9dccc;
  border-radius: var(--radius);
  color: #176649;
  background: var(--success-soft);
  box-shadow: 0 6px 12px rgb(23 25 28 / 12%);
  font-size: 0.8125rem;
}
.app-notice.error { color: #973838; border-color: #e9bcbc; background: var(--danger-soft); }

.workspace-root { width: 100%; }
.shell-health-strip {
  min-height: 2.625rem;
  padding: 0 1.375rem;
  display: flex;
  align-items: center;
  gap: 1.75rem;
  overflow-x: auto;
  color: #aab2ac;
  border-bottom: 1px solid #252b26;
  background: #2a302b;
  font-size: 0.625rem;
  white-space: nowrap;
}
.shell-health-strip b { color: #f4f6f3; font-size: 0.6875rem; font-variant-numeric: tabular-nums; }
.workspace-view { width: 100%; min-height: calc(100vh - 6.625rem); }
.page-skeleton { padding: 1.5rem; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.75rem; }
.page-skeleton span { min-height: 6rem; border-radius: var(--radius); background: linear-gradient(90deg, #e9edef 25%, #f5f7f8 40%, #e9edef 65%); background-size: 300% 100%; animation: skeleton 1.2s ease-in-out infinite; }
.page-skeleton span:last-child { grid-column: 1 / -1; min-height: 24rem; }
@keyframes skeleton { to { background-position: -100% 0; } }

dialog { color: var(--text); }
.app-dialog, .command-dialog {
  width: min(42rem, calc(100vw - 1.5rem));
  max-height: calc(100vh - 1.5rem);
  padding: 0;
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--surface);
  box-shadow: 0 18px 48px rgb(18 21 24 / 24%);
}
.app-dialog::backdrop, .command-dialog::backdrop { background: rgb(17 20 23 / 48%); }
.dialog-form { padding: 1.25rem; display: grid; gap: 0.875rem; }
.dialog-form > header, .command-dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.dialog-form > header span { color: var(--primary); font-size: 0.6875rem; font-weight: 800; }
.dialog-form h2, .command-dialog h2 { margin: 0.125rem 0 0; font-size: 1.125rem; }
.dialog-form > p, .command-dialog-head p { margin: 0; color: var(--muted); font-size: 0.8125rem; }
.dialog-form label { color: var(--muted); font-size: 0.75rem; font-weight: 750; }
.dialog-form textarea {
  min-height: 15rem;
  padding: 0.75rem;
  resize: vertical;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  font: 0.75rem/1.55 Consolas, "SFMono-Regular", monospace;
}
.dialog-form > footer { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.dialog-form > footer span { color: var(--muted); font-size: 0.75rem; }
.dialog-form > footer span.error { color: var(--danger); }
.command-dialog { width: min(54rem, calc(100vw - 1.5rem)); }
.command-dialog.wide { width: min(76rem, calc(100vw - 1.5rem)); }
.command-dialog-head { position: sticky; top: 0; z-index: 2; padding: 1rem 1rem 0.875rem; background: var(--surface); border-bottom: 1px solid var(--line); }
.command-dialog-body { padding: 1rem; }

@media (max-width: 980px) {
  :root { --sidebar-width: 4.25rem; }
  .app-sidebar { padding-inline: 0.625rem; }
  .brand { justify-content: center; padding: 0; }
  .brand > span:last-child, .primary-nav a span, .primary-nav b, .service-health, .operator-profile > span:last-child { display: none; }
  .primary-nav a { grid-template-columns: 1fr; justify-items: center; padding: 0; }
  .operator-profile { grid-template-columns: 1fr; justify-items: center; }
  .page-header { padding-inline: 1rem; }
  .header-rule-link span { display: none; }
}

@media (max-width: 640px) {
  :root { --sidebar-width: 3.75rem; }
  body { padding-bottom: 0; }
  .app-sidebar {
    inset: 0 auto 0 0;
    width: var(--sidebar-width);
    height: 100vh;
    padding: 0.75rem 0.375rem;
    flex-direction: column;
    border-top: 0;
    border-right: 1px solid #101316;
  }
  .brand { min-height: 2.75rem; display: flex; justify-content: center; }
  .brand > span:last-child, .service-health, .operator-profile, .nav-section-label { display: none; }
  .primary-nav { width: 100%; margin: 0.75rem 0 0; flex-direction: column; overflow-y: auto; }
  .primary-nav a { min-width: 0; min-height: 3.25rem; grid-template-columns: 1fr; flex: 0 0 auto; gap: 0; }
  .primary-nav a svg { width: 1.25rem; height: 1.25rem; }
  .primary-nav a span, .primary-nav b { display: none; }
  .app-main { margin-left: var(--sidebar-width); }
  .page-header { position: sticky; min-height: 4rem; padding: 0.625rem 0.75rem; }
  .page-heading h1 { font-size: 1.125rem; }
  .page-heading p, .header-rule-link, #reloadView, #globalMenuButton { display: none; }
  #importAccountsButton { width: 2.5rem; padding: 0; }
  #importAccountsButton span { display: none; }
  .shell-health-strip { scrollbar-width: none; }
  .shell-health-strip::-webkit-scrollbar { display: none; }
  .app-notice { top: 4.5rem; right: 0.75rem; left: 0.75rem; }
  .dialog-form > footer { align-items: stretch; flex-direction: column; }
  .dialog-form > footer .button { align-self: flex-end; }
  .page-skeleton { padding: 0.75rem; grid-template-columns: 1fr 1fr; }
}

@media (pointer: coarse) {
  .button, .icon-button, .primary-nav a, .top-menu button, .top-menu a { min-height: 2.75rem; }
}

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

