/* EZTunnel license console. Dark by default, light on request or by system preference.
   No inline styles anywhere: the CSP only allows this stylesheet. */

:root {
  color-scheme: dark;
  --bg: #0a0c11;
  --bg-2: #0e1117;
  --surface: #131720;
  --surface-2: #181d28;
  --surface-3: #1f2532;
  --line: #232a38;
  --line-strong: #2f3849;
  --text: #e9edf5;
  --text-2: #b3bccd;
  --dim: #8793a9;
  --accent: #35d6b4;
  --accent-ink: #04231c;
  --accent-soft: rgba(53, 214, 180, .12);
  --info: #6aa8ff;
  --info-soft: rgba(106, 168, 255, .13);
  --ok: #4cd98a;
  --ok-soft: rgba(76, 217, 138, .13);
  --warn: #f1b74a;
  --warn-soft: rgba(241, 183, 74, .14);
  --bad: #ff6b6b;
  --bad-soft: rgba(255, 107, 107, .14);
  --shadow: 0 18px 50px rgba(0, 0, 0, .55);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar: 244px;
  --font: ui-sans-serif, "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "JetBrains Mono", "SF Mono", Consolas, monospace;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f5f9;
  --bg-2: #eaedf3;
  --surface: #ffffff;
  --surface-2: #f6f8fb;
  --surface-3: #eceff5;
  --line: #dde2ec;
  --line-strong: #c8d0de;
  --text: #121723;
  --text-2: #3b465a;
  --dim: #667389;
  --accent: #0a9a7c;
  --accent-ink: #ffffff;
  --accent-soft: rgba(10, 154, 124, .11);
  --info: #2f6fdb;
  --info-soft: rgba(47, 111, 219, .1);
  --ok: #17874f;
  --ok-soft: rgba(23, 135, 79, .1);
  --warn: #a96b00;
  --warn-soft: rgba(169, 107, 0, .11);
  --bad: #d0343f;
  --bad-soft: rgba(208, 52, 63, .09);
  --shadow: 0 18px 50px rgba(20, 30, 55, .18);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #f3f5f9;
    --bg-2: #eaedf3;
    --surface: #ffffff;
    --surface-2: #f6f8fb;
    --surface-3: #eceff5;
    --line: #dde2ec;
    --line-strong: #c8d0de;
    --text: #121723;
    --text-2: #3b465a;
    --dim: #667389;
    --accent: #0a9a7c;
    --accent-ink: #ffffff;
    --accent-soft: rgba(10, 154, 124, .11);
    --info: #2f6fdb;
    --info-soft: rgba(47, 111, 219, .1);
    --ok: #17874f;
    --ok-soft: rgba(23, 135, 79, .1);
    --warn: #a96b00;
    --warn-soft: rgba(169, 107, 0, .11);
    --bad: #d0343f;
    --bad-soft: rgba(208, 52, 63, .09);
    --shadow: 0 18px 50px rgba(20, 30, 55, .18);
  }
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  background-image: radial-gradient(1200px 500px at 85% -10%, var(--accent-soft), transparent 60%);
  background-repeat: no-repeat;
  color: var(--text);
  font: 14px/1.5 var(--font);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
h1, h2, h3 { font-weight: 650; letter-spacing: -.01em; }
.mono { font-family: var(--mono); font-size: 12px; }
.dim { color: var(--dim); }
.num { font-variant-numeric: tabular-nums; }
.break { word-break: break-all; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

svg.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- sign-in ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card {
  width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 18px; padding: 30px 28px 26px; box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(145deg, var(--accent), color-mix(in srgb, var(--accent) 55%, var(--info)));
  color: var(--accent-ink);
}
.brand-mark svg { width: 22px; height: 22px; stroke-width: 2.1; }
.brand-name { font-weight: 700; letter-spacing: -.02em; font-size: 15px; line-height: 1.15; }
.brand-name small { display: block; font-weight: 500; font-size: 11px; color: var(--dim); letter-spacing: .02em; }
.login-card h1 { font-size: 22px; margin: 24px 0 4px; }
.login-card p.lead { color: var(--dim); margin-bottom: 20px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 22px;
  padding: 20px 14px 16px; background: var(--bg-2); border-right: 1px solid var(--line);
}
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .09em; color: var(--dim); padding: 0 12px 6px; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 10px;
  color: var(--text-2); text-decoration: none; font-weight: 520; position: relative;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.nav a[aria-current="page"]::before {
  content: ""; position: absolute; left: -14px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent);
}
.nav .pill { margin-left: auto; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.sidebar-foot .row { display: flex; gap: 8px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px;
  padding: 14px 28px; background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px); border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 18px; white-space: nowrap; }
.topbar .grow { flex: 1; }
.btn.menu-btn { display: none; }
.search { position: relative; width: min(420px, 100%); }
.search input[type=search] {
  width: 100%; height: 38px; padding: 0 44px 0 38px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); outline: none;
}
.search input[type=search]:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search .icon { position: absolute; left: 12px; top: 10px; color: var(--dim); }
.search kbd {
  position: absolute; right: 10px; top: 8px; font: 11px var(--mono); color: var(--dim);
  border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px;
}
.results {
  position: absolute; left: 0; right: 0; top: 44px; background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: 12px; box-shadow: var(--shadow); padding: 6px; max-height: 60vh; overflow: auto; z-index: 30;
}
.results h4 { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--dim); padding: 8px 10px 4px; }
.results button {
  display: flex; width: 100%; align-items: center; gap: 10px; text-align: left; padding: 8px 10px; border: 0;
  background: none; border-radius: 8px; cursor: pointer;
}
.results button:hover, .results button:focus-visible { background: var(--surface-3); }
.results .empty { padding: 14px 10px; color: var(--dim); }

.content { padding: 26px 28px 60px; max-width: 1280px; width: 100%; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head p { color: var(--dim); max-width: 60ch; }
.page-head h2 { font-size: 22px; }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 14px;
  border-radius: 9px; border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--text);
  cursor: pointer; font-weight: 560; white-space: nowrap; transition: background .12s, border-color .12s, transform .06s;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: transparent; color: var(--accent-ink); }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 88%, white); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); background: transparent; }
.btn.danger:hover { background: var(--bad-soft); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.small { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn.icon-only { width: 36px; padding: 0; }
.btn.small.icon-only { width: 30px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .field > .label { font-size: 12px; font-weight: 600; color: var(--text-2); }
.field .hint { font-size: 12px; color: var(--dim); }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=search], select, textarea {
  width: 100%; height: 38px; padding: 0 12px; border-radius: 9px; border: 1px solid var(--line-strong);
  background: var(--bg-2); outline: none; color: var(--text);
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { height: auto; padding: 10px 12px; min-height: 80px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }

.switch {
  position: relative; width: 44px; height: 26px; border-radius: 26px; border: 0; cursor: pointer;
  background: var(--surface-3); box-shadow: inset 0 0 0 1px var(--line-strong); transition: background .15s;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--text-2); transition: transform .15s, background .15s;
}
.switch[aria-checked="true"] { background: var(--ok); box-shadow: none; }
.switch[aria-checked="true"]::after { transform: translateX(18px); background: #fff; }
.switch:disabled { opacity: .5; cursor: default; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line-strong); background: transparent;
  color: var(--text-2); cursor: pointer; font-size: 13px; font-weight: 540;
}
.chip:hover { background: var(--surface-2); }
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 55%, transparent); color: var(--accent); }

.pill {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--surface-3); color: var(--text-2);
}
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.info { background: var(--info-soft); color: var(--info); }
.pill.accent { background: var(--accent-soft); color: var(--accent); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; display: inline-block; }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px 0; }
.card-head h3 { font-size: 14px; }
.card-head .sub { color: var(--dim); font-size: 12px; }
.card-body { padding: 14px 18px 18px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 16px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.content > * + * { margin-top: 16px; }
.kpi { padding: 16px 16px 14px; display: flex; flex-direction: column; gap: 4px; position: relative; overflow: hidden; }
.kpi .label { font-size: 12px; color: var(--dim); font-weight: 560; display: flex; align-items: center; gap: 6px; }
.kpi .value { font-size: 28px; font-weight: 700; letter-spacing: -.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi .note { font-size: 12px; color: var(--dim); }
.kpi.alert .value { color: var(--bad); }
.kpi.alert { border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.kpi.warn .value { color: var(--warn); }
.kpi a.cover { position: absolute; inset: 0; }

/* chart */
.chart { display: flex; align-items: flex-end; gap: 6px; height: 170px; padding-top: 8px; }
.chart .col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: stretch; height: 100%; gap: 2px; min-width: 0; position: relative; }
.chart .seg { border-radius: 4px; min-height: 0; }
.chart .seg.renewed { background: var(--accent); }
.chart .seg.activated { background: var(--info); }
.chart .seg.rejected { background: var(--bad); }
.chart .tick { text-align: center; font-size: 10px; color: var(--dim); margin-top: 6px; }
.chart-wrap { display: flex; gap: 6px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--dim); }
.legend span::before { content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 6px; background: var(--c); vertical-align: -1px; }
.legend .renewed { --c: var(--accent); }
.legend .activated { --c: var(--info); }
.legend .rejected { --c: var(--bad); }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--dim); font-weight: 600; padding: 10px 14px; white-space: nowrap; border-bottom: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; }
td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover td { background: var(--surface-2); }
td .sub { display: block; color: var(--dim); font-size: 12px; }
.empty-state { padding: 44px 20px; text-align: center; color: var(--dim); }
.empty-state strong { display: block; color: var(--text); margin-bottom: 4px; font-size: 15px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.toolbar .grow { flex: 1; }
.toolbar input[type=search], .toolbar input[type=text] { max-width: 280px; }
.toolbar select { max-width: 260px; }

.meter { display: inline-flex; align-items: center; gap: 8px; }
.meter .bar { width: 64px; height: 6px; border-radius: 6px; background: var(--surface-3); overflow: hidden; }
.meter .bar i { display: block; height: 100%; width: var(--w, 0%); background: var(--ok); border-radius: 6px; }
.meter.mid .bar i { background: var(--warn); }
.meter.high .bar i { background: var(--bad); }

.attention { display: flex; flex-direction: column; }
.attention button {
  display: flex; align-items: center; gap: 12px; text-align: left; padding: 11px 18px; background: none; border: 0;
  border-top: 1px solid var(--line); cursor: pointer;
}
.attention button:first-child { border-top: 0; }
.attention button:hover { background: var(--surface-2); }
.attention .what { flex: 1; min-width: 0; }
.attention .what b { display: block; font-weight: 600; }
.attention .what span { color: var(--dim); font-size: 12px; }
.attention .icon-wrap { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; flex: none; }
.attention .icon-wrap.bad { background: var(--bad-soft); color: var(--bad); }
.attention .icon-wrap.warn { background: var(--warn-soft); color: var(--warn); }
.attention .icon-wrap.info { background: var(--info-soft); color: var(--info); }
.all-clear { display: flex; align-items: center; gap: 12px; padding: 22px 18px; color: var(--dim); }
.all-clear .icon-wrap { width: 34px; height: 34px; border-radius: 50%; background: var(--ok-soft); color: var(--ok); display: grid; place-items: center; }

/* key/value lists */
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 9px 18px; }
dl.facts dt { color: var(--dim); font-size: 12px; padding-top: 2px; }
dl.facts dd { min-width: 0; word-break: break-word; }
.copyable { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; }
.copyable button { background: none; border: 0; color: var(--dim); cursor: pointer; padding: 2px; border-radius: 5px; display: inline-flex; }
.copyable button:hover { color: var(--accent); background: var(--surface-3); }

.secret-box {
  background: var(--bg-2); border: 1px dashed color-mix(in srgb, var(--accent) 55%, var(--line-strong)); border-radius: 10px;
  padding: 12px 14px; display: flex; flex-direction: column; gap: 6px;
}
.callout { padding: 12px 14px; border-radius: 10px; background: var(--info-soft); color: var(--text-2); display: flex; gap: 10px; font-size: 13px; }
.callout.warn { background: var(--warn-soft); }
.callout.bad { background: var(--bad-soft); }

/* ---------- overlays ---------- */
.scrim { position: fixed; inset: 0; background: rgba(4, 6, 10, .6); backdrop-filter: blur(2px); z-index: 50; animation: fade .15s ease; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: var(--surface); z-index: 60;
  border-left: 1px solid var(--line-strong); box-shadow: var(--shadow); display: flex; flex-direction: column; animation: slide .2s cubic-bezier(.2, .8, .2, 1);
}
.drawer-head { display: flex; align-items: flex-start; gap: 12px; padding: 18px 20px 14px; border-bottom: 1px solid var(--line); }
.drawer-head .titles { flex: 1; min-width: 0; }
.drawer-head h2 { font-size: 17px; }
.drawer-body { overflow-y: auto; padding: 18px 20px 32px; display: flex; flex-direction: column; gap: 22px; flex: 1; }
.section h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--dim); margin-bottom: 10px; display: flex; align-items: center; justify-content: space-between; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.tl { display: flex; flex-direction: column; }
.tl .item { display: grid; grid-template-columns: 130px 1fr; gap: 12px; padding: 7px 0; border-top: 1px solid var(--line); font-size: 13px; }
.tl .item:first-child { border-top: 0; }
.tl .when { color: var(--dim); font-size: 12px; }

dialog {
  border: 1px solid var(--line-strong); border-radius: 16px; background: var(--surface); color: var(--text); padding: 0;
  width: min(520px, calc(100vw - 24px)); box-shadow: var(--shadow); margin: auto;
}
dialog::backdrop { background: rgba(4, 6, 10, .6); backdrop-filter: blur(2px); }
dialog[open] { animation: pop .16s ease; }
dialog .dlg-head { padding: 20px 22px 4px; }
dialog .dlg-head h2 { font-size: 18px; }
dialog .dlg-head p { color: var(--dim); margin-top: 4px; }
dialog .dlg-body { padding: 16px 22px; display: flex; flex-direction: column; gap: 14px; }
dialog .dlg-foot { padding: 14px 22px 20px; display: flex; justify-content: flex-end; gap: 8px; }

.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; pointer-events: none; }
.toast {
  pointer-events: auto; background: var(--surface-3); border: 1px solid var(--line-strong); border-radius: 11px; padding: 11px 14px;
  box-shadow: var(--shadow); display: flex; align-items: center; gap: 10px; max-width: min(380px, calc(100vw - 32px)); animation: rise .18s ease;
}
.toast.bad { border-color: color-mix(in srgb, var(--bad) 55%, var(--line)); }
.toast.ok .icon { color: var(--ok); }
.toast.bad .icon { color: var(--bad); }

.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 8px; height: 14px; }
.skeleton.block { height: 90px; border-radius: var(--radius); }

@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateX(32px); opacity: 0; } }
@keyframes pop { from { transform: scale(.97); opacity: 0; } }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }
@keyframes shimmer { to { background-position: -200% 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- responsive ---------- */
@media (max-width: 1020px) {
  .split, .grid.cols-3 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; z-index: 70; left: 0; top: 0; bottom: 0; width: min(280px, 86vw); transform: translateX(-102%);
    transition: transform .2s ease; box-shadow: var(--shadow);
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(4, 6, 10, .55); z-index: 65; }
  .btn.menu-btn { display: inline-flex; }
  .topbar { padding: 10px 14px; gap: 10px; }
  .topbar h1 { display: none; }
  .search { flex: 1; width: auto; }
  .search kbd { display: none; }
  .content { padding: 18px 14px 56px; }
  .grid.cols-2, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .drawer { width: 100vw; }
  .tl .item { grid-template-columns: 1fr; gap: 2px; }
  dl.facts { grid-template-columns: minmax(0, 1fr); gap: 2px 0; }
  dl.facts dd { margin-bottom: 8px; }
}
