/* Tunnel Control Panel — themed (light/dark via prefers-color-scheme), responsive. */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --text: #1b1f24;
  --muted: #5b6572;
  --border: #dfe3e8;
  --primary: #2563eb;
  --primary-text: #ffffff;
  --danger: #dc2626;
  --ok: #16a34a;
  --warn: #d97706;
  --shadow: 0 6px 24px rgba(20, 24, 33, 0.12);
  --radius: 12px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1319;
    --surface: #171c24;
    --surface-2: #1f2630;
    --text: #e7ebf0;
    --muted: #9aa5b3;
    --border: #2a323d;
    --primary: #3b82f6;
    --danger: #ef4444;
    --ok: #22c55e;
    --warn: #f59e0b;
    --shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.mono { font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 17px; margin: 0 0 12px; }

.app { min-height: 100vh; }
.centered { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px; }

/* Buttons */
.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  padding: 9px 14px;
  border-radius: 9px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.02s ease;
}
.btn:hover { border-color: var(--primary); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn.danger:hover { background: color-mix(in srgb, var(--danger) 12%, transparent); }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 10px; font-size: 13px; }
.icon-btn { background: none; border: none; color: var(--muted); font-size: 18px; cursor: pointer; line-height: 1; }

/* Login */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}
.login { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 12px; }
.field-label { font-size: 13px; color: var(--muted); }
.login input {
  width: 100%;
  padding: 11px 12px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 15px;
}
.login input:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.error { color: var(--danger); font-size: 13px; min-height: 18px; margin: 0; }

/* Dashboard */
.dashboard { max-width: 960px; margin: 0 auto; padding: 24px 20px 48px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.topbar .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.dashboard .card { padding: 20px; }

.table-scroll { overflow-x: auto; }
table.hosts { width: 100%; border-collapse: collapse; font-size: 14px; }
table.hosts th, table.hosts td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.hosts th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
table.hosts tr:last-child td { border-bottom: none; }
.empty { color: var(--muted); padding: 24px 4px; text-align: center; }

/* Status pills */
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; border: 1px solid var(--border); }
.pill-online, .pill-active { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, transparent); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.pill-offline { color: var(--muted); }
.pill-revoked, .pill-suspended { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); background: color-mix(in srgb, var(--danger) 12%, transparent); }
.pill-unknown { color: var(--warn); }

/* Modal */
.overlay { position: fixed; inset: 0; background: rgba(6, 9, 14, 0.55); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); width: 100%; max-width: 420px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; align-items: center; text-align: center; }
.code-big { font-size: 26px; font-weight: 700; letter-spacing: 0.08em; padding: 8px 12px; background: var(--surface-2); border-radius: 9px; }
.qr { width: 200px; height: 200px; image-rendering: pixelated; background: #fff; padding: 8px; border-radius: 9px; }
.command-row { display: flex; gap: 8px; align-items: center; width: 100%; }
.command-row.end { justify-content: flex-end; }
.command { flex: 1; text-align: left; background: var(--surface-2); padding: 9px 11px; border-radius: 8px; font-size: 13px; overflow-x: auto; white-space: nowrap; }

/* Toasts */
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); padding: 10px 16px; border-radius: 9px; box-shadow: var(--shadow); z-index: 60; font-size: 14px; }
.toast-info { background: var(--surface); border: 1px solid var(--border); color: var(--text); }
.toast-error { background: var(--danger); color: #fff; }

@media (max-width: 560px) {
  .topbar { flex-direction: column; align-items: stretch; }
  .topbar .actions { justify-content: stretch; }
  .topbar .actions .btn { flex: 1; }
}
