/* agent-32 console — shared design system (design/STYLE.md).
   Page-specific styles live in css/<area>.css. */
:root {
  --display: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --r: 8px;
  --r-card: 12px;
  --r-lg: 14px;
}
/* Colors. Dark is the default; light applies when the user picks it
   (data-theme="light" on <html>, see js/theme.js) or, with no choice saved,
   when the system prefers light. Code, terminal and stream panels ("wells")
   keep the dark colors in both themes, so they re-declare them. */
:root,
.secret, pre.raw, pre.code, .ag-out, .ag-log.compact, .auth-term, .inst-well,
.inst-wait.term, .inst-term-panel, .kp-secret-row input, .kp-code, .tm-link input {
  --bg: #0d1014;          /* page */
  --side: #0b0e12;        /* sidebar */
  --panel: #151a21;       /* cards */
  --raised: #1b222b;      /* hover, badges, active nav */
  --well: #090b0e;        /* code, terminal, streams */
  --line: #1f262f;        /* dividers */
  --line-2: #262e38;      /* inputs */
  --line-card: #222a34;   /* cards */
  --line-3: #343d49;      /* secondary buttons */
  --text: #e8eaed;
  --text-2: #c3cad3;      /* secondary text, labels */
  --body: #b4bcc6;        /* body-muted */
  --muted: #9ba4af;       /* small labels */
  --faint: #7d8793;       /* ≥13px non-essential only */
  --accent: #f2b33d;
  --accent-2: #f6c66a;
  --accent-ink: #0d1014;
  --ok: #4ade80;
  --ok-text: #86efac;
  --info: #93c5fd;
  --warn: #f2b33d;
  --warn-line: #7a5a1a;
  --bad: #f87171;
  --bad-line: #7f2a2a;
  --bad-bg: #3a1518;
  --bad-hover: #4a1a1e;   /* danger button hover */
  --accent-text: #f2b33d; /* amber as text, borders, icons */
  --accent-text-2: #f6c66a;
  --ok-line: #1f5135;
  --aside: #11151a;       /* auth brand panel */
  --tile: #1d242e;
  --overlay: rgba(5, 7, 9, 0.7);
  --shadow: rgba(0, 0, 0, 0.5);
  --hover-tint: rgba(232, 234, 237, 0.06);
  color-scheme: dark;
  color: var(--text); /* so a well's content inherits the dark text color */
}
:root[data-theme="light"] {
  --bg: #f6f7f9; --side: #eef0f3; --panel: #ffffff; --raised: #edf0f3; --well: #11151a;
  --line: #e2e5e9; --line-2: #d3d8de; --line-card: #dde1e6; --line-3: #a9b1bb;
  --text: #12161b; --text-2: #2f3640; --body: #424a55; --muted: #59626e; --faint: #67707c;
  --accent: #f2b33d; --accent-2: #e8a52a; --accent-ink: #12161b;
  --accent-text: #8f5200; --accent-text-2: #6e3f00;
  --ok: #16a34a; --ok-text: #15803d; --ok-line: #a7d8b9; --info: #1d4ed8;
  --warn: #9a5800; --warn-line: #e2b65c;
  --bad: #b91c1c; --bad-line: #f0b4b4; --bad-bg: #fdecec; --bad-hover: #f9dcdc;
  --aside: #eef0f3; --tile: #e4e8ec;
  --overlay: rgba(18, 22, 27, 0.35); --shadow: rgba(18, 22, 27, 0.18); --hover-tint: rgba(18, 22, 27, 0.05);
  color-scheme: light;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f6f7f9; --side: #eef0f3; --panel: #ffffff; --raised: #edf0f3; --well: #11151a;
    --line: #e2e5e9; --line-2: #d3d8de; --line-card: #dde1e6; --line-3: #a9b1bb;
    --text: #12161b; --text-2: #2f3640; --body: #424a55; --muted: #59626e; --faint: #67707c;
    --accent: #f2b33d; --accent-2: #e8a52a; --accent-ink: #12161b;
    --accent-text: #8f5200; --accent-text-2: #6e3f00;
    --ok: #16a34a; --ok-text: #15803d; --ok-line: #a7d8b9; --info: #1d4ed8;
    --warn: #9a5800; --warn-line: #e2b65c;
    --bad: #b91c1c; --bad-line: #f0b4b4; --bad-bg: #fdecec; --bad-hover: #f9dcdc;
    --aside: #eef0f3; --tile: #e4e8ec;
    --overlay: rgba(18, 22, 27, 0.35); --shadow: rgba(18, 22, 27, 0.18); --hover-tint: rgba(18, 22, 27, 0.05);
    color-scheme: light;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font: 14px/1.5 var(--sans); }
body { -webkit-font-smoothing: antialiased; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }
code, pre, .mono { font-family: var(--mono); font-size: 13px; }
code { color: var(--text); background: var(--raised); padding: 1px 6px; border-radius: 4px; }
pre code { background: none; padding: 0; }
b, strong { font-weight: 600; color: var(--text); }
.boot { padding: 40px; color: var(--muted); font-family: var(--mono); font-size: 13px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- console shell: AppNav + main ---------- */
.shell { display: flex; flex-wrap: wrap; align-items: stretch; min-height: 100vh; }
.shell > .side-wrap { flex: 1 1 248px; max-width: 100%; display: flex; flex-direction: column; }
.shell > main { flex: 999 1 560px; min-width: 0; padding: 28px clamp(16px, 3vw, 40px) 48px; display: flex; flex-direction: column; gap: 24px; }
.side {
  background: var(--side); border-right: 1px solid var(--line); min-height: 100%;
  padding: 20px 14px; display: flex; flex-direction: column; gap: 20px; font-size: 14px;
}
.side-in { position: sticky; top: 20px; display: flex; flex-direction: column; gap: 20px; min-height: calc(100vh - 40px); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); padding: 0 8px; }
.brand:hover { text-decoration: none; }
.brand svg { flex: none; }
.ws { position: relative; }
.ws-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; min-height: 48px;
  padding: 8px 12px; background: var(--panel); border: 1px solid var(--line-2); border-radius: 10px; color: var(--text); text-align: left;
}
.ws-btn:hover { background: var(--raised); border-color: var(--line-3); }
.ws-btn .t { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.ws-btn .n { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ws-btn .r { font-size: 12px; color: var(--muted); font-weight: 400; }
.ws-menu {
  position: absolute; z-index: 30; top: calc(100% + 6px); left: 0; right: 0; background: var(--panel); border: 1px solid var(--line-3);
  border-radius: 10px; padding: 6px; box-shadow: 0 24px 64px var(--shadow); display: flex; flex-direction: column; gap: 2px;
}
.ws-menu[hidden] { display: none; }
.ws-menu button { justify-content: space-between; width: 100%; border: 0; background: none; min-height: 40px; padding: 0 10px; color: var(--text-2); font-weight: 500; }
.ws-menu button:hover, .ws-menu button[aria-checked="true"] { background: var(--raised); color: var(--text); }
.ws-menu button .r { font-size: 12px; color: var(--muted); font-weight: 400; }
.ws-menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 2px; }
/* a workspace the caller's country may not use (blocked_here) */
.ws-btn .r.na { color: var(--warn); }
.ws-menu button .t { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; line-height: 1.3; text-align: left; }
.ws-menu button.na { min-height: 48px; padding-top: 6px; padding-bottom: 6px; }
.ws-menu button.na .n { color: var(--muted); }
.ws-menu .na-note { font-size: 12px; font-weight: 400; color: var(--warn); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 12px; min-height: 40px; padding: 8px 10px; border-radius: var(--r); color: var(--body); }
.nav a:hover { background: var(--raised); color: var(--text); text-decoration: none; }
.nav a.on { background: var(--raised); color: var(--text); font-weight: 600; }
.nav a svg { flex: none; }
.nav .grow { flex: 1; }
.nav .count { font-size: 12px; font-weight: 600; color: var(--accent-ink); background: var(--accent); border-radius: 999px; padding: 0 8px; }
.side .fill { flex: 1; }
.credit {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 52px; padding: 8px 12px;
  border-radius: 10px; background: var(--panel); border: 1px solid var(--line-2); color: var(--text);
}
.credit:hover { text-decoration: none; border-color: var(--line-3); }
.credit .l { display: flex; flex-direction: column; line-height: 1.35; }
.credit .k { font-size: 12px; color: var(--muted); }
.credit .v { font: 500 15px var(--mono); }
.credit .add { font-size: 13px; font-weight: 600; color: var(--accent-text); }
.credit.low { border-color: var(--warn-line); color: var(--warn); }
.credit.out { border-color: var(--bad-line); color: var(--bad); }
.credit.na { border-style: dashed; }
.credit.na .v { font: 500 13px var(--sans); color: var(--warn); }
.me { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 8px; }
.me .e { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me button { border: 0; background: none; padding: 10px 4px; min-height: 44px; color: var(--text-2); font-size: 13px; font-weight: 400; }
.me button:hover { color: var(--text); background: none; }

/* ---------- page header ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px; }
.page-head .titles { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.page-head .title-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; min-width: 0; }
.page-head .actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--text); text-decoration: none; }
.eyebrow { font: 500 13px var(--mono); color: var(--accent-text); margin: 0; }
h1 { font: 600 28px/1.15 var(--display); letter-spacing: -0.02em; margin: 0; overflow-wrap: anywhere; }
h2 { font: 600 18px/1.3 var(--display); letter-spacing: -0.01em; margin: 0 0 12px; }
h3 { font: 600 15px/1.35 var(--display); margin: 0 0 8px; }
.lede { color: var(--body); margin: 0; font-size: 15px; max-width: 720px; }

/* ---------- generic layout helpers ---------- */
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.body { color: var(--body); }
.small { font-size: 13px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.narrow { max-width: 880px; }

/* ---------- buttons ---------- */
button, .btn {
  font: 500 14px/1 var(--sans); color: var(--text); background: transparent; border: 1px solid var(--line-3);
  padding: 0 16px; min-height: 40px; border-radius: var(--r); cursor: pointer;
  display: inline-flex; gap: 8px; align-items: center; justify-content: center; white-space: nowrap;
}
button:hover, .btn:hover { background: var(--raised); text-decoration: none; color: var(--text); }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
button.primary:hover, .btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); color: var(--accent-ink); }
button.danger, .btn.danger { background: var(--bad-bg); border-color: var(--bad-line); color: var(--bad); }
button.danger:hover, .btn.danger:hover { background: var(--bad-hover); color: var(--bad); }
button.ghost, .btn.ghost { border-color: transparent; color: var(--text-2); }
button.ghost:hover, .btn.ghost:hover { background: var(--raised); color: var(--text); }
button.sm, .btn.sm, button.small { min-height: 32px; padding: 0 12px; font-size: 13px; }
button.icon { padding: 0; width: 40px; }
button.icon.sm { width: 32px; }
button:disabled, .btn[aria-disabled="true"] { opacity: 0.45; cursor: default; pointer-events: none; }
.copy { min-height: 32px; width: 32px; padding: 0; border-color: var(--line-2); color: var(--muted); flex: none; }
.copy:hover { color: var(--text); }
.copy.done { color: var(--ok-text); border-color: var(--ok-line); }

/* ---------- forms ---------- */
input, select, textarea {
  font: 14px var(--sans); color: var(--text); background: var(--bg); border: 1px solid var(--line-2);
  padding: 0 12px; min-height: 40px; border-radius: var(--r); min-width: 0;
}
textarea { padding: 10px 12px; width: 100%; resize: vertical; font-family: var(--mono); font-size: 13px; line-height: 1.6; }
select { padding-right: 32px; appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239BA4AF' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, select:focus, textarea:focus { border-color: var(--accent-text); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; }
input[type="checkbox"], input[type="radio"] { min-height: 0; width: 16px; height: 16px; accent-color: var(--accent); }
label, .label { display: flex; flex-direction: column; gap: 6px; color: var(--text-2); font-size: 13px; font-weight: 500; }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; color: var(--text-2); }
.hint { font-size: 13px; color: var(--muted); font-weight: 400; }
.field-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.field-row > label { flex: 1 1 200px; }

/* ---------- cards, tables, key-values ---------- */
.card { background: var(--panel); border: 1px solid var(--line-card); border-radius: var(--r-card); padding: 20px 24px; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin-bottom: 16px; }
.card-head h2, .card-head h3 { margin: 0; }
.table-wrap { overflow-x: auto; position: relative; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; font-weight: 500; color: var(--muted); padding: 12px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px 16px; height: 48px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--raised); }
td.num, th.num { text-align: right; font-family: var(--mono); font-size: 13px; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.kv { display: grid; grid-template-columns: minmax(120px, 180px) 1fr; gap: 12px 20px; align-items: baseline; margin: 0; }
.kv > dt, .kv > div:nth-child(odd) { color: var(--muted); font-size: 13px; }
.kv > dd { margin: 0; min-width: 0; }
.secret { display: flex; align-items: center; gap: 10px; background: var(--well); border: 1px dashed var(--accent-text); padding: 10px 12px; border-radius: var(--r); font: 13px var(--mono); color: var(--text); word-break: break-all; }
.secret > span { flex: 1; min-width: 0; }
pre.raw, pre.code { background: var(--well); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; overflow: auto; max-height: 60vh; white-space: pre-wrap; color: #d6dae0; line-height: 1.7; margin: 0; }

/* ---------- status ---------- */
.badge { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 500; line-height: 1; padding: 5px 10px; border-radius: 999px; background: var(--raised); color: var(--text-2); white-space: nowrap; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--faint); flex: none; }
.badge.running::before, .badge.exited::before, .badge.ok::before { background: var(--ok); }
.badge.ok { color: var(--ok-text); }
.badge.sleeping::before, .badge.waking::before, .badge.info::before { background: var(--info); }
.badge.waking::before { animation: pulse 1.2s infinite; }
.badge.provisioning::before, .badge.stopping::before, .badge.pending_payment::before, .badge.starting::before, .badge.warn::before { background: var(--warn); animation: pulse 1.2s infinite; }
.badge.stopped::before { background: var(--faint); }
.badge.suspended, .badge.error, .badge.failed, .badge.timeout, .badge.deleting, .badge.bad { color: var(--bad); }
.badge.suspended::before, .badge.error::before, .badge.failed::before, .badge.timeout::before, .badge.deleting::before, .badge.bad::before { background: var(--bad); }
.badge.plain::before { display: none; }
@keyframes pulse { 50% { opacity: 0.35; } }
.role { display: inline-block; font-size: 12px; font-weight: 500; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line-3); color: var(--text-2); }

/* ---------- banners ---------- */
.banner { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; background: var(--panel); border: 1px solid var(--line-card); border-radius: var(--r-card); padding: 14px 18px; }
.banner > svg { flex: none; color: var(--muted); }
.banner .msg { flex: 1 1 280px; min-width: 0; color: var(--text-2); }
.banner .msg b { display: block; }
.banner.warn { border-color: var(--warn-line); }
.banner.warn > svg, .banner.warn .msg b { color: var(--warn); }
.banner.danger { border-color: var(--bad-line); }
.banner.danger > svg, .banner.danger .msg b { color: var(--bad); }
.banner.info > svg { color: var(--info); }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { padding: 10px 14px; min-height: 44px; display: inline-flex; align-items: center; color: var(--body); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.on { color: var(--text); border-color: var(--accent-text); }

/* ---------- dialog ---------- */
dialog.dlg { background: var(--panel); color: var(--text); border: 1px solid var(--line-3); border-radius: var(--r-lg); padding: 24px; width: min(480px, calc(100vw - 32px)); box-shadow: 0 24px 64px var(--shadow); }
dialog.dlg::backdrop { background: var(--overlay); }
dialog.dlg h2 { margin: 0 0 8px; }
dialog.dlg .actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 20px; }

/* ---------- toast ---------- */
.toast { position: fixed; bottom: 20px; right: 20px; background: var(--raised); border: 1px solid var(--line-3); padding: 12px 16px; border-radius: 10px; max-width: min(440px, calc(100vw - 40px)); z-index: 40; box-shadow: 0 24px 64px var(--shadow); }
.toast.bad { border-color: var(--bad-line); color: var(--bad); }
/* the server was updated since this tab loaded (core.js noteConsoleVersion) */
.update-bar { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 45; display: flex; align-items: center; gap: 10px; max-width: calc(100vw - 32px); padding: 8px 8px 8px 16px; background: var(--raised); border: 1px solid var(--accent); border-radius: 10px; box-shadow: 0 16px 48px var(--shadow); font-size: 14px; }
.update-bar span { flex: 1 1 auto; min-width: 0; }

.err-msg { color: var(--bad); font-size: 13px; }
.err-msg:empty { display: none; }

/* ---------- small screens ---------- */
@media (max-width: 860px) {
  .side { border-right: 0; border-bottom: 1px solid var(--line); padding: 14px 16px; }
  .side-in { position: static; min-height: 0; gap: 14px; }
  .side .fill { display: none; }
  .nav { flex-direction: row; overflow-x: auto; scrollbar-width: none; margin: 0 -4px; }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { white-space: nowrap; }
  .shell > main { padding: 22px 16px 48px; }
  input, select, textarea { font-size: 16px; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv > dd, .kv > div:nth-child(even) { margin-bottom: 10px; }
}

/* sidebar footer: theme button + sign out */
.me-acts { display: flex; align-items: center; gap: 2px; flex: none; }
.me .theme-btn { display: inline-flex; align-items: center; justify-content: center; width: 40px; padding: 0; color: var(--text-2); }

/* light mode: the select chevron uses the light --muted gray */
:root[data-theme="light"] select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2359626E' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2359626E' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); }
}
