:root {
  color-scheme: dark;
  --page: #0a0f18;
  --sidebar: #0d1420;
  --surface: #111a28;
  --surface-raised: #172233;
  --surface-soft: #131e2d;
  --border: #253347;
  --border-soft: #1e2a3a;
  --text: #edf2f8;
  --muted: #94a3b8;
  --subtle: #65758a;
  --teal: #67d4bd;
  --blue: #83aaff;
  --amber: #ffbd75;
  --red: #ff7d88;
  --purple: #c2a0ff;
  --radius: 14px;
  font-family: system-ui, 'Noto Sans CJK SC', 'Microsoft YaHei', sans-serif;
  background: var(--page);
  color: var(--text);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--page); color: var(--text); font-size: 14px; }
button, input, select { font: inherit; }
button, a, select { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
button { color: inherit; }
[hidden] { display: none !important; }
.skip-link { position: fixed; top: 8px; left: 8px; transform: translateY(-150%); z-index: 100; padding: 10px 14px; border-radius: 8px; background: var(--teal); color: #06120f; font-weight: 700; }
.skip-link:focus { transform: translateY(0); }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 3px; }
.topbar { height: 70px; display: flex; align-items: center; justify-content: space-between; padding: 0 30px; border-bottom: 1px solid var(--border-soft); background: #0c131e; }
.brand { display: inline-flex; align-items: center; gap: 11px; }
.brand > span:last-child { display: grid; gap: 1px; }
.brand strong { font-size: 12px; letter-spacing: .15em; }
.brand small { font-size: 11px; color: var(--muted); }
.brand-mark { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid rgba(103,212,189,.28); border-radius: 10px; background: linear-gradient(145deg,#17363a,#152439); color: var(--teal); font: 600 18px 'DM Mono',monospace; }
.topbar-meta { display: flex; align-items: center; gap: 20px; color: var(--muted); }
.connection { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; }
.status-dot, .sidebar-indicator { width: 7px; height: 7px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 0 4px rgba(103,212,189,.1); }
.connection-stale .status-dot, .connection-degraded .status-dot { background: var(--amber); box-shadow: 0 0 0 4px rgba(255,189,117,.1); }
.topbar-divider { width: 1px; height: 24px; background: var(--border); }
.user-label { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.user-avatar { display: grid; place-items: center; width: 27px; height: 27px; border-radius: 50%; background: #213148; color: #b8c9e3; font-size: 11px; }
.app-layout { display: grid; grid-template-columns: 226px minmax(0,1fr); min-height: calc(100vh - 70px); }
.sidebar { position: sticky; top: 0; height: calc(100vh - 70px); display: flex; flex-direction: column; padding: 26px 15px 18px; border-right: 1px solid var(--border-soft); background: var(--sidebar); }
.nav-label, .eyebrow { margin: 0; color: #74869d; font: 500 10px 'DM Mono',monospace; letter-spacing: .14em; }
.nav-label { padding: 0 12px 12px; }
.nav-item { display: flex; align-items: center; gap: 11px; min-height: 42px; margin: 2px 0; padding: 0 12px; border: 1px solid transparent; border-radius: 9px; color: #aab8ca; transition: background .18s,border-color .18s,color .18s; }
.nav-item:hover { background: #131e2c; color: var(--text); }
.nav-item.is-active { border-color: #25394a; background: #152531; color: #a7e8dc; }
.nav-icon { width: 18px; color: #8292a7; font-size: 17px; text-align: center; }
.nav-icon svg { display: block; width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.nav-item.is-active .nav-icon { color: var(--teal); }
.sidebar-bottom { display: flex; align-items: flex-start; gap: 10px; margin-top: auto; padding: 14px 11px; border: 1px solid var(--border-soft); border-radius: 10px; background: #111a26; }
.sidebar-bottom .sidebar-indicator { flex: 0 0 7px; margin-top: 6px; background: var(--blue); box-shadow: 0 0 0 4px rgba(131,170,255,.1); }
.sidebar-bottom strong, .sidebar-bottom small { display: block; }
.sidebar-bottom strong { font-size: 12px; font-weight: 600; }
.sidebar-bottom small { margin-top: 4px; color: var(--muted); font-size: 10px; line-height: 1.5; }
.main-content { width: min(100%, 1540px); min-width: 0; margin: 0 auto; padding: 34px clamp(20px,3.4vw,54px) 26px; outline: none; }
.page-heading, .section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; }
.page-heading { margin-bottom: 26px; }
h1,h2,h3,p { margin-top: 0; }
.page-heading h1 { margin: 8px 0 5px; font-size: clamp(24px,2.2vw,30px); letter-spacing: -.03em; font-weight: 600; }
.page-heading .muted { margin-bottom: 0; }
.muted,.section-note { color: var(--muted); }
.muted { font-size: 12px; line-height: 1.65; }
.small { font-size: 11px; }
.heading-actions { display: flex; align-items: center; gap: 15px; }
.updated-label { color: var(--subtle); font: 11px 'DM Mono',monospace; white-space: nowrap; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 36px; padding: 0 13px; border: 1px solid var(--border); border-radius: 8px; background: #182435; cursor: pointer; transition: background .18s,border-color .18s,color .18s; }
.button:hover { border-color: #3c536b; background: #1d2c40; }
.button-primary { border-color: #419c8c; background: #247365; color: #f2fffc; font-weight: 600; }
.button-primary:hover { border-color: #69d3be; background: #2c8977; }
.button-secondary { color: #c2cfdf; }
.button-quiet { min-height: 32px; border-color: transparent; background: transparent; color: var(--muted); }
.button-quiet:hover { border-color: var(--border); background: var(--surface-raised); color: var(--text); }
.button-wide { width: 100%; min-height: 42px; }
.view-stack { display: grid; min-width: 0; gap: 18px; }
.metrics-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 13px; }
.metric-card,.panel { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.metric-card { min-height: 128px; padding: 17px 18px 14px; }
.metric-card-top { display: flex; justify-content: space-between; align-items: center; color: #aab7c8; font-size: 12px; }
.metric-mark { width: 8px; height: 8px; border: 1px solid var(--teal); border-radius: 3px; transform: rotate(45deg); opacity: .85; }
.metric-value { display: block; margin-top: 14px; font: 600 31px 'DM Mono',monospace; letter-spacing: -.04em; }
.metric-note { display: block; margin-top: 4px; color: var(--subtle); font-size: 10px; }
.panel { min-width: 0; padding: 20px; }
.section-heading { align-items: center; margin-bottom: 18px; }
.section-heading h2,.history-controls h2 { margin: 5px 0 0; font-size: 17px; font-weight: 600; letter-spacing: -.015em; }
.section-note { font-size: 11px; }
.chain-stages { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 10px; }
.chain-stage { position: relative; display: flex; flex-direction: column; min-height: 104px; padding: 14px; border: 1px solid var(--border-soft); border-radius: 11px; background: var(--surface-soft); }
.chain-stage:not(:last-child)::after { position: absolute; top: 30px; right: -11px; z-index: 1; width: 10px; border-top: 1px solid #405168; content: ''; }
.stage-index { color: #61758d; font: 11px 'DM Mono',monospace; }
.chain-stage strong { margin: 10px 0 13px; font-size: 13px; font-weight: 600; }
.badge { display: inline-flex; align-items: center; width: fit-content; padding: 4px 8px; border: 1px solid #334255; border-radius: 999px; background: #1b2737; color: #c3cedb; font-size: 10px; line-height: 1.1; white-space: nowrap; }
.badge-unknown,.badge-never_seen { border-color: #334255; background: #182331; color: #a3b0bf; }
.badge-succeeded,.badge-passed,.badge-published,.badge-approved,.badge-complete,.badge-healthy { border-color: #2e655c; background: #17342f; color: #9be3d5; }
.badge-running,.badge-partial,.badge-backlog { border-color: #80623b; background: #372b1d; color: #ffd09a; }
.badge-failed,.badge-rejected,.badge-attention { border-color: #79434c; background: #382229; color: #ffabb2; }
.badge-hold,.badge-stale,.badge-degraded { border-color: #76603d; background: #31291f; color: #eac68e; }
.badge-queued { border-color: #345471; background: #152535; color: #bad8f4; }
.badge-blocked { border-color: #79434c; background: #382229; color: #ffabb2; }
.workload-filter { display: grid; gap: 5px; color: var(--muted); font-size: 11px; }
.workload-status { margin-bottom: 15px; color: var(--teal); font-size: 12px; line-height: 1.6; }
.workload-list { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
.workload-list > .empty-state { grid-column: 1 / -1; }
.workload-card { min-width: 0; padding: 15px; border: 1px solid var(--border-soft); border-radius: 10px; background: var(--surface-soft); }
.workload-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.workload-heading > div { min-width: 0; }
.workload-heading strong { display: block; font-size: 13px; overflow-wrap: anywhere; }
.workload-version { display: block; margin-top: 5px; color: var(--muted); font: 11px/1.5 monospace; overflow-wrap: anywhere; }
.workload-meta { margin: 12px 0 5px; color: #b9c5d3; font-size: 11px; line-height: 1.6; overflow-wrap: anywhere; }
.workload-details summary { width: fit-content; color: var(--teal); font-size: 11px; cursor: pointer; }
.workload-detail-body { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); }
.workload-detail-body p { margin-bottom: 8px; font-size: 11px; line-height: 1.7; overflow-wrap: anywhere; white-space: pre-wrap; }
.workload-detail-body strong { color: var(--muted); font-weight: 500; }
.table-wrap { min-height: 58px; }
.table-scroll { width: 100%; overflow-x: auto; scrollbar-color: #39485b transparent; }
table { width: 100%; border-collapse: collapse; min-width: 660px; text-align: left; }
th { padding: 0 12px 11px; border-bottom: 1px solid var(--border); color: #8090a5; font: 500 10px 'DM Mono',monospace; letter-spacing: .05em; white-space: nowrap; }
td { padding: 13px 12px; border-bottom: 1px solid var(--border-soft); color: #b9c5d3; font-size: 12px; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(255,255,255,.018); }
.strong-cell { color: #edf2f8; font-weight: 600; }
.text-link,.text-button { color: #8fdccb; font-size: 11px; cursor: pointer; }
.text-link:hover,.text-button:hover { color: #b8f3e8; text-decoration: underline; }
.text-button { padding: 5px 7px; border: 0; background: transparent; }
.agent-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(190px,1fr)); gap: 10px; }
.agent-card { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 10px; padding: 13px; border: 1px solid var(--border-soft); border-radius: 10px; background: #121d2a; }
.agent-card strong { overflow: hidden; font: 11px 'DM Mono',monospace; text-overflow: ellipsis; }
.agent-card .muted { grid-column: 1 / -1; margin: 0; }
.notice { padding: 12px 14px; border: 1px solid; border-radius: 10px; font-size: 12px; line-height: 1.55; }
.notice-info { border-color: #345471; background: #152535; color: #bad8f4; }
.notice-history { margin-bottom: 10px; border-color: #4a5b70; background: #1b2635; color: #c5d1de; }
.empty-state { display: grid; justify-items: center; gap: 5px; padding: 26px 15px; border: 1px dashed #344257; border-radius: 10px; text-align: center; }
.empty-state strong { font-size: 12px; font-weight: 600; }
.empty-state p { max-width: 520px; margin: 0; color: var(--muted); font-size: 11px; line-height: 1.6; }
.page-footer { display: flex; justify-content: space-between; gap: 12px; margin-top: 25px; padding-top: 14px; border-top: 1px solid var(--border-soft); color: #6f7e91; font-size: 10px; }
.filter-panel { display: flex; min-width: 0; align-items: flex-end; gap: 12px; flex-wrap: wrap; padding: 15px 17px; }
.filter-panel label,.control-group label { display: grid; gap: 6px; color: #98a8bb; font-size: 10px; }
input,select { min-height: 36px; min-width: 150px; padding: 0 10px; border: 1px solid #304056; border-radius: 7px; background: #0e1723; color: var(--text); }
input::placeholder { color: #65758a; }
.filter-panel input { min-width: 210px; }
.load-more { display: block; margin: 14px auto 0; }
.detail-panel { scroll-margin-top: 18px; }
.detail-heading { align-items: flex-start; }
.detail-heading h2 { margin-top: 6px; font-size: 21px; }
.detail-stages { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 9px; margin: 16px 0; }
.detail-stage { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 11px; border: 1px solid var(--border-soft); border-radius: 9px; color: #aebccc; font-size: 11px; }
.forgejo-links { display: flex; gap: 15px; margin: 14px 0; color: var(--blue); font-size: 11px; }
.forgejo-links a:hover { text-decoration: underline; }
.timeline { margin: 18px 0 0 4px; padding: 0; list-style: none; }
.timeline-entry { position: relative; display: grid; grid-template-columns: 15px minmax(0,1fr) auto; align-items: start; gap: 11px; min-height: 74px; padding-bottom: 16px; }
.timeline-entry:not(:last-child)::before { position: absolute; top: 12px; bottom: -1px; left: 5px; width: 1px; background: #2e3c50; content: ''; }
.timeline-dot { position: relative; z-index: 1; width: 11px; height: 11px; margin-top: 4px; border: 2px solid #5c7f83; border-radius: 50%; background: var(--surface); }
.timeline-entry strong { font-size: 12px; font-weight: 600; }
.timeline-entry p { margin: 5px 0; color: #a4b1c1; font-size: 11px; line-height: 1.5; overflow-wrap: anywhere; }
.timeline-entry time { color: var(--subtle); font: 10px 'DM Mono',monospace; }
.log-output { grid-column: 2 / -1; max-height: 320px; overflow: auto; padding: 12px; border: 1px solid var(--border); border-radius: 8px; background: #080d14; color: #cad5df; font: 11px/1.6 'DM Mono',monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.log-toggle { grid-column: 3; grid-row: 1; }
.history-controls { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.history-controls h2 { margin-bottom: 5px; }
.history-controls p { margin: 0; }
.control-group { display: flex; gap: 10px; }
.resource-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 15px; }
.chart-card { min-width: 0; padding: 16px; }
.chart-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.chart-heading h3 { margin: 0; font-size: 13px; font-weight: 600; }
.history-chart { display: block; width: 100%; height: auto; margin-top: 12px; }
.chart-summary { margin: 7px 0 0; font: 10px 'DM Mono',monospace; }
.cgroup-panel { grid-column: 1 / -1; }
.cgroup-panel > h3 { margin: 0 0 12px; font: 12px 'DM Mono',monospace; color: #b5c4d6; }
.cgroup-charts { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px; }
.cgroup-chart { min-width: 0; padding: 10px; border: 1px solid var(--border-soft); border-radius: 9px; }
.cgroup-chart strong { font-size: 11px; font-weight: 500; color: #aebccc; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 30; max-width: min(420px,calc(100vw - 40px)); padding: 12px 16px; border: 1px solid #40536c; border-radius: 10px; background: #1a2738; box-shadow: 0 16px 40px rgba(0,0,0,.35); color: #d8e4ef; font-size: 12px; }
.login-shell { display: grid; min-height: 100vh; place-items: center; padding: 20px; background: radial-gradient(ellipse at 50% 20%,#18293a 0%,#0a0f18 52%); }
.login-card { width: min(100%,410px); padding: 32px; border: 1px solid var(--border); border-radius: 17px; background: rgba(17,26,40,.96); box-shadow: 0 25px 80px rgba(0,0,0,.38); }
.login-card .brand-mark { width: 42px; height: 42px; margin-bottom: 25px; font-size: 21px; }
.login-card h1 { margin: 7px 0 7px; font-size: 26px; font-weight: 600; }
.login-card > .muted { margin-bottom: 24px; }
.login-card form { display: grid; gap: 9px; }
.login-card label { margin-top: 6px; color: #b9c6d4; font-size: 11px; }
.login-card input { height: 42px; }
.login-card button { margin-top: 14px; }
.form-error { margin: 3px 0 0; color: #ff9ea7; font-size: 11px; }

@media (max-width: 1050px) {
  .app-layout { grid-template-columns: 190px minmax(0,1fr); }
  .main-content { padding-right: 22px; padding-left: 22px; }
  .metrics-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (max-width: 720px) {
  .topbar { height: 60px; padding: 0 14px; }
  .topbar-meta { gap: 10px; }
  .connection { font-size: 0; }
  .connection .status-dot { font-size: 12px; }
  .topbar-divider { display: none; }
  .app-layout { display: block; min-height: calc(100vh - 60px); }
  .sidebar { position: sticky; z-index: 10; top: 0; width: 100%; height: auto; flex-direction: row; align-items: center; gap: 5px; padding: 7px 10px; border-right: 0; border-bottom: 1px solid var(--border-soft); }
  .nav-label,.sidebar-bottom { display: none; }
  .nav-item { flex: 1; justify-content: center; gap: 6px; min-height: 38px; margin: 0; padding: 0 6px; font-size: 11px; }
  .nav-icon { width: auto; font-size: 15px; }
  .main-content { padding: 22px 13px 20px; }
  .page-heading { align-items: flex-start; margin-bottom: 19px; }
  .page-heading h1 { font-size: 23px; }
  .heading-actions { flex-direction: column-reverse; align-items: flex-end; gap: 5px; }
  .updated-label { font-size: 9px; }
  .metrics-grid { gap: 9px; }
  .metric-card { min-height: 108px; padding: 13px; }
  .metric-value { margin-top: 11px; font-size: 25px; }
  .panel { padding: 15px; }
  .section-heading { align-items: flex-start; }
  .section-note { max-width: 45%; text-align: right; line-height: 1.5; }
  .chain-stages { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .chain-stage:not(:last-child)::after { display: none; }
  .detail-stages { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .resource-grid { grid-template-columns: 1fr; }
  .workload-list { grid-template-columns: 1fr; }
  .workload-filter select { min-width: 105px; }
  .cgroup-panel { grid-column: auto; }
  .cgroup-charts { grid-template-columns: 1fr; }
  .history-controls { align-items: flex-start; flex-direction: column; }
  .control-group { width: 100%; }
  .control-group label { flex: 1; min-width: 0; }
  .control-group select { min-width: 0; width: 100%; }
  .filter-panel { align-items: stretch; flex-direction: column; }
  .filter-panel label,.filter-panel input,.filter-panel select { width: 100%; min-width: 0; }
  .filter-panel input,.filter-panel select { min-width: 0; }
  .page-footer { flex-direction: column; }
  .timeline-entry { grid-template-columns: 15px minmax(0,1fr); }
  .timeline-entry time { grid-column: 2; }
  .log-toggle { grid-column: 2; grid-row: auto; justify-self: start; }
  .log-output { grid-column: 2; }
}
@media (max-width: 360px) {
  .brand small { display: none; }
  .user-label { display: none; }
  .chain-stage { min-height: 96px; padding: 11px; }
  .stage-state .badge { padding: 4px 6px; font-size: 9px; }
}
@media (prefers-reduced-motion: reduce) {
  *,*::before,*::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
