/* axovi · man — calm, monochrome, one accent. Light by default, dark via system or toggle. */

:root {
  color-scheme: light;
  --bg: #fafafa;
  --surface: #ffffff;
  --surface-2: #f4f4f5;
  --track: #ececef;
  --code-bg: #fbfbfc;
  --border: #e6e6e9;
  --border-strong: #d6d6db;
  --text: #18181b;
  --text-2: #52525b;
  --text-3: #71717a;
  --text-4: #a1a1aa;
  --bar: #3f3f46;
  --accent: #5b5bd6;
  --accent-text: #4b4bc4;
  --accent-soft: rgba(91, 91, 214, 0.1);
  --ok: #15803d;
  --ok-soft: rgba(21, 128, 61, 0.1);
  --warn: #b45309;
  --warn-soft: rgba(217, 119, 6, 0.11);
  --crit: #cf2c2c;
  --crit-soft: rgba(220, 38, 38, 0.09);
  --backdrop: rgba(24, 24, 27, 0.32);
  --shadow-pop: 0 12px 32px -8px rgba(24, 24, 27, 0.18), 0 2px 6px rgba(24, 24, 27, 0.06);

  --font: ui-sans-serif, -apple-system, "SF Pro Text", "Segoe UI", Inter, Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --radius: 12px;
  --radius-sm: 8px;
  --gutter: 24px;
  --tabbar: 0px;
  --ease: cubic-bezier(0.2, 0, 0, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0a0a0b;
    --surface: #111113;
    --surface-2: #19191c;
    --track: #232327;
    --code-bg: #0d0d0f;
    --border: #232326;
    --border-strong: #303035;
    --text: #ededef;
    --text-2: #a8a8b0;
    --text-3: #8b8b94;
    --text-4: #62626b;
    --bar: #d4d4d8;
    --accent: #8b8cf6;
    --accent-text: #a4a5ff;
    --accent-soft: rgba(139, 140, 246, 0.14);
    --ok: #3fb950;
    --ok-soft: rgba(63, 185, 80, 0.13);
    --warn: #e0a42f;
    --warn-soft: rgba(224, 164, 47, 0.13);
    --crit: #f2554d;
    --crit-soft: rgba(242, 85, 77, 0.13);
    --backdrop: rgba(0, 0, 0, 0.6);
    --shadow-pop: 0 16px 40px -8px rgba(0, 0, 0, 0.6);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0a0b;
  --surface: #111113;
  --surface-2: #19191c;
  --track: #232327;
  --code-bg: #0d0d0f;
  --border: #232326;
  --border-strong: #303035;
  --text: #ededef;
  --text-2: #a8a8b0;
  --text-3: #8b8b94;
  --text-4: #62626b;
  --bar: #d4d4d8;
  --accent: #8b8cf6;
  --accent-text: #a4a5ff;
  --accent-soft: rgba(139, 140, 246, 0.14);
  --ok: #3fb950;
  --ok-soft: rgba(63, 185, 80, 0.13);
  --warn: #e0a42f;
  --warn-soft: rgba(224, 164, 47, 0.13);
  --crit: #f2554d;
  --crit-soft: rgba(242, 85, 77, 0.13);
  --backdrop: rgba(0, 0, 0, 0.6);
  --shadow-pop: 0 16px 40px -8px rgba(0, 0, 0, 0.6);
}

/* ---- Base ------------------------------------------------------------------ */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
code, pre, .mono { font-family: var(--mono); font-size: 0.92em; }
svg.icon { flex: none; display: block; }
a { color: inherit; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: var(--accent-soft); }

.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;
}
.skip { position: absolute; left: -9999px; top: 8px; z-index: 100; padding: 8px 12px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border); }
.skip:focus { left: 16px; }
.noscript { padding: 32px; text-align: center; color: var(--text-2); }

.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.grow { flex: 1 1 auto; }
.truncate { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.link { color: var(--accent-text); font-size: 13px; font-weight: 500; text-decoration: none; }
.link:hover { text-decoration: underline; text-underline-offset: 3px; }
.link-btn { padding: 2px 0; border: 0; background: none; color: var(--accent-text); font-size: 12.5px; cursor: pointer; }
.link-btn:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---- Shell ----------------------------------------------------------------- */

.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
}
.topbar-inner {
  display: flex; align-items: center; gap: 8px;
  max-width: calc(1080px + 2 * var(--gutter)); height: 56px;
  margin: 0 auto; padding: 0 calc(var(--gutter) - 8px) 0 var(--gutter);
}
.brand { display: inline-flex; align-items: baseline; font-size: 15px; font-weight: 600; letter-spacing: -0.01em; text-decoration: none; white-space: nowrap; }
.brand-sep { margin: 0 6px; color: var(--text-4); font-weight: 400; }
.brand-sub { color: var(--text-3); font-weight: 500; }

.nav { display: flex; gap: 2px; margin-left: 28px; }
.nav-link {
  padding: 6px 10px; border-radius: var(--radius-sm);
  color: var(--text-3); font-size: 13.5px; font-weight: 500; text-decoration: none;
  transition: color 120ms var(--ease), background-color 120ms var(--ease);
}
.nav-link:hover { color: var(--text); background: var(--surface-2); }
.nav-link[aria-current="page"] { color: var(--text); background: var(--surface-2); }

.top-actions { display: flex; align-items: center; gap: 2px; margin-left: auto; }
.top-actions .top-security { display: none; }
.top-security span { display: none; }
.top-security[aria-current="page"] { color: var(--text); background: var(--surface-2); }

.tabbar { display: none; }

.page {
  max-width: calc(1080px + 2 * var(--gutter));
  margin: 0 auto;
  padding: 32px var(--gutter) calc(64px + var(--tabbar));
  outline: none;
}
.page > * + * { margin-top: 24px; }
.page > .host-line { margin-top: 10px; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.page-title { min-width: 0; }
.page-head h1 { font-size: 22px; line-height: 1.25; font-weight: 600; letter-spacing: -0.02em; }
.page-sub { margin-top: 4px; color: var(--text-3); font-size: 13px; }
.page-sub:empty::before { content: "\00a0"; }
.page-actions { display: flex; gap: 8px; flex: none; }

.stack > * + * { margin-top: 24px; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.split-wide { grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); }

.section-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 8px 12px; margin-bottom: 10px; min-height: 30px; }
.section-head > :first-child { flex: 1 1 140px; min-width: 0; }
.section-head h2 { font-size: 14px; font-weight: 600; letter-spacing: -0.005em; }
.section-sub { margin-top: 2px; color: var(--text-3); font-size: 12.5px; }
.section-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.section-note { color: var(--text-3); font-size: 12.5px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.card-pad { padding: 16px 18px; }
.rows.card { overflow: hidden; }

.host-line { padding: 0 2px; color: var(--text-3); font-size: 12.5px; overflow-wrap: anywhere; }
.host-line:empty { display: none; }

/* ---- Rows ------------------------------------------------------------------ */

.row { display: flex; align-items: center; gap: 12px; min-height: 54px; padding: 11px 16px; }
.row + .row { border-top: 1px solid var(--border); }
.row-main { display: flex; flex-direction: column; gap: 1px; flex: 1 1 auto; min-width: 0; }
.row-title { display: flex; align-items: center; gap: 8px; min-width: 0; font-weight: 500; color: var(--text); }
.row-sub { color: var(--text-3); font-size: 12.5px; }
.row-end { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; flex: none; font-size: 13px; color: var(--text-2); white-space: nowrap; text-align: right; }
.row-actions { display: flex; gap: 2px; flex: none; }
span.row-title.truncate, span.row-sub.truncate { display: block; }

.empty { padding: 18px 16px; color: var(--text-3); font-size: 13.5px; }
.row-title.faint { color: var(--text-3); }
.sess-row .row-end { flex-direction: row; align-items: center; gap: 10px; }

/* ---- Controls -------------------------------------------------------------- */

.btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font-size: 13.5px; font-weight: 500; white-space: nowrap;
  cursor: pointer; user-select: none; text-decoration: none;
  transition: background-color 120ms var(--ease), border-color 120ms var(--ease), color 120ms var(--ease), opacity 120ms var(--ease);
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; background: var(--surface); }
.btn-primary { background: var(--text); border-color: var(--text); color: var(--bg); }
.btn-primary:hover { background: var(--text); opacity: 0.86; }
.btn-primary:disabled { background: var(--text); }
.btn-danger { background: var(--crit); border-color: var(--crit); color: #fff; }
.btn-danger:hover { background: var(--crit); opacity: 0.88; }
.btn-danger:disabled { background: var(--crit); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-ghost:disabled { background: transparent; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 7px; }
.btn-icon { width: 34px; padding: 0; }
.btn-sm.btn-icon { width: 30px; }
.btn-block { width: 100%; }
.btn.is-done { color: var(--ok); }
.btn-wrap { display: inline-flex; flex: none; }
.btn-wrap > .btn:disabled { pointer-events: none; }

.btn.is-busy { pointer-events: none; }
.btn.is-busy > * { visibility: hidden; }
.btn.is-busy::after, .spinner {
  content: "";
  width: 14px; height: 14px;
  border: 1.5px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: spin 700ms linear infinite;
}
.btn.is-busy::after { position: absolute; inset: 0; margin: auto; }
.btn.is-busy:disabled { opacity: 0.8; }
.spinner { display: inline-block; color: var(--accent); flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.input {
  width: 100%; height: 38px; padding: 0 11px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font-size: 14px;
  transition: border-color 120ms var(--ease), box-shadow 120ms var(--ease);
}
.input::placeholder { color: var(--text-4); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input:disabled { opacity: 0.6; }
textarea.input { height: auto; padding: 9px 11px; }
select.input {
  appearance: none; -webkit-appearance: none; padding-right: 32px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b8b94' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 10l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 14px;
}
.input-sm { height: 30px; font-size: 13px; width: auto; max-width: 240px; }

.input-group {
  display: flex; align-items: stretch;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface);
  transition: border-color 120ms var(--ease), box-shadow 120ms var(--ease);
}
.input-group:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input-group .input { border: 0; box-shadow: none; background: transparent; min-width: 0; }
.input-addon { display: flex; align-items: center; padding: 0 11px; border-left: 1px solid var(--border); color: var(--text-3); font-size: 13.5px; white-space: nowrap; }
.input-addon-btn { display: grid; place-items: center; width: 38px; flex: none; border: 0; background: none; color: var(--text-3); cursor: pointer; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.input-addon-btn:hover { color: var(--text); }

.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 13px; font-weight: 500; color: var(--text-2); }
.hint { color: var(--text-3); font-size: 12px; }
.hint[data-score="1"] { color: var(--warn); }
.hint[data-score="2"] { color: var(--text-2); }
.hint[data-score="3"] { color: var(--ok); }
.form-error { color: var(--crit); font-size: 13px; overflow-wrap: anywhere; }
.form-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.inline-form { display: flex; align-items: center; gap: 8px; }
.inline-form > select { flex: 1 1 auto; min-width: 0; }

.check { display: flex; align-items: flex-start; gap: 10px; color: var(--text-2); font-size: 13.5px; cursor: pointer; }
.check input { width: 16px; height: 16px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }

.chip {
  display: inline-flex; align-items: center; height: 20px; padding: 0 7px;
  border-radius: 999px; background: var(--surface-2); color: var(--text-2);
  font-size: 11.5px; font-weight: 500; line-height: 1; white-space: nowrap; flex: none;
}
.chip.tone-accent { background: var(--accent-soft); color: var(--accent-text); }
.chip.tone-ok { background: var(--ok-soft); color: var(--ok); }
.chip.tone-warning { background: var(--warn-soft); color: var(--warn); }
.chip.tone-critical { background: var(--crit-soft); color: var(--crit); }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--text-4); }
.dot.tone-ok { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.dot.tone-warning { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.dot.tone-critical { background: var(--crit); box-shadow: 0 0 0 3px var(--crit-soft); }

.meter { position: relative; height: 4px; border-radius: 999px; background: var(--track); overflow: hidden; }
.meter > span {
  display: block; height: 100%; width: calc(var(--v, 0) * 100%);
  border-radius: inherit; background: var(--bar);
  transition: width 180ms var(--ease);
}
.meter.tone-warning > span { background: var(--warn); }
.meter.tone-critical > span { background: var(--crit); }
.meter.is-unknown { opacity: 0.55; }
.meter.is-unknown > span { width: 0; }
.meter-spacer { display: block; height: 4px; }

.callout {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text-2); font-size: 13.5px;
}
.callout > .icon { margin-top: 2px; color: var(--text-3); }
.callout-body { min-width: 0; flex: 1; }
.callout-body strong { display: block; color: var(--text); font-weight: 600; }
.callout-body p { margin-top: 2px; overflow-wrap: anywhere; }
.callout-extra { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.callout.tone-warning { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 22%, transparent); }
.callout.tone-warning > .icon { color: var(--warn); }
.callout.tone-critical { background: var(--crit-soft); border-color: color-mix(in srgb, var(--crit) 22%, transparent); }
.callout.tone-critical > .icon { color: var(--crit); }
.task-list { display: flex; flex-direction: column; gap: 4px; font-size: 13px; overflow-wrap: anywhere; }
.callout-body .task-list strong { display: inline; }

.skeleton { display: flex; flex-direction: column; gap: 10px; padding: 16px 0; }
.skeleton > span { display: block; height: 12px; border-radius: 6px; background: var(--surface-2); animation: pulse 1.4s ease-in-out infinite; }
.skeleton > span:nth-child(3n + 1) { width: 72%; }
.skeleton > span:nth-child(3n + 2) { width: 54%; }
.skeleton > span:nth-child(3n) { width: 64%; }
@keyframes pulse { 50% { opacity: 0.45; } }

/* ---- Stats ----------------------------------------------------------------- */

.stats {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 1px;
  background: var(--border); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
}
.stats-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stat { display: flex; flex-direction: column; gap: 2px; min-width: 0; padding: 14px 16px 16px; background: var(--surface); }
.stat-label { color: var(--text-3); font-size: 12.5px; }
.stat-value { font-size: 22px; line-height: 1.3; font-weight: 600; letter-spacing: -0.02em; white-space: nowrap; }
.stat-value-sm { display: flex; align-items: center; gap: 9px; font-size: 15px; letter-spacing: -0.005em; padding: 3px 0 2px; }
.stat-value.tone-warning, .win-value.tone-warning { color: var(--warn); }
.stat-value.tone-critical, .win-value.tone-critical { color: var(--crit); }
.stat-sub { color: var(--text-3); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat > .meter, .stat > .meter-spacer { margin-top: 10px; }

/* ---- Accounts -------------------------------------------------------------- */

.acct-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  column-gap: 16px;
}
.acct { display: grid; grid-row: span 3; grid-template-rows: subgrid; row-gap: 0; margin-bottom: 16px; min-width: 0; }
@supports not (grid-template-rows: subgrid) {
  .acct { display: flex; flex-direction: column; }
}
.acct-head { display: flex; align-items: center; gap: 6px; padding: 10px 10px 10px 18px; border-bottom: 1px solid var(--border); min-height: 52px; }
.acct-title { font-size: 15px; font-weight: 600; letter-spacing: 0.01em; margin-right: 4px; }

.prov { display: flex; flex-direction: column; min-width: 0; padding: 16px 18px; }
.prov + .prov { border-top: 1px solid var(--border); }
.prov-head { display: flex; align-items: center; gap: 8px; min-height: 22px; }
.prov-name { font-size: 13.5px; font-weight: 600; }
.prov-plan { color: var(--text-3); font-size: 12.5px; }
.prov-chips { display: flex; gap: 6px; margin-left: auto; }
.prov-email { margin-top: 2px; color: var(--text-2); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prov-extra { margin-top: 2px; color: var(--text-3); font-size: 12px; }
.prov-error, .acct-warn { margin-top: 6px; font-size: 12.5px; color: var(--text-2); }
.prov-error.tone-warning, .acct-warn { color: var(--warn); }
.prov-error.tone-critical { color: var(--crit); }
.prov-empty { color: var(--text-3); font-size: 13px; }
.wins { display: flex; flex-direction: column; gap: 14px; margin-top: 16px; transition: opacity 120ms var(--ease); }
.wins.is-dim { opacity: 0.55; }
.prov-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; min-height: 46px; margin-top: auto; padding-top: 16px; }
.prov-foot > :last-child:not(:first-child) { margin-left: auto; }
.prov-meta { color: var(--text-3); font-size: 12px; }

.win-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 7px; font-size: 13px; }
.win-label { color: var(--text-2); }
.win-value { font-weight: 600; }
.win-foot { margin-top: 6px; color: var(--text-3); font-size: 12px; }

/* Tablets: one account per row, Codex and Claude side by side. */
@media (min-width: 720px) and (max-width: 979px) {
  .acct-grid { grid-template-columns: minmax(0, 1fr); }
  .acct { grid-row: auto; grid-template-rows: auto; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .acct-head { grid-column: 1 / -1; }
  .prov + .prov { border-top: 0; border-left: 1px solid var(--border); }
}

/* ---- Overview ---------------------------------------------------------------- */

.active-acct { flex-direction: column; align-items: stretch; gap: 10px; padding: 14px 16px; }
.active-acct-head { display: flex; align-items: center; gap: 10px; min-width: 0; min-height: 20px; }
.active-acct-prov { color: var(--text-3); font-size: 13px; width: 52px; flex: none; }
.active-acct-name { font-weight: 600; }
.active-acct-head > time, .active-acct-head > .faint { color: var(--text-3); font-size: 12px; white-space: nowrap; }
.active-acct > .faint { padding-left: 62px; font-size: 13px; }

/* Window lines: label · bar · % · reset, in columns that line up across providers. */
.wlines {
  display: grid; grid-template-columns: minmax(0, 11em) minmax(48px, 1fr) 3.4em 6.6em;
  align-items: center; gap: 9px 12px; padding-left: 62px; font-size: 13px;
  transition: opacity 120ms var(--ease);
}
.wlines.is-dim { opacity: 0.55; }
.wl { display: contents; }
.wl-label { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wl-value { font-weight: 600; text-align: right; }
.wl-value.tone-warning { color: var(--warn); }
.wl-value.tone-critical { color: var(--crit); }
.wl-reset { display: inline-flex; align-items: center; justify-content: flex-end; gap: 4px; color: var(--text-3); font-size: 12px; white-space: nowrap; }
.wl-reset .icon { opacity: 0.8; }
.svc .row-end { flex-direction: row; gap: 4px; }
.top-proc { min-height: 48px; padding-top: 8px; padding-bottom: 8px; }
.top-proc .row-title { font-weight: 500; font-size: 13px; }
.top-proc .row-end > span:first-child { color: var(--text); }
.host-ips { white-space: nowrap; }
.host-line > span + span::before { content: " · "; color: var(--text-4); }
.mail-line { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.mail-sum .row-sub { margin: 4px 0 0 18px; }

/* ---- Sessions ------------------------------------------------------------------ */

.sess-meta { display: flex; align-items: center; gap: 14px; flex: none; }
.sess-time { min-width: 76px; }
.id-cell { display: inline-flex; align-items: center; gap: 2px; color: var(--text-3); font-size: 12.5px; }
.id-cell .btn { color: var(--text-3); }
.proc .row-title { font-weight: 400; font-size: 13px; }

/* ---- CLI ------------------------------------------------------------------------- */

.ver { display: grid; grid-template-columns: minmax(0, 1fr) 210px 250px; gap: 16px; min-height: 64px; }
.ver-nums { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--text); }
.ver-nums .icon { color: var(--text-3); }
.ver-nums .row-sub { margin-left: 4px; font-weight: 400; }
.ver-end { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.ver-actions { display: flex; align-items: center; gap: 10px; }

.job { overflow: hidden; }
.job-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.job-error { padding: 10px 16px; border-bottom: 1px solid var(--border); color: var(--crit); font-size: 13px; }
.log {
  margin: 0; padding: 12px 16px; max-height: 300px; overflow: auto;
  background: var(--code-bg); color: var(--text-2);
  font: 12.5px/1.65 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere;
}

.segmented { display: inline-flex; gap: 2px; padding: 3px; margin-bottom: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); max-width: 100%; }
.seg {
  display: inline-flex; align-items: baseline; gap: 8px; padding: 6px 12px; min-width: 0;
  border: 0; border-radius: 7px; background: transparent; color: var(--text-3);
  font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: background-color 120ms var(--ease), color 120ms var(--ease);
}
.seg:hover { color: var(--text); }
.seg[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--border), 0 1px 2px rgba(0, 0, 0, 0.05); }
.seg-sub { color: var(--text-3); font-size: 12px; font-weight: 400; }

.editor { overflow: hidden; }
.editor-status { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 8px 14px; border-bottom: 1px solid var(--border); color: var(--text-3); font-size: 12.5px; }
.editor-status .mono { flex: 1 1 auto; }
.code { display: flex; height: clamp(240px, 46vh, 560px); background: var(--code-bg); }
.code:focus-within { box-shadow: inset 0 0 0 1px var(--accent); }
.code-gutter {
  flex: none; min-width: 46px; margin: 0; padding: 12px 10px 12px 12px;
  overflow: hidden; text-align: right; user-select: none;
  border-right: 1px solid var(--border); color: var(--text-4);
  font: 13px/20px var(--mono);
}
.code-gutter .is-err { color: var(--crit); font-weight: 700; }
.code-input {
  flex: 1 1 auto; min-width: 0; margin: 0; padding: 12px 14px;
  border: 0; outline: 0; resize: none; background: transparent; color: var(--text);
  font: 13px/20px var(--mono); white-space: pre; overflow: auto; tab-size: 2;
}
.code-input:disabled { color: var(--text-3); }
.editor-errors { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px 0; }
.editor-errors:empty { display: none; }
.editor-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 12px 14px; border-top: 1px solid var(--border); }
.editor-errors + .editor-foot { border-top: 0; }
.editor-backups { display: flex; align-items: center; gap: 4px; min-width: 0; }

/* ---- Mail -------------------------------------------------------------------------- */

.dns-card { overflow: hidden; }
.dns-top { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 16px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.dns-tabs { margin: 0; }
.seg-count { color: var(--text-3); font-size: 12px; font-weight: 400; }
.dns-help { flex: 1 1 260px; min-width: 0; }
.dns-help code { padding: 0 4px; border-radius: 4px; background: var(--surface-2); color: var(--text); font-size: 12px; }
.dns-help b { font-weight: 600; color: var(--text-2); }
.dns-callout { padding: 12px 16px 0; }
.dns { width: 100%; border-collapse: collapse; font-size: 13px; table-layout: fixed; }
.dns th { padding: 10px 12px 8px; text-align: left; font-size: 12px; font-weight: 500; color: var(--text-3); border-bottom: 1px solid var(--border); white-space: nowrap; }
.dns td { padding: 10px 12px; vertical-align: top; }
.dns tbody tr + tr td { border-top: 1px solid var(--border); }
.dns .dns-status { width: 44px; padding-left: 16px; padding-right: 0; }
.dns .dns-type { width: 72px; }
.dns .dns-host { width: 31%; }
.dns .dns-ttl { width: 64px; padding-right: 16px; text-align: right; }
.dns td.dns-status { padding-top: 15px; }
.dns td.dns-type { padding-top: 14px; }
.dns td.dns-ttl { padding-top: 15px; color: var(--text-2); }
.dns-ok td { color: var(--text-2); }
.status-icon { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--surface-2); color: var(--text-3); }
.status-icon.tone-ok { background: var(--ok-soft); color: var(--ok); }
.status-icon.tone-critical { background: var(--crit-soft); color: var(--crit); }
.status-icon.tone-warning { background: var(--warn-soft); color: var(--warn); }
.dns-status-text, .dns-status-note { display: none; }
.type-badge {
  display: inline-block; min-width: 46px; padding: 1px 6px;
  border: 1px solid var(--border-strong); border-radius: 5px; text-align: center;
  color: var(--text-2); font: 600 10.5px/16px var(--mono); letter-spacing: 0.03em;
}
/* A value box you can read, select, and copy with one click. */
.dns-copy {
  display: flex; align-items: flex-start; gap: 2px; min-width: 0;
  padding: 2px 2px 2px 9px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--code-bg);
}
.dns-copy > .btn { margin-left: auto; }
/* Records that are already right stay copyable but step back visually. */
.dns-ok .dns-copy { border-color: transparent; background: transparent; }
.dns-ok .dns-code { color: var(--text-2); }
.dns-code {
  flex: 1 1 auto; min-width: 0; margin: 5px 0;
  font-size: 12.5px; line-height: 1.5; color: var(--text); overflow-wrap: anywhere; user-select: all;
}
.dns-code.is-long { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; cursor: zoom-in; user-select: text; border-radius: 3px; }
.dns-code.is-long.is-open { display: block; cursor: zoom-out; }
.dns-code.is-long:focus-visible { outline-offset: 1px; }
.dns-note, .dns-extra, .dns-actual { margin-top: 5px; font-size: 12px; overflow-wrap: anywhere; }
.dns-note { color: var(--text-3); }
.dns-extra { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--text-3); }
.dns-extra b { color: var(--text); font-weight: 600; }
.dns-actual { color: var(--crit); }
.dns-actual.faint { color: var(--text-3); }
.dns-foot { display: flex; align-items: baseline; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--border); }
.dns-foot .hint { flex: 1; }

.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 10px 18px; margin: 0; font-size: 13px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; overflow-wrap: anywhere; color: var(--text); }
.kv-line { display: block; }

/* ---- Toasts & dialogs ----------------------------------------------------------------- */

.toasts {
  position: fixed; right: 20px; bottom: 20px; z-index: 60;
  display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
  max-width: min(400px, calc(100vw - 32px)); pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  border-radius: 10px; background: var(--text); color: var(--bg);
  font-size: 13.5px; font-weight: 500; box-shadow: var(--shadow-pop);
  pointer-events: auto; opacity: 0; transform: translateY(6px);
  transition: opacity 160ms var(--ease), transform 160ms var(--ease);
}
.toast.is-in { opacity: 1; transform: none; }
.toast-error .icon { color: var(--crit); }
:root[data-theme="dark"] .toast-error .icon { color: #d42a2a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .toast-error .icon { color: #d42a2a; } }

.modal {
  width: min(440px, calc(100vw - 32px)); max-height: calc(100dvh - 48px);
  padding: 0; border: 1px solid var(--border); border-radius: 14px;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-pop);
  overflow: auto;
}
.modal::backdrop { background: var(--backdrop); }
.modal[open] { animation: modal-in 160ms var(--ease); }
@keyframes modal-in { from { opacity: 0; transform: translateY(6px) scale(0.99); } }
.modal-form { display: flex; flex-direction: column; gap: 14px; padding: 20px; }
.modal-title { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.modal-text { margin-top: -6px; color: var(--text-2); font-size: 13.5px; overflow-wrap: anywhere; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

/* ---- Auth ------------------------------------------------------------------------------ */

.auth {
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px;
  padding: 32px 16px calc(32px + env(safe-area-inset-bottom));
}
.auth-brand { display: flex; align-items: baseline; font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.auth-card { width: min(380px, 100%); padding: 28px; display: flex; flex-direction: column; gap: 16px; }
.auth-wide { width: min(460px, 100%); }
.auth-title { font-size: 18px; font-weight: 600; letter-spacing: -0.015em; }
.auth-row { display: flex; justify-content: flex-end; margin-top: -8px; }
.auth-card > .btn-primary { margin-top: 2px; height: 38px; }

.stepper { display: flex; gap: 18px; font-size: 12.5px; color: var(--text-3); }
.stepper li { display: flex; align-items: center; gap: 7px; }
.step-num { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--border-strong); font-size: 11px; font-weight: 600; }
.stepper .is-current { color: var(--text); font-weight: 500; }
.stepper .is-current .step-num { background: var(--text); border-color: var(--text); color: var(--bg); }
.stepper .is-done .step-num { background: var(--ok-soft); border-color: transparent; color: var(--ok); }

/* QR stays dark-on-white in both themes so every scanner can read it. */
.qr { align-self: center; padding: 14px; border-radius: var(--radius); background: #fff; border: 1px solid var(--border); line-height: 0; }
.qr img { width: 200px; height: 200px; }
.secret { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 8px 10px 12px; border-radius: 10px; background: var(--surface-2); }
.secret-code { display: block; margin-top: 2px; font-size: 13px; letter-spacing: 0.06em; overflow-wrap: anywhere; color: var(--text); }

.codes { display: flex; flex-direction: column; gap: 12px; }
.codes-title { font-size: 16px; font-weight: 600; }
.codes-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 16px;
  padding: 14px 16px; border-radius: 10px; background: var(--surface-2);
  font-size: 14px; letter-spacing: 0.04em;
}
.codes-grid li { font-size: 14px; }
.codes-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---- Tone utilities: last, so they win over .row-title / .row-end colours ---------------- */

.tone-text-ok { color: var(--ok); }
.tone-text-warning { color: var(--warn); }
.tone-text-critical { color: var(--crit); }
.tone-text-muted { color: var(--text-3); }

/* ---- Mobile ----------------------------------------------------------------------------- */

@media (max-width: 719px) {
  :root { --gutter: 16px; --tabbar: calc(60px + env(safe-area-inset-bottom)); }
  body { font-size: 15px; }

  .topbar-inner { height: 52px; padding-right: 8px; }
  .nav { display: none; }
  .top-actions .top-security { display: inline-flex; }

  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    display: grid; grid-template-columns: repeat(5, 1fr);
    padding-bottom: env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    -webkit-backdrop-filter: saturate(1.4) blur(12px);
    backdrop-filter: saturate(1.4) blur(12px);
    border-top: 1px solid var(--border);
  }
  .tab {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    min-height: 60px; color: var(--text-3); font-size: 11px; font-weight: 500; text-decoration: none;
  }
  .tab[aria-current="page"] { color: var(--text); }
  .tab:focus-visible { outline-offset: -4px; border-radius: 12px; }

  .page { padding-top: 22px; }
  .page > * + * { margin-top: 20px; }
  .page-head h1 { font-size: 20px; }

  .split, .split-wide { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .stack > * + * { margin-top: 20px; }

  .stats, .stats-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats > :last-child:nth-child(odd) { grid-column: 1 / -1; }
  .stat { padding: 12px 14px 14px; }
  .stat-value:not(.stat-value-sm) { font-size: 20px; }

  .input { height: 44px; font-size: 16px; }
  .input-sm { height: 38px; font-size: 15px; }
  .code-input { font-size: 16px; line-height: 22px; }
  .code-gutter { line-height: 22px; }
  .btn { height: 42px; }
  .btn-sm { height: 38px; }
  .btn-icon { width: 42px; }
  .btn-sm.btn-icon { width: 38px; }
  .auth-card > .btn-primary { height: 44px; }

  .row { flex-wrap: wrap; row-gap: 6px; padding: 12px 14px; }
  .row-end { font-size: 12.5px; }
  .sess .row-main { flex-basis: 100%; }
  .sess-meta { flex: 1 1 auto; }
  .proc .row-main { flex-basis: calc(100% - 90px); }
  .proc .row-end { flex-direction: row; gap: 8px; margin-left: auto; }
  .segmented { display: flex; }
  .seg { flex: 1; justify-content: center; }
  .seg-sub { display: none; }
  .ver { grid-template-columns: minmax(0, 1fr); row-gap: 10px; }
  .ver-end { align-items: stretch; }
  .ver-actions .btn { flex: 1; }
  .audit .row-main { flex-basis: calc(100% - 96px); }
  .box { flex-wrap: nowrap; }
  .sess-row .row-end { margin-left: auto; }
  .recovery-row { flex-direction: column; align-items: stretch; gap: 12px; }

  .wlines, .active-acct > .faint { padding-left: 0; }
  .wlines { grid-template-columns: minmax(0, 7.2em) minmax(36px, 1fr) 3.2em 5.6em; column-gap: 10px; }
  .wl-reset .icon { display: none; }
  .wl-label { white-space: normal; line-height: 1.3; }
  .prov-foot > .btn, .prov-foot > .btn-wrap { flex: 1 1 100%; }
  .prov-foot > .btn-wrap > .btn { flex: 1; }

  .dns-top { padding: 12px 14px; }
  .dns-tabs { display: flex; width: 100%; }
  .dns thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .dns, .dns tbody { display: block; }
  .dns tr {
    display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center;
    grid-template-areas: "type status" "host host" "val val" "ttl ttl";
    gap: 8px 10px; padding: 14px;
  }
  .dns tbody tr + tr { border-top: 1px solid var(--border); }
  .dns td, .dns tbody tr + tr td, .dns td.dns-status, .dns td.dns-type, .dns td.dns-host, .dns td.dns-ttl {
    display: block; width: auto; padding: 0; border: 0; text-align: left;
  }
  .dns td.dns-status { grid-area: status; display: flex; align-items: center; gap: 6px; }
  .dns td.dns-type { grid-area: type; }
  .dns td.dns-host { grid-area: host; }
  .dns td.dns-val { grid-area: val; }
  .dns td.dns-ttl { grid-area: ttl; font-size: 12.5px; color: var(--text-3); }
  .dns td[data-label]::before { content: attr(data-label); display: block; margin-bottom: 4px; color: var(--text-3); font-size: 12px; }
  .dns td.dns-ttl::before { display: inline; margin: 0 6px 0 0; }
  .dns-status .status-icon { width: 18px; height: 18px; }
  .dns-status-text { display: inline; font-size: 12.5px; font-weight: 500; }
  /* The record's purpose (SPF, DKIM…) joins the status line; the cell copy is dropped. */
  .dns-status-note { display: inline; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-3); font-size: 12.5px; }
  .dns-status-note::before { content: "· "; }
  .dns tr:not(.dns-ok) .dns-host .dns-note { display: none; }
  .dns tr.dns-ok .dns-status-note { display: none; }
  .dns-code { font-size: 13.5px; }
  .dns-foot { flex-direction: column; gap: 6px; padding: 12px 14px; }
  /* Records that are already right: one compact block, no labels, no TTL. */
  .dns tr.dns-ok { grid-template-areas: "type host" "status val"; column-gap: 8px; row-gap: 2px; padding: 10px 14px; }
  .dns tr.is-gorilla td.dns-ttl { display: none; }
  .dns tr.dns-ok { align-items: start; }
  .dns tr.dns-ok td.dns-status { justify-content: center; padding-top: 10px; }
  .dns tr.dns-ok td.dns-type { padding-top: 10px; }
  .dns tr.dns-ok .dns-status-text, .dns tr.dns-ok td.dns-ttl, .dns tr.dns-ok td[data-label]::before { display: none; }
  .dns tr.dns-ok .dns-copy { padding-left: 0; }
  .dns tr.dns-ok .dns-code { margin: 4px 0; font-size: 13px; }
  .dns tr.dns-ok .dns-note { margin-top: 0; }

  .editor-foot .grow { display: none; }
  .editor-backups { flex: 1 1 100%; }
  .editor-backups .input-sm { flex: 1; max-width: none; }
  .editor-foot > .btn { flex: 1; }

  .toasts { left: 16px; right: 16px; bottom: calc(var(--tabbar) + 12px); max-width: none; align-items: stretch; }
  body:not(:has(.tabbar)) .toasts { bottom: 16px; }

  .modal { border-radius: 16px; }
  .modal-actions > .btn { flex: 1; }
  .auth-card { padding: 22px 18px; }
}

@media (max-width: 400px) {
  .stepper li:not(.is-current) span:last-child { display: none; }
  .codes-grid { gap: 8px 10px; padding: 12px; }
}

@media (pointer: coarse) {
  .btn-icon::before { content: ""; position: absolute; inset: -3px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0ms !important; animation-duration: 0ms !important; }
  .btn.is-busy::after, .spinner { animation: spin 1.6s linear infinite !important; }
  .skeleton > span { animation: none !important; }
}
