/* ============================================================
   NAC Dashboard — modern dark SaaS theme
   Sidebar shell · gradient accents · cards · responsive
   ============================================================ */
:root {
  --bg: #0a0e18;
  --bg-soft: #0e1422;
  --panel: #121929;
  --card: #172036;
  --line: #232f49;
  --line-soft: #1b2540;
  --text: #e9eef8;
  --muted: #8fa0bd;
  --accent: #7d9aff;
  --accent-2: #4f6ef7;
  --accent-soft: rgba(102, 129, 255, 0.15);
  --ok: #34d399;
  --warn: #fbbf24;
  --err: #f87171;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 12px 32px rgba(2, 6, 16, 0.45);
  --sidebar-w: 236px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background:
    radial-gradient(1100px 500px at 85% -10%, rgba(79, 110, 247, 0.16), transparent 60%),
    radial-gradient(900px 420px at -10% 110%, rgba(52, 211, 153, 0.07), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", "Myanmar Text", "Padauk", system-ui, sans-serif;
  font-size: 14.5px;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }

/* ================= Modal ================= */
.modal-overlay {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(4, 7, 14, 0.72); backdrop-filter: blur(4px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 6vh 16px; overflow-y: auto;
}
.modal {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px 20px; width: min(880px, 100%);
}
.modal .codes { max-height: 180px; overflow-y: auto; }
.act-cell { white-space: nowrap; }
.act-cell .btn + .btn { margin-left: 6px; }
.muted { color: var(--muted); }
.error { color: var(--err); font-size: 13.5px; }
.msg { color: var(--ok); font-size: 13.5px; font-weight: 600; }
::selection { background: rgba(102, 129, 255, 0.35); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #26314d; border-radius: 8px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

/* ================= Shell layout ================= */
.app { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 40;
  display: flex; flex-direction: column; gap: 18px;
  background: linear-gradient(180deg, #101828 0%, #0d1322 100%);
  border-right: 1px solid var(--line-soft);
  padding: 20px 14px;
}
.side-brand { display: flex; align-items: center; gap: 11px; padding: 2px 8px 14px; }
.side-brand .logo {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; font-size: 18px;
  background: linear-gradient(135deg, var(--accent-2), #7c5df0);
  box-shadow: 0 6px 18px rgba(79, 110, 247, 0.4);
}
.side-brand b { display: block; font-size: 16px; letter-spacing: 0.3px; }
.side-brand span { display: block; font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.side-nav { display: flex; flex-direction: column; gap: 4px; }
.tab {
  display: flex; align-items: center; gap: 10px;
  background: transparent; border: 1px solid transparent; color: var(--muted);
  padding: 10px 12px; border-radius: var(--radius-sm); cursor: pointer;
  font-size: 14px; font-weight: 600; font-family: inherit; text-align: left;
  transition: background .15s, color .15s, border-color .15s;
}
.tab:hover { background: var(--card); color: var(--text); }
.tab.active { background: var(--accent-soft); color: var(--accent); border-color: rgba(127, 154, 255, 0.28); }
.nav-ic { font-size: 16px; width: 22px; text-align: center; flex: 0 0 22px; }
.side-foot { margin-top: auto; padding: 10px 8px 2px; font-size: 11.5px; line-height: 1.5; }

.topbar, .app-main, .login-wrap { margin-left: var(--sidebar-w); }

.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 14px 26px; position: sticky; top: 0; z-index: 30;
  background: rgba(10, 14, 24, 0.82); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line-soft);
}
.page-title { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: 0.2px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.user-email { color: var(--muted); font-size: 13px; }

.app-main { max-width: 1060px; padding: 24px 26px 48px; }

/* ================= Buttons ================= */
.btn {
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  padding: 9px 16px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 600;
  cursor: pointer; transition: border-color .15s, background .15s, transform .05s, box-shadow .15s;
}
.btn:hover { border-color: #3a4c74; background: #1c2742; }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: linear-gradient(135deg, var(--accent-2), #6a5cf0);
  border-color: transparent; color: #fff;
  box-shadow: 0 6px 18px rgba(79, 110, 247, 0.32);
}
.btn.primary:hover { filter: brightness(1.1); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--card); color: var(--text); border-color: var(--line); }
.btn.danger { background: rgba(248, 113, 113, 0.1); border-color: rgba(248, 113, 113, 0.45); color: var(--err); }
.btn.danger:hover { background: var(--err); border-color: var(--err); color: #fff; }
.btn.sm { padding: 5px 12px; font-size: 12.5px; border-radius: 8px; }
.btn.block { width: 100%; margin-top: 18px; padding: 11px; font-size: 15px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ================= Inputs ================= */
input, select {
  width: 100%; padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: #0d1526; color: var(--text); font-size: 14px;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus { outline: none; border-color: var(--accent-2); box-shadow: 0 0 0 3px var(--accent-soft); }
input::placeholder { color: #5a6a8a; }

/* ================= Login ================= */
.login-wrap { display: flex; justify-content: center; padding: 10vh 20px 40px; }
.login-card { width: 380px; padding: 30px 28px; border-radius: 20px; box-shadow: var(--shadow); }
.login-logo {
  width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; font-size: 24px;
  background: linear-gradient(135deg, var(--accent-2), #7c5df0); margin-bottom: 16px;
  box-shadow: 0 8px 22px rgba(79, 110, 247, 0.4);
}
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-card label, .form-grid label {
  display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin: 14px 0 5px;
  letter-spacing: 0.2px;
}

/* ================= Cards / panels ================= */
.card {
  background: linear-gradient(180deg, rgba(255,255,255,0.015), transparent 40%), var(--panel);
  border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 22px;
  box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 6px; font-size: 16.5px; }
.form-grid { display: grid; grid-template-columns: 200px 1fr; gap: 2px 16px; align-items: center; }
.price-row { display: flex; gap: 8px; }
.panel h2 { font-size: 16.5px; margin: 24px 0 12px; }
.result-head { display: flex; justify-content: space-between; align-items: center; margin-top: 22px; flex-wrap: wrap; gap: 10px; }

/* ================= Stat cards ================= */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); gap: 14px; }
.stat {
  display: flex; align-items: center; gap: 14px;
  background: linear-gradient(180deg, rgba(255,255,255,0.02), transparent 45%), var(--panel);
  border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 16px 18px;
  box-shadow: var(--shadow);
}
.stat-ic {
  width: 42px; height: 42px; flex: 0 0 42px; border-radius: 12px; display: grid; place-items: center;
  font-size: 18px; background: var(--accent-soft); color: var(--accent);
}
.stat .num { font-size: 26px; font-weight: 800; line-height: 1.1; letter-spacing: 0.3px; }
.stat .lbl { font-size: 12px; color: var(--muted); margin-top: 3px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* ================= Tables ================= */
.tbl {
  width: 100%; border-collapse: separate; border-spacing: 0;
  background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow);
}
.tbl th, .tbl td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line-soft); font-size: 13.5px; }
.tbl th { color: var(--muted); font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: 0.7px; background: rgba(255,255,255,0.015); }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr { transition: background .12s; }
.tbl tbody tr:hover { background: rgba(102, 129, 255, 0.05); }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 700; letter-spacing: 0.2px; }
.badge.ok { background: rgba(52, 211, 153, 0.14); color: var(--ok); }
.badge.warn { background: rgba(251, 191, 36, 0.13); color: var(--warn); }

.codes {
  background: #0c1322; border: 1px solid var(--line-soft); border-radius: var(--radius);
  padding: 16px 18px; font-family: Consolas, Menlo, monospace; font-size: 15px; letter-spacing: 1.5px;
  white-space: pre-wrap; line-height: 1.9; color: #cfe0ff; box-shadow: var(--shadow);
}
.gw-name { margin: 20px 0 10px; font-size: 15px; }
.gw-name .badge { margin-left: 6px; }
.mono { font-family: Consolas, Menlo, monospace; font-size: 13px; }

/* ===== Security tab ===== */
.checklist { margin: 10px 0 0; padding-left: 20px; line-height: 1.9; font-size: 14px; }
.checklist li::marker { color: var(--accent); font-weight: 800; }
.checklist b { color: var(--accent); }

/* ===== Owner page extras ===== */
.result { margin-top: 14px; background: #16324a; }
.result pre { margin: 6px 0 0; padding: 10px; background: #0b1622; border-radius: 8px; overflow-x: auto; }
select[multiple] { min-width: 180px; background: var(--card); }

/* ================= Print sheet (WiFi cards) ================= */
.print-sheet { display: none; }
@media print {
  body * { visibility: hidden; }
  .print-sheet, .print-sheet * { visibility: visible; }
  .print-sheet { display: block !important; position: absolute; inset: 0; background: #fff; }
}
@media screen {
  .print-sheet:not(.hidden) {
    display: block; position: fixed; inset: 0; background: #fff; z-index: 100;
    overflow: auto; padding: 20px; color: #111;
  }
  .print-sheet:not(.hidden)::before {
    content: "✕"; position: fixed; top: 8px; right: 14px; font-size: 22px; cursor: pointer; color: #666;
  }
}
.print-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media print { .print-grid { grid-template-columns: repeat(2, 1fr); gap: 6mm; } }

/* --- sheet header / footer (screen + print) --- */
.ps-head { margin-bottom: 14px; border-bottom: 2px solid #222; padding-bottom: 10px; }
.ps-title { display: flex; justify-content: space-between; align-items: baseline; font-size: 20px; font-weight: 800; }
.ps-title .ps-count { font-size: 13px; font-weight: 600; color: #555; }
.ps-sub { margin-top: 4px; font-size: 13px; color: #444; }
.ps-foot { margin-top: 16px; padding-top: 8px; border-top: 1px solid #999; font-size: 11px; color: #666; text-align: center; }

.wifi-card {
  position: relative; border: 1.5px solid #2b3b5e; border-radius: 14px; background: #fff;
  break-inside: avoid; overflow: hidden; font-family: "Segoe UI", "Myanmar Text", sans-serif;
  padding: 12px 16px 10px; color: #101828;
}
.wc-bar { position: absolute; inset: 0 0 auto 0; height: 6px; background: linear-gradient(90deg, #2f80ed, #7c5df0); }
.wc-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-top: 4px; }
.wc-ssid { font-size: 15px; font-weight: 800; }
.wc-shop { font-size: 10.5px; color: #667; text-align: right; }
.wc-label { margin-top: 8px; font-size: 9.5px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; color: #8892a6; }
.wc-pin { font-size: 30px; font-weight: 800; letter-spacing: 6px; line-height: 1.25; color: #101828; }
.wc-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 6px; }
.wc-plan { font-size: 11.5px; font-weight: 700; color: #2f80ed; }
.wc-chip { font-size: 10px; font-weight: 600; color: #33415c; background: #eef2f9; border: 1px solid #dde4f0; border-radius: 999px; padding: 2px 8px; }
.wc-steps { margin-top: 8px; padding-top: 6px; border-top: 1px dashed #ccd4e4; font-size: 9.5px; color: #8892a6; }
@media print {
  .wifi-card { border-color: #99a; }
  .wc-bar { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ================= Responsive (narrow screens: sidebar → bottom bar) ================= */
@media (max-width: 640px) {
  .sidebar {
    top: auto; bottom: 0; left: 0; right: 0; width: auto; flex-direction: row; align-items: center;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px)); border-right: 0;
    border-top: 1px solid var(--line-soft); background: rgba(13, 19, 34, 0.96); backdrop-filter: blur(10px);
  }
  .side-brand, .side-foot { display: none; }
  .side-nav { flex-direction: row; width: 100%; gap: 2px; overflow-x: auto; }
  .side-nav .tab { flex: 1 0 auto; flex-direction: column; gap: 3px; padding: 7px 6px; font-size: 10.5px; border-radius: 10px; }
  .nav-ic { font-size: 17px; }
  .topbar, .app-main, .login-wrap { margin-left: 0; }
  .app-main { padding: 16px 14px 92px; }
  .topbar { padding: 12px 14px; }
  .login-wrap { padding-top: 6vh; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid label { margin: 12px 0 2px; }
  .user-email { display: none; }
  .page-title { font-size: 16.5px; }
}
