/* Sushi managed servers: the app's dark palette (packages/brand/src/tokens.css), sake as the action colour. */
:root {
  color-scheme: dark;
  --bg: #0e110f;
  --surface: #161a17;
  --surface-2: #1d221e;
  --border: rgba(214, 232, 220, 0.08);
  --border-strong: rgba(214, 232, 220, 0.15);
  --text: #eeece5;
  --text-2: #cfd3ce;
  --muted: #9aa39d;
  --dim: #6d766f;
  --accent: #ff7a5a;
  --accent-hover: #ff8f73;
  --accent-text: #ff9678;
  --accent-soft: rgba(255, 122, 90, 0.14);
  --on-accent: #1a0e0a;
  --ok: #7fd49b;
  --ok-soft: rgba(127, 212, 155, 0.13);
  --warn: #f2c46b;
  --warn-soft: rgba(242, 196, 107, 0.13);
  --danger: #ff6b6b;
  --danger-soft: rgba(255, 107, 107, 0.13);
  --radius: 14px;
  --radius-sm: 9px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, Inter, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--mono); font-size: 0.92em; color: var(--text-2); }
h1 { font-size: 1.6rem; line-height: 1.25; margin: 0 0 0.5rem; letter-spacing: -0.01em; }
h2 { font-size: 1.1rem; margin: 0 0 0.75rem; }
h3 { font-size: 0.95rem; margin: 1rem 0 0.4rem; color: var(--text-2); }
p { margin: 0 0 0.75rem; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.optional { color: var(--dim); font-weight: 400; font-size: 0.85em; margin-left: 0.35em; }

/* Frame */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding: 0.9rem clamp(16px, 4vw, 40px);
  border-bottom: 1px solid var(--border);
  background: rgba(14, 17, 15, 0.9);
  position: sticky; top: 0; z-index: 2; backdrop-filter: blur(8px);
}
.brand { display: inline-flex; align-items: center; gap: 0.6rem; color: var(--text); font-weight: 650; }
.brand:hover { text-decoration: none; }
.brand em { font-style: normal; color: var(--muted); font-weight: 450; }
.nav { display: flex; align-items: center; gap: 1.1rem; flex-wrap: wrap; }
.nav a, .nav .link { color: var(--text-2); font-size: 0.92rem; }
.nav form { margin: 0; }
.nav-add { color: var(--accent-text) !important; }
.main { max-width: 1040px; margin: 0 auto; padding: 2rem clamp(16px, 4vw, 40px) 4rem; }

/* Surfaces */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.35rem 1.5rem; margin-bottom: 1.25rem;
}
.card.narrow { max-width: 460px; margin: 3rem auto; }
.card.empty { text-align: center; padding: 2.5rem 1.5rem; }
.card.empty p { max-width: 560px; margin-left: auto; margin-right: auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-head h1 { display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap; margin: 0; }
.crumb { margin: 0 0 0.25rem; font-size: 0.88rem; }
.crumb a { color: var(--muted); }
.columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 0 1.25rem; }

/* Buttons */
.button, button.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  min-height: 38px; padding: 0 1rem; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: var(--accent); color: var(--on-accent);
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
.button:hover { background: var(--accent-hover); text-decoration: none; }
.button.ghost { background: transparent; color: var(--text); border-color: var(--border-strong); }
.button.ghost:hover { background: var(--surface-2); }
.button.small { min-height: 30px; padding: 0 0.7rem; font-size: 0.85rem; font-weight: 550; }
.button.danger { background: transparent; color: var(--danger); border-color: rgba(255, 107, 107, 0.35); }
.button.danger:hover { background: var(--danger-soft); }
button.link { background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }
button.link:hover { color: var(--text); }
:focus-visible { outline: 2px solid rgba(255, 122, 90, 0.72); outline-offset: 2px; }

/* Forms */
.form { display: flex; flex-direction: column; gap: 1rem; }
.form fieldset { border: 0; margin: 0 0 0.5rem; padding: 0; display: flex; flex-direction: column; gap: 0.9rem; }
.form legend { font-weight: 650; font-size: 1.02rem; margin-bottom: 0.75rem; padding: 0; }
.form label { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.9rem; color: var(--text-2); font-weight: 550; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0.9rem 1rem; }
input, textarea, select {
  width: 100%; font: inherit; font-weight: 400; color: var(--text);
  background: var(--bg); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 0.55rem 0.7rem;
}
textarea { resize: vertical; font-family: var(--mono); font-size: 0.88rem; line-height: 1.5; }
input:focus, textarea:focus { outline: none; border-color: rgba(255, 122, 90, 0.72); }
input::placeholder, textarea::placeholder { color: var(--dim); }
.hint { color: var(--muted); font-weight: 400; font-size: 0.82rem; }
.field-error { color: var(--danger); font-weight: 500; font-size: 0.84rem; }
.choice-row { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.form .choice {
  flex-direction: row; align-items: center; gap: 0.5rem; cursor: pointer;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 0.5rem 0.85rem;
}
.form .choice:has(input:checked) { border-color: rgba(255, 122, 90, 0.6); background: var(--accent-soft); color: var(--text); }
.choice input, .check input { width: auto; accent-color: var(--accent); }
.form .check { flex-direction: row; align-items: baseline; gap: 0.55rem; flex-wrap: wrap; }
/* Only the secret field for the chosen sign-in shows (the server reads only that one). */
.form:has(input[name="auth_kind"][value="key"]:checked) .only-password,
.form:has(input[name="auth_kind"][value="password"]:checked) .only-key { display: none; }
.actions { display: flex; gap: 0.75rem; }
.alert { background: var(--danger-soft); color: #ffb3b3; border-radius: var(--radius-sm); padding: 0.65rem 0.85rem; }
.notice { background: var(--ok-soft); color: var(--ok); border-radius: var(--radius-sm); padding: 0.65rem 0.85rem; }

/* Table */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.table th { text-align: left; font-weight: 550; color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; }
.table th, .table td { padding: 0.8rem 1rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table td a { color: var(--text); }

/* Status pills */
.pill { display: inline-block; font-size: 0.78rem; font-weight: 600; padding: 0.15rem 0.6rem; border-radius: 999px; white-space: nowrap; letter-spacing: 0; }
.pill-ready { background: var(--accent-soft); color: var(--accent-text); }
.pill-claimed { background: var(--warn-soft); color: var(--warn); }
.pill-set_up { background: var(--ok-soft); color: var(--ok); }
.pill-failed, .pill-locked { background: var(--danger-soft); color: var(--danger); }
.pill-revoked, .pill-expired { background: var(--surface-2); color: var(--muted); }

/* Share card */
.share { border-color: rgba(255, 122, 90, 0.28); }
.codes { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; margin-bottom: 1.1rem; }
.codes > div { display: flex; flex-direction: column; align-items: flex-start; gap: 0.35rem; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.85rem 1rem; }
.label { color: var(--muted); font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; display: block; margin-bottom: 0.35rem; }
.codes .label { margin: 0; }
code.big { font-size: 1.35rem; letter-spacing: 0.06em; color: var(--text); font-weight: 600; }
.share-text, .secret { width: 100%; margin-bottom: 0.75rem; background: var(--bg); }
.row { display: flex; align-items: center; gap: 0.8rem; flex-wrap: wrap; }

/* Facts, actions, history */
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.45rem 1.1rem; margin: 0 0 1rem; }
.facts dt { color: var(--muted); font-size: 0.88rem; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.error-text { color: #ffb3b3; }
.notes { color: var(--text-2); white-space: normal; }
.action-list { display: flex; flex-direction: column; gap: 0.85rem; }
.action-list form { display: flex; align-items: center; gap: 0.8rem; flex-wrap: wrap; margin: 0; }
.danger-zone { padding-top: 0.85rem; border-top: 1px solid var(--border); }
.danger-zone input { width: 13rem; }
.events { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; font-size: 0.9rem; }
.events li { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: baseline; }
.events .muted.small:first-child { min-width: 5.5rem; }
.event-kind { font-weight: 600; color: var(--text-2); text-transform: capitalize; }

/* LLM login */
.llm-logins { list-style: none; margin: 0 0 1rem; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.llm-logins li { display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap; padding: 0.55rem 0.8rem; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.llm-logins form { margin: 0 0 0 auto; }
.llm-form { padding-top: 1rem; margin-top: 1rem; border-top: 1px solid var(--border); }
.llm-form details summary { cursor: pointer; color: var(--text-2); margin-bottom: 0.6rem; }

@media (max-width: 560px) {
  .card { padding: 1.1rem; }
  .facts { grid-template-columns: 1fr; gap: 0.1rem; }
  .facts dd { margin-bottom: 0.5rem; }
}
.table code, .table td.muted { white-space: nowrap; }

/* Staff model naming and price comparison. */
.inference-options { gap: 0; }
.inference-option .option-choices { display: flex; flex-direction: column; gap: 0.8rem; padding-top: 0.5rem; }
.inference-rates { margin-top: 1.15rem; }
.inference-rates input { min-width: 110px; }
.price-calculator { margin: 1rem 0 0.6rem; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.price-fill { align-self: end; padding-bottom: 2px; }
.button:disabled { opacity: 0.5; cursor: default; }
.auth-footer { margin-top: 1rem; }
.credit-total { font-size: 2.7rem; font-weight: 650; line-height: 1.25; margin: 0.2rem 0 0.6rem; }

.install-log { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 32rem; overflow-y: auto; font-size: 0.82rem; }
.control-feedback, .control-notice { color: var(--text-2); }
.control-feedback:not([hidden]) { padding: 0.85rem 1rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
#server-control[aria-busy="true"] button[type="submit"] { cursor: wait; opacity: 0.7; }
