@font-face { font-family: "Chakra Petch"; src: url("../assets/fonts/chakra-petch-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Chakra Petch"; src: url("../assets/fonts/chakra-petch-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Chakra Petch"; src: url("../assets/fonts/chakra-petch-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Figtree"; src: url("../assets/fonts/figtree-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Figtree"; src: url("../assets/fonts/figtree-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Figtree"; src: url("../assets/fonts/figtree-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Figtree"; src: url("../assets/fonts/figtree-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root, [data-theme="dark"] {
  --bg: #0D1E34;
  --side: #0B1A2E;          /* logo background */
  --panel: #10243C;
  --panel-2: #152C48;
  --line: #1E3858;
  --steel: #2A6A8F;
  --text: #D5E3F0;
  --strong: #EEF5FB;
  --muted: #8199B3;
  --accent: #11ACEA;
  --accent-2: #13B5B1;
  --on-accent: #04121F;
  --danger: #F0647A;
  --danger-soft: rgba(240,100,122,.12);
  --danger-text: #FFC2CB;
  --safe: #13B5B1;
  --warn: #F2B35B;
  --hover: rgba(21,44,72,.6);
  --sel: rgba(17,172,234,.08);
  --shadow: 0 14px 34px rgba(2,8,18,.55);
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #F3F7FB;
  --side: #FFFFFF;
  --panel: #FFFFFF;
  --panel-2: #EAF2F9;
  --line: #D9E4EE;
  --steel: #8FB2CC;
  --text: #22364D;
  --strong: #0B1A2E;
  --muted: #5F7690;
  --accent: #0A93CC;
  --accent-2: #0E9C98;
  --on-accent: #FFFFFF;
  --danger: #D23A55;
  --danger-soft: rgba(210,58,85,.08);
  --danger-text: #B3233F;
  --safe: #0E8C88;
  --warn: #C98410;
  --hover: #F2F7FB;
  --sel: rgba(10,147,204,.07);
  --shadow: 0 14px 34px rgba(11,26,46,.14);
  color-scheme: light;
}
:root {
  --grad: linear-gradient(90deg, var(--accent), var(--accent-2));
  --display: "Chakra Petch", "Segoe UI", system-ui, sans-serif;
  --body: "Figtree", "Segoe UI", system-ui, sans-serif;
  --r: 8px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 var(--body); -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.muted { color: var(--muted); }
code { font-family: ui-monospace, Consolas, monospace; font-size: .9em; background: var(--panel-2); padding: 1px 6px; border-radius: 4px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 16px; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); color: var(--text); font-weight: 600; font-size: 14px; white-space: nowrap; }
.btn:hover { border-color: var(--steel); color: var(--strong); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-block { width: 100%; height: 44px; }
.btn-primary { background: var(--grad); border-color: transparent; color: var(--on-accent); }
.btn-primary:hover { color: var(--on-accent); filter: brightness(1.07); border-color: transparent; }
.btn-ghost { background: transparent; }
.btn-danger { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 45%, transparent); color: var(--danger-text); }
.btn-danger:hover { border-color: var(--danger); color: var(--danger-text); }
.link-btn { background: none; border: 0; padding: 0; color: var(--muted); font-size: 13px; }
.link-btn:hover { color: var(--strong); text-decoration: underline; }
.theme-btn { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); display: grid; place-items: center; color: var(--muted); }
.theme-btn:hover { color: var(--strong); border-color: var(--steel); }
.theme-btn.floating { position: fixed; top: 18px; right: 18px; }

/* Auth */
.center-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(420px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; box-shadow: var(--shadow); }
.auth-logo { background: #0B1A2E; border-radius: 10px; padding: 6px 14px; }
[data-theme="light"] .auth-logo { background: transparent; padding: 0 8px; }
/* Each theme gets its own logo: navy badge in dark mode, clean on white in light mode */
.logo-light { display: none !important; }
[data-theme="light"] .logo-dark { display: none !important; }
[data-theme="light"] .logo-light { display: block !important; }
.auth-logo img { width: 100%; display: block; }
.auth-product { font: 600 16px/1 var(--display); color: var(--strong); text-align: center; margin: 14px 0 20px; letter-spacing: .03em; }
.auth-card h1 { font: 700 24px/1.2 var(--display); color: var(--strong); margin: 18px 0 8px; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--panel-2); border-radius: var(--r); padding: 4px; margin-bottom: 18px; }
.tabs button { height: 36px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-weight: 600; }
.tabs button[aria-selected="true"] { background: var(--panel); color: var(--strong); box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; font-size: 13.5px; color: var(--muted); font-weight: 500; }
.field input, .input, select.input { height: 42px; padding: 0 12px; background: var(--bg); border: 1px solid var(--line); border-radius: var(--r); color: var(--strong); font-size: 15px; outline: 0; }
.field input:focus, .input:focus { border-color: var(--accent); }
.form-msg { font-size: 14px; padding: 10px 12px; border-radius: var(--r); background: var(--danger-soft); color: var(--danger-text); margin: 0 0 14px; }
.form-msg.ok { background: color-mix(in srgb, var(--safe) 14%, transparent); color: var(--safe); }
#forgotBtn { display: block; margin: 14px auto 0; }
.auth-foot { font-size: 13px; text-align: center; margin: 18px 0 0; }

/* Layout */
.app { display: grid; grid-template-columns: 252px 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: var(--side); border-right: 1px solid var(--line); padding: 16px 14px; }
.brand { padding: 0 0 14px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.brand-logo { width: 100%; display: block; border-radius: 8px; background: #0B1A2E; }
[data-theme="light"] .brand-logo { background: transparent; border-radius: 0; }
.brand-name { font: 600 14px/1 var(--display); color: var(--strong); text-align: center; margin-top: 10px; letter-spacing: .04em; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item { position: relative; display: flex; align-items: center; gap: 11px; padding: 10px 12px; border: 0; border-radius: var(--r); background: transparent; color: var(--muted); text-align: left; }
.nav-item span { flex: 1; }
.nav-item b { font: 600 12px/1 var(--display); }
.nav-item:hover { color: var(--strong); background: var(--hover); }
.nav-item.is-active { color: var(--strong); background: var(--panel-2); }
.nav-item.is-active::before { content: ""; position: absolute; left: -14px; top: 9px; bottom: 9px; width: 3px; background: var(--grad); border-radius: 0 3px 3px 0; }
.side-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 14px; display: flex; flex-direction: column; gap: 12px; }
.who-name { color: var(--strong); font-weight: 600; font-size: 14px; }
.who-mail { color: var(--muted); font-size: 12.5px; word-break: break-all; }
.plan { display: inline-block; margin-top: 6px; font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 20px; border: 1px solid var(--line); color: var(--muted); }
.plan.unlimited { color: var(--safe); border-color: color-mix(in srgb, var(--safe) 50%, transparent); }
.plan.trial { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 50%, transparent); }
.gmail-box { font-size: 12.5px; color: var(--muted); }
.gmail-box b { display: block; color: var(--text); font-weight: 600; word-break: break-all; }
.side-links { display: flex; align-items: center; gap: 14px; }

.main { min-width: 0; padding: 26px 32px 130px; max-width: 1280px; }
.top { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.top h1 { font: 700 30px/1.1 var(--display); color: var(--strong); margin: 0; }
.top p { margin: 6px 0 0; font-size: 14px; }
.top-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.note { font-size: 13px; color: var(--muted); max-width: 320px; text-align: right; }

/* Scan */
.scan { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 22px 24px 16px; margin-bottom: 18px; }
.trace { position: relative; display: grid; grid-template-columns: repeat(3, 1fr); }
.trace-line { position: absolute; left: 7px; right: 7px; top: 7px; height: 2px; background: var(--line); }
.trace-line i { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--grad); transition: width .4s ease; }
.node { display: flex; flex-direction: column; gap: 10px; }
.node:nth-child(3) { align-items: center; }
.node:nth-child(4) { align-items: flex-end; }
.node-dot { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--steel); background: var(--panel); position: relative; z-index: 1; }
.node.on .node-dot { border-color: var(--accent); }
.node.now .node-dot { background: var(--accent); box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 20%, transparent); }
.node.done .node-dot { background: var(--accent-2); border-color: var(--accent-2); }
.node-label { font: 600 13px/1 var(--display); color: var(--muted); }
.node.on .node-label { color: var(--strong); }
.scan-row #scanStatus { flex: 1; min-width: 0; }
.scan-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 16px; font-size: 14px; font-variant-numeric: tabular-nums; }

/* Banners and states */
.banner { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 18px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); margin-bottom: 18px; }
.banner.warn { border-color: color-mix(in srgb, var(--warn) 45%, transparent); background: color-mix(in srgb, var(--warn) 8%, var(--panel)); }
.banner p { margin: 0; }
.state { max-width: 640px; padding: 30px 0; }
.state h2 { font: 700 26px/1.2 var(--display); color: var(--strong); margin: 0 0 10px; }
.state p { color: var(--muted); margin: 0 0 18px; }
.empty { padding: 40px 10px; text-align: center; color: var(--muted); }

/* Summary */
.summary { display: flex; flex-wrap: wrap; gap: 8px 28px; padding-bottom: 16px; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.summary div { display: flex; align-items: baseline; gap: 7px; }
.summary b { font: 700 22px/1 var(--display); color: var(--strong); font-variant-numeric: tabular-nums; }
.summary span { color: var(--muted); font-size: 13.5px; }
.summary .safe b { color: var(--safe); }

/* Filters */
.filters { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 14px; display: flex; flex-direction: column; gap: 12px; }
.f-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.seg { display: inline-flex; background: var(--panel-2); border-radius: var(--r); padding: 3px; }
.seg button { height: 32px; padding: 0 14px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-weight: 600; font-size: 13.5px; }
.seg button[aria-pressed="true"] { background: var(--panel); color: var(--strong); box-shadow: 0 1px 3px rgba(0,0,0,.18); }
.search { flex: 1 1 260px; display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--bg); color: var(--muted); }
.search:focus-within { border-color: var(--accent); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--strong); }
.f-select { height: 34px; padding: 0 10px; border: 1px solid var(--line); border-radius: var(--r); background: var(--bg); color: var(--strong); font-size: 13.5px; }
.f-select.set { border-color: var(--accent); }
.chip { height: 32px; padding: 0 12px; border-radius: 16px; border: 1px solid var(--line); background: transparent; color: var(--muted); font-size: 13px; font-weight: 500; }
.chip:hover { color: var(--strong); border-color: var(--steel); }
.chip[aria-pressed="true"] { color: var(--strong); border-color: var(--accent); background: var(--sel); }
.f-label { font-size: 12.5px; color: var(--muted); font-weight: 600; margin-right: 2px; }
.f-match { margin-left: auto; font-size: 13px; color: var(--muted); }

/* Group list */
.list-head, .row { display: grid; grid-template-columns: 30px minmax(0, 1fr) 150px 76px 424px; gap: 14px; align-items: center; }
.list-head { padding: 6px 14px; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.chk { display: flex; justify-content: center; }
.chk input { width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; }
.group { border-top: 1px solid var(--line); }
.group:last-of-type { border-bottom: 1px solid var(--line); }
.group:hover { background: var(--hover); }
.group.sel { background: var(--sel); }
.row { padding: 11px 14px; }
.who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.avatar { width: 36px; height: 36px; flex: none; display: grid; place-items: center; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--line); font: 700 15px/1 var(--display); color: var(--strong); }
.who-t { min-width: 0; }
.nm { color: var(--strong); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ad { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tag { display: inline-block; margin-left: 6px; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 4px; border: 1px solid var(--line); color: var(--muted); vertical-align: 1px; }
.tag.safe { color: var(--safe); border-color: color-mix(in srgb, var(--safe) 45%, transparent); }
.tag.done { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.vol b { font: 600 15px/1 var(--display); color: var(--strong); }
.vol small { color: var(--muted); font-size: 12px; margin-left: 4px; }
.bar { height: 4px; margin-top: 7px; border-radius: 2px; background: var(--line); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--grad); }
.last { color: var(--muted); font-size: 13px; }
.acts { display: flex; gap: 6px; position: relative; }
.act { height: 32px; padding: 0 10px; display: inline-flex; align-items: center; gap: 6px; border-radius: var(--r); border: 1px solid var(--line); background: transparent; color: var(--text); font-size: 13px; font-weight: 600; }
.act:hover { border-color: var(--steel); color: var(--strong); background: var(--panel); }
.act:disabled { opacity: .35; cursor: not-allowed; background: transparent; }
.act.danger:hover { border-color: var(--danger); color: var(--danger-text); background: var(--danger-soft); }
.act.icon { width: 32px; padding: 0; justify-content: center; }
.act.icon.on { color: var(--safe); border-color: color-mix(in srgb, var(--safe) 50%, transparent); }
.act svg { width: 16px; height: 16px; }
.group.open .exp svg { transform: rotate(180deg); }
.menu { position: absolute; right: 0; top: 38px; z-index: 20; min-width: 190px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 6px; display: flex; flex-direction: column; }
.menu button, .menu a { text-align: left; padding: 8px 10px; border: 0; background: none; border-radius: 6px; font-size: 13.5px; color: var(--text); text-decoration: none; }
.menu button:hover, .menu a:hover { background: var(--panel-2); color: var(--strong); }
.detail { padding: 0 14px 16px 58px; }
.detail ul { list-style: none; margin: 0 0 10px; padding: 0; border-left: 2px solid var(--steel); }
.detail li { display: flex; gap: 14px; padding: 5px 0 5px 14px; font-size: 13.5px; }
.detail li .s { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.detail li .m { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); margin-right: 8px; vertical-align: 2px; }
.detail a { color: var(--accent); font-size: 13px; text-decoration: none; }
.detail a:hover { text-decoration: underline; }
.more { display: flex; justify-content: center; padding: 18px; }

/* Panels / tools */
.grid2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; margin-bottom: 18px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; margin-bottom: 14px; }
.grid2 .panel { margin: 0; display: flex; flex-direction: column; }
.panel h3 { font: 600 17px/1.25 var(--display); color: var(--strong); margin: 0 0 6px; }
.panel p { color: var(--muted); font-size: 14px; margin: 0 0 14px; }
.panel .grow { flex: 1; }
.big { font: 700 26px/1 var(--display); color: var(--strong); margin-bottom: 14px; }
.big small { font: 500 13px var(--body); color: var(--muted); margin-left: 6px; }
.section-title { font: 600 18px/1.2 var(--display); color: var(--strong); margin: 26px 0 12px; }
.plain { list-style: none; margin: 0; padding: 0; }
.plain li { display: flex; align-items: center; gap: 14px; padding: 10px 0; border-top: 1px solid var(--line); }
.plain li:first-child { border-top: 0; }
.plain .grow { flex: 1; min-width: 0; }
.plain .sub { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plain .nm { font-size: 14px; }
.toggle { display: flex; gap: 12px; align-items: center; padding: 6px 0; cursor: pointer; }
.toggle input { width: 18px; height: 18px; accent-color: var(--safe); }
.add-row { display: flex; gap: 8px; margin-bottom: 12px; }
.add-row .input { flex: 1; }

/* Admin table */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; font-weight: 600; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { white-space: nowrap; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td .nm { font-size: 14px; }
td .sub { color: var(--muted); font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; text-align: right; }
.status-on { color: var(--safe); font-weight: 600; }
.status-off { color: var(--danger); font-weight: 600; }

/* Bulk bar */
.bulk { position: fixed; left: calc(252px + 32px); right: 32px; bottom: 18px; max-width: 1216px; display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; padding: 12px 14px 12px 18px; background: var(--panel-2); border: 1px solid var(--steel); border-radius: 12px; box-shadow: var(--shadow); z-index: 30; animation: rise .2s ease; }
.bulk-text { font-weight: 600; color: var(--strong); }
.bulk-acts { display: flex; gap: 8px; flex-wrap: wrap; }
@keyframes rise { from { transform: translateY(10px); opacity: 0; } }

/* Modal & toasts */
.modal-wrap { position: fixed; inset: 0; z-index: 50; background: rgba(4,10,20,.6); display: grid; place-items: center; padding: 20px; }
.modal { width: min(480px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 24px; box-shadow: var(--shadow); }
.modal h2 { font: 700 20px/1.25 var(--display); color: var(--strong); margin: 0 0 10px; }
.modal-body p { margin: 0 0 10px; }
.check-row { display: flex; gap: 10px; align-items: center; margin-top: 12px; cursor: pointer; }
.check-row input { width: 17px; height: 17px; accent-color: var(--accent); }
.modal .field { margin-top: 14px; }
.modal-acts { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.toasts { position: fixed; top: 16px; right: 16px; z-index: 60; display: flex; flex-direction: column; gap: 8px; width: min(380px, 92vw); }
.toast { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--panel-2); color: var(--strong); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: var(--r); font-size: 14px; box-shadow: var(--shadow); animation: rise .2s ease; }
.toast.err { border-left-color: var(--danger); }
.toast.busy { border-left-color: var(--warn); }
.toast span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.toast button { background: none; border: 0; color: var(--accent); font-weight: 700; padding: 0; }
.spin { width: 14px; height: 14px; flex: none; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--warn); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1150px) {
  .list-head, .row { grid-template-columns: 30px minmax(0, 1fr) 110px 196px; }
  .last, .lh-last { display: none; }
  .act .lbl { display: none; }
  .act { width: 32px; padding: 0; justify-content: center; }
}
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .main { padding: 18px 14px 150px; }
  .bulk { left: 12px; right: 12px; }
  .list-head { display: none; }
  .row { grid-template-columns: 30px minmax(0, 1fr); }
  .vol, .acts { grid-column: 2; }
  .note { text-align: left; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
