/* LumenTV operator panel: one calm design — a dark sidebar, white cards on a soft grey page, one blue accent. */
:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --faint: #9ca3af;
  --line: #e5e7eb;
  --line-strong: #d1d5db;
  --accent: #2563eb;
  --accent-soft: #e8efff;
  --accent-text: #1d4ed8;
  --ok: #059669;
  --ok-soft: #e6f6f0;
  --warn: #b45309;
  --warn-soft: #fef3e2;
  --bad: #dc2626;
  --bad-soft: #fdecec;
  --side: #0f172a;
  --side-text: #cbd5e1;
  --side-active: #1e293b;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 16px rgba(15, 23, 42, .04);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1020;
    --card: #131a2c;
    --text: #e5e7eb;
    --muted: #9aa4b5;
    --faint: #6b7487;
    --line: #232c40;
    --line-strong: #323c52;
    --accent: #4f8cff;
    --accent-soft: #1a2747;
    --accent-text: #8fb4ff;
    --ok: #34d399;
    --ok-soft: #0f2a24;
    --warn: #fbbf24;
    --warn-soft: #2b2312;
    --bad: #f87171;
    --bad-soft: #2d1618;
    --side: #070b16;
    --side-active: #141c30;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
h1 { font-size: 26px; font-weight: 700; }
h2 { font-size: 17px; font-weight: 650; }
h3 { font-size: 15px; font-weight: 600; }
p { margin: 0; line-height: 1.5; }
a { color: var(--accent-text); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--bad); font-size: 14px; min-height: 1.2em; }
[hidden] { display: none !important; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(420px, 100%); background: var(--card); border-radius: 20px; padding: 36px; box-shadow: var(--shadow); display: grid; gap: 16px; border: 1px solid var(--line); }
.login-card h1 { margin-top: 8px; }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: linear-gradient(135deg, #3b82f6, #6366f1); position: relative; }
.brand-mark::after { content: ""; position: absolute; left: 11px; top: 8px; border-left: 9px solid #fff; border-top: 6px solid transparent; border-bottom: 6px solid transparent; }

/* Shell */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar { background: var(--side); color: var(--side-text); padding: 22px 14px; display: flex; flex-direction: column; gap: 22px; position: sticky; top: 0; height: 100vh; }
.sidebar .brand { color: #fff; padding: 0 10px; }
.sidebar nav { display: grid; gap: 2px; flex: 1; align-content: start; }
.sidebar nav a { display: flex; align-items: center; gap: 12px; color: var(--side-text); text-decoration: none; padding: 10px 12px; border-radius: 10px; font-weight: 500; }
.sidebar nav a:hover { background: var(--side-active); color: #fff; }
.sidebar nav a.active { background: var(--accent); color: #fff; }
.nav-title { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #64748b; padding: 18px 12px 6px; }
.me { border-top: 1px solid #1e293b; padding: 14px 10px 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.me-name { font-size: 13px; color: #e2e8f0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ico { width: 18px; height: 18px; display: inline-block; background: currentColor; -webkit-mask: var(--icon) center / contain no-repeat; mask: var(--icon) center / contain no-repeat; flex: none; }

.view { padding: 32px clamp(16px, 4vw, 48px) 64px; max-width: 1180px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head p { margin-top: 6px; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); text-decoration: none; font-size: 14px; margin-bottom: 10px; }
.back:hover { color: var(--text); }

/* Cards and grids */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-body { padding: 20px 22px; display: grid; gap: 16px; }
.card-head { padding: 16px 22px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-head p { margin-top: 2px; }
.stack { display: grid; gap: 20px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; align-items: start; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 4px; }
.stat .label { color: var(--muted); font-size: 13px; }

/* Lists of things */
.rows { display: grid; }
.row { display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: center; padding: 14px 22px; border-top: 1px solid var(--line); }
.rows .row:first-child { border-top: none; }
a.row { color: inherit; text-decoration: none; }
a.row:hover, .row.clickable:hover { background: var(--bg); }
.row-main { min-width: 0; display: grid; gap: 4px; }
.row-title { font-weight: 600; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row-sub { color: var(--muted); font-size: 13px; display: flex; gap: 6px 14px; flex-wrap: wrap; }
.row-actions { display: flex; gap: 8px; align-items: center; }
.empty { padding: 36px 22px; text-align: center; color: var(--muted); display: grid; gap: 12px; justify-items: center; }

table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; padding: 12px 22px; border-bottom: 1px solid var(--line); }
.table td { padding: 14px 22px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover { background: var(--bg); }
.table .name { font-weight: 600; }
.table .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }

.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.search { flex: 1; min-width: 220px; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: var(--bg); color: var(--muted); white-space: nowrap; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.active, .badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.pending, .badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.blocked, .badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.plain::before { display: none; }

/* Forms */
.field { display: grid; gap: 6px; font-size: 14px; }
.field > span { font-weight: 500; }
.field .hint { color: var(--muted); font-size: 12.5px; }
input, select, textarea { font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--line-strong); border-radius: 10px; padding: 10px 12px; width: 100%; }
textarea { min-height: 96px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
input:focus, select:focus, textarea:focus { outline: 3px solid var(--accent-soft); border-color: var(--accent); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px 16px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.switch { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 4px 0; }
.switch input { appearance: none; width: 44px; height: 26px; border-radius: 999px; background: var(--line-strong); position: relative; flex: none; cursor: pointer; padding: 0; border: none; transition: background .15s; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(18px); }
.switch .text { display: grid; gap: 2px; }
.switch .text small { color: var(--muted); }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch { width: 34px; height: 34px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; padding: 0; }
.swatch.on { border-color: var(--text); }

/* Buttons */
.btn { font: inherit; font-weight: 600; font-size: 14px; border-radius: 10px; padding: 10px 16px; border: 1px solid var(--line-strong); background: var(--card); color: var(--text); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--faint); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: var(--bad-soft); border-color: var(--bad); }
.btn.ghost { background: transparent; border-color: transparent; color: inherit; }
.btn.ghost:hover { background: rgba(127, 127, 127, .12); }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }

/* Chips (PIA servers) */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-strong); border-radius: 999px; padding: 6px 12px; font-size: 13px; cursor: pointer; background: var(--card); user-select: none; }
.chip input { display: none; }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.region-list { max-height: 360px; overflow: auto; border: 1px solid var(--line); border-radius: 12px; padding: 12px; }

/* Code and pre */
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 15px; letter-spacing: .12em; font-weight: 700; background: var(--bg); padding: 2px 8px; border-radius: 6px; }
pre.log { white-space: pre-wrap; word-break: break-word; font-size: 12.5px; background: var(--bg); padding: 14px; border-radius: 10px; max-height: 360px; overflow: auto; margin: 0; }
details.crash { border-top: 1px solid var(--line); padding: 12px 22px; }
details.crash summary { cursor: pointer; display: flex; gap: 12px; align-items: center; }
details.crash pre { margin-top: 10px; }

/* Dialog */
.dialog { border: none; border-radius: 18px; padding: 0; width: min(560px, calc(100vw - 32px)); background: var(--card); color: var(--text); box-shadow: 0 24px 64px rgba(0, 0, 0, .28); }
.dialog::backdrop { background: rgba(15, 23, 42, .55); }
.dialog form { display: grid; gap: 16px; padding: 24px; }
.dialog .dialog-head { display: grid; gap: 6px; }

/* Toast */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 20px); background: #111827; color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 14px; opacity: 0; pointer-events: none; transition: all .2s; z-index: 50; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--bad); }

@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px; gap: 10px; min-width: 0; }
  .sidebar nav { display: flex; flex-wrap: nowrap; overflow-x: auto; flex: 1 1 100%; order: 3; scrollbar-width: none; }
  .sidebar nav a { padding: 8px 10px; white-space: nowrap; flex: none; }
  .nav-admin { display: contents; }
  .nav-title { display: none; }
  .me { border: none; padding: 0; margin-left: auto; min-width: 0; flex: 1 1 0; justify-content: flex-end; }
  .view { min-width: 0; }
  .table th:nth-child(n+4), .table td:nth-child(n+4) { display: none; }
}
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); }
@media (max-width: 520px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .table th, .table td { padding: 12px 14px; }
  .table th:nth-child(3), .table td:nth-child(3) { display: none; }
  .row { flex-wrap: wrap; }
}
