/* ─── ribbet-v2 admin dashboard ─── dark, dense, professional ──── */

/* CRITICAL: any element using display: grid/flex/block will override the
 * default `[hidden] { display: none }` user-agent rule, leaving the
 * element visible even when the JS sets the `hidden` attribute. This
 * is the well-known "display vs hidden" trap. Force-hide everything
 * that carries the attribute, with !important so class rules can't win.
 * Bug fixed 2026-05-16: login-screen, app-shell, idle-lock, drawer,
 * modal, backdrop all use explicit display values and were ignoring
 * `hidden`. Result: every page-load showed the idle-lock overlay over
 * the login screen, which made unlock-clicks succeed via API but never
 * hide the lock.
 */
[hidden] { display: none !important; }

:root {
  --bg-0:        #0b0d10;
  --bg-1:        #11141a;
  --bg-2:        #161a22;
  --bg-3:        #1d222c;
  --bg-hover:    #1a1f29;
  --border:      #232936;
  --border-soft: #1a1f29;
  --text:        #e6e9ef;
  --text-2:      #aab1bd;
  --text-3:      #6f7787;
  --primary:     #6366f1;
  --primary-2:   #4f46e5;
  --success:     #22c55e;
  --warn:        #f59e0b;
  --danger:      #ef4444;
  --info:        #06b6d4;
  --shadow:      0 10px 30px rgba(0,0,0,.4);
  --mono:        ui-monospace, 'JetBrains Mono', 'SF Mono', Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; background: var(--bg-0); }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', system-ui, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ─── LOGIN ─────────────────────────────────────────────────────── */
.login-shell {
  min-height: 100vh; display: grid; place-items: center;
  background:
    radial-gradient(1200px 600px at 70% 10%, rgba(99,102,241,.10), transparent 60%),
    radial-gradient(800px 500px at 20% 90%, rgba(6,182,212,.06), transparent 60%),
    var(--bg-0);
}
.login-card {
  width: min(420px, calc(100% - 32px));
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
  box-shadow: var(--shadow);
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), var(--info));
  color: #fff; font-weight: 800; font-size: 18px;
  display: grid; place-items: center;
}
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: .2px; }
.brand-sub { color: var(--text-3); font-size: 12px; }

.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 12px; color: var(--text-2); font-weight: 500; }
.field input, .search, .select, .modal input, .drawer input {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 14px;
  width: 100%;
  transition: border-color .12s;
}
.field input:focus, .search:focus, .select:focus { border-color: var(--primary); outline: none; }

.login-status { margin-top: 10px; min-height: 18px; font-size: 13px; color: var(--text-2); }
.login-status.err { color: var(--danger); }

.login-foot {
  margin-top: 22px; padding-top: 16px;
  border-top: 1px solid var(--border-soft);
  font-size: 11.5px; color: var(--text-3);
  display: flex; align-items: center; gap: 8px;
}
.dot-ok { width: 7px; height: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 3px rgba(34,197,94,.18); }

/* ─── BUTTONS ──────────────────────────────────────────────────── */
.btn {
  font-family: inherit; font-size: 14px; font-weight: 500;
  padding: 9px 14px; border-radius: 8px; border: 1px solid transparent;
  cursor: pointer; transition: background .12s, border-color .12s, transform .04s;
  background: var(--bg-2); color: var(--text);
  display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { background: var(--bg-3); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-2); }
.btn-danger  { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { filter: brightness(1.05); }
.btn-ghost   { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--bg-2); color: var(--text); }
.btn-sm { padding: 6px 10px; font-size: 12.5px; }

/* ─── APP SHELL ───────────────────────────────────────────────── */
.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
  background: var(--bg-0);
}

/* sidebar */
.sidebar {
  background: var(--bg-1);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 16px 12px;
  position: sticky; top: 0; height: 100vh;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 18px; border-bottom: 1px solid var(--border-soft); margin-bottom: 10px; }
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; font-size: 13.5px;
  background: transparent; color: var(--text-2);
  border: none; border-radius: 8px;
  cursor: pointer; text-align: left;
  font-family: inherit;
  transition: background .1s, color .1s;
}
.ni-icon { font-size: 14px; color: var(--text-3); width: 16px; text-align: center; }
.nav-item:hover { background: var(--bg-2); color: var(--text); }
.nav-item.is-active {
  background: rgba(99,102,241,.12);
  color: var(--text);
  box-shadow: inset 2px 0 0 var(--primary);
}
.nav-item.is-active .ni-icon { color: var(--primary); }

.sidebar-foot {
  padding-top: 12px; border-top: 1px solid var(--border-soft);
  display: grid; gap: 8px;
}
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px; background: var(--bg-2); border-radius: 8px; }
.user-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); flex-shrink: 0; }
.user-meta { min-width: 0; flex: 1; }
.user-email { font-size: 12.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-role  { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: .5px; }

/* topbar */
.main { min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px;
  background: var(--bg-0);
  border-bottom: 1px solid var(--border-soft);
  position: sticky; top: 0; z-index: 5;
}
.topbar-title { margin: 0; font-size: 18px; font-weight: 600; }
.topbar-subtitle { color: var(--text-3); font-size: 12.5px; margin-left: 10px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.conn-status {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-2);
  padding: 5px 10px; background: var(--bg-2); border-radius: 100px;
}
.conn-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 3px rgba(34,197,94,.16); }
.conn-status.conn-err .conn-dot { background: var(--danger); box-shadow: 0 0 0 3px rgba(239,68,68,.16); }
.conn-status.conn-warn .conn-dot { background: var(--warn); box-shadow: 0 0 0 3px rgba(245,158,11,.16); }

/* views */
.view { display: none; padding: 24px; }
.view.is-active { display: block; }

/* ─── KPI GRID ─────────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.kpi-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  position: relative; overflow: hidden;
}
.kpi-card.warn { border-color: rgba(245,158,11,.5); background: linear-gradient(180deg, rgba(245,158,11,.04), var(--bg-1)); }
.kpi-label { font-size: 11.5px; color: var(--text-3); text-transform: uppercase; letter-spacing: .6px; font-weight: 600; }
.kpi-value { font-size: 28px; font-weight: 700; margin-top: 6px; font-variant-numeric: tabular-nums; font-family: var(--mono); letter-spacing: -.5px; }
.kpi-sub   { font-size: 12px; color: var(--text-3); margin-top: 4px; }

/* ─── CARDS ────────────────────────────────────────────────────── */
.card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 16px;
}
.card.no-pad { padding: 0; }
.card-header { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; gap: 10px; }
.card-title  { margin: 0; font-size: 14.5px; font-weight: 600; }
.card-sub    { color: var(--text-3); font-size: 12.5px; }

/* ─── TOOLBARS ────────────────────────────────────────────────── */
.toolbar {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 14px;
}
.search { max-width: 360px; flex: 1; }
.select { width: auto; min-width: 150px; }
.toolbar-meta { margin-left: auto; color: var(--text-3); font-size: 12px; }

/* ─── TABLES ──────────────────────────────────────────────────── */
.table-scroll {
  overflow: auto;
  max-height: calc(100vh - 240px);
  border-radius: 12px;
}
.card.no-pad .table-scroll { border-radius: 12px; }
.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13.5px;
}
.table thead th {
  position: sticky; top: 0;
  background: var(--bg-2);
  color: var(--text-3); font-weight: 600;
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px;
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  z-index: 1;
}
.table tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table.data-table tbody tr { cursor: pointer; }
.table.data-table tbody tr:hover td { background: var(--bg-hover); }
.t-num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.t-ts  { white-space: nowrap; color: var(--text-2); font-size: 12.5px; }
.t-act { text-align: right; width: 1%; white-space: nowrap; }
.td-empty { padding: 22px !important; text-align: center; color: var(--text-3); font-size: 13px; }
.mono { font-family: var(--mono); }

/* ─── STATUS BADGES ───────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 8px;
  font-size: 11.5px; font-weight: 500;
  border-radius: 100px;
  border: 1px solid transparent;
  text-transform: capitalize;
  letter-spacing: .2px;
  white-space: nowrap;
}
.badge.ok       { background: rgba(34,197,94,.10);  color: #4ade80; border-color: rgba(34,197,94,.25); }
.badge.warn     { background: rgba(245,158,11,.10); color: #fbbf24; border-color: rgba(245,158,11,.25); }
.badge.danger   { background: rgba(239,68,68,.10);  color: #fca5a5; border-color: rgba(239,68,68,.25); }
.badge.info     { background: rgba(6,182,212,.10);  color: #67e8f9; border-color: rgba(6,182,212,.25); }
.badge.neutral  { background: var(--bg-3); color: var(--text-2); border-color: var(--border); }
.badge.muted    { background: transparent; color: var(--text-3); border-color: var(--border); }
.badge.tiny     { padding: 1px 6px; font-size: 10.5px; }

.id-mono { font-family: var(--mono); font-size: 11.5px; color: var(--text-2); }
.id-mono:hover { color: var(--text); }
.email-cell { font-weight: 500; }

/* ─── DRAWER ──────────────────────────────────────────────────── */
.backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 50;
  animation: fade-in .12s ease-out;
}
.drawer {
  position: fixed; top: 0; right: 0;
  width: min(540px, 100%); height: 100vh;
  background: var(--bg-1); border-left: 1px solid var(--border);
  box-shadow: -20px 0 40px rgba(0,0,0,.3);
  z-index: 60; overflow: hidden;
  display: flex; flex-direction: column;
  animation: slide-in-right .18s ease-out;
}
.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.drawer-title { margin: 0; font-size: 15px; font-weight: 600; }
.drawer-body { padding: 20px; overflow-y: auto; flex: 1; }
.drawer-section { margin-bottom: 22px; }
.drawer-section h3 { margin: 0 0 8px; font-size: 12px; color: var(--text-3); text-transform: uppercase; letter-spacing: .6px; font-weight: 600; }
.dl { display: grid; grid-template-columns: minmax(120px, 1fr) 2fr; gap: 6px 14px; font-size: 13px; }
.dl dt { color: var(--text-3); }
.dl dd { margin: 0; }

@keyframes slide-in-right { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ─── MODAL ───────────────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: grid; place-items: center; z-index: 100;
  animation: fade-in .12s ease-out;
}
.modal-card {
  width: min(440px, calc(100% - 32px));
  background: var(--bg-1); border: 1px solid var(--border); border-radius: 12px;
  padding: 22px; box-shadow: var(--shadow);
}
.modal-title { margin: 0 0 8px; font-size: 16px; font-weight: 600; }
.modal-body  { margin: 0 0 14px; color: var(--text-2); font-size: 13.5px; }
.modal-typeline { display: grid; gap: 6px; font-size: 12px; color: var(--text-3); margin-bottom: 14px; }
.modal-typeline code { background: var(--bg-3); padding: 1px 6px; border-radius: 4px; color: var(--text); font-family: var(--mono); font-size: 12px; }
.modal-typeline input { font-family: var(--mono); }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ─── TOASTS ──────────────────────────────────────────────────── */
.toast-host {
  position: fixed; bottom: 18px; right: 18px; z-index: 200;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  padding: 11px 14px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px; color: var(--text);
  min-width: 240px; max-width: 360px;
  box-shadow: var(--shadow);
  animation: slide-in-right .14s ease-out;
  pointer-events: auto;
}
.toast.ok    { border-left: 3px solid var(--success); }
.toast.warn  { border-left: 3px solid var(--warn); }
.toast.err   { border-left: 3px solid var(--danger); }
.toast.info  { border-left: 3px solid var(--info); }
.toast .t-title { font-weight: 600; margin-bottom: 2px; }
.toast .t-body  { color: var(--text-2); font-size: 12.5px; }

/* ─── IDLE LOCK ───────────────────────────────────────────────── */
.idle-lock {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(11,13,16,.95);
  display: grid; place-items: center;
  backdrop-filter: blur(6px);
}
.idle-card {
  width: min(360px, calc(100% - 32px));
  background: var(--bg-1); border: 1px solid var(--border); border-radius: 14px;
  padding: 28px; text-align: center;
}
.idle-card .brand-mark { margin: 0 auto 14px; }
.idle-card h2 { margin: 0 0 6px; font-size: 17px; }
.idle-card p  { color: var(--text-3); font-size: 13px; margin: 0 0 16px; }
.idle-card form { display: grid; gap: 8px; margin-bottom: 8px; }
.idle-card input { width: 100%; }

/* ─── CODES VAULT ─────────────────────────────────────────────── */
.codes-grid {
  display: grid;
  grid-template-columns: 1fr 1.1fr;
  gap: 16px;
  align-items: start;
}
.data-table tr.is-selected td {
  background: rgba(99,102,241,.10);
  border-left: 2px solid var(--primary);
}
textarea {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 13px;
  font-family: var(--mono);
  width: 100%;
  resize: vertical;
  min-height: 90px;
}
textarea:focus { border-color: var(--primary); outline: none; }

.reveal-code-box {
  background: var(--bg-0);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px 14px;
  font-family: var(--mono);
  font-size: 18px;
  text-align: center;
  letter-spacing: .5px;
  word-break: break-all;
  color: #4ade80;
  margin: 14px 0 8px;
  user-select: all;
}
.reveal-countdown {
  text-align: center;
  font-size: 12px;
  color: var(--text-3);
  margin-bottom: 14px;
}

/* ─── SCROLLBARS (webkit) ─────────────────────────────────────── */
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--border); border-radius: 100px; }
*::-webkit-scrollbar-thumb:hover { background: #2a3142; }

/* ─── MOBILE ──────────────────────────────────────────────────── */
@media (max-width: 960px) {
  .codes-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; padding: 8px; overflow-x: auto; }
  .sidebar-brand, .sidebar-foot { display: none; }
  .sidebar-nav { flex-direction: row; gap: 4px; }
  .nav-item { white-space: nowrap; padding: 8px 10px; }
  .nav-item.is-active { box-shadow: inset 0 -2px 0 var(--primary); }
  .topbar { padding: 12px 16px; }
  .view   { padding: 14px; }
  .table-scroll { max-height: calc(100vh - 200px); }
  .drawer { width: 100%; }
}
