/*! components.css — the plain building blocks every screen uses, drawn only from tokens.css variables.

   What it does: page shell (sidebar + main), cards, buttons, fields, tables, status badges, tabs, modal, the theme
   button and the theme picker grid. Works the same in all 23 themes because it never names a colour.
   Main classes: .app .sidebar .main · .card · .btn .btn-primary .btn-danger · .field · table.list · .badge
   (.ok .warn .danger .info) · .tabs .tab · .modal-backdrop .modal · .theme-btn · .theme-grid .theme-card .tp
   Plain-finish rules built in: one solid accent, no gradients, no glows, no lift on hover, a visible focus ring
   for the keyboard, modest corners, long tables scroll inside their box.
   Gotchas: body::before draws the theme's faint --pattern; tables use --font with tabular numbers. */

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
    font: 15px/1.5 var(--font);
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}
body::before {
    content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
    background-image: var(--pattern); background-size: var(--pattern-size);
}
h1, h2, h3 { font-family: var(--font-display); color: var(--heading); line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.6rem; font-weight: 650; }
h2 { font-size: 1.15rem; font-weight: 600; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.mono { font-family: var(--font-mono); }
::selection { background: rgb(var(--trim-rgb) / .3); }

/* Shell: menu on the left on wide screens, on top on a phone. */
.app { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.sidebar { background: var(--chrome); border-right: 1px solid var(--line); padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; font: 700 1.05rem var(--font-display); color: var(--heading); padding: 4px 8px 16px; }
.logo { width: 34px; height: 34px; border-radius: var(--radius-sm); background: var(--trim); color: var(--on-trim); display: grid; place-items: center; font-weight: 800; }
.nav-group { font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); padding: 12px 8px 4px; }
.nav-link { position: relative; display: block; padding: 8px 10px; border-radius: var(--radius-sm); color: var(--ink-2); text-decoration: none; }
.nav-link:hover { background: var(--surface-hover); color: var(--ink); }
.nav-link[aria-current=page] { background: var(--accent-soft); color: var(--heading); font-weight: 600; }
.nav-link[aria-current=page]::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 2px; background: var(--trim); }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 12px; }
.main { padding: 24px 28px; min-width: 0; }
@media (max-width: 760px) {
    .app { grid-template-columns: 1fr; }
    .sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
    .main { padding: 16px; }
}

/* Panels */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.stat-num { font: 700 1.8rem var(--font-display); color: var(--heading); font-variant-numeric: tabular-nums; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* Buttons: solid colours, a slightly brighter hover, a focus ring for the keyboard. */
.btn { font: 600 .95rem var(--font); padding: 9px 16px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--ink); cursor: pointer; }
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: var(--on-primary); border-color: transparent; }
.btn-primary:hover:not(:disabled) { filter: brightness(1.1); border-color: transparent; }
.btn-danger { background: #c62842; color: #fff; border-color: transparent; }
:is(.btn, a, .nav-link, .theme-card):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Fields: label above, 1px border, soft ring on focus. */
.field { display: grid; gap: 4px; }
.field label { font-size: .85rem; color: var(--ink-2); }
input, select, textarea { font: inherit; color: var(--ink); background: var(--input-bg); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: 8px 10px; }
:is(input, select, textarea):focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
:is(input[type=checkbox], input[type=radio]) { accent-color: var(--trim); }

/* Tables: readable font, tabular numbers, scroll inside their box instead of growing the page forever. */
.table-box { max-height: 60vh; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table.list { width: 100%; border-collapse: collapse; font: .92rem var(--font); font-variant-numeric: tabular-nums; }
table.list th { position: sticky; top: 0; background: var(--surface-2); color: var(--ink-2); text-align: left; font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
table.list :is(th, td) { padding: 8px 12px; border-bottom: 1px solid var(--line); }
table.list tbody tr:hover { background: var(--surface-hover); }

/* Status: the four meanings keep their own colour in every theme. */
.badge { display: inline-block; font-size: .78rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; border: 1px solid currentColor; }
.badge.ok { color: var(--ok); }
.badge.warn { color: var(--warn); }
.badge.danger { color: var(--danger); }
.badge.info { color: var(--info); }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tab { background: none; border: 0; padding: 8px 12px; color: var(--muted); font: 600 .92rem var(--font); cursor: pointer; }
.tab.active { color: var(--heading); box-shadow: inset 0 -2px 0 var(--trim); }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 10; }
.modal { position: fixed; z-index: 11; left: 50%; top: 6vh; transform: translateX(-50%); width: min(920px, 94vw); max-height: 88vh; overflow: auto;
    background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius); box-shadow: 0 20px 50px -20px rgba(0, 0, 0, .6); padding: 20px; }

/* Theme button (menu foot) and theme picker: every card is a tiny preview drawn in its own theme. */
.theme-btn { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--ink); cursor: pointer; font: inherit; text-align: left; }
.theme-dot { width: 22px; height: 22px; border-radius: 50%; background: var(--bg); border: 5px solid var(--primary); box-shadow: 0 0 0 1px var(--line-strong); }
.theme-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); margin-bottom: 14px; }
.theme-card { display: grid; gap: 6px; padding: 6px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--ink); cursor: pointer; text-align: left; font: inherit; }
.theme-card[aria-pressed=true] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.theme-card small { color: var(--muted); display: block; }
.tp { display: grid; grid-template-columns: 28% 1fr; height: 70px; border-radius: 5px; overflow: hidden; background: var(--bg); border: 1px solid var(--line); }
.tp-side { background: var(--chrome); border-right: 1px solid var(--line); }
.tp-main { padding: 7px; display: grid; gap: 5px; align-content: start; }
.tp-title { font: 700 .9rem var(--font-display); color: var(--heading); }
.tp-line { height: 5px; border-radius: 3px; background: var(--line-strong); }
.tp-btn { width: 40px; height: 12px; border-radius: 3px; background: var(--primary); }
.section-title { font-size: .75rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 10px 0 6px; }
