/* Eneon Tunnels dashboard. Brand: navy #003d92, blue #068ce3, cyan #0dbdf1. */
:root {
  --brand-navy: #003d92;
  --brand-blue: #068ce3;
  --brand-cyan: #0dbdf1;
  --bg: #060d1f;
  --bg-alt: #0b1630;
  --card: #0e1a36;
  --card-2: #12224a;
  --line: #1f3260;
  --ink: #eaf1fb;
  --muted: #8ea3c4;
  --primary: #2ec0ff;
  --primary-ink: #04111f;
  --ok: #2fd27f;
  --off: #64748b;
  --danger: #ff6b6b;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --radius: 14px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f5f8fc;
  --bg-alt: #eaf0f8;
  --card: #ffffff;
  --card-2: #f2f6fc;
  --line: #d7e1ef;
  --ink: #0a1324;
  --muted: #5b6b85;
  --primary: #0559d4;
  --primary-ink: #ffffff;
  --shadow: 0 8px 24px rgba(10, 30, 70, .08);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  background:
    radial-gradient(1200px 500px at 85% -10%, rgba(13, 189, 241, .12), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(0, 61, 146, .25), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
}
[hidden] { display: none !important; }
code, .mono { font-family: var(--mono); font-size: .9em; }
code { background: var(--card-2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; }
.muted { color: var(--muted); }
h1, h2, h3 { margin: 0; line-height: 1.25; }
a { color: var(--primary); }

/* Buttons */
.btn {
  appearance: none; border: 1px solid var(--line); background: var(--card-2); color: var(--ink);
  font: inherit; font-weight: 600; font-size: 14px; padding: 9px 14px; border-radius: 10px;
  cursor: pointer; transition: transform .08s ease, background .15s ease, border-color .15s ease;
  white-space: nowrap;
}
.btn:hover { border-color: var(--brand-blue); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, input:focus-visible { outline: 2px solid var(--brand-cyan); outline-offset: 2px; }
.btn-primary {
  background: linear-gradient(135deg, var(--brand-blue), var(--brand-cyan));
  border-color: transparent; color: #04111f;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); }
.btn-small { font-size: 13px; padding: 6px 10px; border-radius: 8px; }
.btn-icon { padding: 8px 11px; }
.btn-block { width: 100%; }

/* Inputs */
input {
  font: inherit; color: var(--ink); background: var(--bg-alt); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 12px; min-width: 0;
}
input::placeholder { color: var(--muted); opacity: .8; }
.field { display: grid; gap: 6px; text-align: left; margin: 18px 0 8px; font-weight: 600; font-size: 14px; }
.error { color: var(--danger); font-size: 14px; margin: 6px 0 0; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 24px; background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.brand strong { font-size: 17px; letter-spacing: .2px; }
.badge {
  display: inline-block; margin-left: 6px; font-size: 11px; font-weight: 600; color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; vertical-align: 2px;
}
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Content */
.content { max-width: 1200px; margin: 0 auto; padding: 24px; }
.summary { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 18px; display: flex; align-items: baseline; gap: 8px; box-shadow: var(--shadow);
}
.stat span { font-size: 24px; font-weight: 700; }
.stat:first-child span { color: var(--ok); }
.summary-note { flex: 1 1 320px; margin: 0; font-size: 14px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }
@media (max-width: 420px) { .grid { grid-template-columns: 1fr; } .content { padding: 16px; } .topbar { padding: 12px 16px; } }

/* Device card */
.card {
  background: linear-gradient(180deg, var(--card), color-mix(in srgb, var(--card) 85%, var(--bg)));
  border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 14px;
}
.card.online { border-color: color-mix(in srgb, var(--ok) 35%, var(--line)); }
.card-head { display: flex; align-items: center; gap: 12px; }
.title { flex: 1; min-width: 0; }
.name { font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.id { background: none; border: 0; padding: 0; color: var(--muted); cursor: pointer; font-size: 12px; }
.id:hover { color: var(--primary); }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--off); flex: none; }
.online .dot { background: var(--ok); box-shadow: 0 0 0 4px color-mix(in srgb, var(--ok) 20%, transparent); animation: pulse 2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--ok) 6%, transparent); } }
.state { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.online .state { color: var(--ok); }

.meta { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; margin: 0; }
.meta div { min-width: 0; }
.meta dt { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.meta dd { margin: 0; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.open { background: var(--card-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.open-row { display: flex; gap: 8px; flex-wrap: wrap; }
.open-row .port { width: 150px; flex: 1 1 120px; }
.open-row .lan { flex: 1 1 100%; order: 3; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.chip {
  border: 1px solid var(--line); background: transparent; color: var(--muted); border-radius: 999px;
  font: inherit; font-size: 12px; padding: 3px 10px; cursor: pointer;
}
.chip:hover { color: var(--ink); border-color: var(--brand-blue); }
.device:not(.online) .open { opacity: .55; }
.card-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Empty state */
.empty { text-align: center; padding: 60px 16px; }
.empty h2 { margin: 16px 0 6px; }
.empty .btn { margin-top: 12px; }

/* Modal */
.modal { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(2, 6, 18, .6); backdrop-filter: blur(3px); }
.modal-box {
  position: relative; width: min(720px, 100%); max-height: calc(100vh - 32px); overflow: auto;
  background: var(--card); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 18px; }
.modal-body { padding: 18px 20px 22px; display: grid; gap: 14px; }
.modal-body p { margin: 0; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row input { flex: 1 1 220px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.tab {
  background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted); font: inherit;
  font-weight: 600; padding: 8px 12px; cursor: pointer;
}
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--brand-cyan); }

.cmd {
  position: relative; background: #050b19; color: #d9e7ff; border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 84px 12px 14px; font-family: var(--mono); font-size: 12.5px; line-height: 1.6;
  word-break: break-all; white-space: pre-wrap;
}
.cmd .copy { position: absolute; top: 8px; right: 8px; }
.note {
  border-left: 3px solid var(--brand-cyan); background: var(--card-2); padding: 10px 12px; border-radius: 8px;
  font-size: 13.5px; color: var(--muted);
}
.note.warn { border-left-color: #f5b74a; }

.list { display: grid; gap: 8px; }
.list-item {
  display: flex; align-items: center; gap: 10px; justify-content: space-between; background: var(--card-2);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
}
.list-item small { color: var(--muted); display: block; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 30;
  background: var(--card-2); color: var(--ink); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 16px; box-shadow: var(--shadow); font-weight: 600; font-size: 14px;
}
.toast.err { border-color: var(--danger); color: var(--danger); }

@media (prefers-reduced-motion: reduce) { .online .dot { animation: none; } * { transition: none !important; } }

/* Signed-out pages */
.auth {
  min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 420px);
  gap: 48px; align-items: center; max-width: 1080px; margin: 0 auto; padding: 32px 24px;
}
.auth-intro h1 { font-size: clamp(30px, 4vw, 44px); margin: 14px 0 12px;
  background: linear-gradient(135deg, var(--ink), var(--brand-cyan)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.auth-intro p { color: var(--muted); font-size: 17px; max-width: 520px; }
.ticks { list-style: none; padding: 0; margin: 22px 0 0; display: grid; gap: 10px; }
.ticks li { padding-left: 28px; position: relative; }
.ticks li::before { content: "✓"; position: absolute; left: 0; color: var(--brand-cyan); font-weight: 700; }
.auth-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 28px;
  box-shadow: var(--shadow);
}
.auth-card h2 { font-size: 22px; margin-bottom: 6px; }
.auth-card form { display: grid; gap: 4px; }
.auth-card .btn-primary { margin-top: 14px; }
.auth-links { display: flex; justify-content: space-between; gap: 12px; margin-top: 16px; font-size: 14px; flex-wrap: wrap; }
.success { color: var(--ok); }
@media (max-width: 820px) {
  .auth { grid-template-columns: 1fr; gap: 24px; }
  .auth-intro .ticks { display: none; }
}

/* Navigation */
.tabs-nav { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs-nav a {
  color: var(--muted); text-decoration: none; font-weight: 600; font-size: 14px; padding: 8px 12px; border-radius: 10px;
}
.tabs-nav a:hover { color: var(--ink); background: var(--card-2); }
.tabs-nav a[aria-current="page"] { color: var(--ink); background: var(--card-2); box-shadow: inset 0 -2px 0 var(--brand-cyan); }
.whoami { font-size: 13px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 760px) { .whoami { display: none; } }
.foot { text-align: center; font-size: 12.5px; padding: 24px 16px 32px; }

/* Page headings */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { font-size: 24px; }
.page-head p { margin: 4px 0 0; }
.usage { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); }
.bar { width: 120px; height: 8px; border-radius: 99px; background: var(--card-2); border: 1px solid var(--line); overflow: hidden; }
.bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--brand-blue), var(--brand-cyan)); }

/* Panels (account, keys, admin) */
.panel {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow); margin-bottom: 18px; display: grid; gap: 12px;
}
.panel h2 { font-size: 17px; }
.panel form { display: grid; gap: 4px; max-width: 460px; }
.panel.danger { border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); background: var(--card-2); }
tr:last-child td { border-bottom: 0; }
td .btn { margin-right: 4px; }
td input.limit { width: 70px; padding: 5px 8px; }
.pill { display: inline-block; font-size: 11.5px; font-weight: 700; border-radius: 99px; padding: 2px 9px; border: 1px solid var(--line); color: var(--muted); }
.pill.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, var(--line)); }
.pill.bad { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }
.pill.info { color: var(--brand-cyan); border-color: color-mix(in srgb, var(--brand-cyan) 40%, var(--line)); }

/* Phones */
@media (max-width: 640px) {
  .topbar { display: grid; grid-template-columns: 1fr auto; gap: 8px 10px; padding: 10px 16px; }
  .topbar .brand strong { font-size: 16px; }
  .topbar .actions { grid-column: 2; grid-row: 1; flex-wrap: nowrap; }
  .topbar .actions .btn { padding: 7px 10px; font-size: 13px; }
  .tabs-nav { grid-column: 1 / -1; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -4px; }
  .tabs-nav::-webkit-scrollbar { display: none; }
  .tabs-nav a { flex: none; }
  .content { padding: 16px; }
  .page-head h1 { font-size: 21px; }
  .page-head > .row { width: 100%; justify-content: space-between; }
  .grid { grid-template-columns: 1fr; }
  .card { padding: 16px; }
  .card-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .card-actions .btn { width: 100%; }
  .open-row .btn { flex: 1 1 100%; }
  .panel { padding: 16px; }
  .modal { padding: 0; place-items: end stretch; }
  .modal-box { width: 100%; max-height: 92vh; border-radius: 18px 18px 0 0; }
  .cmd { font-size: 11.5px; padding-right: 14px; padding-top: 40px; }

  /* Tables become stacked cards with labels */
  .table-wrap { border: 0; overflow: visible; }
  table, thead, tbody, tr, td { display: block; width: 100%; }
  thead { display: none; }
  tr { background: var(--card-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; }
  td { border: 0; padding: 5px 0; white-space: normal; display: grid; grid-template-columns: 96px 1fr; gap: 8px; align-items: center; }
  td::before { content: attr(data-label); font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
  td[data-label=""] { grid-template-columns: 1fr; }
  td[data-label=""]::before { display: none; }
  td .btn { margin: 2px 4px 2px 0; }
  td.actions-cell > div { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
}
