/* Codex apps dashboard: one token-based stylesheet for every page.
   Light is the default. Dark applies with data-theme="dark", or with the system
   preference when no explicit theme is chosen (see theme.js). */

/* ---------- Design tokens ---------- */
:root {
  color-scheme: light;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;

  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --surface-3: #f1f3f6;
  --border: #e3e6eb;
  --border-strong: #cfd4dc;
  --text: #121826;
  --text-2: #3d4554;
  --text-3: #5f6878;
  --text-4: #8a93a3;

  --accent: #5b4ee0;
  --accent-hover: #4c3fcf;
  --accent-soft: #eeecfd;
  --accent-text: #4a3dc9;
  --on-accent: #ffffff;
  --focus: #7d72f0;

  --success: #0f7a4a;  --success-bg: #ebf8f1;  --success-border: #b7e5cc;
  --warning: #9a5b00;  --warning-bg: #fff7e6;  --warning-border: #f5d48f;
  --danger: #b4261a;   --danger-bg: #fdf1f0;   --danger-border: #f4c4bf;
  --info: #1d5fbf;     --info-bg: #eef5ff;     --info-border: #bcd6fb;

  --tone-violet: #6b5fd8; --tone-violet-bg: #efedfd;
  --tone-blue: #2f6fc5;   --tone-blue-bg: #eaf2fd;
  --tone-rose: #b8476a;   --tone-rose-bg: #fcedf2;
  --tone-teal: #157f78;   --tone-teal-bg: #e7f6f4;

  --chart-1: #6656e6;
  --chart-2: #9a5fdc;
  --chart-3: #d08a1c;
  --chart-grid: #e8ebf0;
  --chart-axis: #7a8394;
  --chart-area: #6656e6;
  --ring-track: #dff3e9;
  --ring-value: #15a06d;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .05);
  --shadow-lg: 0 24px 60px rgba(16, 24, 40, .18), 0 4px 12px rgba(16, 24, 40, .08);
  --backdrop: rgba(17, 20, 31, .45);

  --radius-xs: 5px;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --sidebar-width: 248px;
  --topbar-height: 64px;
}

/* Dark tokens: explicit choice, or system preference without an explicit light choice. */
:root[data-theme="dark"] { color-scheme: dark; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { color-scheme: dark; } }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c0e13; --surface: #14171e; --surface-2: #181c24; --surface-3: #1f242e;
    --border: #262c37; --border-strong: #353d4b;
    --text: #eceff4; --text-2: #c5cbd6; --text-3: #959eae; --text-4: #6c7586;
    --accent: #6a5ef0; --accent-hover: #7d72f5; --accent-soft: #23203f; --accent-text: #b2a9ff; --on-accent: #ffffff; --focus: #9a90ff;
    --success: #6fdba5; --success-bg: #0f2a1e; --success-border: #1e5a3f;
    --warning: #f4bf5a; --warning-bg: #2a1f0b; --warning-border: #6b4d12;
    --danger: #ff9b91; --danger-bg: #2e1513; --danger-border: #74302a;
    --info: #8cc2ff; --info-bg: #0f2038; --info-border: #24497a;
    --tone-violet: #b3a9ff; --tone-violet-bg: #262245;
    --tone-blue: #8cbcff;   --tone-blue-bg: #13263f;
    --tone-rose: #f3a0bb;   --tone-rose-bg: #3a1726;
    --tone-teal: #6dd8cd;   --tone-teal-bg: #0f2f2c;
    --chart-1: #9187ff; --chart-2: #c497ff; --chart-3: #f0b04b;
    --chart-grid: #262c37; --chart-axis: #8892a3; --chart-area: #8b80ff;
    --ring-track: #183428; --ring-value: #4fd49a;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-md: 0 4px 14px rgba(0, 0, 0, .35), 0 1px 3px rgba(0, 0, 0, .3);
    --shadow-lg: 0 24px 70px rgba(0, 0, 0, .6), 0 4px 14px rgba(0, 0, 0, .4);
    --backdrop: rgba(0, 0, 0, .6);
  }
}
:root[data-theme="dark"] {
  --bg: #0c0e13; --surface: #14171e; --surface-2: #181c24; --surface-3: #1f242e;
  --border: #262c37; --border-strong: #353d4b;
  --text: #eceff4; --text-2: #c5cbd6; --text-3: #959eae; --text-4: #6c7586;
  --accent: #6a5ef0; --accent-hover: #7d72f5; --accent-soft: #23203f; --accent-text: #b2a9ff; --on-accent: #ffffff; --focus: #9a90ff;
  --success: #6fdba5; --success-bg: #0f2a1e; --success-border: #1e5a3f;
  --warning: #f4bf5a; --warning-bg: #2a1f0b; --warning-border: #6b4d12;
  --danger: #ff9b91; --danger-bg: #2e1513; --danger-border: #74302a;
  --info: #8cc2ff; --info-bg: #0f2038; --info-border: #24497a;
  --tone-violet: #b3a9ff; --tone-violet-bg: #262245;
  --tone-blue: #8cbcff;   --tone-blue-bg: #13263f;
  --tone-rose: #f3a0bb;   --tone-rose-bg: #3a1726;
  --tone-teal: #6dd8cd;   --tone-teal-bg: #0f2f2c;
  --chart-1: #9187ff; --chart-2: #c497ff; --chart-3: #f0b04b;
  --chart-grid: #262c37; --chart-axis: #8892a3; --chart-area: #8b80ff;
  --ring-track: #183428; --ring-value: #4fd49a;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, .35), 0 1px 3px rgba(0, 0, 0, .3);
  --shadow-lg: 0 24px 70px rgba(0, 0, 0, .6), 0 4px 14px rgba(0, 0, 0, .4);
  --backdrop: rgba(0, 0, 0, .6);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01";
}
h1, h2, h3, h4 { margin: 0; color: var(--text); letter-spacing: -.01em; line-height: 1.25; }
h1 { font-size: 20px; font-weight: 650; }
h2 { font-size: 17px; font-weight: 650; display: flex; align-items: center; gap: 8px; }
h3 { font-size: 15px; font-weight: 620; }
h4 { font-size: 13px; font-weight: 620; }
p { margin: 0 0 8px; }
a { color: inherit; text-decoration: none; }
code, pre { font-family: var(--mono); font-size: 12px; }
code { background: var(--surface-3); border: 1px solid var(--border); border-radius: var(--radius-xs); padding: 1px 5px; color: var(--text-2); overflow-wrap: anywhere; }
pre { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--surface-3); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; color: var(--text-2); max-height: 420px; overflow: auto; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
svg { flex-shrink: 0; }
.icon { width: 18px; height: 18px; }
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}
[hidden] { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: 12px; top: -48px; z-index: 100; background: var(--surface); padding: 8px 12px; border-radius: var(--radius-sm); box-shadow: var(--shadow-md); }
.skip-link:focus { top: 12px; }
.muted, .panel-muted { color: var(--text-3); }
.eyebrow { font-size: 11px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; color: var(--accent-text); margin: 0 0 6px; }
.text-link, .usage-link, .opencode-guide { display: inline-flex; align-items: center; gap: 4px; color: var(--accent-text); font-weight: 550; }
.text-link:hover, .usage-link:hover, .opencode-guide:hover { text-decoration: underline; text-underline-offset: 3px; }
.text-link .icon, .usage-link svg { width: 14px; height: 14px; }
details > summary { cursor: pointer; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--text-3); font-weight: 600; font-size: 12px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- App shell ---------- */
.app-shell { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 4px;
  padding: 18px 14px;
  background: var(--surface);
  border-right: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 14px; font-weight: 700; font-size: 15px; letter-spacing: -.01em; }
.brand-name small { display: block; font-size: 11px; font-weight: 500; color: var(--text-3); letter-spacing: 0; }
.brand-mark {
  position: relative; display: grid; place-items: center; width: 34px; height: 34px; flex-shrink: 0;
  border-radius: 10px; background: var(--accent); color: var(--on-accent);
  font: 800 20px/1 var(--mono); letter-spacing: -3px; padding-right: 4px; box-shadow: var(--shadow-sm);
}
.brand-mark > span { position: absolute; right: 5px; bottom: 6px; font-size: 13px; }
.nav-section { display: flex; flex-direction: column; gap: 2px; padding: 6px 0; }
.nav-label { margin: 8px 10px 4px; font-size: 11px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; color: var(--text-4); }
.workspace-views { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; border: 0; border-radius: var(--radius-sm); background: transparent;
  color: var(--text-2); font-size: 14px; font-weight: 520; text-align: left;
}
.nav-item .icon { width: 18px; height: 18px; color: var(--text-3); }
.nav-item > .icon:last-child:not(:first-child) { width: 14px; height: 14px; margin-left: auto; color: var(--text-4); }
.nav-item > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item:hover { background: var(--surface-3); color: var(--text); }
.nav-item.selected, .nav-item[aria-selected="true"], .nav-item[aria-current="page"] { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.nav-item.selected .icon, .nav-item[aria-selected="true"] .icon, .nav-item[aria-current="page"] .icon { color: var(--accent-text); }
.nav-count { margin-left: auto; min-width: 22px; padding: 0 6px; border-radius: 999px; background: var(--surface-3); color: var(--text-3); font-size: 12px; font-weight: 600; text-align: center; }
.nav-item[aria-selected="true"] .nav-count { background: var(--surface); color: var(--accent-text); }
.sidebar-footer { margin-top: auto; padding: 14px 10px 4px; border-top: 1px solid var(--border); }
.build-facts { margin: 0; display: grid; gap: 8px; }
.build-facts div { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.build-facts dt { font-size: 12px; color: var(--text-3); }
.build-facts dd { margin: 0; font-size: 12px; color: var(--text-2); font-weight: 550; }
.nav-scrim { display: none; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  min-height: var(--topbar-height); padding: 10px 28px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-title { min-width: 0; flex: 1; }
.topbar-title h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-subtitle { margin: 2px 0 0; font-size: 13px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.topbar .nav-toggle { display: none; }
.theme-switch { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-3); border: 1px solid var(--border); border-radius: 10px; }
.theme-switch button { display: grid; place-items: center; width: 30px; height: 28px; border: 0; border-radius: 7px; background: transparent; color: var(--text-3); }
.theme-switch button .icon { width: 16px; height: 16px; }
.theme-switch button:hover { color: var(--text); }
.theme-switch button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.account { display: flex; align-items: center; gap: 8px; padding-left: 8px; margin-left: 2px; border-left: 1px solid var(--border); font-size: 13px; color: var(--text-3); }
.account form { margin: 0; }
.avatar { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-text); font-size: 13px; font-weight: 700; }
.account-email { max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.content { width: 100%; max-width: 1360px; margin: 0 auto; padding: 24px 28px 32px; display: flex; flex-direction: column; gap: 20px; }
.content:focus { outline: none; }
.workspace-view { display: flex; flex-direction: column; gap: 20px; }
.workspace-view[hidden] { display: none; }
.content-footer { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 4px; padding-top: 16px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-3); }
.footer-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); }
.footer-divider { color: var(--text-4); }
.footer-end { margin-left: auto; }

/* ---------- Live "Updated 12 s ago" (live.js) ---------- */
.live-updated { display: none; align-items: center; gap: 6px; margin: 0; font-size: 12px; color: var(--text-3); white-space: nowrap; font-variant-numeric: tabular-nums; }
.live-in-actions:not([hidden]) { display: inline-flex; margin-right: 4px; }
.live-dot { width: 7px; height: 7px; flex: none; border-radius: 50%; background: var(--success); }
.live-updated[data-tone="warn"] .live-dot { background: var(--warning); }
.live-updated[data-tone="bad"] { color: var(--danger); }
.live-updated[data-tone="bad"] .live-dot { background: var(--danger); }
.live-updated.is-loading .live-dot { animation: live-pulse 1s ease-in-out infinite; }
@keyframes live-pulse { 50% { opacity: .25; } }
@media (max-width: 640px) {
  .live-in-actions:not([hidden]) { display: none; }
  .live-under-title:not([hidden]) { display: flex; margin-top: 2px; font-size: 11.5px; }
}

/* ---------- Phone navigation: bottom bar + drawer settings ---------- */
.bottom-nav, .drawer-settings, .drawer-email { display: none; }
@media (max-width: 640px) {
  body.has-bottom-nav .bottom-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
    padding: 0 4px env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: saturate(1.4) blur(10px);
    border-top: 1px solid var(--border);
  }
  .bottom-nav-item {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    min-height: 56px; padding: 6px 2px; border: 0; background: none;
    color: var(--text-3); font-size: 11px; font-weight: 560;
  }
  .bottom-nav-item .icon { width: 21px; height: 21px; }
  .bottom-nav-item[aria-current="page"] { color: var(--accent-text); font-weight: 650; }
  body.has-bottom-nav .content { padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
  body.has-bottom-nav .topbar { flex-wrap: nowrap; }
  body.has-bottom-nav .topbar-title { order: 0; flex: 1 1 auto; }
  body.has-bottom-nav .topbar-subtitle,
  body.has-bottom-nav .topbar .nav-toggle,
  body.has-bottom-nav .topbar .theme-switch,
  body.has-bottom-nav .topbar .account { display: none; }
  body.has-bottom-nav .drawer-settings { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
  body.has-bottom-nav .drawer-settings form { margin: 0; }
  body.has-bottom-nav .drawer-email { display: block; margin: 0 0 10px; font-size: 12px; color: var(--text-3); overflow-wrap: anywhere; }
}

/* ---------- Buttons ---------- */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 36px; padding: 7px 13px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font-size: 13px; font-weight: 580; line-height: 1.2; white-space: nowrap;
  box-shadow: var(--shadow-sm);
  transition: background .12s, border-color .12s, color .12s, box-shadow .12s;
}
.button .icon, .button svg { width: 16px; height: 16px; }
.button:hover:not(:disabled) { background: var(--surface-3); }
.button:active:not(:disabled) { transform: translateY(1px); }
.secondary, .manage-app, .quiet { background: var(--surface); color: var(--text); }
.quiet { border-color: transparent; box-shadow: none; }
.primary, .open-app, .button.primary {
  background: var(--accent); border-color: var(--accent); color: var(--on-accent);
}
.primary:hover:not(:disabled), .open-app:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.danger, .button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
:root[data-theme="dark"] .danger { color: #1b0b09; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .danger { color: #1b0b09; } }
.danger:hover:not(:disabled) { filter: brightness(.95); background: var(--danger); }
.start, .vm-action.start { background: var(--success-bg); border-color: var(--success-border); color: var(--success); }
.start:hover:not(:disabled) { background: var(--success-bg); border-color: var(--success); }
.stop-action, .vm-action.stop-action { background: var(--surface); border-color: var(--border-strong); color: var(--danger); }
.stop-action:hover:not(:disabled) { background: var(--danger-bg); border-color: var(--danger-border); }
.icon-button {
  display: inline-grid; place-items: center; width: 36px; height: 36px; padding: 0;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text-3);
}
.icon-button:hover { background: var(--surface-3); color: var(--text); }
.icon-button svg, .icon-button .icon { width: 17px; height: 17px; }
.refresh-icon { display: inline-grid; place-items: center; }
#refresh[aria-busy="true"] .refresh-icon { animation: spin 1s linear infinite; }
#refresh[aria-busy="true"] { cursor: progress; }
.panel-actions, .dialog-actions, .setup-card-actions, .proposal-actions, .task-actions, .form-actions, .section-actions {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
}
.dialog-actions { justify-content: flex-end; margin-top: 20px; }

/* ---------- Badges, chips, status ---------- */
.badge, .panel-state, .billing-state, .branch, .scope-tag, .chip, .heading-count {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 9px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text-2);
  font-size: 12px; font-weight: 580; line-height: 1.5; white-space: nowrap;
}
.badge.running, .panel-state.is-running, .billing-state.connected { background: var(--success-bg); border-color: var(--success-border); color: var(--success); }
.badge.transition { background: var(--warning-bg); border-color: var(--warning-border); color: var(--warning); }
.badge.warning { background: var(--warning-bg); border-color: var(--warning-border); color: var(--warning); }
.badge.danger { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger); }
.branch { border-radius: var(--radius-xs); font-family: var(--mono); font-size: 12px; }
.branch svg { width: 13px; height: 13px; }
.scope-tag, .chip { border-radius: var(--radius-xs); }
.chip code { border: 0; background: none; padding: 0; }
.heading-count { padding: 0 8px; font-size: 12px; color: var(--text-3); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.status-dot { display: inline-block; flex-shrink: 0; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.green-dot { color: var(--success); }
.readiness { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 560; color: var(--text-3); }
.readiness.healthy { color: var(--success); }
.readiness.warning { color: var(--warning); }

/* ---------- Notices ---------- */
.notice, #notice, .workspace-alert, .panel-notice {
  margin: 0; padding: 10px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--info-border); background: var(--info-bg); color: var(--info); font-size: 13px;
}
#factory-message.notice { border-color: var(--border); background: var(--surface-2); color: var(--text-2); }
.notice:empty, #factory-message:empty { display: none; }
.panel-notice.is-error, .workspace-alert { border-color: var(--danger-border); background: var(--danger-bg); color: var(--danger); }
.error-box, .panel-warning, .job-error {
  margin: 0; padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--warning-border); background: var(--warning-bg); color: var(--warning);
  font-size: 13px; overflow-wrap: anywhere;
}
.job-error { border-color: var(--danger-border); background: var(--danger-bg); color: var(--danger); }
ul.panel-warning { padding-left: 28px; }
.protection-note { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); color: var(--text-3); font-size: 13px; }
.panel-empty, .usage-placeholder, .graph-empty, .quota-empty {
  padding: 18px; border: 1px dashed var(--border-strong); border-radius: var(--radius);
  color: var(--text-3); font-size: 13px; text-align: center; background: var(--surface-2);
}

/* ---------- Cards and sections ---------- */
.card, .ops-card, .usage-account, .setup-board, .metric, .app-card, .task-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.card, .ops-card { padding: 20px; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.section-heading p { margin: 4px 0 0; color: var(--text-3); font-size: 13px; }
.updated { font-size: 12px; color: var(--text-3); white-space: nowrap; }

/* ---------- Overview metrics ---------- */
.overview { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.metric { position: relative; display: flex; align-items: center; gap: 14px; padding: 16px 18px 38px; }
.metric small { display: block; font-size: 13px; color: var(--text-3); font-weight: 520; }
.metric strong { display: block; font-size: 28px; font-weight: 680; letter-spacing: -.02em; line-height: 1.15; color: var(--text); font-variant-numeric: tabular-nums; }
.metric-caption { position: absolute; left: 18px; bottom: 12px; display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-3); }
.metric-icon { display: grid; place-items: center; width: 42px; height: 42px; flex-shrink: 0; border-radius: 11px; }
.metric-icon .icon { width: 21px; height: 21px; }
.violet { background: var(--tone-violet-bg); color: var(--tone-violet); }
.blue { background: var(--tone-blue-bg); color: var(--tone-blue); }
.rose { background: var(--tone-rose-bg); color: var(--tone-rose); }
.teal { background: var(--tone-teal-bg); color: var(--tone-teal); }
.green { background: var(--success-bg); color: var(--success); }
.slate { background: var(--surface-3); color: var(--text-3); }
.amber { background: var(--warning-bg); color: var(--warning); }
.fleet-mini { width: 42px; height: 42px; flex-shrink: 0; }
.fleet-mini svg { width: 42px; height: 42px; }
.fleet-mini text { font-size: 11px; font-weight: 700; fill: var(--text-2); font-family: var(--font); }
.fleet-track { stroke: var(--ring-track); }
.fleet-value { stroke: var(--ring-value); }

/* ---------- Application toolbar ---------- */
.applications { display: flex; flex-direction: column; gap: 14px; }
.toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.toolbar-title { margin-right: auto; font-size: 16px; }
.filter-tabs { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-3); border: 1px solid var(--border); border-radius: 10px; }
.filter-tab { min-height: 30px; padding: 4px 12px; border: 0; border-radius: 7px; background: transparent; color: var(--text-3); font-size: 13px; font-weight: 560; }
.filter-tab:hover { color: var(--text); }
.filter-tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.search { display: inline-flex; flex-direction: row; align-items: center; gap: 8px; min-height: 38px; padding: 0 12px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); color: var(--text-3); }
.search .icon { width: 16px; height: 16px; }
.search input { width: 200px; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 13px; color: var(--text); }
.search input::placeholder { color: var(--text-4); }
.search:focus-within { border-color: var(--focus); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- Application cards ---------- */
.app-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 440px), 1fr)); gap: 16px; align-items: start; }
.app-card { display: flex; flex-direction: column; overflow: hidden; transition: border-color .15s, box-shadow .15s; }
.app-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); }
.app-card.card-attention { border-color: var(--warning-border); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px 10px; }
.app-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.app-title > div { min-width: 0; }
.app-icon { display: grid; place-items: center; width: 40px; height: 40px; flex-shrink: 0; border-radius: 10px; font-size: 13px; font-weight: 700; text-transform: uppercase; }
.app-title h3 { font-size: 16px; }
.repo-link { display: block; max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; color: var(--text-3); }
.repo-link:hover { color: var(--accent-text); text-decoration: underline; text-underline-offset: 3px; }
.environment-line { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 12px; padding: 0 18px 12px; font-size: 12px; color: var(--text-3); }
.environment-line > span { display: inline-flex; align-items: center; gap: 6px; overflow-wrap: anywhere; }
.environment-line svg { width: 14px; height: 14px; }
.card-body { display: flex; flex-direction: column; gap: 12px; padding: 14px 18px; border-top: 1px solid var(--border); }
.runtime-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.status-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.status-grid > div { padding: 10px 12px; min-width: 0; }
.status-grid > div + div { border-left: 1px solid var(--border); }
.fact-label { display: block; font-size: 11px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--text-4); }
.fact-value { display: block; margin: 3px 0 1px; font-size: 14px; font-weight: 600; color: var(--text); text-transform: capitalize; overflow-wrap: anywhere; }
.status-grid small { display: block; font-size: 12px; color: var(--text-3); overflow-wrap: anywhere; }
.commit-block { padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.commit-meta { display: flex; justify-content: space-between; gap: 8px; }
.commit-meta > span:last-child { font-size: 12px; color: var(--text-3); white-space: nowrap; }
.commit-subject { margin: 6px 0 8px; font-size: 14px; font-weight: 550; color: var(--text); overflow-wrap: anywhere; }
.git-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 12px; color: var(--text-3); }
.changes { margin-left: auto; }
.card-errors summary { font-weight: 600; }
.card-errors ul { margin: 8px 0 0; padding-left: 18px; }
.runtime-details, .card-technical, .vm-configuration, .chart-data, .vm-token-table, .vm-token-coverage, .task-history, .task-instruction, .evidence, .run {
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface);
}
.runtime-details > summary, .card-technical > summary, .vm-configuration > summary, .chart-data > summary, .vm-token-table > summary,
.vm-token-coverage > summary, .task-history > summary, .task-instruction > summary, .evidence > summary, .billing-block details > summary {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 9px 12px; list-style: none; font-size: 13px; font-weight: 580; color: var(--text-2);
}
.runtime-details > summary::-webkit-details-marker, .card-technical > summary::-webkit-details-marker, .vm-configuration > summary::-webkit-details-marker,
.chart-data > summary::-webkit-details-marker, .vm-token-table > summary::-webkit-details-marker, .vm-token-coverage > summary::-webkit-details-marker,
.task-history > summary::-webkit-details-marker, .task-instruction > summary::-webkit-details-marker, .evidence > summary::-webkit-details-marker,
.run > summary::-webkit-details-marker { display: none; }
.runtime-details > summary > span, .vm-configuration > summary > span { display: none; }
:is(.runtime-details, .card-technical, .vm-configuration, .chart-data, .vm-token-table, .vm-token-coverage, .task-history, .task-instruction, .evidence) > summary::after {
  content: ""; width: 7px; height: 7px; margin-right: 3px; border-right: 1.6px solid var(--text-3); border-bottom: 1.6px solid var(--text-3);
  transform: rotate(45deg); transition: transform .15s;
}
:is(.runtime-details, .card-technical, .vm-configuration, .chart-data, .vm-token-table, .vm-token-coverage, .task-history, .task-instruction, .evidence)[open] > summary::after { transform: rotate(-135deg); }
:is(.runtime-details, .card-technical, .vm-configuration, .chart-data, .vm-token-table, .vm-token-coverage, .task-history, .task-instruction, .evidence)[open] > summary { border-bottom: 1px solid var(--border); }
.card-technical[open] { display: flex; flex-direction: column; gap: 10px; padding-bottom: 12px; }
.card-technical[open] > :not(summary) { margin: 0 12px; }
.runtime-expanded { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; padding: 12px; }
.runtime-expanded > div { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--text-3); }
.runtime-expanded strong { font-size: 14px; font-weight: 600; color: var(--text); }
.container-list { list-style: none; margin: 0; padding: 0 12px 6px; }
.container-list li { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0; border-top: 1px solid var(--border); font-size: 13px; }
.container-list li span:last-child { color: var(--text-3); text-align: right; }
.copy-ssh { display: flex; align-items: center; gap: 8px; width: calc(100% - 24px); margin: 4px 12px 12px; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text-2); }
.copy-ssh:hover { border-color: var(--border-strong); }
.copy-ssh code { border: 0; background: none; padding: 0; font-size: 13px; }
.copy-ssh svg { width: 15px; height: 15px; }
.copy-ssh svg:last-child { margin-left: auto; color: var(--text-3); }
.opencode-panel { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.opencode-panel strong { display: block; font-size: 13px; }
.opencode-panel small { font-size: 12px; color: var(--text-3); }
.config-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; margin: 0; padding: 12px; }
.config-grid dt { font-size: 12px; color: var(--text-3); }
.config-grid dd { margin: 2px 0 0; font-size: 13px; color: var(--text); overflow-wrap: anywhere; }
.disk-config { display: flex; justify-content: space-between; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--border); font-size: 13px; color: var(--text-3); }
.disk-config strong { color: var(--text); font-weight: 560; }
.vm-token-card, .billing-block { padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.vm-token-heading, .billing-title { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.vm-token-scope { font-size: 12px; color: var(--text-3); }
.vm-token-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 8px 0; }
.vm-token-stats small { display: block; font-size: 12px; color: var(--text-3); }
.vm-token-stats strong { font-size: 20px; font-weight: 680; color: var(--text); font-variant-numeric: tabular-nums; }
.vm-token-card p, .vm-token-empty { margin: 0; font-size: 12px; color: var(--text-3); }
.billing-amount { display: block; margin: 6px 0 2px; font-size: 22px; font-weight: 680; color: var(--text); font-variant-numeric: tabular-nums; }
.billing-amount.unknown-amount { color: var(--text-3); }
.billing-status-message, .billing-checked { display: block; font-size: 12px; color: var(--text-3); }
.billing-block p { margin: 6px 0 0; font-size: 12px; color: var(--text-3); }
.billing-block details { margin-top: 8px; }
.billing-block details > summary { padding: 4px 0; }
.billing-block details a { color: var(--accent-text); }
.budget-summary { padding: 8px 12px; border-radius: var(--radius-sm); background: var(--info-bg); color: var(--info); font-size: 13px; font-weight: 560; }
.budget-summary.budget-alert { background: var(--warning-bg); color: var(--warning); }
.active-work { margin: 0; padding: 8px 12px; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--accent-text); font-size: 13px; font-weight: 560; }
.card-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface-2); }
.card-actions .vm-action { margin-left: auto; }
.card-timestamp { display: flex; align-items: center; gap: 6px; padding: 8px 18px 12px; background: var(--surface-2); font-size: 12px; color: var(--text-3); }
.timestamp-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); }
.timestamp-dot.stale { background: var(--warning); }
.empty-state, .loading-state { grid-column: 1 / -1; padding: 44px 20px; border: 1px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface); text-align: center; color: var(--text-3); }
.empty-state > span { display: block; font-size: 30px; margin-bottom: 6px; color: var(--text-4); }
.empty-state h3 { margin-bottom: 4px; }
.loading-orbit { display: block; width: 26px; height: 26px; margin: 0 auto 12px; border: 2.5px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }

/* ---------- Setup ---------- */
.setup-board { padding: 20px; }
.setup-board > header { margin-bottom: 16px; }
.setup-apps { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 12px; }
.setup-card { display: flex; flex-direction: column; gap: 10px; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.setup-card > div:first-child { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.setup-card > div:first-child strong { font-size: 15px; }
.setup-card > p { margin: 0; color: var(--text-2); font-size: 13px; }
.setup-card-actions { margin-top: auto; }
.setup-intro { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.setup-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; counter-reset: step; }
.setup-step { position: relative; padding: 12px 14px 12px 46px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); counter-increment: step; }
.setup-step::before { content: counter(step); position: absolute; left: 12px; top: 11px; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--surface-3); color: var(--text-2); font-size: 12px; font-weight: 700; }
.setup-step > div:first-child { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.setup-step-body { margin-top: 8px; font-size: 13px; color: var(--text-2); display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.setup-step-body p { margin: 0; }
.setup-command { display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 6px 6px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.setup-command code { flex: 1; border: 0; background: none; padding: 0; }
.setup-results { margin: 0; padding-left: 20px; font-size: 13px; color: var(--success); }

/* ---------- Operations ---------- */
.deployment-status { display: flex; flex-wrap: wrap; gap: 10px 24px; align-items: center; }
.deployment-status > div { display: flex; flex-direction: column; gap: 2px; font-size: 13px; color: var(--text-3); }
.deployment-status strong { color: var(--text); font-size: 14px; }
.deployment-status a { color: var(--accent-text); }
#deployment-status { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; }
#deployment-status > .deployment-status { align-self: stretch; }
#deployment-status:empty { display: none; }
.gateway-panel { display: flex; justify-content: space-between; align-items: center; gap: 24px; flex-wrap: wrap; }
.gateway-copy { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.gateway-copy p { margin: 0; }
.gateway-controls { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.gateway-controls p { margin: 0; }
.usage-section { display: flex; flex-direction: column; gap: 14px; }
.usage-section > .section-heading { margin: 0; }
.usage-account { overflow: hidden; }
.usage-account.usage-stale .usage-grid { opacity: .7; }
.usage-account-meta { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 18px; border-bottom: 1px solid var(--border); font-size: 13px; color: var(--text-2); }
.account-plan { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.account-plan i { width: 8px; height: 8px; border-radius: 50%; background: var(--success); }
.usage-source, .report-note { font-weight: 450; color: var(--text-3); font-size: 12px; }
.usage-grid { display: grid; grid-template-columns: minmax(240px, 1fr) minmax(0, 2fr); gap: 24px; padding: 18px; }
.quota-panel { display: flex; flex-direction: column; gap: 14px; }
.quota-panel h3 { font-size: 14px; }
.quota-window-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 13px; color: var(--text-2); }
.quota-window-head strong { font-size: 18px; font-variant-numeric: tabular-nums; }
.quota-window-head small { font-size: 12px; font-weight: 500; color: var(--text-3); }
.quota-window p { margin: 4px 0 0; font-size: 12px; color: var(--text-3); }
meter { display: block; width: 100%; height: 8px; margin-top: 6px; border: 0; border-radius: 999px; background: var(--surface-3); appearance: none; -webkit-appearance: none; }
meter::-webkit-meter-bar { height: 8px; border: 0; border-radius: 999px; background: var(--surface-3); }
meter::-webkit-meter-optimum-value, meter::-webkit-meter-suboptimum-value, meter::-webkit-meter-even-less-good-value { border-radius: 999px; background: var(--chart-1); }
meter::-moz-meter-bar { border-radius: 999px; background: var(--chart-1); }
.quota-window.low meter::-webkit-meter-optimum-value { background: var(--warning); }
.quota-window.critical meter::-webkit-meter-optimum-value { background: var(--danger); }
.quota-window.low meter::-moz-meter-bar { background: var(--warning); }
.quota-window.critical meter::-moz-meter-bar { background: var(--danger); }
.token-activity { display: flex; flex-direction: column; gap: 10px; min-width: 0; padding-left: 24px; border-left: 1px solid var(--border); }
.activity-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.activity-heading strong { display: block; font-size: 26px; font-weight: 680; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.activity-heading small { font-size: 12px; color: var(--text-3); }
.chart-ranges { display: inline-flex; gap: 2px; padding: 3px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-3); }
.chart-range { min-height: 26px; padding: 2px 10px; border: 0; border-radius: 6px; background: transparent; color: var(--text-3); font-size: 12px; font-weight: 600; }
.chart-range.selected, .chart-range.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.token-graph, .vm-token-graph, .resource-chart svg { width: 100%; height: auto; overflow: visible; }
.chart-grid { stroke: var(--chart-grid); stroke-width: 1; }
.chart-axis { fill: var(--chart-axis); font-size: 11px; font-family: var(--font); }
.chart-line { fill: none; stroke: var(--chart-1); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.area-stop-top { stop-color: var(--chart-area); stop-opacity: .28; }
.area-stop-bottom { stop-color: var(--chart-area); stop-opacity: .02; }
.chart-hit { fill: transparent; }
.chart-dot { fill: var(--surface); stroke: var(--chart-1); stroke-width: 2; }
.chart-tooltip { opacity: 0; pointer-events: none; transition: opacity .12s; }
.chart-tooltip rect { fill: var(--text); }
.chart-tooltip text { fill: var(--surface); font-size: 12px; font-weight: 600; font-family: var(--font); }
.chart-point:hover .chart-tooltip, .chart-point:focus .chart-tooltip { opacity: 1; }
.chart-point:focus { outline: none; }
.chart-point:focus .chart-dot { stroke-width: 3; }
.series-line { stroke: var(--chart-1); }
.series-dot { fill: var(--chart-1); }
.series-line.series-memory { stroke: var(--chart-2); }
.series-dot.series-memory { fill: var(--chart-2); }
.series-line.series-disk { stroke: var(--chart-3); }
.series-dot.series-disk { fill: var(--chart-3); }
.chart-data table, .vm-token-table table { margin: 0; }
.chart-data > :not(summary), .vm-token-table > div, .vm-token-coverage > p { padding: 0 12px 10px; }
.vm-token-coverage > p { margin: 10px 0 0; font-size: 12px; color: var(--text-3); }
.usage-account-footer { display: flex; flex-wrap: wrap; gap: 8px 20px; padding: 10px 18px; border-top: 1px solid var(--border); background: var(--surface-2); font-size: 12px; color: var(--text-3); }
.usage-account-footer b { color: var(--text); }
.usage-cadence { margin-left: auto; }

/* ---------- Dialogs ---------- */
dialog { color: var(--text); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); padding: 0; }
dialog::backdrop { background: var(--backdrop); backdrop-filter: blur(2px); }
.confirm-dialog, #stop-dialog, .feature-confirm { width: min(460px, calc(100vw - 32px)); border-radius: var(--radius-lg); }
.confirm-dialog > form, #stop-dialog > form, .feature-confirm > form { padding: 24px; }
.confirm-dialog h2 { font-size: 19px; margin-bottom: 8px; }
.confirm-dialog p:not(.eyebrow) { color: var(--text-2); font-size: 14px; }
.dialog-icon { display: grid; place-items: center; width: 42px; height: 42px; margin-bottom: 14px; border-radius: 11px; background: var(--danger-bg); color: var(--danger); }
.retain-note { margin-top: 12px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--success-bg); color: var(--success); font-size: 13px; }
.check-label { display: flex !important; flex-direction: row !important; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }
.check-label input { width: 16px; height: 16px; accent-color: var(--accent); }
#interrupt-choice[hidden] { display: none !important; }

/* Manage panel: a right-hand sheet. */
.workspace-panel {
  position: fixed; inset: 0 0 0 auto; margin: 0;
  width: min(780px, 100vw); max-width: none; height: 100vh; max-height: none;
  border-width: 0 0 0 1px; border-radius: 0;
  overflow: hidden;
}
.workspace-panel[open] { display: flex; flex-direction: column; animation: sheet-in .2s ease-out; }
@keyframes sheet-in { from { transform: translateX(24px); opacity: .5; } }
#workspace-panel-content { display: flex; flex-direction: column; min-height: 0; height: 100%; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 20px 24px 16px; border-bottom: 1px solid var(--border); }
.panel-identity { display: flex; gap: 14px; align-items: center; min-width: 0; }
.panel-avatar { display: grid; place-items: center; width: 44px; height: 44px; flex-shrink: 0; border-radius: 12px; background: var(--accent-soft); color: var(--accent-text); font-weight: 700; }
.panel-heading { min-width: 0; }
.panel-heading .eyebrow { margin-bottom: 2px; }
.panel-title-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.panel-title-line h2 { font-size: 20px; }
.panel-subtitle { margin: 2px 0 0; color: var(--text-3); font-size: 13px; }
.panel-close { display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text-3); font-size: 20px; line-height: 1; }
.panel-close:hover { background: var(--surface-3); color: var(--text); }
.panel-tabs { display: flex; gap: 2px; padding: 0 16px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: thin; }
.panel-tabs button { display: inline-flex; align-items: center; gap: 7px; padding: 12px 10px; margin-bottom: -1px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--text-3); font-size: 13px; font-weight: 580; white-space: nowrap; }
.panel-tabs button svg { width: 16px; height: 16px; }
.panel-tabs button:hover { color: var(--text); }
.panel-tabs button.selected, .panel-tabs button[aria-selected="true"] { color: var(--accent-text); border-bottom-color: var(--accent); }
.panel-body { flex: 1; min-height: 0; overflow-y: auto; padding: 20px 24px 28px; display: flex; flex-direction: column; gap: 14px; }
.panel-body > * { margin: 0; flex-shrink: 0; }
.panel-section-title { font-size: 14px; margin-top: 8px; }
.panel-intro { font-size: 13px; }
.readiness-banner { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface-2); }
.readiness-banner > div { flex: 1; min-width: 0; }
.readiness-banner strong { display: block; }
.readiness-banner small { color: var(--text-3); font-size: 12px; }
.readiness-banner a { color: var(--accent-text); font-weight: 580; white-space: nowrap; }
.readiness-symbol { display: grid; place-items: center; width: 36px; height: 36px; flex-shrink: 0; border-radius: 50%; background: var(--surface-3); color: var(--text-3); font-size: 16px; font-weight: 700; }
.readiness-banner.is-healthy { border-color: var(--success-border); background: var(--success-bg); }
.readiness-banner.is-healthy .readiness-symbol { background: var(--success); color: var(--surface); }
.readiness-banner.is-waiting { border-color: var(--warning-border); background: var(--warning-bg); }
.readiness-banner.is-waiting .readiness-symbol { background: var(--warning); color: var(--surface); }
.manage-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.manage-facts > div { padding: 10px 12px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); margin: 0 -1px -1px 0; }
.manage-facts span { display: block; font-size: 11px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--text-4); }
.manage-facts strong { display: block; margin-top: 3px; font-size: 14px; overflow-wrap: anywhere; }
.resource-grid { display: grid; gap: 12px; }
.resource-chart { padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.resource-chart > div:first-child { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.resource-chart h4 { margin-bottom: 6px; }
.resource-chart strong { font-size: 18px; font-variant-numeric: tabular-nums; }
.resource-chart small, .resource-chart p { font-size: 12px; color: var(--text-3); }
.cost-bars { display: flex; flex-direction: column; gap: 6px; }
.cost-bars > div { display: grid; grid-template-columns: 1fr 70px 90px; gap: 10px; align-items: center; font-size: 12px; color: var(--text-3); }
.cost-bars meter { margin: 0; }
.cost-bars strong { font-size: 13px; color: var(--text); text-align: right; }
.vm-usage-panel { display: flex; flex-direction: column; gap: 12px; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); }
.vm-usage-panel .vm-token-heading p { margin: 2px 0 0; font-size: 12px; color: var(--text-3); }
.vm-token-chart-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; font-weight: 580; }
.vm-token-subtitle { font-size: 13px; }
.vm-token-breakdown { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.vm-token-breakdown > div { padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.vm-token-breakdown span { display: block; font-size: 12px; color: var(--text-3); }
.vm-token-breakdown strong { font-size: 16px; font-variant-numeric: tabular-nums; }
.vm-token-footnote { font-size: 12px; color: var(--text-3); }
.git-panel-summary { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; font-size: 13px; color: var(--text-2); }
.git-panel-summary a { margin-left: auto; color: var(--accent-text); font-weight: 580; }
.file-list, .commit-list, .event-list, .backup-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.file-list:empty, .commit-list:empty { display: none; }
.file-list li, .commit-list li { display: flex; gap: 10px; align-items: flex-start; padding: 8px 12px; border-top: 1px solid var(--border); font-size: 13px; }
.file-list li:first-child, .commit-list li:first-child, .event-list li:first-child { border-top: 0; }
.commit-list li small { display: block; color: var(--text-3); font-size: 12px; }
.event-list li { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: start; padding: 10px 12px; border-top: 1px solid var(--border); }
.event-list strong { display: block; font-size: 13px; font-weight: 580; }
.event-list small, .event-list time { font-size: 12px; color: var(--text-3); }
.event-dot { width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; background: var(--accent); }
.backup-list a { display: flex; justify-content: space-between; gap: 10px; padding: 10px 12px; border-top: 1px solid var(--border); font-size: 13px; }
.backup-list a:first-child { border-top: 0; }
.backup-list a:hover { background: var(--surface-2); }
.backup-list small { display: block; color: var(--text-3); font-size: 12px; }
.backup-list:empty { display: none; }
.checkpoint-intro { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.checkpoint-intro p { margin: 0; color: var(--text-2); font-size: 13px; }
.log-controls { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.service-logs { display: flex; flex-direction: column; gap: 8px; }
.service-list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.service-list > div { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 9px 12px; border-top: 1px solid var(--border); font-size: 13px; }
.service-list > div:first-child { border-top: 0; }
.service-list > p { margin: 0; padding: 12px; }
.service-name { display: inline-flex; align-items: center; gap: 8px; font-weight: 580; }
.service-name i { width: 8px; height: 8px; border-radius: 50%; background: var(--success); }
.service-list strong { font-weight: 500; color: var(--text-3); text-align: right; }
.panel-section-title span { color: var(--text-3); font-weight: 500; }
.job-ready { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; padding: 14px 16px; border: 1px solid var(--success-border); border-radius: var(--radius); background: var(--success-bg); }
.job-ready a { color: var(--accent-text); font-weight: 580; }
.ssh-box { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.ssh-box > div { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ssh-box .field-caption { font-size: 11px; font-weight: 650; letter-spacing: .06em; color: var(--text-4); }

/* ---------- Forms ---------- */
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 560; color: var(--text-2); }
input:not([type="checkbox"]):not([type="radio"]), select, textarea {
  width: 100%; min-height: 38px; padding: 8px 11px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 450;
}
textarea { resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px var(--accent-soft); }
.search input[type="search"] { min-height: 0; padding: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none !important; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }
.settings-form { display: flex; flex-direction: column; gap: 16px; }
.settings-form section { display: flex; flex-direction: column; gap: 10px; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); }
.settings-form section p { margin: 0; font-size: 13px; color: var(--text-3); }
.settings-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.weekdays { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; border: 0; }
.weekdays legend { margin-bottom: 6px; font-size: 13px; font-weight: 560; color: var(--text-2); }
.weekdays label { flex-direction: row; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-weight: 520; }
.weekdays label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); }
.field-caption { margin: 0; font-size: 12px; color: var(--text-3); }
.select-inline { flex-direction: row; align-items: center; gap: 8px; }
.select-inline span { white-space: nowrap; }
.select-inline select { width: auto; min-width: 140px; }
.inline-form { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }

/* ---------- Factory tasks ---------- */
.tasks-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; align-items: start; }
.tasks-main { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.tasks-main > .section-heading { margin: 0; }
#factory-readiness { margin: 4px 0 0; color: var(--text-3); font-size: 13px; }
.draft-dialog { width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); }
.factory-draft { display: flex; flex-direction: column; gap: 12px; padding: 20px; }
.factory-draft p { margin: 0; }
.factory-draft .dialog-actions { margin-top: 4px; }
.draft-dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.draft-dialog-head h2 { margin: 0; font-size: 19px; }
#factory-new-draft[hidden] { display: none; }
.task-list { display: flex; flex-direction: column; gap: 12px; }
.task-card { display: flex; flex-direction: column; gap: 10px; padding: 16px 18px; }
.task-card.state-failed { border-color: var(--danger-border); }
.task-card.state-awaiting_review { border-color: var(--success-border); }
.task-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.task-head h3 { font-size: 15px; }
.task-meta { margin: 0; font-size: 12px; color: var(--text-3); }
/* Attempt · Heartbeat · Budget as one line of label/value pairs, not three boxes. */
.task-facts { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 0; font-size: 12.5px; }
.task-facts div { display: flex; gap: 5px; min-width: 0; }
.task-facts dt { color: var(--text-3); font-weight: 600; }
.task-facts dd { margin: 0; color: var(--text); overflow-wrap: anywhere; }
.task-instruction > p { margin: 0; padding: 10px 12px; white-space: pre-wrap; font-size: 13px; color: var(--text-2); }
.task-result { padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid var(--success-border); background: var(--success-bg); }
.task-result.is-error { border-color: var(--danger-border); background: var(--danger-bg); }
.task-summary { margin: 0 0 6px; font-weight: 620; color: var(--text); }
.task-result-facts { margin: 0; padding-left: 18px; font-size: 12px; color: var(--text-2); }
.task-history ol { margin: 0; padding: 10px 12px 10px 32px; font-size: 12px; color: var(--text-3); }

/* ---------- Product context ---------- */
.product-hero { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.product-hero h2 { font-size: 22px; margin-bottom: 6px; }
.product-vision { max-width: 760px; color: var(--text-2); font-size: 15px; }
.fact-list { display: grid; gap: 8px 20px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin: 0; }
.fact-list dt { font-size: 12px; color: var(--text-3); }
.fact-list dd { margin: 2px 0 0; font-size: 13px; color: var(--text); overflow-wrap: anywhere; }
.product-hero .fact-list { min-width: 220px; align-content: start; }
.product-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.product-grid .span-2 { grid-column: 1 / -1; }
.card > h2 { margin-bottom: 12px; }
.item-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.item-list li { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 9px 0; border-top: 1px solid var(--border); font-size: 14px; color: var(--text-2); }
.item-list li:first-child { border-top: 0; padding-top: 0; }
.item-list code { white-space: nowrap; flex-shrink: 0; }
.item-list.numbered { counter-reset: item; }
.item-list.numbered li { justify-content: flex-start; counter-increment: item; }
.item-list.numbered li::before { content: counter(item); display: grid; place-items: center; width: 22px; height: 22px; flex-shrink: 0; border-radius: 50%; background: var(--accent-soft); color: var(--accent-text); font-size: 12px; font-weight: 700; }
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.timeline li:not(.panel-empty) { position: relative; padding: 0 0 16px 22px; border-left: 2px solid var(--border); margin-left: 5px; }
.timeline li:not(.panel-empty)::before { content: ""; position: absolute; left: -7px; top: 3px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); }
.timeline li:last-child { padding-bottom: 0; }
.timeline-meta { display: flex; gap: 10px; align-items: baseline; font-size: 13px; }
.timeline-meta time { color: var(--text-3); font-size: 12px; }
.timeline p { margin: 4px 0 0; color: var(--text-2); }
.run-list { display: flex; flex-direction: column; gap: 8px; }
.run > summary { display: flex; align-items: center; gap: 10px; padding: 10px 12px; list-style: none; font-size: 13px; font-weight: 580; }
.run[open] > summary { border-bottom: 1px solid var(--border); }
.run > .fact-list, .run > p { padding: 12px; margin: 0; }
.proposals { display: flex; flex-direction: column; gap: 12px; }
.proposals > .section-heading { margin: 0; }
.proposal { display: flex; flex-direction: column; gap: 10px; }
.proposal p { margin: 0; }
.proposal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.check-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.check-list li { position: relative; padding-left: 22px; font-size: 14px; color: var(--text-2); }
.check-list li::before { content: ""; position: absolute; left: 2px; top: 5px; width: 10px; height: 6px; border-left: 2px solid var(--success); border-bottom: 2px solid var(--success); transform: rotate(-45deg); }
.evidence ul { margin: 0; padding: 10px 12px 10px 30px; font-size: 13px; color: var(--text-2); }
.proposal-actions p { margin: 0; }

/* ---------- Sign in ---------- */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1200px 600px at 50% -10%, var(--accent-soft), transparent 70%), var(--bg); }
.login-card { width: 100%; max-width: 420px; padding: 36px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); }
.login-card .brand-mark { margin-bottom: 24px; width: 42px; height: 42px; font-size: 24px; }
.login-card h1 { font-size: 26px; margin-bottom: 8px; }
.login-card .muted { font-size: 14px; }
.login-card .error-box { margin: 12px 0 0; }
.login-button { width: 100%; justify-content: space-between; margin-top: 20px; min-height: 44px; font-size: 14px; }
.login-card small { display: block; margin-top: 14px; font-size: 12px; color: var(--text-3); }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .overview { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .usage-grid { grid-template-columns: 1fr; }
  .token-activity { padding-left: 0; padding-top: 18px; border-left: 0; border-top: 1px solid var(--border); }
  .account-email { display: none; }
}
@media (max-width: 960px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 50; width: min(300px, 86vw);
    transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg);
  }
  .app-shell.nav-open .sidebar { transform: none; }
  .app-shell.nav-open .nav-scrim { display: block; position: fixed; inset: 0; z-index: 40; background: var(--backdrop); }
  .topbar .nav-toggle { display: inline-grid; }
  .topbar { padding: 10px 16px; gap: 10px; }
  .content { padding: 18px 16px 28px; }
  .label-wide { display: none; }
  .topbar-actions .button { padding: 7px 10px; }
}
@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; }
  .topbar-title { order: 3; flex-basis: 100%; }
  .topbar-actions { margin-left: auto; }
  .topbar-subtitle { white-space: normal; }
  .topbar-actions { gap: 6px; }
  .account { border-left: 0; padding-left: 0; margin-left: 0; }
  .account .avatar { display: none; }
  .overview { gap: 10px; }
  .metric { flex-wrap: wrap; padding: 14px; gap: 10px; }
  .metric-caption { position: static; flex-basis: 100%; }
  .metric-icon, .fleet-mini, .fleet-mini svg { width: 36px; height: 36px; }
  .metric strong { font-size: 24px; }
  .metric-caption { font-size: 12px; }
  .toolbar-title { flex-basis: 100%; }
  .filter-tabs { flex: 1 1 100%; }
  .filter-tab { flex: 1; padding: 4px 6px; }
  .search { flex: 1 1 100%; }
  .search input { width: 100%; }
  .card-head, .card-body, .card-actions { padding-left: 14px; padding-right: 14px; }
  .environment-line, .card-timestamp { padding-left: 14px; padding-right: 14px; }
  .status-grid { grid-template-columns: 1fr; }
  .status-grid > div + div { border-left: 0; border-top: 1px solid var(--border); }
  .runtime-expanded, .config-grid, .vm-token-breakdown { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card-actions .vm-action { margin-left: 0; }
  .gateway-controls { align-items: flex-start; }
  .product-grid { grid-template-columns: 1fr; }
  .task-head { flex-direction: column; gap: 6px; }
  .workspace-panel { width: 100vw; border-left: 0; }
  .panel-head, .panel-body { padding-left: 16px; padding-right: 16px; }
  .content-footer .footer-end { margin-left: 0; flex-basis: 100%; }
}
.panel-tabs button:focus-visible { outline-offset: -4px; }

/* ---------- Factory operations ---------- */
/* Compact metric tiles (Factory and Applications overviews) */
.compact-metrics { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
.compact-metrics .metric { display: flex; align-items: center; gap: 10px; padding: 10px 12px; }
.compact-metrics .metric > div { min-width: 0; }
.compact-metrics .metric small { font-size: 12px; }
.compact-metrics .metric strong { font-size: 20px; line-height: 1.2; }
.compact-metrics .metric-caption { position: static; display: block; margin-top: 2px; font-size: 11.5px; line-height: 1.3; }
.compact-metrics .metric-icon, .compact-metrics .fleet-mini, .compact-metrics .fleet-mini svg { width: 32px; height: 32px; border-radius: 9px; }
.compact-metrics .metric-icon .icon { width: 17px; height: 17px; }
.metric-body { display: flex; flex-direction: column; min-width: 0; }
@media (max-width: 640px) {
  .compact-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .factory-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .compact-metrics .metric { padding: 8px 10px; flex-wrap: nowrap; }
  .compact-metrics .metric strong { font-size: 17px; }
  .compact-metrics .metric small, .compact-metrics .metric-caption { font-size: 11px; }
  .compact-metrics .metric-icon, .compact-metrics .fleet-mini { display: none; }
}
.alert-list:empty { display: none; }
.alert-list { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px; border: 1px solid var(--warning-border); border-radius: var(--radius); background: var(--warning-bg); }
.alert-list h3 { font-size: 14px; color: var(--warning); }
.alert-row { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border); }
.alert-row > div { flex: 1; min-width: 0; }
.alert-row strong { display: block; font-size: 13px; }
.alert-row small { color: var(--text-3); font-size: 12px; }
.factory-projects { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 520px), 1fr)); gap: 16px; align-items: start; }
.factory-project { display: flex; flex-direction: column; gap: 12px; }
.factory-project h4 { font-size: 13px; color: var(--text-2); }
.factory-project-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.autonomy-panel { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; border: 1px solid var(--accent-soft); border-radius: var(--radius); background: color-mix(in srgb, var(--accent-soft) 45%, var(--surface)); }
.autonomy-panel.is-off { border-color: var(--border); background: var(--surface-2); }
.autonomy-panel p { margin: 0; }
.autonomy-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.autonomy-head small { display: block; color: var(--text-3); font-size: 12px; }
.blocker-list, .attestations, .pr-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.blocker-list li { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; border-radius: var(--radius-sm); border: 1px solid var(--warning-border); background: var(--surface); font-size: 13px; }
.blocker-list code { align-self: flex-start; }
.attestations li { position: relative; padding-left: 20px; font-size: 13px; color: var(--text-2); }
.attestations li::before { content: ""; position: absolute; left: 2px; top: 6px; width: 9px; height: 9px; border-radius: 50%; background: var(--warning); }
.attestations li.ok::before { background: var(--success); }
.pr-list li { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }
.task-rows { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; }
.task-row { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); text-align: left; font-size: 13px; }
.task-row:hover { border-color: var(--border-strong); background: var(--surface-2); }
.task-row-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 560; }
.table-scroll { overflow-x: auto; padding: 0 12px 10px; }
.run-stage { display: block; margin-top: 4px; font-size: 11.5px; }
.run-links { display: inline-flex; flex-wrap: wrap; gap: 12px; margin-top: 4px; }
.run-task-link { padding: 0; border: 0; background: none; font: inherit; cursor: pointer; }
.factory-task-sheet { display: flex; flex-direction: column; min-height: 0; height: 100%; }
.task-detail-facts { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.chip.origin-auto { background: var(--accent-soft); border-color: transparent; color: var(--accent-text); }
@media (max-width: 640px) { .task-row .muted { display: none; } .alert-row { flex-wrap: wrap; } }

/* ---------- Claude Code, dev sync, passwords ---------- */
.claude-panel { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.claude-panel strong { display: block; font-size: 13px; }
.claude-panel small { font-size: 12px; color: var(--text-3); }
.claude-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.claude-usage { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.claude-usage strong { font-size: 18px; font-variant-numeric: tabular-nums; }
.claude-note { margin: 0; font-size: 12px; color: var(--text-3); }
.sync-line { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 12px; color: var(--text-3); }
.sync-line span { flex: 1; min-width: 0; }
.sync-line b { color: var(--text-2); font-weight: 600; }
.sync-line.sync-updated, .sync-line.sync-current { color: var(--success); }
.sync-line.sync-blocked, .sync-line.sync-failed { color: var(--warning); }
.password-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 12px; color: var(--text-3); }
.password-row span { font-weight: 600; margin-right: 4px; }
.password-row .button { min-height: 30px; padding: 4px 10px; font-size: 12px; }

/* ---------- Secrets ---------- */
.secrets-connect { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; max-width: 680px; }
.secrets-connect p { margin: 0; }
.secrets-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 460px), 1fr)); gap: 14px; align-items: start; }
.secrets-group h3 { text-transform: capitalize; margin-bottom: 8px; }
.secret-list { list-style: none; margin: 0; padding: 0; }
.secret-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-top: 1px solid var(--border); }
.secret-list li:first-child { border-top: 0; }
.secret-list li > div { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; min-width: 0; }
.secret-list code { overflow-wrap: anywhere; }
.secret-list small { flex-basis: 100%; font-size: 12px; color: var(--text-3); }
.secret-list .button { min-height: 30px; padding: 4px 12px; font-size: 12px; flex-shrink: 0; }
.chip.sensitive { background: var(--warning-bg); border-color: var(--warning-border); color: var(--warning); }
.chip.origin-trigger { background: var(--info-bg); border-color: transparent; color: var(--info); }

/* Application page (#app/<name>) */
.app-page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.app-page-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.app-section { padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.app-section.span-2 { grid-column: 1 / -1; }
.app-section h2 { margin: 0; font-size: 15px; font-weight: 650; }
.app-section h3 { margin: 6px 0 0; font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-3); }
.app-section p { margin: 0; }
.app-section .container-list { padding: 0; }
.app-section .resource-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 1180px) { .app-section .resource-grid { grid-template-columns: minmax(0, 1fr); } }
.fact-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px 16px; margin: 0; }
.fact-list dt { font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--text-3); }
.fact-list dd { margin: 2px 0 0; font-weight: 600; overflow-wrap: anywhere; }
.fact-list dd small { display: block; font-weight: 400; color: var(--text-3); font-size: 12px; text-transform: none; }
.mini-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.mini-list li { display: flex; align-items: center; gap: 10px; font-size: 13px; min-width: 0; }
.mini-list li > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-list .badge { flex: none; text-transform: capitalize; }
.app-name-link { color: inherit; text-decoration: none; }
.app-name-link:hover { text-decoration: underline; text-underline-offset: 3px; }
@media (max-width: 960px) { .app-page-grid { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Monitoring cards (signals at a glance) ---------- */
.app-card { gap: 0; }
.app-card .card-head { padding: 16px 18px 12px; }
.app-sub { display: block; font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-card.state-bad { border-color: var(--danger-border); box-shadow: inset 3px 0 0 var(--danger); }
.app-card.state-warn { border-color: var(--warning-border); box-shadow: inset 3px 0 0 var(--warning); }
.app-card.state-ok { box-shadow: inset 3px 0 0 var(--success); }
.app-card.state-off { box-shadow: inset 3px 0 0 var(--border-strong); }
.tone-ok { --tone: var(--success); --tone-bg: var(--success-bg); }
.tone-warn { --tone: var(--warning); --tone-bg: var(--warning-bg); }
.tone-bad { --tone: var(--danger); --tone-bg: var(--danger-bg); }
.tone-off, .tone-unknown { --tone: var(--text-4); --tone-bg: var(--surface-3); }
.signal-dot { display: inline-block; width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--tone, var(--text-4)); }
.tone-bad .signal-dot { box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 22%, transparent); }
.state-pill { display: inline-flex; align-items: center; gap: 7px; padding: 4px 10px; border-radius: 999px; background: var(--tone-bg); color: var(--tone); font-size: 12px; font-weight: 650; white-space: nowrap; }
.tone-off.state-pill, .tone-unknown.state-pill { color: var(--text-3); }
.signal-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; margin: 0 18px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.signal { display: grid; grid-template-columns: auto 1fr; align-items: center; column-gap: 7px; padding: 8px 10px; background: var(--surface); color: inherit; text-decoration: none; min-width: 0; }
.signal .signal-dot { grid-row: span 2; }
.signal-name { font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.signal-value { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.signal:is(.tone-bad, .tone-warn) .signal-value { color: var(--tone); }
.signal:is(.tone-off, .tone-unknown) .signal-value { color: var(--text-3); font-weight: 500; }
a.signal:hover { background: var(--surface-2); }
a.signal .signal-value::after { content: " ↗"; color: var(--accent-text); }
.card-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; padding: 14px 18px 4px; }
.card-metric { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.card-metric span { font-size: 11px; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-metric strong { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-metric small { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-meter { display: block; width: 100%; height: 4px; }
.mini-meter .meter-track { fill: var(--surface-3); }
.mini-meter .meter-fill { fill: var(--accent); }
.mini-meter.warn .meter-fill { fill: var(--warning); }
.mini-meter.bad .meter-fill { fill: var(--danger); }
.commit-line { display: flex; align-items: center; gap: 8px; margin: 12px 18px 0; padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text-2); font-size: 13px; text-decoration: none; min-width: 0; }
.commit-line:hover { border-color: var(--border-strong); }
.commit-line svg { width: 14px; height: 14px; flex: none; color: var(--text-3); }
.commit-line code { flex: none; font-size: 12px; color: var(--text-3); }
.commit-text { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); font-weight: 550; }
.commit-when { flex: none; font-size: 12px; color: var(--text-3); }
.app-card .card-errors { margin: 10px 18px 0; }
.app-card .active-work { display: flex; align-items: center; gap: 8px; margin: 10px 18px 0; }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; transform: scale(.8); } }
.app-card .card-actions { margin-top: 14px; }
.app-card .card-actions .button { min-height: 34px; padding: 6px 12px; }
.card-zone { margin-left: auto; }
.layout-toggle .filter-tab { padding: 4px 10px; }

/* Table layout */
.app-grid.app-table-mode { display: block; }
.app-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.app-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.app-table th, .app-table td { padding: 10px 12px; border-top: 1px solid var(--border); text-align: left; white-space: nowrap; vertical-align: middle; }
.app-table thead th { border-top: 0; background: var(--surface-2); font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-3); position: sticky; top: 0; }
.app-table tbody th { font-weight: 650; }
.app-table tbody th small { display: block; font-weight: 400; font-size: 12px; color: var(--text-3); }
.app-table tbody tr:hover { background: var(--surface-2); }
.app-table tr.state-bad th[scope="row"] { box-shadow: inset 3px 0 0 var(--danger); }
.app-table tr.state-warn th[scope="row"] { box-shadow: inset 3px 0 0 var(--warning); }
.app-table tr.state-ok th[scope="row"] { box-shadow: inset 3px 0 0 var(--success); }
.table-signal { display: inline-flex; align-items: center; gap: 6px; }
.table-signal:is(.tone-bad, .tone-warn) { color: var(--tone); font-weight: 600; }
.table-signal:is(.tone-off, .tone-unknown) { color: var(--text-3); }
.table-signal a { color: inherit; text-decoration: underline; text-underline-offset: 3px; }
.app-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.row-actions .button { min-height: 30px; padding: 4px 10px; }
.row-actions .vm-action svg { margin: 0; }

@media (max-width: 640px) {
  .signal-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 0 14px; }
  .card-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 12px 14px 0; }
  .commit-line, .app-card .card-errors, .app-card .active-work { margin-left: 14px; margin-right: 14px; }
  .commit-when { display: none; }
  .layout-toggle { flex: 1 1 100%; }
}
.idle-note { display: flex; align-items: center; gap: 8px; margin: 0 18px; padding: 12px 14px; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); color: var(--text-3); font-size: 13px; }
.idle-note svg { width: 15px; height: 15px; flex: none; }
.app-table .idle-cell { color: var(--text-3); font-style: italic; }
.app-table th, .app-table td { padding: 10px 8px; }
.app-table th:first-child, .app-table td:first-child { padding-left: 14px; }
.app-table { font-size: 12.5px; }
@media (max-width: 640px) { .idle-note { margin: 0 14px; } }
.row-actions .button { min-width: 32px; justify-content: center; }
.app-table td:last-child { padding-right: 14px; }
.row-actions .button, .row-actions .vm-action { margin-left: 0; min-width: 32px; width: 32px; padding: 0; gap: 0; }
.app-table .state-pill { padding: 3px 8px; }
.app-table tbody th small { white-space: normal; max-width: 110px; }

/* Factory monitoring cards */
.app-card.factory-project { gap: 0; }
.factory-project .app-sub.repo-link { max-width: 260px; }
.factory-block { display: flex; flex-direction: column; gap: 8px; margin: 14px 18px 0; }
.factory-block h4 { margin: 0; font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--text-3); }
.factory-block .idle-note { margin: 0; }
.factory-now { display: flex; align-items: center; gap: 10px; padding: 4px 4px 4px 12px; border: 1px solid var(--accent-soft); border-radius: var(--radius-sm); background: var(--accent-soft); }
.factory-now .task-row { flex: 1; min-width: 0; background: transparent; border: 0; }
.factory-folds { display: flex; flex-direction: column; gap: 8px; margin: 14px 18px 0; }
.factory-folds .autonomy-panel { margin-top: 10px; }
.factory-project .pr-list { margin: 0; }
.factory-toolbar { justify-content: space-between; }
.card-more { display: none; }
@media (max-width: 640px) {
  .factory-toolbar .filter-tabs { flex: 1 1 auto; }
  .card-more {
    display: block; margin: 14px 14px 0; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--surface-2); color: var(--accent-text); font-size: 13px; font-weight: 580; text-align: left;
  }
  .card-more::after { content: ' ▾'; }
  .card-more[aria-expanded="true"]::after { content: ' ▴'; }
  .factory-project:not(.is-expanded) :is(.card-metrics, .factory-folds) { display: none; }
  .factory-project .card-metrics { padding-top: 12px; }
  .factory-block, .factory-folds { margin-left: 14px; margin-right: 14px; }
  /* App cards: actions stay on one row; Start/Stop shows only its icon. */
  .app-card:not(.factory-project) .card-actions { flex-wrap: nowrap; gap: 6px; }
  .app-card:not(.factory-project) .card-actions .button { padding: 6px 10px; }
  .app-card .card-actions .vm-action { margin-left: auto; padding: 6px 9px; }
  .app-card .vm-action .vm-label { display: none; }
  /* The table needs a wide screen; phones choose between Cards and Map. */
  .layout-toggle [data-layout="table"] { display: none; }
}
.factory-project .pr-list li { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

/* Tasks: current work, then history */
.task-section { display: flex; flex-direction: column; gap: 12px; }
.task-section + .task-section { margin-top: 24px; }
.task-section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.task-section-head h3 { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 15px; }
.task-section .idle-note { margin: 0; }
.task-fold { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.task-fold[open] { border-color: var(--border-strong); }
.task-fold > .task-card { margin: 0 10px 10px; box-shadow: none; }
.task-fold-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; cursor: pointer; list-style: none; font-size: 13px; }
.task-fold-row::-webkit-details-marker { display: none; }
.task-fold-row .task-row-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.task-fold-row .badge { flex: none; text-transform: capitalize; }
@media (max-width: 640px) {
  /* History rows: title on its own line, status, origin, date and PR underneath. */
  .task-fold-row { flex-wrap: wrap; gap: 6px 8px; }
  .task-fold-row .task-row-title { flex: 1 1 100%; order: -1; white-space: normal; }
  .task-section-head .filter-tabs { flex: 1 1 100%; }
}

/* Operations usage */
.usage-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.usage-tile { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); min-width: 0; }
.usage-tile small { font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-3); }
.usage-tile strong { font-size: 20px; font-variant-numeric: tabular-nums; }
.usage-tile span { font-size: 12px; color: var(--text-3); }
.usage-subtitle { margin: 16px 0 4px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.usage-bars { display: block; width: 100%; height: auto; }
.usage-bar { fill: var(--accent); opacity: .85; }
.usage-bar:hover { opacity: 1; }
.usage-split { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.usage-account .app-table-wrap { margin-top: 14px; box-shadow: none; }
.budget-cell .mini-meter { margin-top: 4px; width: 80px; margin-left: auto; }
@media (max-width: 760px) {
  .usage-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .usage-split { grid-template-columns: minmax(0, 1fr); }
  .factory-block, .factory-folds { margin-left: 14px; margin-right: 14px; }
}
#claude-usage .usage-account, #worker-usage .usage-account { padding: 16px 18px; }
.usage-split .usage-bars { max-height: 200px; }
.panel-back { align-self: flex-start; margin: 14px 24px 0; border: 0; background: none; padding: 0; cursor: pointer; }
.factory-detail-body .table-scroll { overflow-x: auto; }
.factory-project .task-rows { display: flex; flex-direction: column; gap: 6px; }

/* ---------- Infrastructure map ---------- */
.app-grid.app-map-mode { display: block; }
.infra-map { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); overflow: hidden; }
.infra-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.infra-legend { display: flex; flex-wrap: wrap; gap: 12px; margin-right: auto; font-size: 12px; color: var(--text-3); }
.infra-legend span { display: inline-flex; align-items: center; gap: 6px; }
.infra-zoom { display: flex; gap: 6px; }
.infra-zoom .icon-button { width: 32px; height: 32px; font-size: 18px; line-height: 1; }
.infra-zoom .button { min-height: 32px; padding: 4px 12px; }
.infra-canvas { position: relative; height: clamp(420px, 68vh, 720px); cursor: grab; touch-action: none;
  background-color: var(--surface);
  background-image: radial-gradient(circle, color-mix(in srgb, var(--text-4) 35%, transparent) 1px, transparent 1.2px);
  background-size: 22px 22px; }
.infra-canvas.is-dragging { cursor: grabbing; }
.app-section .infra-canvas { height: clamp(320px, 46vh, 460px); }
.infra-svg { display: block; width: 100%; height: 100%; user-select: none; }
.infra-hint { position: absolute; left: 14px; bottom: 10px; margin: 0; font-size: 11px; color: var(--text-4); pointer-events: none; }
.infra-column { font-size: 12px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; fill: var(--text-3); }

/* Edges */
.infra-edge-line { fill: none; stroke: var(--tone, var(--border-strong)); stroke-width: 1.6; opacity: .55; transition: opacity .2s, stroke-width .2s; }
.infra-edge.is-idle .infra-edge-line { stroke-dasharray: 4 5; opacity: .35; }
.infra-edge-flow { fill: none; stroke: var(--tone); stroke-width: 2.2; stroke-linecap: round; stroke-dasharray: 2 16; opacity: .9; animation: infra-flow 1.6s linear infinite; }
.infra-arrow { fill: var(--border-strong); }
.infra-port { fill: var(--surface); stroke: var(--tone, var(--border-strong)); stroke-width: 1.6; }
@keyframes infra-flow { to { stroke-dashoffset: -18; } }
@media (prefers-reduced-motion: reduce) { .infra-edge-flow { animation: none; } }
.infra-map.has-focus .infra-edge { opacity: .15; }
.infra-map.has-focus .infra-edge.is-lit { opacity: 1; }
.infra-edge.is-lit .infra-edge-line { opacity: 1; stroke-width: 2.4; }

/* Nodes */
.infra-node { cursor: pointer; transition: opacity .2s; outline: none; }
.infra-map.has-focus .infra-node:not(.is-linked):not(.kind-cluster) { opacity: .4; }
.infra-box { fill: var(--surface); stroke: var(--border-strong); stroke-width: 1; transition: stroke .15s, stroke-width .15s; }
.infra-node:hover > .infra-box, .infra-node:focus-visible > .infra-box { stroke: var(--accent); stroke-width: 1.6; }
.infra-node.is-selected > .infra-box { stroke: var(--accent); stroke-width: 2.4; }
.infra-stripe, .infra-dot { fill: var(--tone, var(--text-4)); }
.infra-node.tone-bad .infra-dot { stroke: color-mix(in srgb, var(--danger) 30%, transparent); stroke-width: 5; }
.infra-title { font-size: 13.5px; font-weight: 650; fill: var(--text); }
.infra-sub { font-size: 12px; fill: var(--text-3); }
.infra-caption { font-size: 11px; fill: var(--text-4); }
.infra-node.kind-chip:is(.tone-bad, .tone-warn) .infra-sub { fill: var(--tone); font-weight: 600; }
.infra-node.kind-cluster > .infra-box { fill: var(--surface-2); stroke: var(--border); stroke-width: 1.2; filter: drop-shadow(0 1px 2px rgb(0 0 0 / .06)); }
.infra-node.kind-cluster.tone-bad > .infra-box { stroke: var(--danger-border); }
.infra-node.kind-cluster.tone-warn > .infra-box { stroke: var(--warning-border); }
.infra-node.kind-cluster.tone-off { opacity: .75; }
.infra-head { fill: var(--tone-bg, var(--surface-3)); }
.infra-node.kind-cluster .infra-title { font-size: 15px; }
.infra-pill { fill: var(--surface); stroke: var(--tone, var(--border)); stroke-width: 1; }
.infra-pill-text { font-size: 11.5px; font-weight: 650; fill: var(--tone, var(--text-3)); }
.infra-node.kind-shared > .infra-box { stroke-width: 1.4; }
.infra-node.kind-repo > .infra-box { fill: var(--surface); }

/* Detail panel */
.infra-detail { position: absolute; top: 12px; right: 12px; width: min(320px, calc(100% - 24px)); max-height: calc(100% - 24px); overflow-y: auto; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); box-shadow: var(--shadow-md); cursor: default; }
.infra-detail header { display: flex; align-items: center; justify-content: space-between; }
.infra-detail h3 { margin: 8px 0 2px; font-size: 16px; overflow-wrap: anywhere; }
.infra-detail dl { display: flex; flex-direction: column; gap: 8px; margin: 12px 0 0; }
.infra-detail dt { font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-3); }
.infra-detail dd { margin: 1px 0 0; font-size: 13px; overflow-wrap: anywhere; }
.infra-links { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--border); }
.infra-links button { border: 0; background: none; padding: 0; cursor: pointer; font: inherit; }
.infra-detail .panel-close { position: static; }
@media (max-width: 640px) {
  .infra-legend { display: none; }
  .infra-detail { top: auto; bottom: 10px; max-height: 55%; }
  .infra-hint { display: none; }
}
/* Portrait map (phones, infra_map.js): drawn at about 1:1 and scrolled with the page; a tap
   opens the details as a sheet above the bottom navigation. */
.infra-map.is-portrait div.infra-canvas { height: auto; cursor: default; touch-action: pan-y pinch-zoom; }
.infra-map.is-portrait .infra-svg { height: auto; }
.infra-map.is-portrait .infra-zoom { display: none; }
.infra-map.is-portrait .infra-detail {
  position: fixed; z-index: 35; left: 8px; right: 8px; top: auto; width: auto; max-height: 55vh;
  bottom: calc(66px + env(safe-area-inset-bottom)); box-shadow: var(--shadow-lg);
}

/* ---------- Factory execution pipeline (factory_pipeline.js) ---------- */
.pipeline-wrap { min-width: 0; }
.factory-now + .pipeline-wrap { margin-top: 10px; }
.task-pipeline { margin: 2px 0; }
.pipeline { --node: 24px; display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); margin: 0; padding: 2px 0; list-style: none; }
.pipe-stage { position: relative; display: flex; flex-direction: column; align-items: center; gap: 5px; min-width: 0; text-align: center; }
/* The connector into a stage takes that stage's colour: how far the run got is visible at a glance. */
.pipe-stage:not(:first-child)::before { content: ""; position: absolute; top: calc(var(--node) / 2 - 1px); left: calc(-50% + var(--node) / 2 + 3px); right: calc(50% + var(--node) / 2 + 3px); height: 2px; border-radius: 1px; background: var(--border-strong); }
.pipe-stage.is-done::before { background: var(--success); }
.pipe-stage:is(.is-active, .is-waiting, .is-stalled)::before { background: linear-gradient(90deg, var(--success), var(--accent)); }
.pipe-stage.is-failed::before { background: var(--danger); }
.pipe-stage:is(.is-skipped, .is-pending)::before { background: none; border-top: 2px dashed var(--border); height: 0; }
.pipe-node { position: relative; display: grid; place-items: center; width: var(--node); height: var(--node); flex: none; border: 2px solid var(--border-strong); border-radius: 50%; background: var(--surface); color: var(--text-3); font-size: 12px; font-weight: 800; line-height: 1; }
.is-done > .pipe-node { border-color: var(--success); background: var(--success); color: #fff; }
.is-failed > .pipe-node { border-color: var(--danger); background: var(--danger); color: #fff; }
.is-stalled > .pipe-node { border-color: var(--warning); background: var(--warning); color: #fff; }
.is-cancelled > .pipe-node, .is-unknown > .pipe-node { border-color: var(--border-strong); background: var(--surface-3); color: var(--text-3); }
.is-skipped > .pipe-node { border-style: dashed; border-color: var(--border); color: var(--text-4); }
.is-waiting > .pipe-node { border-color: var(--warning); border-style: dashed; background: var(--warning-bg); }
.is-active > .pipe-node { border-color: var(--accent-soft); background: var(--accent-soft); }
.is-active > .pipe-node::after { content: ""; position: absolute; inset: -2px; border: 2px solid transparent; border-top-color: var(--accent); border-right-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
.pipe-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; max-width: 100%; }
.pipe-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11.5px; font-weight: 650; color: var(--text-2); }
.is-active .pipe-label { color: var(--accent-text); }
.is-failed .pipe-label { color: var(--danger); }
:is(.is-pending, .is-skipped) .pipe-label { color: var(--text-4); font-weight: 560; }
.pipe-note, .pipe-time { font-size: 11px; line-height: 1.3; color: var(--text-3); }
.pipe-note { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.pipe-time { display: flex; flex-wrap: wrap; justify-content: center; gap: 0 5px; font-variant-numeric: tabular-nums; }
.pipe-date { display: none; }  /* Horizontal: time of day; the full date is in the stage's tooltip. */
.pipe-dur { white-space: nowrap; }
.pipe-hour + .pipe-dur::before { content: "· "; }
/* Cards: the Now row has the full pipeline under it, and execution rows keep only the bar. */
.factory-now .task-row-pipe, .factory-project .task-row .pipe-mini-text { display: none; }
.task-row .muted { white-space: nowrap; }
.is-failed .pipe-note { color: var(--danger); }
.pipe-totals { margin: 8px 0 0; font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }

/* Compact pipeline for list rows: one segment per stage. */
.task-row-pipe { display: inline-flex; align-items: center; gap: 7px; flex: none; min-width: 0; }
.pipe-mini { display: inline-flex; gap: 2px; flex: none; }
.pipe-seg { width: 9px; height: 6px; border-radius: 2px; background: var(--border); }
.pipe-seg.is-done { background: var(--success); }
.pipe-seg.is-failed { background: var(--danger); }
.pipe-seg.is-stalled { background: var(--warning); }
.pipe-seg.is-waiting { background: var(--warning); opacity: .55; }
.pipe-seg.is-active { background: var(--accent); animation: pipe-pulse 1.2s ease-in-out infinite; }
.pipe-seg:is(.is-cancelled, .is-unknown) { background: var(--text-4); }
.pipe-seg.is-skipped { background: none; box-shadow: inset 0 0 0 1px var(--border); }
.pipe-mini-text { font-size: 11.5px; color: var(--text-3); white-space: nowrap; font-variant-numeric: tabular-nums; }
@keyframes pipe-pulse { 50% { opacity: .35; } }
.mini-list li .task-row-pipe { margin-left: auto; }

@media (max-width: 640px) {
  .pipeline { --node: 22px; }
  .pipe-label { font-size: 10.5px; }
  .task-row .pipe-mini-text { display: none; }
  .factory-project .task-row .chip { display: none; }  /* Phone card rows: title and pipeline first. */
  /* Detailed pipeline (task details, Factory tasks cards): a vertical list on phones. */
  .pipeline.is-detailed { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .pipeline.is-detailed .pipe-stage { flex-direction: row; align-items: flex-start; gap: 10px; padding-bottom: 12px; text-align: left; }
  .pipeline.is-detailed .pipe-stage:last-child { padding-bottom: 0; }
  /* Vertical connector: from each node down to the next stage, coloured by that next stage. */
  .pipeline.is-detailed .pipe-stage::before { display: none; }
  .pipeline.is-detailed .pipe-stage:not(:last-child)::after { content: ""; position: absolute; left: calc(var(--node) / 2 - 1px); top: calc(var(--node) + 2px); bottom: 2px; width: 2px; border-radius: 1px; background: var(--border-strong); }
  .pipeline.is-detailed .pipe-stage:has(+ .is-done)::after { background: var(--success); }
  .pipeline.is-detailed .pipe-stage:has(+ :is(.is-active, .is-waiting, .is-stalled))::after { background: linear-gradient(var(--success), var(--accent)); }
  .pipeline.is-detailed .pipe-stage:has(+ .is-failed)::after { background: var(--danger); }
  .pipeline.is-detailed .pipe-stage:has(+ :is(.is-skipped, .is-pending))::after { width: 0; background: none; border-left: 2px dashed var(--border); }
  .pipeline.is-detailed .pipe-text { flex-direction: row; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; padding-top: 3px; }
  .pipeline.is-detailed .pipe-label { font-size: 13px; }
  .pipeline.is-detailed .pipe-note { -webkit-line-clamp: 3; flex-basis: 100%; order: 3; }
  .pipeline.is-detailed .pipe-time { justify-content: flex-start; }
  .pipeline.is-detailed .pipe-date { display: inline; }
  .pipeline.is-detailed .pipe-hour { display: none; }
  .pipeline.is-detailed .pipe-date + .pipe-hour + .pipe-dur::before { content: "· "; }
}
