/* siftp console. One stylesheet, system fonts, no dependencies. */
:root {
  --bg: #f6f8f8;
  --surface: #ffffff;
  --surface-2: #f3f6f6;
  --fg: #111418;
  --muted: #59606b;
  --faint: #868d97;
  --line: #e3e7ea;
  --line-strong: #cfd5da;
  --accent: #0b8462;
  --accent-fg: #ffffff;
  --accent-soft: #e6f3ee;
  --accent-text: #07694e;
  --ctx: #8b929c;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --warn: #8a5a00;
  --warn-soft: #fff4dc;
  --info-soft: #eaf1fb;
  --info: #1d4f91;
  --code-bg: #f1f4f5;
  --shadow: 0 1px 2px rgba(16, 24, 32, 0.05);
  --shadow-lg: 0 12px 40px rgba(16, 24, 32, 0.18);
  --focus: #0b8462;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --sidebar: 244px;
  --radius: 10px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0e11;
    --surface: #12161b;
    --surface-2: #171c22;
    --fg: #e6e9ec;
    --muted: #a0a8b3;
    --faint: #7a828d;
    --line: #222830;
    --line-strong: #323a44;
    --accent: #19aa70;
    --accent-fg: #04140d;
    --accent-soft: #10241c;
    --accent-text: #4fd1a1;
    --ctx: #5f6873;
    --danger: #ff8a7d;
    --danger-soft: #2a1512;
    --warn: #f0b94a;
    --warn-soft: #2a2110;
    --info-soft: #111c2c;
    --info: #8db8f2;
    --code-bg: #161b21;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.6);
    --focus: #4fd1a1;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 22px; line-height: 1.25; }
h2 { font-size: 15px; }
p { margin: 0 0 8px; }
a { color: var(--accent-text); text-underline-offset: 2px; }
code, .mono { font-family: var(--mono); font-size: 0.92em; }
code { background: var(--code-bg); padding: 1px 5px; border-radius: 5px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.boot { padding: 24px 16px; color: var(--muted); }
.icon { flex: none; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
button:focus-visible, .btn:focus-visible { outline-offset: 2px; }

/* ------------------------------------------------------------- shell */
.shell { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar);
  background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 16px 12px; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 8px; padding: 4px 8px 16px; }
.brand-mark { width: 24px; height: 24px; flex: none; display: block; }
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: -0.02em; }
.brand-sub { color: var(--faint); font-size: 13px; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav-link {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px;
  color: var(--muted); text-decoration: none; font-weight: 500;
}
.nav-link:hover { background: var(--surface-2); color: var(--fg); }
.nav-link[aria-current="page"] { background: var(--accent-soft); color: var(--accent-text); }
.who { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 8px; }
.who-link { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--fg); padding: 6px; border-radius: 8px; }
.who-link:hover { background: var(--surface-2); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-text);
  display: grid; place-items: center; font-weight: 600; flex: none;
}
.who-text { display: flex; flex-direction: column; min-width: 0; }
.who-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-sub { color: var(--faint); font-size: 12px; }
.main { margin-left: var(--sidebar); padding: 28px 32px 64px; min-width: 0; outline: none; }
.page { max-width: 1120px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }
.topbar { display: none; }
.scrim { display: none; }

.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.page-titles { min-width: 0; }
.page-sub { color: var(--muted); margin: 4px 0 0; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumb { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; margin-bottom: 6px; flex-wrap: wrap; }
.crumb a { color: var(--muted); }

/* ---------------------------------------------------------- controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--fg); font: inherit; font-weight: 500; cursor: pointer;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn.primary:hover { filter: brightness(1.06); background: var(--accent); }
.btn.danger { color: var(--danger); border-color: var(--line-strong); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.solid-danger { background: var(--danger); color: var(--surface); border-color: var(--danger); }
.btn.small { height: 28px; padding: 0 10px; font-size: 13px; }
.btn.big { height: 46px; padding: 0 22px; font-size: 16px; border-radius: 10px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 8px;
  border: 1px solid transparent; background: transparent; color: var(--fg); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }

.input, select.input, textarea.input {
  width: 100%; height: 34px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--fg); font: inherit;
}
textarea.input { height: auto; min-height: 84px; padding: 8px 10px; font-family: var(--mono); font-size: 13px; resize: vertical; }
.input::placeholder { color: var(--faint); }
.input:focus-visible { outline: 2px solid var(--focus); outline-offset: 0; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field-label { font-weight: 500; font-size: 13px; }
.field-help { color: var(--muted); font-size: 12.5px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .wide { grid-column: 1 / -1; }
.inline { display: flex; gap: 8px; align-items: center; }
.inline > .input { flex: 1; min-width: 0; }
.inline select.input { flex: 0 0 auto; width: auto; }
.check-row { display: flex; flex-wrap: wrap; gap: 8px; }
.check {
  display: flex; align-items: flex-start; gap: 8px; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 8px; cursor: pointer; min-width: 150px; flex: 1 1 150px;
}
.check:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.check input { margin-top: 3px; accent-color: var(--accent); }
.check-t { font-weight: 500; }
.check-d { color: var(--muted); font-size: 12.5px; display: block; }
.radio-card { display: flex; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.radio-card:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.radio-card input { margin-top: 3px; accent-color: var(--accent); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.tab {
  padding: 9px 14px; color: var(--muted); text-decoration: none; font-weight: 500;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab[aria-current="page"] { color: var(--fg); border-bottom-color: var(--accent); }
.tab:hover { color: var(--fg); }

/* ------------------------------------------------------------- cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.card > :not(.card-head) { margin: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.card-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.card-body { padding: 16px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); min-width: 0; }
.tile-label { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.tile-value { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; margin-top: 4px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.tile-sub { color: var(--faint); font-size: 12.5px; margin-top: 2px; }

.kv { display: grid; grid-template-columns: minmax(110px, 160px) 1fr; gap: 8px 16px; padding: 16px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* ------------------------------------------------------------ meters */
.meter { position: relative; height: 12px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); overflow: visible; }
.meter.thin { height: 6px; border: 0; background: var(--line); }
.meter-fill { height: 100%; border-radius: 999px; background: var(--accent); min-width: 2px; }
.meter-fill.over { background: var(--danger); }
.meter-mark { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--ctx); border-radius: 1px; }
.meter-legend { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 8px; color: var(--muted); font-size: 12.5px; }
.meter-legend .key { display: inline-flex; align-items: center; gap: 6px; }
.tick { display: inline-block; width: 2px; height: 12px; background: var(--ctx); border-radius: 1px; }
.meter-box { padding: 16px; }
.meter-big { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; gap: 12px; flex-wrap: wrap; }
.meter-big strong { font-size: 22px; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------ tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12.5px; padding: 9px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface-2); }
.table td { padding: 10px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .nowrap { white-space: nowrap; }
.table .grow { width: 100%; }
.cell-clip { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-link { color: var(--fg); font-weight: 600; text-decoration: none; }
.row-link:hover { text-decoration: underline; }
.mono-cell { font-family: var(--mono); font-size: 12.5px; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }

.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.list > li:last-child { border-bottom: 0; }
.li-main { flex: 1; min-width: 180px; }
.li-title { font-weight: 600; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.li-sub { color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }

/* ------------------------------------------------ badges and statuses */
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 500; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.badge.accent { background: var(--accent-soft); color: var(--accent-text); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.bad { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.status { display: inline-flex; align-items: center; gap: 5px; font-weight: 500; font-size: 13px; }
.status.ok { color: var(--accent-text); }
.status.warn { color: var(--warn); }
.status.bad { color: var(--danger); }
.status.info { color: var(--muted); }
.perms { display: inline-flex; gap: 3px; }
.perm { font-family: var(--mono); font-size: 12px; width: 20px; height: 20px; display: inline-grid; place-items: center; border-radius: 5px; background: var(--accent-soft); color: var(--accent-text); }
.perm.off { background: var(--surface-2); color: var(--faint); }

.banner { display: flex; gap: 10px; padding: 10px 12px; border-radius: 8px; align-items: flex-start; }
.banner.error { background: var(--danger-soft); color: var(--danger); }
.banner.warn { background: var(--warn-soft); color: var(--warn); }
.banner.info { background: var(--info-soft); color: var(--info); }
.banner.ok { background: var(--accent-soft); color: var(--accent-text); }
.banner .icon { margin-top: 2px; }
.banner-body { min-width: 0; }
.banner-msg { font-weight: 500; overflow-wrap: anywhere; }
.banner-hint { opacity: 0.9; overflow-wrap: anywhere; }
.banner-doc { font-size: 12.5px; color: inherit; }
.errors:empty { display: none; }

.empty { text-align: center; padding: 36px 16px; color: var(--muted); }
.empty-title { font-weight: 600; color: var(--fg); margin-bottom: 4px; }
.empty-text { max-width: 460px; margin: 0 auto 12px; }

/* ------------------------------------------------------------ dialogs */
dialog.dialog {
  border: 1px solid var(--line-strong); border-radius: 14px; padding: 0; background: var(--surface); color: var(--fg);
  width: min(460px, calc(100vw - 32px)); box-shadow: var(--shadow-lg); max-height: calc(100vh - 32px);
}
dialog.dialog.wide { width: min(640px, calc(100vw - 32px)); }
dialog.dialog::backdrop { background: rgba(8, 12, 16, 0.55); }
.dialog-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.dialog-text { color: var(--muted); margin: 0; overflow-wrap: anywhere; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.secret { display: flex; gap: 8px; align-items: stretch; }
.secret-value {
  flex: 1; min-width: 0; padding: 10px 12px; background: var(--code-bg); border: 1px solid var(--line);
  border-radius: 8px; overflow-wrap: anywhere; word-break: break-all; user-select: all; font-size: 13px;
}
.secret-value.plain { font-family: var(--sans); }

/* ------------------------------------------------------------- toasts */
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 100; max-width: calc(100vw - 32px); }
.toast { display: flex; gap: 8px; align-items: center; padding: 10px 14px; border-radius: 10px; background: var(--fg); color: var(--bg); box-shadow: var(--shadow-lg); font-weight: 500; }
.toast.error { background: var(--danger); color: var(--surface); }
.toast .icon { flex: none; }

/* ----------------------------------------------------- bare (sign-in) */
body.bare { background: var(--bg); }
.bare-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.bare-card {
  width: min(440px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 32px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 16px;
}
.bare-card.wide { width: min(520px, 100%); }
.bare-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.bare-brand .brand-mark { width: 30px; height: 30px; }
.bare-card h1 { font-size: 22px; }
.host-big { font-size: 20px; font-weight: 650; overflow-wrap: anywhere; }
.facts { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; display: grid; gap: 6px; }
.facts div { display: flex; justify-content: space-between; gap: 12px; }
.facts span:first-child { color: var(--muted); }
.facts span:last-child { overflow-wrap: anywhere; text-align: right; }

/* -------------------------------------------------------------- misc */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.filters .field { flex: 1 1 130px; max-width: 220px; }
.toggle { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 500; }
.toggle input { accent-color: var(--accent); width: 16px; height: 16px; }
.logline { font-family: var(--mono); font-size: 12.5px; }
.lvl { font-family: var(--mono); font-size: 11.5px; font-weight: 600; text-transform: uppercase; }
.lvl.error { color: var(--danger); }
.lvl.warn { color: var(--warn); }
.log-msg { white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--mono); font-size: 12.5px; }
.pre { background: var(--code-bg); border: 1px solid var(--line); border-radius: 8px; padding: 12px; overflow-x: auto; font-family: var(--mono); font-size: 12.5px; white-space: pre; margin: 0; position: relative; }
.copy-block { display: flex; gap: 8px; align-items: flex-start; }
.copy-block .pre { flex: 1; min-width: 0; }
.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.section-note { padding: 12px 16px; color: var(--muted); border-top: 1px solid var(--line); }
.card-body.stack > p { margin: 0; }
.scroll-box { max-height: 520px; overflow: auto; }
.userbar { display: grid; grid-template-columns: minmax(90px, 140px) 1fr auto; gap: 12px; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.userbar:last-child { border-bottom: 0; }
.userbar > * { min-width: 0; overflow-wrap: anywhere; }
.userbar .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.userbar .amt { color: var(--muted); font-size: 12.5px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.fb-row { cursor: default; }
.fb-name { display: inline-flex; align-items: center; gap: 8px; background: none; border: 0; padding: 0; font: inherit; color: var(--fg); }
button.fb-name { cursor: pointer; font-weight: 500; }
button.fb-name:hover { text-decoration: underline; }
.fb-name .icon { color: var(--ctx); }

/* ------------------------------------------------------------ narrow */
@media (max-width: 1000px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  body { font-size: 15px; }
  .topbar {
    position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px;
    height: 52px; padding: 0 8px 0 4px; background: var(--surface); border-bottom: 1px solid var(--line);
  }
  .topbar .brand-name { font-size: 15px; }
  .topbar-title { margin-left: auto; padding-right: 8px; color: var(--muted); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .sidebar { transform: translateX(-100%); transition: transform 0.18s ease; width: min(280px, 84vw); box-shadow: var(--shadow-lg); }
  body.drawer-open .sidebar { transform: none; }
  body.drawer-open .scrim { display: block; position: fixed; inset: 0; background: rgba(8, 12, 16, 0.5); z-index: 25; }
  .main { margin-left: 0; padding: 20px 16px 56px; }
  h1 { font-size: 20px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .kv { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .kv dd { margin-bottom: 10px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile-value { font-size: 22px; }
  .bare-card { padding: 24px 20px; }
  .toasts { left: 16px; right: 16px; }
  .userbar { grid-template-columns: 1fr auto; }
  .userbar .name { grid-column: 1; }
  .userbar .amt { grid-column: 2; }
  .userbar .meter { grid-column: 1 / -1; }
  .btn { height: 40px; }
  .btn.small { height: 32px; }
  .filters .field { max-width: none; flex: 1 1 100%; }
  /* Tables become stacked rows with their column labels. */
  .table.stack-rows thead { display: none; }
  .table.stack-rows, .table.stack-rows tbody, .table.stack-rows tr, .table.stack-rows td { display: block; width: 100%; }
  .table.stack-rows tr { padding: 10px 16px; border-bottom: 1px solid var(--line); }
  .table.stack-rows td { border: 0; padding: 3px 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  .table.stack-rows td::before { content: attr(data-label); color: var(--muted); font-size: 12.5px; text-align: left; flex: none; }
  .table.stack-rows td:empty { display: none; }
  .table.stack-rows tbody tr:hover td { background: none; }
  .table.stack-rows .cell-clip { max-width: 60vw; }
  .table.stack-rows .row-actions { justify-content: flex-end; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
