:root,
html[data-theme="night"] {
  color-scheme: dark;
  --bg: #070b11;
  --bg-grid: rgba(255,255,255,.012);
  --surface-0: #0a0f17;
  --surface-1: #0e151f;
  --surface-2: #101925;
  --surface-3: #0d1722;
  --surface-4: #0f1824;
  --surface-5: #121d2a;
  --surface-hover: #162233;
  --sidebar-bg: #080d14;
  --stroke: #223044;
  --stroke-soft: #182536;
  --stroke-mid: #1c2d40;
  --stroke-strong: #2b3c51;
  --stroke-hover: #3d5873;
  --text: #e7edf5;
  --text-strong: #f2f6fb;
  --text-soft: #a9b5c5;
  --muted: #6f8096;
  --muted-2: #536378;
  --muted-3: #45566c;
  --accent: #23b7d9;
  --accent-strong: #1aa4c2;
  --accent-deep: #168eaa;
  --accent-text: #8edff0;
  --accent-ink: #d7f6ff;
  --accent-soft: rgba(35, 183, 217, .12);
  --accent-border: rgba(35, 183, 217, .35);
  --blue: #4c8dff;
  --green: #31c48d;
  --green-text: #6fd7b1;
  --green-soft: rgba(49,196,141,.1);
  --amber: #f4b740;
  --amber-text: #ffd071;
  --red: #ef6262;
  --red-text: #ff9999;
  --purple: #a884ff;
  --cyan-soft: #76d2e6;
  --info: #7dd3fc;
  --gold: #fcd34d;
  --btn-fg: #f2fdff;
  --btn-secondary-bg: #141f2d;
  --btn-secondary-fg: #b8c4d2;
  --input-bg: #101925;
  --input-fg: #dce5f0;
  --placeholder: #526277;
  --scrollbar: #27364a;
  --scrollbar-hover: #34465e;
  --link: #77d6ea;
  --nav: #8291a5;
  --nav-hover: #cbd5e1;
  --nav-active: #dff9ff;
  --caption: #526277;
  --brand: #f4f8fc;
  --map-void: #05090e;
  --map-canvas: #070c12;
  --map-rail: rgba(8,13,20,.98);
  --map-rail-end: rgba(5,9,14,.96);
  --map-image-opacity: .76;
  --map-image-filter: saturate(.72) contrast(1.08);
  --selection-bg: rgba(35,183,217,.28);
  --selection-fg: #fff;
  --badge-bg: #1b2736;
  --badge-fg: #c2ccda;
  --chip-line: #314259;
  --live-dot-ring: rgba(49,196,141,.1);
  --sidebar: 272px;
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --transition: 160ms ease;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Microsoft YaHei UI", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 14px;
}

html[data-theme="day"] {
  color-scheme: light;
  --bg: #dce5ee;
  --bg-grid: rgba(18,36,52,.05);
  --surface-0: #e8eef4;
  --surface-1: #f6f9fc;
  --surface-2: #ffffff;
  --surface-3: #eef3f8;
  --surface-4: #ffffff;
  --surface-5: #e4edf5;
  --surface-hover: #d9e6f0;
  --sidebar-bg: #f3f7fb;
  --stroke: #c2d0dc;
  --stroke-soft: #d4dee8;
  --stroke-mid: #c7d4e0;
  --stroke-strong: #9aafc0;
  --stroke-hover: #7d94a8;
  --text: #1a2734;
  --text-strong: #10202d;
  --text-soft: #3a4e61;
  --muted: #5a6e82;
  --muted-2: #6d8296;
  --muted-3: #7b8fa2;
  --accent: #0d7f99;
  --accent-strong: #0b738b;
  --accent-deep: #0a6a80;
  --accent-text: #0b6f86;
  --accent-ink: #083f4d;
  --accent-soft: rgba(13, 127, 153, .1);
  --accent-border: rgba(13, 127, 153, .38);
  --blue: #2b6fdb;
  --green: #1a9a6c;
  --green-text: #147a56;
  --green-soft: rgba(26,154,108,.12);
  --amber: #c48412;
  --amber-text: #9a680c;
  --red: #d14b4b;
  --red-text: #b13636;
  --purple: #6d4ec4;
  --cyan-soft: #0d7f99;
  --info: #0b73a8;
  --gold: #a87810;
  --btn-fg: #f4fcff;
  --btn-secondary-bg: #ffffff;
  --btn-secondary-fg: #2c3f52;
  --input-bg: #ffffff;
  --input-fg: #1a2734;
  --placeholder: #7b8fa2;
  --scrollbar: #b7c6d4;
  --scrollbar-hover: #93a8ba;
  --link: #0b738b;
  --nav: #4a6074;
  --nav-hover: #1a2734;
  --nav-active: #083f4d;
  --caption: #6d8296;
  --brand: #10202d;
  --map-void: #1b2632;
  --map-canvas: #15202b;
  --map-rail: rgba(246,249,252,.97);
  --map-rail-end: rgba(232,238,244,.97);
  --map-image-opacity: .9;
  --map-image-filter: saturate(.88) contrast(1.04);
  --selection-bg: rgba(13,127,153,.2);
  --selection-fg: #10202d;
  --badge-bg: #e6eef4;
  --badge-fg: #2c3f52;
  --chip-line: #9aafc0;
  --live-dot-ring: rgba(26,154,108,.16);
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--bg); }

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(var(--bg-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px),
    var(--bg);
  background-size: 32px 32px;
  color: var(--text);
}

body.moss-shell { padding-left: var(--sidebar); }

::selection { background: var(--selection-bg); color: var(--selection-fg); }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-hover); }

a { color: var(--link); }

.moss-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 100;
  width: var(--sidebar);
  display: flex;
  flex-direction: column;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--stroke);
}

.moss-brand {
  height: 88px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 22px;
  border-bottom: 1px solid var(--stroke-soft);
}

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-items: end;
  gap: 3px;
  padding: 7px;
  border: 1px solid rgba(35,183,217,.45);
  border-radius: 8px;
  background: var(--accent-soft);
}

.brand-mark i { display: block; background: var(--accent); border-radius: 1px; }
.brand-mark i:nth-child(1) { height: 8px; opacity: .6; }
.brand-mark i:nth-child(2) { height: 18px; }
.brand-mark i:nth-child(3) { height: 12px; opacity: .8; }
.brand-copy { display: flex; flex-direction: column; line-height: 1; }
.brand-copy strong { font-size: 22px; letter-spacing: .16em; color: var(--brand); }
.brand-copy small { margin-top: 7px; color: var(--muted); font: 10px/1 Consolas, monospace; letter-spacing: .12em; }

.moss-nav {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
}

.nav-caption {
  padding: 16px 12px 8px;
  color: var(--caption);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .14em;
}

.moss-nav a {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 50px;
  margin: 3px 0;
  padding: 0 14px;
  border-radius: 8px;
  color: var(--nav);
  text-decoration: none;
  transition: color var(--transition), background var(--transition);
}

.moss-nav a svg { width: 20px; height: 20px; fill: currentColor; flex: 0 0 auto; }
.moss-nav a:hover { color: var(--nav-hover); background: var(--accent-soft); }
.moss-nav a.active { color: var(--nav-active); background: var(--accent-soft); }
.moss-nav a.active::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 9px;
  bottom: 9px;
  width: 2px;
  background: var(--accent);
}

.moss-sidebar-foot {
  min-height: 96px;
  padding: 14px 16px 16px;
  border-top: 1px solid var(--stroke-soft);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.moss-sidebar-foot small { color: var(--caption); font: 11px Consolas, monospace; }
.service-indicator { color: var(--text-soft); font-size: 12px; }
.service-indicator i {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(49,196,141,.1);
}
.service-indicator.offline { color: var(--red-text); }
.service-indicator.offline i { background: var(--red); box-shadow: 0 0 0 3px rgba(239,98,98,.1); }

.moss-menu-toggle, .moss-nav-backdrop { display: none; }

.wrap {
  width: 100%;
  max-width: 1920px;
  margin: 0 auto;
  padding: 22px 26px 36px;
}

.topbar {
  min-height: 54px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.title {
  color: var(--text-strong);
  font-size: 22px;
  line-height: 1.25;
  font-weight: 650;
  letter-spacing: -.02em;
}

.sub {
  color: var(--muted);
  margin-top: 5px;
  font-size: 12px;
  line-height: 1.55;
}

.actions {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
}

.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.card {
  background: var(--surface-1);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  padding: 15px;
}

.card h2, .card h3 { color: var(--text); font-weight: 600; }
.metric { margin-top: 8px; color: var(--text-strong); font: 650 28px/1.1 Consolas, monospace; }
.label { color: var(--muted); font-size: 12px; }

table { width: 100%; border-collapse: collapse; }
th, td {
  text-align: left;
  padding: 9px 10px;
  border-bottom: 1px solid var(--stroke-soft);
  vertical-align: middle;
}
th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
}
tbody tr { transition: background var(--transition); }
tbody tr:hover { background: rgba(35,183,217,.025); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border: 1px solid var(--stroke-strong);
  border-radius: 999px;
  background: var(--badge-bg);
  color: var(--badge-fg);
  font-size: 11px;
  line-height: 1.2;
}
.badge.ok { background: var(--green-soft); border-color: color-mix(in srgb, var(--green) 30%, transparent); color: var(--green-text); }
.badge.bad { background: color-mix(in srgb, var(--red) 12%, transparent); border-color: color-mix(in srgb, var(--red) 32%, transparent); color: var(--red-text); }
.badge.run { background: var(--accent-soft); border-color: var(--accent-border); color: var(--accent-text); }
.badge.muted { background: var(--surface-3); border-color: var(--stroke-mid); color: var(--muted); }

button, .btn, input, select, textarea {
  min-height: 32px;
  border: 1px solid var(--stroke-strong);
  border-radius: var(--radius-sm);
  outline: none;
  background: var(--input-bg);
  color: var(--input-fg);
  padding: 6px 10px;
  font: inherit;
  font-size: 12px;
  transition: border-color var(--transition), background var(--transition), color var(--transition), transform 100ms ease;
}

input::placeholder, textarea::placeholder { color: var(--placeholder); }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  background: var(--accent-deep);
  border-color: var(--accent);
  color: var(--btn-fg);
  text-decoration: none;
  font-weight: 550;
}
button:hover, .btn:hover { background: var(--accent-strong); border-color: var(--accent); }
button:active, .btn:active { transform: translateY(1px); }
.btn.secondary, button.secondary { background: var(--btn-secondary-bg); border-color: var(--stroke-strong); color: var(--btn-secondary-fg); }
.btn.secondary:hover, button.secondary:hover { background: var(--surface-5); color: var(--text-strong); }
.btn.danger, button.danger { background: color-mix(in srgb, var(--red) 12%, transparent); border-color: color-mix(in srgb, var(--red) 42%, transparent); color: var(--red-text); }
.btn.danger:hover, button.danger:hover { background: rgba(239,98,98,.2); }
button:disabled, .btn.disabled { opacity: .45; cursor: not-allowed; }

.formline {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.error, .notice.bad {
  background: color-mix(in srgb, var(--red) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--red) 28%, transparent);
  color: var(--red-text);
  padding: 11px 13px;
  border-radius: var(--radius);
  margin-bottom: 14px;
}

.notice {
  background: var(--green-soft);
  border: 1px solid color-mix(in srgb, var(--green) 25%, transparent);
  color: var(--green-text);
}

code, pre, .mono { font-family: Consolas, "SFMono-Regular", monospace; }

@keyframes moss-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .45; }
}

@keyframes moss-enter {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.wrap > * { animation: moss-enter 220ms ease both; }

@media (max-width: 1250px) {
  :root { --sidebar: 240px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
  :root { --sidebar: 224px; }
  body.moss-shell { padding-left: 0; }
  .moss-sidebar { transform: translateX(-100%); transition: transform 200ms ease; }
  body.nav-open .moss-sidebar { transform: translateX(0); }
  .moss-nav-backdrop {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: block;
    pointer-events: none;
    opacity: 0;
    background: rgba(2,6,12,.72);
    transition: opacity 200ms ease;
  }
  body.nav-open .moss-nav-backdrop { pointer-events: auto; opacity: 1; }
  .moss-menu-toggle {
    position: fixed;
    right: 14px;
    top: 14px;
    z-index: 80;
    width: 36px;
    height: 34px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 9px;
    background: var(--surface-5);
    border-color: var(--stroke-strong);
  }
  .moss-menu-toggle span { display: block; width: 16px; height: 1px; background: var(--text-soft); }
  .wrap { padding: 16px 14px 28px; }
  .topbar { padding-right: 42px; flex-direction: column; }
  .actions { justify-content: flex-start; }
  .grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* 阅读增强：中控需要长时间观察，避免高密度信息字号过小 */
body { font-size: 16px; }
.moss-nav a { font-size: 17px; font-weight: 600; }
.nav-caption { font-size: 14px; }
.moss-sidebar-foot small,
.service-indicator { font-size: 14px; }
.title { font-size: 26px; }
.sub, .label { font-size: 14px; }
button, .btn, input, select, textarea {
  min-height: 36px;
  font-size: 14px;
}
button, .btn { white-space: nowrap; }
th { font-size: 13px; }
td { font-size: 14px; }

body .eyebrow,
body .panel-tools,
body .alert-heading,
body .health-item span,
body .side-panel label,
body .settings-summary h3,
body .flow-head span { font-size: 12px !important; }

body .panel-title,
body .lane-title,
body .device-name,
body .group-name,
body .card-state,
body .alert-item strong,
body .health-item strong,
body .device-item,
body .setting-row label,
body .flow-head strong,
body .flow-step strong,
body .col-head .title,
body .resource-toolbar strong,
body .settings-section-head strong { font-size: 15px !important; }

body .member-main,
body .detail-v,
body .alert-item span,
body .settings-section-head strong { font-size: 13px !important; }

body .log-row,
body .raw-log-view { font-size: 12px !important; }

body .card-meta,
body .card-error,
body .member-sub,
body .status,
body .tiny-btn,
body .detail-k,
body .session-meta,
body .ev-meta,
body .actor-cell,
body .team-id,
body .flow-step span,
body .flow-aside p,
body .flow-state,
body .setting-row small,
body .settings-section-head span { font-size: 12px !important; }

body .metric-chip { font-size: 13px !important; }
body .metric-chip strong { font-size: 24px !important; }
body .lane-count { font-size: 12px !important; }
body .status { padding: 3px 7px !important; }
body .tiny-btn { min-height: 30px; padding: 4px 8px; }

/* 字号提升后的防冲突布局 */
.topbar { align-items: flex-start; }
.actions,
.quick-actions,
.card-actions,
.log-toolbar,
.formline { flex-wrap: wrap; }
.actions form,
.quick-actions form { display: flex; margin: 0; }
.dashboard {
  grid-template-columns: repeat(5, minmax(260px, 1fr)) !important;
  overflow-x: auto;
}
.lane { min-width: 260px !important; }
.setting-row { grid-template-columns: minmax(0, 1fr) 130px !important; }
.settings-submit { flex-wrap: wrap; }
.panel-head { min-height: 54px !important; }
.kpi-strip { overflow-x: auto !important; }
.metric-chip { min-width: 132px; }

@media (max-width: 1250px) {
  :root { --sidebar: 240px; }
  .topbar { padding-right: 0; }
}

@media (max-width: 820px) {
  .topbar { padding-right: 44px; }
  .quick-actions { justify-content: flex-start !important; }
  .setting-row { grid-template-columns: minmax(0, 1fr) 112px !important; }
}

.theme-switch {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--stroke-strong);
  border-radius: 8px;
  background: var(--surface-2);
}
button.theme-btn {
  min-height: 28px;
  padding: 3px 9px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  box-shadow: none;
}
button.theme-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}
button.theme-btn.active {
  background: var(--accent-soft);
  color: var(--accent-text);
}
.sidebar-theme {
  width: 100%;
  justify-content: stretch;
}
.sidebar-theme .theme-btn {
  flex: 1;
  min-height: 32px;
  font-size: 12px;
}
