/* Giao diện sáng — tông xanh công nghệ (blue → cyan), nhẹ mắt */
:root {
  --bg: #f3f7fc; --panel: #ffffff; --ink: #1e293b; --muted: #64748b; --line: #e2e8f0; --line-strong: #cbd5e1;
  --accent: #2563eb; --accent-2: #06b6d4; --accent-soft: #eff6ff; --accent-ink: #1d4ed8;
  --grad: linear-gradient(135deg, #2563eb 0%, #06b6d4 100%);
  --ok: #059669; --ok-soft: #ecfdf5; --warn: #d97706; --warn-soft: #fffbeb; --danger: #dc2626; --danger-soft: #fef2f2;
  --side: #ffffff; --side-ink: #334155; --side-muted: #94a3b8; --side-hover: #f1f5f9;
  --radius: 12px; --shadow: 0 1px 2px rgba(15,23,42,.04), 0 2px 8px rgba(37,99,235,.05);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; color: var(--ink); background: var(--bg); }
.app { display: flex; min-height: 100vh; }
.booting .app { visibility: hidden; }  /* ẩn khung trống cho tới khi biết đã đăng nhập hay chưa */

/* ---- thanh bên ---- */
.sidebar { width: 250px; background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; flex-shrink: 0; border-right: 1px solid var(--line); }
.brand { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; padding: 16px 18px 14px; border-bottom: 1px solid var(--line); }
.brand-logo { width: 100%; max-width: 168px; height: auto; display: block; }
.brand small { color: var(--muted); font-size: 11.5px; letter-spacing: .02em; }
.dialog .dialog-logo { width: 100%; max-width: 230px; height: auto; display: block; margin: 0 auto 18px; }
nav { flex: 1; overflow-y: auto; padding: 8px 10px; }
nav .group { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--side-muted); padding: 14px 10px 4px; }
nav a { display: flex; justify-content: space-between; align-items: center; padding: 7px 10px; margin: 1px 0; color: var(--side-ink); text-decoration: none; border-radius: 8px; cursor: pointer; transition: background .12s, color .12s; }
nav a:hover { background: var(--side-hover); color: var(--accent-ink); }
nav a.active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); }
nav a .cnt { font-size: 11px; background: #eef2f7; color: var(--muted); padding: 1px 7px; border-radius: 10px; font-weight: 500; }
nav a.active .cnt { background: #dbeafe; color: var(--accent-ink); }
.side-foot { padding: 12px 14px; border-top: 1px solid var(--line); background: #fafcff; } .side-foot small { display: block; margin-top: 8px; color: var(--side-muted); }
.sidebar .btn { background: var(--panel); color: var(--accent-ink); border-color: #bfdbfe; }
.sidebar .btn:hover { background: var(--accent-soft); }
.sidebar .range { display: grid; gap: 6px; margin-bottom: 10px; }
.sidebar .range label { font-size: 11px; color: var(--muted); display: grid; gap: 2px; }
.sidebar .range input, .sidebar .range select { padding: 4px 6px; font-size: 12px; }
.sidebar .range .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.range-on { color: var(--accent-ink) !important; font-weight: 600; }
.user-box { font-size: 12px; color: var(--side-ink); margin-bottom: 10px; display: grid; gap: 6px; }
.user-box b { color: var(--ink); } .user-box .links { display: flex; gap: 12px; }
.user-box a { color: var(--accent); cursor: pointer; text-decoration: none; } .user-box a:hover { text-decoration: underline; }

/* ---- vùng chính ---- */
main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 14px 24px; background: rgba(255,255,255,.9); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar h1 { font-size: 19px; margin: 0; flex: 1; font-weight: 650; }
.topbar h1::before { content: ""; display: inline-block; width: 4px; height: 18px; border-radius: 2px; background: var(--grad); margin-right: 10px; vertical-align: -2px; }
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.icon-btn { display: none; background: none; border: 1px solid var(--line); border-radius: 8px; padding: 4px 10px; font-size: 18px; cursor: pointer; color: var(--ink); }
.view { padding: 20px 24px 40px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; margin-bottom: 16px; }
.card h3 { margin: 0 0 4px; font-size: 15px; } .card .sub { color: var(--muted); margin: 0 0 12px; font-size: 13px; }
.grid { display: grid; gap: 16px; } .g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { position: relative; overflow: hidden; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px 14px 18px; box-shadow: var(--shadow); }
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--grad); }
a.kpi:hover { border-color: #bfdbfe; background: #fbfdff; }
.kpi span { color: var(--muted); font-size: 12px; } .kpi b { display: block; font-size: 22px; margin-top: 4px; font-variant-numeric: tabular-nums; color: #0f172a; }

/* ---- nút, ô nhập ---- */
.btn { background: var(--panel); border: 1px solid var(--line-strong); color: var(--ink); padding: 7px 12px; border-radius: 8px; cursor: pointer; font: inherit; white-space: nowrap; transition: background .12s, border-color .12s; }
.btn:hover { border-color: #93c5fd; background: #f8fbff; }
.btn.primary { background: var(--grad); color: #fff; border-color: transparent; box-shadow: 0 2px 6px rgba(37,99,235,.25); }
.btn.primary:hover { filter: brightness(1.05); background: var(--grad); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.block { width: 100%; } .btn.danger { color: var(--danger); } .btn.danger:hover { border-color: #fca5a5; background: var(--danger-soft); } .btn.small { padding: 4px 9px; font-size: 12px; }
select, input[type=text], input[type=password], input[type=date], input[type=number], input[type=search], textarea { font: inherit; border: 1px solid var(--line-strong); border-radius: 8px; padding: 6px 9px; background: #fff; color: var(--ink); }
select:focus, input:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
textarea { width: 100%; min-height: 140px; font-family: Consolas, monospace; font-size: 12px; }
label.inline { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.toolbar .spacer { flex: 1; }

/* ---- bảng ---- */
.tbl-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 10px; max-height: 70vh; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 7px 10px; border-bottom: 1px solid #edf1f6; text-align: left; white-space: nowrap; }
thead { position: sticky; top: 0; z-index: 2; }
th { background: #f5f8fc; color: #334155; font-weight: 600; cursor: pointer; user-select: none; }
th:hover { color: var(--accent-ink); }
.filter-row th { padding: 4px 6px; cursor: default; background: #f8fafd; }
.filter-row input { width: 100%; min-width: 70px; padding: 3px 6px; font-size: 12px; font-weight: 400; }
th.todo, td.todo { background: #f0f9ff; } th.todo { background: #e0f2fe; color: #0369a1; cursor: default; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:hover td { background: #f6f9fe; } tr:hover td.todo { background: #e6f4fd; }
td.todo [contenteditable] { min-width: 120px; outline: none; display: block; white-space: pre-wrap; }
td.todo [contenteditable]:focus { box-shadow: 0 0 0 2px rgba(6,182,212,.35); border-radius: 4px; background: #fff; }
td.todo [contenteditable]:empty::before { content: "…"; color: #b6c2d2; }
td.zero { color: #c0cad8; }
.pager { display: flex; gap: 8px; align-items: center; margin-top: 8px; color: var(--muted); font-size: 12px; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; background: #eef2f7; color: var(--muted); }
.pill.ok { background: var(--ok-soft); color: var(--ok); } .pill.warn { background: var(--warn-soft); color: var(--warn); } .pill.bad { background: var(--danger-soft); color: var(--danger); }
.drop { border: 2px dashed #bfd4f2; border-radius: var(--radius); padding: 22px; text-align: center; color: var(--muted); cursor: pointer; background: #f8fbff; transition: .12s; }
.drop:hover, .drop.over { border-color: var(--accent-2); background: #ecfeff; color: #0e7490; }
.muted { color: var(--muted); } .note { font-size: 12px; color: var(--muted); }
.chart-box { position: relative; height: 280px; }
.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty b { display: block; font-size: 16px; color: var(--ink); margin-bottom: 6px; }
.toast { position: fixed; bottom: 20px; right: 20px; background: #0f172a; color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: 0 8px 24px rgba(15,23,42,.18); opacity: 0; transform: translateY(10px); transition: .2s; pointer-events: none; z-index: 50; }
.toast.show { opacity: 1; transform: none; }
.guide ol { padding-left: 20px; } .guide li { margin-bottom: 6px; }
.settings-table td input { width: 100%; min-width: 80px; }
.bar { height: 6px; border-radius: 3px; background: #e8eef6; overflow: hidden; min-width: 60px; }
.bar i { display: block; height: 100%; background: var(--grad); }
a { color: var(--accent); }
code { background: #eef4fb; color: #1e40af; padding: 1px 5px; border-radius: 4px; font-size: 12px; }

/* ---- đăng nhập, hộp thoại ---- */
.overlay { position: fixed; inset: 0; z-index: 40; background: rgba(15,23,42,.35); backdrop-filter: blur(2px); display: grid; place-items: center; padding: 16px; }
.overlay[hidden] { display: none; }
.overlay.solid { background: radial-gradient(circle at 15% 20%, #dbeafe 0, transparent 45%), radial-gradient(circle at 85% 80%, #cffafe 0, transparent 45%), #f3f7fc; backdrop-filter: none; }
.dialog { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 20px 50px rgba(37,99,235,.12); padding: 26px; width: 100%; max-width: 380px; }
.dialog h2 { margin: 0 0 4px; font-size: 20px; }
.dialog .sub { color: var(--muted); margin: 0 0 16px; font-size: 13px; }
.dialog label { display: grid; gap: 4px; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
.dialog input[type=text], .dialog input[type=password] { width: 100%; padding: 9px 11px; }
.dialog .err { color: var(--danger); font-size: 13px; min-height: 18px; margin: 0 0 8px; }
.dialog .row { display: flex; gap: 8px; justify-content: flex-end; align-items: center; }
.err { color: var(--danger); }
.secret { font-family: Consolas, monospace; font-size: 16px; background: #ecfeff; border: 1px dashed var(--accent-2); color: #0e7490; padding: 8px 12px; border-radius: 8px; display: inline-block; user-select: all; }

@media (max-width: 900px) {
  .sidebar { position: fixed; left: -260px; z-index: 20; transition: left .2s; box-shadow: 0 10px 30px rgba(15,23,42,.15); }
  .sidebar.open { left: 0; }
  .icon-btn { display: inline-block; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .view { padding: 16px; }
  .topbar { padding: 12px 16px; flex-wrap: wrap; }
}
