:root {
  color-scheme: dark;
  --bg: #131415;
  --panel: #1a1c1e;
  --raised: #212427;
  --line: #2b2f33;
  --line-strong: #3a3f44;
  --text: #e4e1dc;
  --muted: #9a978f;
  --faint: #6f6c66;
  --ember: #c8703a;
  --ember-text: #e0915f;
  --ok: #5fa877;
  --warn: #d1a93a;
  --error: #d05a4e;
  --offline: #6d7278;
  --radius: 6px;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font: 14px/1.6 var(--sans);
}
* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; min-height: 100vh; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
h1, h2, p { margin: 0; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--ember-text); outline-offset: 2px; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* Panels: 1px line, a faint top highlight like brushed sheet metal. */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .035); }
.panel-head { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 14px 0 16px; border-bottom: 1px solid var(--line); }
.panel-head h2 { font-size: 14px; font-weight: 600; }
.panel-code { font: 11px/1 var(--mono); letter-spacing: .08em; color: var(--faint); padding: 3px 5px; border: 1px solid var(--line); border-radius: 3px; }
.panel-source { margin-left: auto; color: var(--faint); font-size: 12px; }
.panel-source.failed { color: var(--warn); }

/* Brand: the single breathing ember. */
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; }
.wordmark { font: 600 15px/1 var(--mono); letter-spacing: .28em; }
.ember-mark { width: 8px; height: 8px; border-radius: 50%; background: var(--ember); box-shadow: 0 0 0 3px rgba(200, 112, 58, .16); animation: breathe 4s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .ember-mark { animation: none; } * { transition: none !important; } }

button.primary { border: 0; border-radius: var(--radius); padding: 9px 16px; background: var(--ember); color: #1a0f08; font-weight: 600; cursor: pointer; }
button.primary:hover { background: #d27c46; }
button:disabled { opacity: .55; cursor: progress; }
.icon-button { display: inline-grid; place-items: center; width: 28px; height: 28px; border: 1px solid var(--line); border-radius: 4px; background: transparent; color: var(--muted); cursor: pointer; }
.icon-button:hover { color: var(--text); border-color: var(--line-strong); }
.icon-button svg { width: 15px; height: 15px; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(340px, 100%); display: grid; gap: 14px; padding: 28px; }
.login-sub { color: var(--muted); font-size: 13px; margin-top: -4px; }
.login-card label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.login-card input { font: inherit; padding: 8px 10px; border-radius: 4px; border: 1px solid var(--line); background: var(--bg); color: var(--text); }
.login-card input:focus { outline: none; border-color: var(--ember); }
.form-error { min-height: 1.4em; color: var(--error); font-size: 13px; }

/* Top bar */
.topbar { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 28px; height: 48px; padding: 0 20px; background: rgba(19, 20, 21, .94); border-bottom: 1px solid var(--line); backdrop-filter: blur(6px); }
.mainnav { display: flex; align-self: stretch; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.nav-item { display: inline-flex; align-items: center; gap: 6px; padding: 0 12px; color: var(--muted); text-decoration: none; white-space: nowrap; border-bottom: 2px solid transparent; }
.nav-item[aria-current="page"] { color: var(--text); border-bottom-color: var(--ember); }
.nav-item.planned { color: var(--faint); cursor: default; }
.nav-item small { font-size: 11px; color: var(--faint); padding: 0 4px; border: 1px solid var(--line); border-radius: 3px; line-height: 16px; }
.account { position: relative; margin-left: auto; }
.account summary { display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-radius: 4px; cursor: pointer; list-style: none; color: var(--muted); }
.account summary::-webkit-details-marker { display: none; }
.account summary:hover, .account[open] summary { color: var(--text); background: var(--raised); }
.avatar { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 4px; border: 1px solid var(--line-strong); background: var(--raised); color: var(--text); font: 600 12px/1 var(--mono); }
.account-menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 140px; padding: 4px; background: var(--raised); border: 1px solid var(--line-strong); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0, 0, 0, .35); }
.account-menu a, .account-menu button { display: block; width: 100%; text-align: left; padding: 7px 10px; border: 0; border-radius: 4px; background: transparent; color: var(--text); font-size: 14px; text-decoration: none; cursor: pointer; }
.account-menu a:hover, .account-menu button:hover { background: var(--panel); }

/* Overview */
.overview { max-width: 1240px; margin: 0 auto; padding: 20px; display: grid; gap: 16px; }
.summary { display: flex; justify-content: space-between; align-items: center; gap: 24px; flex-wrap: wrap; padding: 18px 20px; }
.summary-line { font-size: 18px; font-weight: 600; }
.summary-line.ember { color: var(--ember-text); }
.summary-detail { color: var(--muted); font-size: 13px; margin-top: 2px; }
.summary-stats { display: flex; gap: 28px; margin: 0; }
.summary-stats div { display: grid; gap: 2px; }
.summary-stats dt { font-size: 12px; color: var(--faint); }
.summary-stats dd { margin: 0; font-size: 14px; }
.columns { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 16px; align-items: start; }

/* Workbench rows */
.groups { padding: 4px 0 8px; }
.group-label { padding: 12px 16px 4px; font-size: 12px; color: var(--faint); letter-spacing: .06em; }
.app-row { display: grid; grid-template-columns: 34px minmax(0, 1fr) minmax(0, 220px) 116px; align-items: center; gap: 14px; padding: 9px 16px; color: inherit; text-decoration: none; border-left: 2px solid transparent; }
.app-row:hover, .app-row:focus-visible { background: var(--raised); border-left-color: var(--ember); outline: none; }
.app-icon { display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 4px; color: var(--muted); background: var(--bg); }
.app-icon svg { width: 18px; height: 18px; }
.app-row:hover .app-icon { color: var(--text); border-color: var(--line-strong); }
.app-text { display: grid; min-width: 0; }
.app-name { font-weight: 500; }
.app-desc { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-host { font: 12px var(--mono); color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Status: always icon + text, colour only supports it. */
.badge { display: inline-flex; align-items: center; gap: 5px; min-width: 64px; font-size: 12px; white-space: nowrap; }
.badge svg { width: 14px; height: 14px; flex: none; }
.badge.ok { color: var(--ok); }
.badge.error { color: var(--error); }
.badge.offline { color: var(--offline); }
.badge.unknown, .badge.checking, .badge.internal { color: var(--faint); }
.badge.unknown svg { stroke-dasharray: 2 2; }
.badge.stale { opacity: .6; }
.badge .ms { color: var(--faint); font-family: var(--mono); }

/* Attention */
.attention { list-style: none; margin: 0; padding: 6px 0; }
.attention li { display: grid; grid-template-columns: 16px 1fr; gap: 10px; padding: 8px 16px; }
.attention li svg { width: 16px; height: 16px; margin-top: 3px; }
.attention .item-title { font-weight: 500; }
.attention .item-meta { color: var(--muted); font-size: 12px; }
.attention li.error svg { color: var(--error); }
.attention li.offline svg { color: var(--offline); }
.attention li.quiet { color: var(--muted); font-size: 13px; }
.attention li.quiet svg { color: var(--ok); }
.attention li.unknown svg { color: var(--faint); }
.coverage { margin: 0 16px 14px; padding-top: 10px; border-top: 1px dashed var(--line); color: var(--faint); font-size: 12px; }

/* Accounts */
.accounts-body { overflow-x: auto; }
.state-note { padding: 18px 16px; color: var(--muted); }
.state-note.error { color: var(--error); }
.accounts { width: 100%; border-collapse: collapse; font-size: 13px; }
.accounts th { padding: 10px 12px; text-align: left; font-weight: 500; font-size: 12px; color: var(--faint); border-bottom: 1px solid var(--line); white-space: nowrap; }
.accounts td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.accounts tr:last-child td { border-bottom: 0; }
.accounts tbody tr:hover { background: var(--raised); }
.accounts .num, .accounts .time { font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }
.account-name { font-weight: 500; }
.account-id { font: 11px var(--mono); color: var(--faint); }
.owner-tag { margin-left: 6px; padding: 0 5px; font-size: 11px; color: var(--ember-text); border: 1px solid rgba(200, 112, 58, .45); border-radius: 3px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { padding: 1px 6px; font-size: 12px; color: var(--text); background: var(--bg); border: 1px solid var(--line-strong); border-radius: 3px; white-space: nowrap; }
.chip.legacy { border-style: dashed; color: var(--muted); }
.chip small { color: var(--faint); margin-right: 4px; }
.dim { color: var(--faint); }
.coverage a { color: var(--muted); }

@media (max-width: 880px) {
  .columns { grid-template-columns: 1fr; }
  .app-row { grid-template-columns: 34px minmax(0, 1fr) 116px; }
  .app-host { display: none; }
}
@media (max-width: 640px) {
  .topbar { gap: 12px; padding: 0 12px; }
  .wordmark { display: none; }
  .nav-item { padding: 0 8px; }
  .account #account-name { display: none; }
  .overview { padding: 12px; gap: 12px; }
  .summary-stats { gap: 18px; }
  .app-row { grid-template-columns: 30px minmax(0, 1fr) auto; gap: 10px; }
  .panel-source { display: none; }
  .panel-head .icon-button { margin-left: auto; }
  .app-row .badge .ms { display: none; }
  .badge { min-width: 0; }
  .accounts thead { display: none; }
  .accounts, .accounts tbody, .accounts tr, .accounts td { display: block; width: 100%; }
  .accounts tr { padding: 10px 4px; border-bottom: 1px solid var(--line); }
  .accounts td { display: flex; gap: 12px; padding: 3px 12px; border: 0; }
  .accounts td::before { content: attr(data-label); flex: none; width: 64px; color: var(--faint); font-size: 12px; }
}
