/* =============================================================================
   FaucetDynasty — UI system
   Single source of truth for the panels. Hand-written, served as-is (no build step).

   Rules (see docs/UI.md):
   1. Use the tokens below. Never a raw hex, px size or radius in a view.
   2. Radius by intent, not by habit: surfaces (cards, tables, the sidebar) are square;
      controls (inputs, buttons, badges, flashes) get --r-ctl.
   3. Compact: --s3/--s4 padding on blocks, --s2 table cells. No big empty areas.
   4. New pattern? Add a component here and show it on /style before using it.
   ============================================================================= */

:root {
    /* surfaces */
    --bg: #0a0f1c;
    --side: #0c1220;
    --card: #101725;
    --card-hi: #141c2c;
    --line: #1f2738;
    --line-hi: #2b3446;

    /* ink */
    --text: #e7ecf5;
    --muted: #8794ab;
    --dim: #64708a;

    /* signal */
    --accent: #f5b942;
    --accent-ink: #191305;
    --accent-line: rgba(245, 185, 66, 0.28);
    --accent-soft: rgba(245, 185, 66, 0.1);
    --good: #3ddc97;
    --good-line: rgba(61, 220, 151, 0.28);
    --good-soft: rgba(61, 220, 151, 0.08);
    --bad: #ff6b6b;
    --bad-line: rgba(255, 107, 107, 0.3);
    --bad-soft: rgba(255, 107, 107, 0.08);

    /* radius — intent, not habit */
    --r-ctl: 3px;   /* inputs, buttons, badges, flashes */
    --r: 0;         /* cards, panels, tables, sidebar */

    /* space */
    --s1: 4px;
    --s2: 8px;
    --s3: 12px;
    --s4: 16px;
    --s5: 22px;
    --s6: 30px;

    /* type */
    --f-xs: 11px;
    --f-sm: 12.5px;
    --f: 14px;
    --f-lg: 15.5px;
    --f-h1: 20px;
    --f-stat: 23px;
    --side-w: 208px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: var(--f)/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: var(--f-sm); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--side-w) 1fr; min-height: 100vh; }

.side {
    background: var(--side);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    padding: var(--s4) 0 var(--s3);
}
.side .brand {
    display: flex;
    align-items: center;
    gap: var(--s2);
    padding: 0 var(--s4) var(--s4);
    font-size: var(--f-lg);
    font-weight: 700;
    color: var(--text);
}
.side .brand:hover { text-decoration: none; }
.side .brand span { color: var(--accent); }
.side .brand img { width: 18px; height: 18px; display: block; }
.side .who {
    padding: 0 var(--s4) var(--s3);
    border-bottom: 1px solid var(--line);
    margin-bottom: var(--s2);
    font-size: var(--f-sm);
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.side nav { display: flex; flex-direction: column; }
.side nav a {
    padding: 7px var(--s4);
    border-left: 2px solid transparent;
    color: var(--muted);
    font-size: var(--f);
}
.side nav a:hover { color: var(--text); background: var(--card); text-decoration: none; }
.side nav a.active { color: var(--text); border-left-color: var(--accent); background: var(--card); }
.side .foot { margin-top: auto; padding: var(--s3) var(--s4) 0; border-top: 1px solid var(--line); }
.side .foot form { margin: 0; }
.side .foot button {
    background: none; border: 0; padding: var(--s1) 0; cursor: pointer;
    color: var(--muted); font-size: var(--f); font-weight: 500;
}
.side .foot button:hover { color: var(--text); }

.content { padding: var(--s6) var(--s6) 60px; max-width: 1120px; }

/* ---------- plain pages ---------- */
.plain { max-width: 700px; margin: 0 auto; padding: var(--s6) var(--s5) 80px; }
.plain .top { display: flex; align-items: center; gap: var(--s3); margin-bottom: var(--s6); }
.plain .top .brand { display: flex; align-items: center; gap: var(--s2); font-size: var(--f-lg); font-weight: 700; color: var(--text); }
.plain .top .brand span { color: var(--accent); }
.plain .top .brand img { width: 18px; height: 18px; }
.plain .top nav { margin-left: auto; display: flex; gap: var(--s4); }
.plain .top nav a { color: var(--muted); font-size: var(--f); }
.plain .top nav a:hover { color: var(--text); text-decoration: none; }

/* ---------- page head ---------- */
.page-head { display: flex; align-items: flex-start; gap: var(--s4); margin-bottom: var(--s5); }
.page-head .t { flex: 1; min-width: 0; }
.page-head .t h1 { margin: 0 0 2px; }
.page-head .t .lead { margin: 0; }
.page-head .actions { display: flex; gap: var(--s2); flex-shrink: 0; }

h1 { font-size: var(--f-h1); font-weight: 650; letter-spacing: -0.2px; margin: 0 0 var(--s1); }
h2 {
    font-size: var(--f-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.9px;
    color: var(--dim);
    margin: var(--s6) 0 var(--s2);
}
h2:first-of-type { margin-top: var(--s4); }
p.lead { color: var(--muted); margin: 0 0 var(--s5); font-size: var(--f); }
p.lead:last-child { margin-bottom: 0; }
.sub { color: var(--muted); font-size: var(--f-sm); margin-top: 3px; }
.hint { color: var(--dim); font-size: var(--f-sm); margin-top: var(--s1); }

/* ---------- blocks ---------- */
.card { background: var(--card); border: 1px solid var(--line); padding: var(--s3) var(--s4); }
.card + .card { border-top: 0; }
.card > h3 {
    font-size: var(--f-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--dim);
    margin: 0 0 var(--s2);
}
.card .row-actions { display: flex; gap: var(--s2); flex-wrap: wrap; }

/* a grid of statistics: one hairline, no gaps, no shadow */
.grid { display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); }
.grid > * { background: var(--card); padding: var(--s3) var(--s4); }
.cols-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.cols-3 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.cols-4 { grid-template-columns: repeat(auto-fit, minmax(172px, 1fr)); }

.stat { font-size: var(--f-stat); font-weight: 650; letter-spacing: -0.4px; font-variant-numeric: tabular-nums; }
.stat.sm { font-size: var(--f-lg); font-weight: 600; }

/* ---------- badges ---------- */
.badge {
    display: inline-block;
    padding: 0 6px;
    border: 1px solid var(--accent-line);
    border-radius: var(--r-ctl);
    background: var(--accent-soft);
    color: var(--accent);
    font-size: var(--f-xs);
    font-weight: 600;
    line-height: 17px;
    letter-spacing: 0.2px;
}
.badge.good { background: var(--good-soft); border-color: var(--good-line); color: var(--good); }
.badge.bad { background: var(--bad-soft); border-color: var(--bad-line); color: var(--bad); }
.badge.muted { background: rgba(135, 148, 171, 0.08); border-color: var(--line); color: var(--muted); }

/* ---------- tables ---------- */
.table { width: 100%; border-collapse: collapse; font-size: var(--f); }
.table th, .table td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); }
.table th {
    font-size: var(--f-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    color: var(--dim);
    white-space: nowrap;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--card-hi); }
.table td.actions { white-space: nowrap; }
.table .row-actions { display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; }

/* ---------- forms ---------- */
.row { display: flex; gap: var(--s3); flex-wrap: wrap; align-items: flex-end; }
.stack { display: flex; flex-direction: column; gap: var(--s3); }
.field { min-width: 0; }
.field > label {
    display: block;
    margin-bottom: 3px;
    color: var(--dim);
    font-size: var(--f-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}
input[type=text], input[type=email], input[type=password], input[type=search], select, textarea {
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--r-ctl);
    color: var(--text);
    font: var(--f)/1.4 inherit;
    padding: 6px 9px;
    min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
.field .error { color: var(--bad); font-size: var(--f-sm); margin-top: 3px; }

.btn, button {
    display: inline-block;
    border: 1px solid var(--accent);
    border-radius: var(--r-ctl);
    background: var(--accent);
    color: var(--accent-ink);
    font: 650 var(--f)/1.3 inherit;
    padding: 6px 12px;
    cursor: pointer;
}
.btn:hover, button:hover { filter: brightness(1.07); text-decoration: none; }
.btn.ghost, button.ghost { background: transparent; border-color: var(--line-hi); color: var(--text); font-weight: 600; }
.btn.ghost:hover, button.ghost:hover { border-color: var(--accent); filter: none; }
.btn.danger, button.danger { background: transparent; border-color: var(--bad-line); color: var(--bad); font-weight: 600; }
.btn.danger:hover, button.danger:hover { background: var(--bad-soft); filter: none; }
.btn.sm, button.sm { padding: 3px 8px; font-size: var(--f-sm); }

/* ---------- flash + states ---------- */
.flash {
    border: 1px solid var(--line);
    border-left-width: 3px;
    border-radius: var(--r-ctl);
    padding: 9px 12px;
    margin-bottom: var(--s4);
    font-size: var(--f);
}
.flash.ok { border-left-color: var(--good); color: var(--good); background: var(--good-soft); }
.flash.err { border-left-color: var(--bad); color: var(--bad); background: var(--bad-soft); }
.flash.note { border-left-color: var(--accent); color: var(--muted); }
.empty { color: var(--muted); font-size: var(--f); padding: var(--s3) 0; }

/* ---------- pager ---------- */
.pager {
    display: flex;
    align-items: center;
    gap: var(--s2);
    margin-top: var(--s3);
    color: var(--muted);
    font-size: var(--f-sm);
}
.pager a { border: 1px solid var(--line); border-radius: var(--r-ctl); padding: 3px 9px; }
.pager a:hover { border-color: var(--accent); text-decoration: none; }
.pager .off { border: 1px solid var(--line); border-radius: var(--r-ctl); padding: 3px 9px; color: var(--dim); opacity: 0.55; }

/* ---------- utilities ---------- */
.mt { margin-top: var(--s4); }
.mt-lg { margin-top: var(--s5); }
.spread { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.nowrap { white-space: nowrap; }
.trunc { max-width: 210px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mw-460 { max-width: 460px; }
.w-240 { width: 240px; }
.w-280 { width: 280px; }
.state-ok { color: var(--good); }
.state-bad { color: var(--bad); }

/* Inputs inside a field fill it; a field's own width comes from a utility class on the wrapper. */
.field > input, .field > select, .field > textarea { width: 100%; }
/* Inputs that sit inline in a table's action cell share one width. */
.row-actions input { width: 130px; }

/* ---------- satellite shell ----------
   An earning domain is a single-purpose page, not a second console: one column, a top bar, and a
   compact hub bar so the member can see the balance they are adding to without leaving the page. */
.sat { max-width: 900px; margin: 0 auto; padding: var(--s5) var(--s5) 60px; }
.sat-top { display: flex; align-items: center; gap: var(--s3); margin-bottom: var(--s4); }
.sat-top .brand { display: flex; align-items: center; gap: var(--s2); font-size: var(--f-lg); font-weight: 700; color: var(--text); }
.sat-top .brand span { color: var(--accent); }
.sat-top .brand img { width: 20px; height: 20px; }
.sat-top nav { margin-left: auto; display: flex; gap: var(--s4); flex-wrap: wrap; }
.sat-top nav a { color: var(--muted); font-size: var(--f); }
.sat-top nav a:hover, .sat-top nav a.active { color: var(--text); text-decoration: none; }
.sat-top nav a.active { color: var(--accent); }
.sat-main { min-height: 40vh; }
.sat-foot {
    display: flex; gap: var(--s4); flex-wrap: wrap; align-items: baseline;
    margin-top: var(--s6); padding-top: var(--s3); border-top: 1px solid var(--line);
    color: var(--muted); font-size: var(--f-sm);
}
.sat-foot a { color: var(--muted); }

/* ---------- hub bar ---------- */
.hubbar {
    display: flex; align-items: center; gap: var(--s5); flex-wrap: wrap;
    background: var(--card); border: 1px solid var(--line);
    padding: var(--s2) var(--s4); margin-bottom: var(--s5);
}
.hub-item { display: flex; flex-direction: column; gap: 2px; min-width: 96px; }
.hub-item .k { color: var(--dim); font-size: var(--f-xs); text-transform: uppercase; letter-spacing: 0.5px; }
.hub-item .v { font-size: var(--f-lg); font-weight: 650; font-variant-numeric: tabular-nums; color: var(--text); }
.hub-item .sub { font-size: var(--f-xs); margin-top: 0; }
.hub-item .pg { width: 130px; }
.hub-user { margin-left: auto; display: flex; align-items: center; gap: var(--s3); }
.hub-user form { margin: 0; }
.linkish { background: none; border: 0; padding: 0; color: var(--muted); font-size: var(--f-sm); cursor: pointer; }
.linkish:hover { color: var(--accent); }

/* ---------- progress (native element, so no inline widths) ---------- */
.pg { appearance: none; -webkit-appearance: none; display: block; width: 100%; height: 4px; border: 0; background: var(--line); margin: var(--s1) 0 3px; }
.pg::-webkit-progress-bar { background: var(--line); }
.pg::-webkit-progress-value { background: var(--accent); }
.pg::-moz-progress-bar { background: var(--accent); }
.pg.alt::-webkit-progress-value { background: var(--good); }
.pg.alt::-moz-progress-bar { background: var(--good); }

/* ---------- claim ---------- */
.claim-card { padding: var(--s4); }
.claim-actions { display: flex; align-items: center; gap: var(--s5); flex-wrap: wrap; }
.btn.lg, button.lg { font-size: var(--f-lg); padding: 12px 22px; }
.claim-payout { display: grid; grid-template-columns: auto auto; gap: 2px var(--s3); align-items: baseline; }
.claim-payout .k { color: var(--dim); font-size: var(--f-sm); }
.claim-payout .v { font-weight: 650; font-variant-numeric: tabular-nums; }
.ad { margin-top: var(--s5); min-height: 90px; border: 1px dashed var(--line-hi); display: flex; align-items: center; justify-content: center; color: var(--dim); font-size: var(--f-sm); }

/* The page a member is being paid to look at. Neutral background: the framed site supplies its own. */
.surf-frame { width: 100%; height: 460px; border: 1px solid var(--line-hi); background: #fff; }
@media (max-width: 860px) {
    .surf-frame { height: 360px; }
}
.prose { line-height: 1.65; }
.prose h2, .prose h3 { margin-top: var(--s4); }
.prose p { margin: 0 0 var(--s3); }
.prose ul { margin: 0 0 var(--s3); padding-left: var(--s4); }

/* A checkbox with its label, used where a form offers a set of options (domain modules). */
.check { display: flex; align-items: center; gap: 6px; font-size: var(--f-sm); }
.check input { width: auto; }

/* ---------- secrets and codes (operator two-step sign-in, recovery codes) ---------- */
.label { color: var(--dim); font-size: var(--f-sm); margin-bottom: var(--s1); }
.secret { font-size: var(--f-md); letter-spacing: 1px; word-break: break-all; }
.uri { font-size: var(--f-xs); color: var(--muted); word-break: break-all; }
.codes { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: var(--s2); margin-top: var(--s3); }
.codes div { background: var(--bg-soft); border: 1px solid var(--line); padding: 6px var(--s2); }

/* ---------- narrow screens ---------- */
@media (max-width: 860px) {
    .shell { grid-template-columns: 1fr; }
    .side { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: var(--s3) 0 0; }
    .side .brand { padding: 0 var(--s4) var(--s3); }
    .side .who { display: none; }
    .side nav { flex-direction: row; overflow-x: auto; }
    .side nav a { border-left: 0; border-bottom: 2px solid transparent; padding: 7px var(--s3); white-space: nowrap; }
    .side nav a.active { border-left: 0; border-bottom-color: var(--accent); }
    .side .foot { border-top: 1px solid var(--line); padding: var(--s2) var(--s4); }
    .content { padding: var(--s5) var(--s4) 60px; }
    .page-head { flex-direction: column; gap: var(--s3); }
    .sat { padding: var(--s4) var(--s4) 48px; }
    .hubbar { gap: var(--s4); }
    .hub-user { margin-left: 0; }
}
