/* ============================================================
   HLS Platform — Admin UI
   Modern dark dashboard. Compact, readable, animated.
   ============================================================ */

:root {
  --bg:          #0b0d14;
  --bg-2:        #0f121c;
  --surface:     #141825;
  --surface-2:   #1a1f2e;
  --surface-3:   #232840;
  --border:      #262c40;
  --border-hi:   #323a56;

  --text:        #e8ecf5;
  --text-2:      #b8c0d0;
  --muted:       #6d7689;

  --accent:      #5b8cff;
  --accent-2:    #7aa7ff;
  --accent-dim:  rgba(91,140,255,.15);
  --success:     #34d399;
  --warning:     #fbbf24;
  --danger:      #f87171;

  --radius:      12px;
  --radius-sm:   8px;
  --mono:        ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --shadow:      0 4px 20px rgba(0,0,0,.25);
  --shadow-lg:   0 12px 40px rgba(0,0,0,.45);
}

/* ---- CRITICAL: honour the `hidden` attribute everywhere ---- */
[hidden] { display: none !important; }

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  line-height: 1.5;
}
input, select, button, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
h1, h2, h3 { font-weight: 600; letter-spacing: -.01em; }
b, strong { font-weight: 600; }

.muted  { color: var(--muted); }
.small  { font-size: .82rem; }
.mono   { font-family: var(--mono); }
.mt     { margin-top: 10px; }
.grow   { flex: 1 1 auto; }
.self-start { align-self: flex-start; }
.err-msg { color: var(--danger); font-size: .85rem; margin-top: 10px; text-align: center; }

/* ============================================================
   LOGIN
   ============================================================ */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 15% 20%, rgba(91,140,255,.12), transparent 40%),
    radial-gradient(circle at 85% 80%, rgba(122,167,255,.08), transparent 45%),
    var(--bg);
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
  animation: fadeUp .4s ease;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.login-logo {
  display: flex;
  justify-content: center;
  color: var(--accent);
  margin-bottom: 14px;
}
.login-card h1 {
  font-size: 1.5rem;
  text-align: center;
  margin-bottom: 4px;
}
.login-card > p {
  text-align: center;
  margin-bottom: 26px;
  color: var(--muted);
  font-size: .92rem;
}
.login-card label {
  display: block;
  font-size: .82rem;
  color: var(--text-2);
  margin-bottom: 14px;
}
.login-card label input {
  display: block;
  width: 100%;
  margin-top: 6px;
}
.btn.block { width: 100%; margin-top: 8px; }

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

/* ---- Sidebar ---- */
.sidebar {
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 22px 0 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 22px 18px;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  letter-spacing: -.01em;
}
.brand svg { color: var(--accent); }
.sidebar nav {
  display: flex;
  flex-direction: column;
  padding: 14px 10px;
  flex: 1;
  gap: 2px;
}
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  color: var(--text-2);
  font-size: .92rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: background .15s, color .15s;
}
.sidebar nav a svg { flex-shrink: 0; opacity: .7; }
.sidebar nav a:hover {
  color: var(--text);
  background: var(--surface);
}
.sidebar nav a.active {
  color: var(--accent);
  background: var(--accent-dim);
}
.sidebar nav a.active svg { opacity: 1; }

.who {
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.who-info {
  display: flex;
  align-items: center;
  gap: 10px;
}
.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .9rem;
  flex-shrink: 0;
}
.who-name { font-weight: 600; font-size: .9rem; color: var(--text); }
.who-role {
  font-size: .72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .5px;
}

/* ---- Main ---- */
.main {
  padding: 22px 32px 40px;
  max-width: 1440px;
  width: 100%;
  overflow-x: hidden;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 1.35rem; }
.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.live-dot {
  color: var(--success);
  font-size: 1.1rem;
  animation: pulse 1.8s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: .35; }
}

/* ---- Pages ---- */
.page { display: none; }
.page.active { display: block; animation: fadeIn .2s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 18px;
}
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.card-head h2 {
  font-size: .95rem;
  color: var(--text);
  font-weight: 600;
  letter-spacing: -.01em;
}
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-bottom: 18px;
}
.grid-2 > .card { margin-bottom: 0; }

/* ============================================================
   KPI CARDS (Dashboard top row)
   ============================================================ */
.kpi-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-bottom: 18px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}
.kpi::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent);
  opacity: .5;
}
.kpi-label {
  font-size: .74rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .6px;
  margin-bottom: 10px;
  font-weight: 600;
}
.kpi-value {
  font-size: 1.9rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.kpi-sub { margin-top: 4px; }

.progress {
  margin-top: 12px;
  height: 6px;
  background: var(--surface-3);
  border-radius: 99px;
  overflow: hidden;
}
.bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 99px;
  transition: width .4s ease, background .4s;
}
.bar.warn   { background: linear-gradient(90deg, var(--warning), #fcd34d); }
.bar.danger { background: linear-gradient(90deg, var(--danger), #fca5a5); }

/* ---- Mini stats (library row) ---- */
.kpi-grid-sm {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
}
.mini {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  text-align: center;
}
.mini-val {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.mini-lbl {
  font-size: .72rem;
  color: var(--muted);
  margin-top: 4px;
  letter-spacing: .3px;
  text-transform: uppercase;
}

/* ---- System info panel ---- */
.sysinfo {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 8px 18px;
  font-size: .88rem;
}
.sysinfo dt {
  color: var(--muted);
  font-weight: 500;
}
.sysinfo dd {
  color: var(--text);
  font-family: var(--mono);
  font-size: .82rem;
  word-break: break-word;
}

/* ---- Net legend ---- */
.net-legend { margin-top: 12px; font-size: .85rem; }
.net-legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
}
.swatch-rx { background: var(--accent); }
.swatch-tx { background: var(--success); }

/* ============================================================
   FORMS
   ============================================================ */
input, select, textarea {
  background: var(--bg-2);
  border: 1px solid var(--border);
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  outline: none;
  color: var(--text);
  transition: border-color .15s, background .15s;
}
input::placeholder, textarea::placeholder { color: var(--muted); }
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  background: var(--surface);
}
input, select {
  min-width: 140px;
}
textarea {
  width: 100%;
  resize: vertical;
  min-height: 72px;
  font-family: var(--mono);
  font-size: .82rem;
}

/* ---- Rows / columns ---- */
.row { display: flex; align-items: center; }
.row.gap { gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.col { display: flex; flex-direction: column; }
.col.gap { gap: 10px; }

/* ============================================================
   BUTTONS
   ============================================================ */
button.btn {
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  font-size: .88rem;
  font-weight: 600;
  letter-spacing: -.005em;
  transition: background .15s, border-color .15s, transform .08s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
button.btn:active:not(:disabled) { transform: translateY(1px); }
button.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn.primary  { background: var(--accent);           color: #fff; }
.btn.primary:hover:not(:disabled)  { background: var(--accent-2); }
.btn.success  { background: var(--success);          color: #07291f; }
.btn.success:hover:not(:disabled)  { filter: brightness(1.08); }
.btn.warn     { background: var(--warning);          color: #3a2a00; }
.btn.warn:hover:not(:disabled)     { filter: brightness(1.08); }
.btn.danger   { background: var(--danger);           color: #fff; }
.btn.danger:hover:not(:disabled)   { filter: brightness(1.08); }
.btn.ghost    { background: var(--surface-2); border-color: var(--border); color: var(--text); }
.btn.ghost:hover:not(:disabled)    { background: var(--surface-3); border-color: var(--border-hi); }
.btn.small    { padding: 5px 12px; font-size: .78rem; }

/* ============================================================
   TABLES
   ============================================================ */
.table-wrap {
  overflow-x: auto;
  margin: 0 -22px -20px;
  border-top: 1px solid var(--border);
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
}
.table th {
  text-align: left;
  padding: 12px 22px;
  color: var(--muted);
  background: var(--bg-2);
  font-weight: 600;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .6px;
  border-bottom: 1px solid var(--border);
}
.table td {
  padding: 12px 22px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background .1s; }
.table tbody tr:hover { background: rgba(91,140,255,.04); }
.empty { text-align: center; padding: 32px; color: var(--muted); }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .3px;
  text-transform: uppercase;
}
.badge.blue   { background: rgba(91,140,255,.16); color: var(--accent); }
.badge.green  { background: rgba(52,211,153,.15); color: var(--success); }
.badge.red    { background: rgba(248,113,113,.15); color: var(--danger); }
.badge.yellow { background: rgba(251,191,36,.15); color: var(--warning); }
.badge.grey   { background: rgba(120,130,150,.18); color: var(--text-2); }

.slug {
  font-family: var(--mono);
  font-size: .82rem;
  color: var(--accent-2);
}
.actions { display: flex; gap: 6px; }

/* ============================================================
   MODAL
   ============================================================ */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.modal-body {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px;
  width: min(460px, 92vw);
  box-shadow: var(--shadow-lg);
}
.modal-body h3 { margin-bottom: 16px; font-size: 1.05rem; }
.modal-body input { width: 100%; margin-bottom: 18px; }

/* ============================================================
   TOAST
   ============================================================ */
.toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  background: var(--success);
  color: #07291f;
  font-weight: 600;
  padding: 12px 22px;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  z-index: 100;
  box-shadow: var(--shadow-lg);
  animation: toastIn .25s ease;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.toast.err { background: var(--danger); color: #fff; }

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hi); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; flex-direction: row; padding: 10px; overflow-x: auto; }
  .sidebar nav { flex-direction: row; padding: 0; }
  .sidebar nav a { white-space: nowrap; }
  .brand { border-bottom: none; padding: 0 10px; }
  .who { border-top: none; padding: 0 10px; flex-direction: row; }
  .main { padding: 16px; }
  .grid-2 { grid-template-columns: 1fr; }
}
