/* Stessa palette della WebUI di contax_full. Nessuna risorsa esterna. */
:root {
  --bg: #0f1218; --surface: #171b24; --surface-2: #1e2330; --surface-3: #262c3b;
  --line: #2b3242; --fg: #e8ecf4; --muted: #98a2b6; --accent: #4ea1ff; --accent-fg: #07121f;
  --ok: #3ecf8e; --warn: #f0be28; --bad: #ff6b6b; --radius: 12px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f3f5f9; --surface: #fff; --surface-2: #f5f7fb; --surface-3: #e9edf4;
    --line: #d9dfe9; --fg: #151a24; --muted: #5d6679; --accent: #1f6fe0; --accent-fg: #fff;
    --ok: #13905a; --warn: #a86f00; --bad: #d33a3a; color-scheme: light;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; padding-bottom: 5rem; }
[hidden] { display: none !important; }
h3 { margin: 0; font-size: 1rem; }
h4 { margin: 1rem 0 .4rem; font-size: .9rem; }
code { font-size: .85em; }
.help { color: var(--muted); font-size: .85rem; }
.spacer { flex: 1; }

.warn-banner { background: var(--warn); color: #231a00; padding: .4rem 1rem; font-weight: 600; font-size: .85rem; text-align: center; }
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); padding: .5rem 1rem 0; position: sticky; top: 0; z-index: 5; }
.brand-row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.brand { font-size: 1.05rem; }
.chip { padding: .15rem .6rem; border-radius: 999px; background: var(--surface-3); color: var(--muted); font-size: .78rem; }
.tabs { display: flex; gap: .15rem; margin-top: .45rem; }
.tab { background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted); font: inherit; padding: .5rem .8rem; cursor: pointer; }
.tab.is-active { color: var(--fg); border-bottom-color: var(--accent); font-weight: 600; }

.page { padding: 1rem; display: flex; flex-direction: column; gap: 1rem; max-width: 1300px; margin: 0 auto; }
.split { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
@media (max-width: 960px) { .split { grid-template-columns: 1fr; } }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }
.card-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .7rem; }
.card-head h3 { margin-right: auto; }

.table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.table th { text-align: left; color: var(--muted); font-weight: 500; font-size: .78rem; padding: .35rem .5rem; border-bottom: 1px solid var(--line); }
.table td { padding: .45rem .5rem; border-bottom: 1px solid var(--line); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .empty { color: var(--muted); text-align: center; }
.table.clickable tbody tr[data-sid] { cursor: pointer; }
.table.clickable tbody tr[data-sid]:hover { background: var(--surface-2); }
.table tr.is-selected { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.state { font-size: .8rem; }
.state.ok { color: var(--ok); } .state.bad { color: var(--bad); } .state.muted { color: var(--muted); }

.stage { background: #000; border-radius: 10px; overflow: hidden; line-height: 0; min-height: 120px; }
.stage img { width: 100%; display: block; }
.counters { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin: .8rem 0; }
.counter { text-align: center; padding: .6rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; }
.counter .value { display: block; font-size: 1.8rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.counter .label { color: var(--muted); font-size: .78rem; }
.counter.up .value { color: var(--ok); } .counter.down .value { color: var(--bad); }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem 1rem; margin: 0; }
.stats dt { color: var(--muted); font-size: .75rem; } .stats dd { margin: 0; font-size: .88rem; }
.alert { background: color-mix(in srgb, var(--bad) 12%, transparent); border: 1px solid var(--bad); color: var(--bad); border-radius: 8px; padding: .5rem .7rem; font-size: .85rem; }
.events { list-style: none; padding: 0; margin: 0; max-height: 18rem; overflow-y: auto; font-size: .88rem; }
.events li { display: grid; grid-template-columns: 1.2rem 1fr auto; gap: .5rem; padding: .3rem 0; border-bottom: 1px solid var(--line); }
.events li.empty { display: block; color: var(--muted); border: 0; }
.events li.in .arrow { color: var(--ok); } .events li.out .arrow { color: var(--bad); }
.events .when { color: var(--muted); font-variant-numeric: tabular-nums; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1rem; }
@media (max-width: 640px) { .grid-2 { grid-template-columns: 1fr; } }
.field { display: block; margin: .6rem 0; }
.field-label { display: block; font-size: .85rem; margin-bottom: .3rem; }
.check { display: flex; gap: .5rem; align-items: center; margin: .7rem 0; font-size: .9rem; }
input[type="text"], input[type="number"], select { width: 100%; font: inherit; color: var(--fg); background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: .45rem .6rem; }

.btn { font: inherit; font-size: .9rem; color: var(--fg); background: var(--surface-3); border: 1px solid var(--line); border-radius: 8px; padding: .45rem .9rem; cursor: pointer; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-fg); border-color: transparent; font-weight: 600; }
.btn.ghost { background: transparent; }
.btn.small { padding: .3rem .65rem; font-size: .84rem; }
.savebar { position: sticky; bottom: 1rem; display: flex; gap: .6rem; align-items: center; background: var(--surface); border: 1px solid var(--accent); border-radius: var(--radius); padding: .6rem .8rem; }

.toasts { position: fixed; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: .4rem; z-index: 10; }
.toast { background: var(--ok); color: #06201a; padding: .55rem 1rem; border-radius: 8px; font-weight: 600; }
.toast-error { background: var(--bad); color: #fff; }
