/* The vault page's look (product/app.md): the same tokens and shapes as the app on <name> (ui/web/src/app.css,
   shadcn/ui's "new-york" style with the zinc palette), written as plain CSS: no web fonts, nothing from elsewhere,
   and every rule works under style-src 'self'. Change the colors in both files together. */

:root {
  --background: #ffffff; --foreground: #09090b;
  --card: #ffffff; --card-foreground: #09090b;
  --muted: #f4f4f5; --muted-foreground: #71717a;
  --accent: #f4f4f5; --accent-foreground: #18181b;
  --primary: #18181b; --primary-foreground: #fafafa;
  --destructive: #dc2626; --destructive-soft: #fef2f2;
  --success: #15803d; --success-soft: #f0fdf4;
  --warning: #b45309; --warning-soft: #fffbeb; --warning-border: #fcd34d;
  --info: #1d4ed8; --info-soft: #eff6ff;
  --border: #e4e4e7; --input: #e4e4e7; --ring: #a1a1aa;
  --sidebar: #fafafa; --sidebar-foreground: #3f3f46; --sidebar-accent: #f4f4f5; --sidebar-border: #e4e4e7;
  --backdrop: rgb(0 0 0 / .5);
  --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / .05);
  --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / .1), 0 1px 2px -1px rgb(0 0 0 / .1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);
  --radius: 10px;
  --font: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --control-h: 36px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --background: #09090b; --foreground: #fafafa;
    --card: #111113; --card-foreground: #fafafa;
    --muted: #27272a; --muted-foreground: #a1a1aa;
    --accent: #27272a; --accent-foreground: #fafafa;
    --primary: #e4e4e7; --primary-foreground: #18181b;
    --destructive: #f87171; --destructive-soft: #2a1215;
    --success: #4ade80; --success-soft: #0f2417;
    --warning: #fbbf24; --warning-soft: #261c08; --warning-border: #92400e;
    --info: #93c5fd; --info-soft: #0f1a2e;
    --border: rgb(255 255 255 / .1); --input: rgb(255 255 255 / .15); --ring: #71717a;
    --sidebar: #111113; --sidebar-foreground: #d4d4d8; --sidebar-accent: #27272a; --sidebar-border: rgb(255 255 255 / .1);
    --backdrop: rgb(0 0 0 / .7);
  }
}
/* phones and touch screens: controls a finger can hit, and form fields iOS doesn't zoom into */
@media (pointer: coarse), (max-width: 767px) { :root { --control-h: 44px; } }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 14px/1.5 var(--font); color: var(--foreground); background: var(--background); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.muted { color: var(--muted-foreground); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg.icon { width: 16px; height: 16px; flex: none; }

/* --- layout: a sidebar for the signed-in screens (body.shell), one column for single steps (body.solo) --- */
body.shell { display: grid; grid-template-columns: 256px minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
.sidebar { position: sticky; top: 0; height: 100vh; height: 100dvh; display: flex; flex-direction: column; gap: 8px; padding: 8px; background: var(--sidebar); color: var(--sidebar-foreground); border-right: 1px solid var(--sidebar-border); overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 8px; min-width: 0; color: var(--foreground); text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 32px; height: 32px; flex: none; border-radius: 8px; background: var(--primary); color: var(--primary-foreground); }
.brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.brand-name { font-weight: 600; }
.brand-host { font-size: 12px; color: var(--muted-foreground); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { padding: 12px 8px 4px; font-size: 12px; font-weight: 500; color: var(--muted-foreground); }
.nav-item { display: flex; align-items: center; gap: 8px; min-height: 32px; padding: 6px 8px; border: 0; border-radius: 6px; background: transparent; color: inherit; font: inherit; text-align: left; text-decoration: none; cursor: pointer; width: 100%; }
.nav-item:hover { background: var(--sidebar-accent); color: var(--foreground); }
button.nav-item { justify-content: flex-start; height: auto; padding: 6px 8px; border: 0; box-shadow: none; font: inherit; white-space: normal; }
button.nav-item:hover { background: var(--sidebar-accent); }
.nav-item[aria-current="page"] { background: var(--sidebar-accent); color: var(--foreground); font-weight: 500; }
.nav-item .count { margin-left: auto; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--primary); color: var(--primary-foreground); font-size: 12px; font-weight: 500; text-align: center; }
.nav-item .ext { margin-left: auto; opacity: .6; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; padding-top: 8px; border-top: 1px solid var(--sidebar-border); }
.sidebar .new { margin: 0 0 4px; width: 100%; }
.content { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: none; }
main { width: 100%; max-width: 1040px; padding: 28px 32px 24px; margin: 0 auto; }
footer { width: 100%; max-width: 1040px; margin: auto auto 0; padding: 16px 32px 24px; color: var(--muted-foreground); font-size: 12px; }
.scrim { display: none; }
@media (max-width: 767px) {
  body.shell { display: block; }
  .topbar { display: flex; align-items: center; gap: 8px; position: sticky; top: 0; z-index: 20; height: 56px; padding: 0 8px; background: var(--background); border-bottom: 1px solid var(--border); }
  .topbar .brand { padding: 4px; }
  .topbar .actions { margin-left: auto; display: flex; gap: 6px; }
  .sidebar { position: fixed; z-index: 40; left: 0; top: 0; width: min(288px, 85vw); transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 30; background: var(--backdrop); }
  .nav-item { min-height: 44px; }
  main { padding: 20px 16px; }
  footer { padding: 16px; }
}
body.solo { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; background: var(--muted); }
@media (prefers-color-scheme: dark) { body.solo { background: var(--background); } }
body.solo .solo-head { width: 100%; max-width: 560px; padding: 32px 16px 0; }
body.solo main { max-width: 560px; padding: 16px; }
body.solo main > .panel { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 24px; }
body.solo footer { max-width: 560px; margin: 0 auto; }
body.solo .topbar, body.solo .sidebar, body.solo .scrim { display: none !important; }
body.solo .content { width: 100%; align-items: center; flex: 1; }
body.shell .solo-head { display: none; }
.vault-mark { background: var(--success); color: var(--background); }
@media (max-width: 767px) { body.solo .solo-head { padding-top: 16px; } body.solo main > .panel { padding: 18px; } }

/* --- page heading --- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 0 0 20px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
h1 { font-size: 24px; line-height: 1.25; font-weight: 600; letter-spacing: -.02em; margin: 0 0 6px; }
.page-head h1 { margin: 0; }
.page-head p, h1 + p.muted { margin: 6px 0 0; }
h1 + p.muted { margin-bottom: 16px; }
body.solo h1 { font-size: 20px; }
h2 { font-size: 16px; font-weight: 600; letter-spacing: -.01em; margin: 28px 0 10px; }
h3 { font-size: 14px; font-weight: 600; margin: 16px 0 6px; }
p { margin: 8px 0; }

/* --- cards, lists --- */
.card { display: block; background: var(--card); color: var(--card-foreground); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-xs); padding: 16px 18px; margin: 10px 0; }
a.card { text-decoration: none; transition: background .15s; }
a.card:hover { background: var(--accent); }
.card > :first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }
.list { border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); overflow: hidden; margin: 10px 0; }
.list > .item { display: flex; gap: 12px; align-items: center; padding: 12px 16px; border-top: 1px solid var(--border); text-decoration: none; color: inherit; }
.list > .item:first-child { border-top: 0; }
a.item:hover { background: var(--accent); }
.item .grow { flex: 1; min-width: 0; }
.item .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; justify-content: flex-end; }
.item .actions select { width: auto; margin: 0; }
.empty { border: 1px dashed var(--border); border-radius: var(--radius); padding: 32px 16px; text-align: center; color: var(--muted-foreground); }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 16px; }
dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
dt { color: var(--muted-foreground); }
dd { margin: 0; word-break: break-word; }
ol, ul { padding-left: 22px; }
li { margin: 4px 0; }

/* --- buttons: <button> is the outline variant; .primary, .destructive, .ghost, .deny; .sm, .icon-only --- */
button, a.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: var(--control-h); padding: 0 16px; border-radius: 8px; border: 1px solid var(--input); background: var(--background); color: var(--foreground); font: 500 14px/1 var(--font); white-space: nowrap; text-decoration: none; cursor: pointer; box-shadow: var(--shadow-xs); transition: background .15s, color .15s, border-color .15s; }
button:hover, a.button:hover { background: var(--accent); }
button.primary, a.button.primary, button.approve { background: var(--primary); border-color: var(--primary); color: var(--primary-foreground); }
button.primary:hover, a.button.primary:hover, button.approve:hover { background: color-mix(in srgb, var(--primary) 88%, var(--background)); }
button.destructive { background: var(--destructive); border-color: var(--destructive); color: #fff; }
button.destructive:hover { background: color-mix(in srgb, var(--destructive) 88%, #000); }
button.deny { color: var(--destructive); border-color: color-mix(in srgb, var(--destructive) 40%, var(--input)); }
button.deny:hover { background: var(--destructive-soft); }
button.ghost, a.button.ghost { border-color: transparent; background: transparent; box-shadow: none; }
button.ghost:hover, a.button.ghost:hover { background: var(--accent); }
button.sm, a.button.sm { height: 32px; padding: 0 12px; font-size: 13px; }
button.icon-only { width: var(--control-h); padding: 0; }
button:disabled, a.button[aria-disabled="true"] { opacity: .5; cursor: default; pointer-events: none; }
@media (pointer: coarse), (max-width: 767px) { button.sm, a.button.sm { height: 40px; } }

/* --- forms --- */
label { display: block; margin: 16px 0 6px; font-weight: 500; }
input, select, textarea { width: 100%; min-height: var(--control-h); padding: 6px 12px; border: 1px solid var(--input); border-radius: 8px; background: transparent; color: var(--foreground); font: 14px/1.5 var(--font); box-shadow: var(--shadow-xs); }
select { background: var(--background); }
textarea { min-height: 120px; padding: 8px 12px; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; border-color: var(--ring); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 45%, transparent); }
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; min-height: 0; padding: 0; margin: 0; box-shadow: none; accent-color: var(--primary); flex: none; }
label.check { display: flex; gap: 10px; align-items: center; font-weight: 500; margin: 10px 0; }
.hint { font-size: 13px; color: var(--muted-foreground); margin: 6px 0 0; }
@media (pointer: coarse), (max-width: 767px) { input, select, textarea { font-size: 16px; } }

/* --- messages, alerts, badges --- */
.msg { margin: 12px 0 0; font-size: 14px; }
.msg.ok { color: var(--success); }
.msg.err { color: var(--destructive); }
.note, .alert, .callout { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; margin: 12px 0; }
.note { background: var(--warning-soft); border-color: var(--warning-border); }
.alert { background: var(--destructive-soft); border-color: color-mix(in srgb, var(--destructive) 35%, var(--border)); }
.alert strong:first-child, .note strong:first-child { display: block; margin-bottom: 2px; }
.badge, .state { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 6px; border: 1px solid var(--border); background: var(--muted); color: var(--foreground); font-size: 12px; font-weight: 500; line-height: 18px; white-space: nowrap; }
.badge.ok, .state.ok { background: var(--success-soft); color: var(--success); border-color: transparent; }
.badge.bad, .state.bad, .state.failed { background: var(--destructive-soft); color: var(--destructive); border-color: transparent; }
.badge.live, .state.running, .state.starting { background: var(--info-soft); color: var(--info); border-color: transparent; }
.badge.warn { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.method { font: 600 12px/1 var(--mono); letter-spacing: .02em; }
.question { font-weight: 600; margin: 0 0 6px; }

/* --- code and keys --- */
code { font: 13px var(--mono); background: var(--muted); border-radius: 4px; padding: 1px 4px; }
pre { white-space: pre-wrap; word-break: break-all; background: var(--muted); border-radius: 8px; padding: 12px; font: 12.5px/1.5 var(--mono); margin: 8px 0 0; max-height: 360px; overflow: auto; }
pre.config { max-height: 220px; font-size: 12px; }
.key { font: 600 20px/1.4 var(--mono); letter-spacing: .04em; word-break: break-all; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin: 8px 0; }

/* --- dialogs: native <dialog> opened with showModal() --- */
dialog.modal { width: calc(100% - 32px); max-width: 520px; max-height: calc(100dvh - 32px); padding: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--background); color: var(--foreground); box-shadow: var(--shadow-lg); overflow: auto; }
dialog.modal.wide { max-width: 640px; }
dialog.modal::backdrop { background: var(--backdrop); }
dialog.modal > form, dialog.modal > .body { padding: 24px; margin: 0; }
.dialog-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 8px; }
.dialog-head h2 { margin: 0; font-size: 18px; line-height: 1.3; }
.dialog-head .close { margin: -8px -8px 0 auto; }
.dialog-head + p { margin-top: 0; color: var(--muted-foreground); }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; margin-top: 24px; }
@media (max-width: 767px) { .dialog-foot { flex-direction: column-reverse; } .dialog-foot button { width: 100%; } }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media print {
  :root { --background: #fff; --foreground: #000; --card: #fff; --border: #999; --muted: #fff; }
  body.shell { display: block; }
  .sidebar, .topbar, .scrim, footer, .row, label.check, .muted { display: none !important; }
  body.solo { background: #fff; }
  body.solo main > .panel { border: 0; box-shadow: none; }
  .key { border: 0; }
}
