/* ===================== adshub UI ===================== */
:root {
  --bg: #0b1220;
  --surface: #131c2e;
  --surface-2: #1a2740;
  --border: #26324a;
  --border-soft: #1f2b42;
  --text: #e6ecf5;
  --muted: #8b9bb4;
  --primary: #4f8cff;
  --primary-ink: #06213f;
  --accent: #38bdf8;
  --success: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --radius: 12px;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.28);
  --fb: #1877f2;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: "Segoe UI", system-ui, Roboto, -apple-system, sans-serif;
  font-size: 14px; line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #2a3856; border-radius: 8px; }

/* Layout */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 244px; flex-shrink: 0; background: var(--surface);
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.brand {
  display: flex; align-items: center; gap: 10px; padding: 20px 20px 16px;
  font-size: 18px; font-weight: 700; letter-spacing: .2px;
}
.brand .logo {
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: grid; place-items: center; font-size: 16px;
}
.nav { padding: 8px 12px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  border-radius: 10px; color: var(--muted); font-weight: 500; margin-bottom: 3px;
  cursor: pointer; transition: background .12s, color .12s; position: relative;
}
.nav-item .ic { width: 20px; text-align: center; font-size: 16px; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: rgba(79,140,255,.14); color: #cfe0ff; font-weight: 600; }
.nav-item.active::before {
  content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px;
  width: 3px; border-radius: 3px; background: var(--primary);
}
.sidebar-foot { padding: 14px 16px; border-top: 1px solid var(--border-soft); }
.sidebar-foot label { font-size: 12px; color: var(--muted); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* Topbar */
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 16px 28px;
  border-bottom: 1px solid var(--border); background: rgba(19,28,46,.6);
  backdrop-filter: blur(6px); position: sticky; top: 0; z-index: 10; flex-wrap: wrap;
}
.topbar h1 { font-size: 18px; margin: 0; font-weight: 700; }
.topbar .sub { color: var(--muted); font-size: 13px; }
.spacer { flex: 1; }
.content { padding: 26px 32px; max-width: 1460px; width: 100%; margin: 0 auto; }

/* Views (router) */
.view { display: none; }
.view.active { display: block; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* Cards & panels */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 18px; margin-bottom: 24px; }
.stat {
  background: linear-gradient(180deg, var(--surface), #111a2b);
  border: 1px solid var(--border); border-radius: 14px; padding: 18px 20px;
  display: flex; align-items: center; gap: 16px; position: relative; overflow: hidden;
}
.stat::after {
  content: ""; position: absolute; right: -20px; top: -20px; width: 90px; height: 90px;
  border-radius: 50%; background: radial-gradient(circle, rgba(79,140,255,.10), transparent 70%);
}
.stat-ic {
  width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center;
  font-size: 22px; flex-shrink: 0;
}
.stat .label { color: var(--muted); font-size: 12.5px; }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 3px; line-height: 1.1; }
.stat .value.sm { font-size: 21px; }
.stat .value .cur { font-size: 14px; color: var(--muted); font-weight: 600; margin-left: 4px; }

.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  margin-bottom: 20px; overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; gap: 12px; padding: 14px 18px;
  border-bottom: 1px solid var(--border-soft);
}
.panel-head h3 { margin: 0; font-size: 14px; font-weight: 600; }
.panel-head .muted { color: var(--muted); font-size: 13px; }
.panel-body { padding: 16px 18px; }
.panel.pad { padding: 16px 18px; }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 14px; text-align: left; font-size: 14px; border-bottom: 1px solid var(--border-soft); }
th { color: var(--muted); font-weight: 600; font-size: 12.5px; text-transform: none; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,.02); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { color: var(--muted); text-align: center; padding: 28px 12px; }

/* Controls */
input, select, textarea, button {
  font: inherit; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 9px; padding: 9px 12px;
}
input::placeholder, textarea::placeholder { color: #61728f; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); }
/* Chống autofill trình duyệt đổi nền trắng */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0 1000px var(--surface-2) inset;
  caret-color: var(--text);
  transition: background-color 9999s ease-in-out 0s;
}
label.inline { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 13px; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--primary); }

.btn { cursor: pointer; background: var(--primary); color: #fff; border: none; font-weight: 600; border-radius: 9px; padding: 9px 14px; }
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid #5b2626; }
.btn.fb { background: var(--fb); color: #fff; }
.btn.sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }

/* Pills / badges */
.pill { padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill.g { background: rgba(79,140,255,.18); color: #9dc0ff; }
.pill.f { background: rgba(56,189,248,.16); color: #7dd3fc; }
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.ok { color: var(--success); } .err { color: var(--danger); font-weight: 600; }
.warn { color: var(--warn); } .muted { color: var(--muted); } .off { color: #5e6f8c; }
.up { color: var(--danger); } .down { color: var(--success); } .flat { color: var(--muted); }

.alert { background: rgba(248,113,113,.10); border: 1px solid rgba(248,113,113,.35); color: #fecaca;
  padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; }
.hint { font-size: 12.5px; color: var(--muted); }

/* Toolbar row */
.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 16px; }

/* Chart */
#chart svg { display: block; }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(3,7,18,.6); display: none;
  align-items: center; justify-content: center; z-index: 100; backdrop-filter: blur(2px); }
.modal-bg.show { display: flex; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 22px; width: 460px; max-width: 94vw; box-shadow: var(--shadow); }
.modal.wide { width: 580px; }
.modal h3 { margin: 0 0 16px; font-size: 17px; }
.field { margin-bottom: 14px; }
.field > label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input, .field select, .field textarea { width: 100%; }
.row { display: flex; gap: 16px; }
.row-btns { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* Toast */
.toast { position: fixed; right: 22px; bottom: 22px; background: var(--surface-2);
  border: 1px solid var(--border); padding: 12px 18px; border-radius: 10px; z-index: 200;
  box-shadow: var(--shadow); transform: translateY(20px); opacity: 0; transition: .2s; pointer-events: none; }
.toast.show { transform: none; opacity: 1; }

@media (max-width: 760px) {
  .sidebar { width: 64px; }
  .brand span, .nav-item .txt, .sidebar-foot { display: none; }
  .content { padding: 16px; }
}
