/* fpgold dashboard — dark theme (layout from the approved mockup) */
:root {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #1e222b;
  --border: #2a2f3a;
  --border-soft: #232833;
  --text: #e6e8ec;
  --muted: #9aa1ae;
  --accent: #8fb0ff;
  --accent-strong: #3f6fe8;
  --live-bg: #12301f; --live-fg: #86e0a6;
  --off-bg: #252a35;  --off-fg: #bcc2cd;
  --kill-bg: #3b1818; --kill-fg: #ffa39b;
  --warn-bg: #3a2b12; --warn-fg: #f5c46b;
  --dry-bg: #1b2648;  --dry-fg: #b3c7ff;
  --radius: 10px;
  --font: "IBM Plex Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; }
a { color: var(--accent); }
a:hover { color: #c3d3ff; }
h1 { margin: 0; font-size: 24px; font-weight: 600; }
h2 { margin: 0; font-size: 16px; font-weight: 600; }

.layout { display: flex; flex-wrap: wrap; min-height: 100vh; }
.nav { flex: 0 0 240px; min-width: 240px; background: #0b0d11; border-right: 1px solid var(--border-soft); padding: 20px 14px; display: flex; flex-direction: column; gap: 20px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px; }
.brand-mark { width: 28px; height: 28px; border-radius: 7px; background: #e2a93b; color: #111; display: flex; align-items: center; justify-content: center; font-weight: 600; }
.brand small { display: block; color: var(--muted); font-size: 12px; }
.nav-links { display: flex; flex-direction: column; gap: 2px; }
.nav-link { display: flex; align-items: center; min-height: 40px; padding: 0 12px; border-radius: 8px; color: #c4c9d3; text-decoration: none; }
.nav-link:hover { background: var(--surface-2); color: #fff; }
.nav-link.active { background: #262c38; color: #fff; font-weight: 500; }
.nav-user { margin-top: auto; padding: 12px; border-radius: 8px; background: var(--surface); display: flex; flex-direction: column; gap: 8px; color: var(--muted); font-size: 12px; }
.nav-user strong { color: var(--text); font-size: 14px; font-weight: 500; }

.main { flex: 999 1 560px; min-width: 0; padding: 28px 32px 48px; display: flex; flex-direction: column; gap: 20px; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-body { padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.kpi { padding: 18px 20px; display: flex; flex-direction: column; gap: 6px; }
.kpi .value { font-family: var(--mono); font-size: 28px; font-weight: 500; }
.kpi.danger { border-color: #5a2522; }
.kpi.danger .value, .kpi.danger .label { color: var(--kill-fg); }

.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; white-space: nowrap; }
td.wrap { white-space: normal; }
.num { text-align: right; }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.b-live { background: var(--live-bg); color: var(--live-fg); }
.b-off { background: var(--off-bg); color: var(--off-fg); }
.b-kill { background: var(--kill-bg); color: var(--kill-fg); }
.b-warn { background: var(--warn-bg); color: var(--warn-fg); }
.b-dry { background: var(--dry-bg); color: var(--dry-fg); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 16px; border-radius: 8px; border: 1px solid #3a404d; background: var(--surface-2); color: var(--text); font: 500 14px var(--font); cursor: pointer; text-decoration: none; }
.btn:hover { border-color: #566073; }
.btn-primary { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
.btn-danger { border-color: #6b2b27; color: var(--kill-fg); }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 13px; }

form.inline { display: inline; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: #c4c9d3; }
input, select, textarea { font: 14px var(--font); color: var(--text); background: #11141a; border: 1px solid #343a46; border-radius: 8px; padding: 0 12px; min-height: 44px; width: 100%; }
textarea { padding: 10px 12px; min-height: 110px; font-family: var(--mono); font-size: 13px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, .nav-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.check { flex-direction: row; align-items: center; gap: 10px; min-height: 44px; font-size: 14px; color: var(--text); }
.check input { width: 18px; height: 18px; min-height: 0; }

.alert { padding: 12px 16px; border-radius: 8px; border: 1px solid; }
.alert-error { background: var(--kill-bg); border-color: #6b2b27; color: var(--kill-fg); }
.alert-info { background: var(--dry-bg); border-color: #2c3c70; color: var(--dry-fg); }
details > summary { cursor: pointer; color: var(--accent); min-height: 32px; display: flex; align-items: center; }

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; padding: 28px; display: flex; flex-direction: column; gap: 16px; }

@media (max-width: 640px) {
  .main { padding: 20px 16px 40px; }
  .nav { flex-basis: 100%; }
}

/* A pair of fields: captions, fields and hints share rows (subgrid), so fields stay on one line even when one
   caption wraps or only one field has a hint under it. */
.grid-2 { align-items: start; }
.grid-2 > label:not(.check) { display: grid; grid-row: span 3; grid-template-rows: subgrid; row-gap: 6px; }

/* Settings: one field per row, caption and hint on the left, a fixed-width field on the right. */
.field-list { display: flex; flex-direction: column; }
.field-row { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 8px 24px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border-soft); }
.field-row:first-child { padding-top: 0; }
.field-row:last-child { border-bottom: 0; }
.field-label { gap: 2px; font-size: 14px; color: var(--text); }
.field-hint { font-size: 12px; color: var(--muted); }
.field-error { font-size: 12px; color: var(--kill-fg); }
@media (max-width: 640px) { .field-row { grid-template-columns: 1fr; } }

/* Collapsible cards (settings): the whole header toggles, a chevron shows the state. */
details.fold > summary { list-style: none; cursor: pointer; color: inherit; min-height: 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::after { content: "▸"; color: var(--muted); font-size: 14px; transition: transform .15s; margin-left: auto; }
details.fold[open] > summary::after { transform: rotate(90deg); }
details.fold:not([open]) > summary { border-bottom: 0; }
details.fold > summary:hover h2 { color: var(--accent); }
.neg { color: var(--kill-fg); }
details.inline-more { display: inline-flex; align-items: center; gap: 8px; }
details.inline-more > summary { min-height: 0; list-style: none; }
details.inline-more > summary::-webkit-details-marker { display: none; }
.chain { display: flex; flex-direction: column; }
.chain-step { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 16px; padding: 10px 0; border-bottom: 1px dashed var(--border); }
.chain-step:last-child { border-bottom: 0; }
.chain-step .note { grid-column: 1 / -1; font-size: 12px; color: var(--muted); }
.chain-step.final .mono { font-weight: 600; }
