/* DAFC Audio - shared design system. One file, linked from every page,
   so the look stays consistent as pages get added rather than each view
   re-inventing its own palette (that's how the original handful of pages
   ended up with near-identical-but-not-quite-identical inline <style>
   blocks - this replaces all of that). */

:root {
  --bg: #0b0e14;
  --bg-soft: #10141d;
  --panel: #151a25;
  --panel-2: #1b2130;
  --border: #262d3d;
  --text: #e9edf5;
  --muted: #8b96ab;
  --muted-2: #5f6b82;
  --primary: #3d8bfd;
  --primary-hover: #5a9dff;
  --primary-ink: #06121f;
  --live: #ff4d5e;
  --live-bg: rgba(255, 77, 94, 0.12);
  --ok: #2ecf7a;
  --ok-bg: rgba(46, 207, 122, 0.12);
  --warn: #ffb020;
  --warn-bg: rgba(255, 176, 32, 0.12);
  --error: #ff5d6c;
  --error-bg: rgba(255, 93, 108, 0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; min-width: 0; }
html, body { margin: 0; overflow-x: hidden; width: 100%; }
body {
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(61, 139, 253, 0.10), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(255, 77, 94, 0.06), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); }
h1, h2, h3 { font-weight: 650; letter-spacing: -0.01em; }
p { line-height: 1.55; color: var(--muted); }
::selection { background: rgba(61, 139, 253, 0.35); }

/* --- standalone auth-card pages (login, MFA, change password) --- */

.auth-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  padding-top: max(24px, env(safe-area-inset-top));
  padding-bottom: max(24px, env(safe-area-inset-bottom));
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 36px 32px;
}
.auth-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 22px;
}
.auth-brand .dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--live);
  box-shadow: 0 0 12px rgba(255, 77, 94, 0.7);
}
.auth-brand span {
  font-size: 15px; font-weight: 700; letter-spacing: 0.02em; color: var(--text);
}
.auth-card h1 { font-size: 19px; text-align: center; margin: 0 0 22px; }
.auth-card p.hint { font-size: 13px; margin: -6px 0 18px; text-align: center; }

/* --- forms --- */

label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; font-weight: 600; letter-spacing: 0.01em; }
input, select, textarea {
  width: 100%;
  padding: 11px 13px;
  margin-bottom: 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  font-size: 14px;
  font-family: var(--font);
  transition: border-color 0.15s ease;
}
input::placeholder { color: var(--muted-2); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); }
input[data-code] { font-family: var(--mono); letter-spacing: 0.25em; text-align: center; font-size: 18px; }

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--primary);
  color: var(--primary-ink);
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.05s ease, background 0.15s ease, border-color 0.15s ease;
}
button:hover, .btn:hover { background: var(--primary-hover); }
button:active, .btn:active { transform: scale(0.98); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
form > button, form > .btn-row > button { width: 100%; }

.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--panel-2); border-color: var(--muted-2); }
.btn-danger { background: var(--error); color: #2a0508; }
.btn-danger:hover { background: #ff7883; }
.btn-sm { padding: 7px 12px; font-size: 12.5px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row > * { flex: 0 0 auto; }

a.back, a.link-muted { display: inline-block; color: var(--muted); text-decoration: none; font-size: 13px; }
a.back:hover, a.link-muted:hover { color: var(--text); }

/* --- alerts --- */

.alert { border-radius: var(--radius-sm); padding: 11px 14px; font-size: 13px; margin-bottom: 16px; border: 1px solid transparent; line-height: 1.4; }
.alert-error { background: var(--error-bg); border-color: rgba(255, 93, 108, 0.35); color: var(--error); }
.alert-ok { background: var(--ok-bg); border-color: rgba(46, 207, 122, 0.35); color: var(--ok); }
.alert-warn { background: var(--warn-bg); border-color: rgba(255, 176, 32, 0.35); color: var(--warn); }

/* --- app shell (dashboards) --- */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  padding-top: calc(14px + env(safe-area-inset-top));
  background: rgba(21, 26, 37, 0.92);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.app-header .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 14.5px; color: var(--text); text-decoration: none; }
.app-header .brand .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--live); box-shadow: 0 0 10px rgba(255, 77, 94, 0.7); }
.app-nav { display: flex; align-items: center; gap: 4px; }
.app-nav a { color: var(--muted); text-decoration: none; font-size: 13.5px; padding: 7px 12px; border-radius: 999px; transition: background 0.15s ease, color 0.15s ease; }
.app-nav a:hover { color: var(--text); background: var(--panel-2); }
.app-nav a.active { color: var(--text); background: var(--panel-2); }
.app-nav .sep { width: 1px; height: 18px; background: var(--border); margin: 0 6px; }

/* --- mobile burger menu --- */
.nav-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 38px;
  height: 34px;
  padding: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.nav-toggle span { display: block; width: 18px; height: 2px; background: var(--text); border-radius: 1px; }

@media (max-width: 720px) {
  .nav-toggle { display: flex; }
  .app-nav {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
    padding: 8px 16px 16px;
  }
  .app-nav.open { display: flex; }
  .app-nav a { padding: 11px 12px; font-size: 14.5px; }
  .app-nav .sep { display: none; }
  .app-nav .nav-user { order: -1; padding: 6px 12px 10px; font-size: 12.5px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
}

main.container { max-width: 880px; margin: 0 auto; padding: 32px 24px 64px; }
main.container.wide { max-width: 1080px; }
@media (max-width: 480px) {
  main.container { padding: 20px 16px 48px; }
  .card { padding: 18px 16px; }
  .btn-row { gap: 8px; }
  .badge { font-size: 10px; padding: 3px 8px; }
}

.page-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; margin: 0; }
.page-head .sub { font-size: 13px; color: var(--muted); margin-top: 2px; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 20px;
}
.card h2 { font-size: 15px; margin: 0 0 4px; }
.card h2 + p.card-sub { margin-top: 0; margin-bottom: 16px; font-size: 13px; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 640px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.stat { background: var(--bg-soft); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 16px 18px; }
.stat .stat-label { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 650; }
.stat .stat-value { font-size: 26px; font-weight: 700; margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat .stat-value.mono { font-family: var(--mono); font-size: 20px; }

/* --- badges --- */

.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 999px; text-transform: uppercase; letter-spacing: 0.05em; border: 1px solid var(--border); color: var(--muted); }
.badge-live { background: var(--live-bg); border-color: rgba(255, 77, 94, 0.4); color: var(--live); }
.badge-live .pulse { width: 6px; height: 6px; border-radius: 50%; background: var(--live); animation: pulse 1.4s ease-in-out infinite; }
.badge-off { background: var(--panel-2); color: var(--muted); }
.badge-ok { background: var(--ok-bg); border-color: rgba(46, 207, 122, 0.4); color: var(--ok); }
.badge-warn { background: var(--warn-bg); border-color: rgba(255, 176, 32, 0.4); color: var(--warn); }
.badge-role { background: var(--panel-2); color: var(--muted); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }

/* --- tables --- */

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 650; padding: 0 10px 10px; border-bottom: 1px solid var(--border); }
td { padding: 12px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
td .mono { font-family: var(--mono); font-size: 12.5px; color: var(--muted); }
.table-wrap { overflow-x: auto; }

.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.filter-bar input, .filter-bar select { margin-bottom: 0; flex: 1 1 160px; min-width: 120px; }
.filter-bar input[type="search"] { flex: 2 1 200px; }

/* --- account list (admin) --- */

.acct-list { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.acct-row { padding: 14px 18px; border-bottom: 1px solid var(--border); background: var(--panel); }
.acct-row:last-child { border-bottom: none; }
.acct-email { font-weight: 650; font-size: 14.5px; word-break: break-all; }
.acct-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.acct-meta .plain { font-size: 12.5px; color: var(--muted); }
.acct-meta .icon-btn { margin-left: 2px; }
.acct-meta .icon-group { display: flex; gap: 6px; margin-left: auto; }
@media (max-width: 480px) {
  .acct-row { padding: 12px 14px; }
  .acct-meta .icon-group { margin-left: 0; width: 100%; padding-top: 4px; border-top: 1px dashed var(--border); margin-top: 6px; }
}

/* --- credential box --- */

.cred-box { background: var(--bg-soft); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px; margin-bottom: 14px; }
.cred-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 0; }
.cred-row .cred-label { font-size: 12px; color: var(--muted); }
.cred-row .cred-value { font-family: var(--mono); font-size: 14px; color: var(--text); word-break: break-all; }

/* --- player --- */

.player-card { text-align: center; padding: 36px 24px; }
.player-status { margin: 0 auto 18px; }
.player-controls { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 18px; flex-wrap: wrap; }
.play-btn {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--primary); color: var(--primary-ink);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; border: none; cursor: pointer;
}
.play-btn:hover { background: var(--primary-hover); }
.volume-row { display: flex; align-items: center; gap: 10px; width: 200px; }
.volume-row input[type="range"] { margin: 0; width: 100%; }
@media (max-width: 400px) { .volume-row { width: 140px; } }

/* --- icon buttons + tooltips --- */

.icon-btn {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
.icon-btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.icon-btn:hover { background: var(--panel-2); color: var(--text); border-color: var(--muted-2); }
.icon-btn.danger:hover { background: var(--error-bg); color: var(--error); border-color: rgba(255, 93, 108, 0.4); }

[data-tooltip] { position: relative; }
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: #05070b;
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.12s ease, transform 0.12s ease;
  pointer-events: none;
  z-index: 20;
}
[data-tooltip]:hover::after, [data-tooltip]:focus-visible::after {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}
@media (hover: none) { [data-tooltip]::after { display: none; } }

/* --- modal --- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 7, 11, 0.65);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}
.modal-overlay.open { display: flex; }
.modal-box {
  width: 100%;
  max-width: 420px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
}
.modal-box h3 { margin: 0 0 6px; font-size: 17px; }
.modal-box #modal-desc { margin: 0 0 16px; font-size: 13.5px; }
.modal-box form > button, .modal-box form > .btn-row > button { width: auto; }

/* --- misc --- */

.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }
.footer-note { text-align: center; font-size: 12px; color: var(--muted-2); margin-top: 24px; }
