/* GuildNet control panel. Tokens from docs/design/DESIGN_HANDOFF.md. No inline styles: the CSP forbids them. */
@font-face { font-family: "Sora"; src: url("../fonts/Sora.ttf") format("truetype"); font-weight: 100 800; font-display: swap; }
@font-face { font-family: "IBM Plex Sans Arabic"; src: url("../fonts/IBMPlexSansArabic-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "IBM Plex Sans Arabic"; src: url("../fonts/IBMPlexSansArabic-Medium.ttf") format("truetype"); font-weight: 500; font-display: swap; }
@font-face { font-family: "IBM Plex Sans Arabic"; src: url("../fonts/IBMPlexSansArabic-SemiBold.ttf") format("truetype"); font-weight: 600; font-display: swap; }
@font-face { font-family: "IBM Plex Sans Arabic"; src: url("../fonts/IBMPlexSansArabic-Bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url("../fonts/JetBrainsMono.ttf") format("truetype"); font-weight: 100 800; font-display: swap; }

:root {
  --void: #070B14; --surface: #0D1424; --raised: #131C30; --sidebar: #0A101D; --line: #1F2A44; --line-soft: #1A2440; --line-strong: #2A3756;
  --text: #E6ECF7; --text-2: #B4BFD6; --muted: #8A97B3;
  --cyan: #22D3EE; --cyan-light: #67E8F9; --on-cyan: #04131A;
  --violet: #A855F7; --violet-light: #D8B4FE;
  --direct: #34D399; --direct-text: #6EE7B7; --relay: #FBBF24; --relay-text: #FCD34D; --offline: #F87171; --offline-text: #FCA5A5;
  --indigo-text: #C7D2FE;
  --font: "IBM Plex Sans Arabic", system-ui, sans-serif; --disp: "Sora", "IBM Plex Sans Arabic", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--void); color: var(--text); font-family: var(--font); font-size: 14px; }
a { color: var(--cyan); }
a:hover { color: var(--cyan-light); }
.mono { font-family: var(--mono); }
.disp { font-family: var(--disp); }
.muted { color: var(--muted); }
.text-2 { color: var(--text-2); }
.ok-text { color: var(--direct-text); }
.warn-text { color: var(--relay-text); }
.bad-text { color: var(--offline-text); }
.violet-text { color: var(--violet-light); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ico { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ico-sm { width: 14px; height: 14px; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

/* ---------- shell ---------- */
.shell { min-height: 100vh; display: flex; flex-wrap: wrap; align-content: flex-start; } /* wrapped (phones): no stretched sidebar */
.side { flex: 1 1 220px; padding: 22px 14px; background: var(--sidebar); border-right: 1px solid var(--line-soft); display: flex; flex-direction: column; gap: 22px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; color: var(--text); text-decoration: none; }
.brand:hover { color: var(--text); }
.brand-name { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name b { font-family: var(--disp); font-size: 17px; font-weight: 800; letter-spacing: -0.02em; }
.brand-name small { font-family: var(--mono); font-size: 10px; color: var(--muted); letter-spacing: 0.1em; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 10px; border-radius: 8px; color: var(--text-2); text-decoration: none; }
.nav a:hover { background: rgba(34, 211, 238, .05); color: var(--text); }
.nav a.active { background: rgba(34, 211, 238, .1); color: var(--cyan-light); font-weight: 600; }
.nav .count { margin-left: auto; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.nav a.active .count { color: inherit; }
.nav .count.amber { color: var(--relay-text); }
.side-foot { margin-top: auto; padding: 0 10px; font-family: var(--mono); font-size: 11px; color: var(--muted); line-height: 1.6; display: flex; flex-direction: column; gap: 10px; }
.side-user { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-family: var(--font); font-size: 13px; }
.main { flex: 999 1 560px; min-width: 0; padding: 26px 30px; display: flex; flex-direction: column; gap: 20px; }

/* ---------- header ---------- */
.head { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; }
.head h1 { margin: 0; font-family: var(--disp); font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
.head .end { margin-left: auto; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.head .sub { font-size: 13px; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- chips ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 11px; padding: 5px 10px; border-radius: 999px; white-space: nowrap; }
.chip.ok { background: rgba(52, 211, 153, .12); color: var(--direct-text); }
.chip.warn { background: rgba(251, 191, 36, .12); color: var(--relay-text); }
.chip.bad { background: rgba(248, 113, 113, .12); color: var(--offline-text); }
.chip.cyan { background: rgba(34, 211, 238, .1); color: var(--cyan-light); }
.chip.violet { background: rgba(168, 85, 247, .16); color: var(--violet-light); }
.chip.indigo { background: rgba(124, 140, 245, .14); color: var(--indigo-text); }
.chip.outline { border: 1px solid var(--cyan); color: var(--cyan-light); background: transparent; font-family: var(--font); font-size: 12px; padding: 3px 9px; }
.tag { font-size: 12px; padding: 3px 9px; border-radius: 6px; white-space: nowrap; }
.tag.device { background: rgba(34, 211, 238, .1); color: var(--cyan-light); }
.tag.subnet { background: rgba(124, 140, 245, .14); color: var(--indigo-text); }
.tag.exit_node { background: rgba(52, 211, 153, .12); color: var(--direct-text); }
.tag.room { background: rgba(168, 85, 247, .16); color: var(--violet-light); }

/* ---------- controls ---------- */
.seg { display: flex; padding: 3px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); }
.seg a { height: 34px; padding: 0 12px; border-radius: 7px; color: var(--muted); display: inline-flex; align-items: center; text-decoration: none; font-size: 13px; }
.seg a.on { background: var(--line); color: var(--text); font-weight: 600; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.filters a { height: 32px; padding: 0 12px; border-radius: 8px; color: var(--muted); display: inline-flex; align-items: center; text-decoration: none; font-size: 12px; }
.filters a.on { background: var(--line); color: var(--text); font-weight: 600; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 14px; border-radius: 9px;
  border: 1px solid var(--line-strong); background: transparent; color: var(--text); font: 600 13px var(--font); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--cyan); color: var(--text); }
.btn-primary { border: 0; background: var(--cyan); color: var(--on-cyan); }
.btn-primary:hover { background: var(--cyan-light); color: var(--on-cyan); }
.btn-danger { border-color: #5B2A33; color: var(--offline-text); }
.btn-danger:hover { border-color: var(--offline); color: var(--offline-text); }
.btn-sm { height: 32px; padding: 0 12px; border-radius: 8px; font-size: 12px; }
.btn-icon { width: 34px; padding: 0; }
.btn-lg { height: 44px; padding: 0 18px; border-radius: 12px; font-size: 15px; }
.inline { display: inline; margin: 0; }
.search { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px; border-radius: 10px; background: var(--surface);
  border: 1px solid var(--line); color: var(--muted); min-width: 240px; }
.search input { flex: 1; border: 0; background: transparent; color: var(--text); font: 14px var(--font); outline: none; min-width: 0; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; color: var(--muted); }
.field input[type=text], .field input[type=email], .field input[type=password], .field input[type=number], .field input[type=url], .field select {
  height: 42px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--raised); color: var(--text); font: 14px var(--font); }
.field input:focus, .field select:focus { border-color: var(--cyan); outline: none; }
.field small { font-size: 12px; color: var(--muted); }
.field textarea { padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--raised); color: var(--text); font: 14px/1.5 var(--font); resize: vertical; }
.field textarea:focus { border-color: var(--cyan); outline: none; }
.field input[type=file] { padding: 9px 0; color: var(--text-2); font: 13px var(--font); }
.field.plain { border: 0; margin: 0; padding: 0; min-width: 0; }
.check { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.check input { width: 18px; height: 18px; accent-color: var(--cyan); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); gap: 14px; }
.form-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ---------- cards ---------- */
.row { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.row.stretch { align-items: stretch; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 18px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.card.flush { padding: 0; gap: 0; overflow-x: auto; position: relative; } /* relative: keeps .sr-only labels inside the scroll area */
.card.amber { border-color: #5A4512; }
.card-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.card.flush .card-head { padding: 16px 18px 6px; }
.card-title { font-weight: 600; font-size: 15px; }
.card-head .end { margin-left: auto; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.grow-2 { flex: 1.7 1 520px; }
.grow-16 { flex: 1.6 1 480px; }
.grow-1 { flex: 1 1 300px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); gap: 14px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; }
.stat-label { font-size: 13px; color: var(--muted); }
.stat-value { display: flex; align-items: baseline; gap: 8px; }
.stat-value b { font-family: var(--disp); font-size: 30px; font-weight: 700; }
.stat-value span { font-family: var(--mono); font-size: 13px; color: var(--muted); }
.stat-value .ok-text { color: var(--direct-text); }
.stat-value .warn-text { color: var(--relay-text); }
.stat-value .violet-text { color: var(--violet-light); }

/* ---------- tables ---------- */
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl.w600 { min-width: 600px; }
.tbl.w760 { min-width: 760px; }
.tbl.w860 { min-width: 860px; }
.tbl th { text-align: left; color: var(--muted); font-size: 12px; letter-spacing: 0.04em; font-weight: 500; padding: 10px; text-transform: uppercase; }
.tbl td { padding: 10px; border-top: 1px solid var(--line-soft); vertical-align: middle; }
.tbl th:first-child, .tbl td:first-child { padding-left: 18px; }
.tbl th:last-child, .tbl td:last-child { padding-right: 18px; }
.tbl td.right, .tbl th.right { text-align: right; }
.tbl td.mono { font-size: 13px; color: var(--text-2); }
.tbl tr.dim td { color: var(--muted); }
.who { display: flex; align-items: center; gap: 10px; }
.who-text { display: flex; flex-direction: column; min-width: 0; }
.who-text b { font-weight: 600; }
.who-text small { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.empty { padding: 18px; color: var(--muted); font-size: 13px; }

/* ---------- avatars (palette from docs/API.md) ---------- */
.av { width: 30px; height: 30px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex: none; }
.av0 { background: #0E4F5C; color: #CFFAFE; } .av1 { background: #3B2A63; color: #E9D5FF; } .av2 { background: #164E63; color: #CFFAFE; }
.av3 { background: #713F12; color: #FEF3C7; } .av4 { background: #1E3A5F; color: #DBEAFE; } .av5 { background: #1F2A44; color: #B4BFD6; }
.av6 { background: #1E3A2A; color: #86EFAC; } .av7 { background: #3A1A1F; color: #FCA5A5; }

/* ---------- overview ---------- */
.legend { display: flex; align-items: center; gap: 16px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legend .l-direct { background: var(--direct); } .legend .l-relay { background: var(--relay); }
.chart { width: 100%; height: 170px; display: block; border-bottom: 1px solid var(--line); }
.chart .d { fill: var(--direct); } .chart .r { fill: var(--relay); }
.axis { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.events { display: flex; flex-direction: column; gap: 12px; }
.ev { display: flex; gap: 10px; font-size: 13px; line-height: 1.45; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: none; }
.ev .dot { margin-top: 6px; }
.ev small { display: block; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.dot.info { background: var(--cyan); } .dot.warning { background: var(--relay); } .dot.error { background: var(--offline); }
.dot.success { background: var(--direct); } .dot.room { background: var(--violet); }
.load { width: 100%; height: 6px; display: block; }
.load .track { fill: var(--line); } .load .ok { fill: var(--direct); } .load .busy { fill: var(--relay); } .load .full { fill: var(--offline); } .load .cyan { fill: var(--cyan); }
.usage { display: flex; align-items: center; gap: 8px; }
.usage .load { width: 80px; }

/* ---------- pending approvals ---------- */
.pend { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--raised); }
.pend .who-text { flex: 1; }
.pend .acts { display: flex; gap: 6px; }

/* ---------- flash ---------- */
.flash { padding: 12px 14px; border-radius: 12px; font-size: 14px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.flash.ok { background: rgba(52, 211, 153, .1); border: 1px solid rgba(52, 211, 153, .35); color: var(--direct-text); }
.flash.bad { background: rgba(248, 113, 113, .1); border: 1px solid rgba(248, 113, 113, .35); color: var(--offline-text); }
.flash code { font-family: var(--mono); color: var(--text); background: var(--raised); padding: 4px 8px; border-radius: 6px; word-break: break-all; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.login { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 28px; display: flex; flex-direction: column; gap: 18px; }
.login .brand { padding: 0; }
.login h1 { margin: 0; font-family: var(--disp); font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.login p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.login .stack { display: flex; flex-direction: column; gap: 18px; }
.or { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; }
.or::before, .or::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
/* Google's dark-theme sign-in button: #131314 fill, #8E918F outline, #E3E3E3 label, colour "G" mark. */
.btn-google { background: #131314; border-color: #8E918F; color: #E3E3E3; gap: 10px; }
.btn-google:hover { background: #1F1F21; border-color: #E3E3E3; color: #E3E3E3; }
.g-mark { width: 18px; height: 18px; flex: none; }
.wrap-any { overflow-wrap: anywhere; }

@media (max-width: 720px) {
  .main { padding: 20px 16px; }
  .side { padding: 16px; gap: 14px; border-right: 0; border-bottom: 1px solid var(--line-soft); }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav a { height: 36px; }
  .side-foot { margin-top: 0; flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; }
  .head .end { margin-left: 0; width: 100%; }
  .head .end > .search, .head .end > .form-actions { flex: 1 1 100%; }
  .search { min-width: 0; flex: 1; }
}

/* ---------- user dashboard (/account) ---------- */
.rename { display: inline-block; vertical-align: middle; }
.rename summary { list-style: none; }
.rename summary::-webkit-details-marker { display: none; }
.rename[open] summary { border-color: var(--cyan); }
.rename-form { display: flex; gap: 6px; margin-top: 6px; }
.rename-form input { height: 32px; width: 160px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--raised); color: var(--text); font: 13px var(--mono); }
.plain-steps { margin: 0; padding-inline-start: 20px; color: var(--text-2); display: flex; flex-direction: column; gap: 6px; }
.cmd-line { display: block; padding: 10px 12px; border-radius: 10px; background: var(--void); border: 1px solid var(--line-strong); font-family: var(--mono); font-size: 12.5px; color: var(--cyan-light); overflow-x: auto; white-space: nowrap; }
.login-links a { color: var(--text-2); }

/* Right-to-left (Arabic) for the dashboard: mirror what the panel lays out with physical sides. */
@media (min-width: 721px) { [dir="rtl"] .side { border-right: 0; border-left: 1px solid var(--line-soft); } }
[dir="rtl"] .brand-name small { font-family: var(--font); letter-spacing: 0; font-size: 11px; }
[dir="rtl"] .head .end, [dir="rtl"] .card-head .end, [dir="rtl"] .nav .count { margin-left: 0; margin-right: auto; }
[dir="rtl"] .tbl th { text-align: right; }
[dir="rtl"] .tbl .right { text-align: left; }
