/* ==========================================================================
   Blank Store — control panel theme.
   Dark, modern, no framework. Logical properties throughout so the whole
   layout mirrors automatically for Arabic (dir="rtl").
   ========================================================================== */

:root {
    --bg: #080d18;
    --bg-2: #0b1220;
    --panel: rgba(20, 29, 48, .72);
    --panel-solid: #141d30;
    --panel-2: rgba(255, 255, 255, .04);
    --line: rgba(255, 255, 255, .09);
    --line-2: rgba(255, 255, 255, .14);
    --text: #eaf0fb;
    --muted: #8d9bb5;
    --accent: #4d8bff;
    --accent-2: #2f6ae0;
    --accent-glow: rgba(77, 139, 255, .35);
    --cyan: #22d3ee;
    --ok: #2ee6a8;
    --bad: #ff5f6d;
    --warn: #ffb020;
    --radius: 18px;
    --radius-sm: 12px;
    --sidebar-w: 248px;
    --font: 'Inter', -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-ar: 'Noto Kufi Arabic', 'Segoe UI', Tahoma, sans-serif;
    --shadow: 0 24px 60px -30px rgba(0, 0, 0, .95);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(1200px 620px at 12% -10%, rgba(77, 139, 255, .16), transparent 62%),
        radial-gradient(900px 520px at 100% 0%, rgba(34, 211, 238, .09), transparent 58%),
        radial-gradient(800px 600px at 50% 110%, rgba(46, 230, 168, .06), transparent 60%),
        var(--bg);
    background-attachment: fixed;
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* Arabic: Noto Kufi Arabic everywhere, with a little extra line-height. */
html[lang="ar"] body,
html[lang="ar"] button,
html[lang="ar"] input,
html[lang="ar"] select,
html[lang="ar"] textarea { font-family: var(--font-ar); line-height: 1.85; }
html[lang="ar"] .mono,
html[lang="ar"] code { font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 26px; font-weight: 800; letter-spacing: -.02em; margin: 0 0 4px; }
h2 { letter-spacing: -.01em; }

.mono { font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace; }
.tiny { font-size: 12px; }
.small { font-size: 13px; }
.muted { color: var(--muted); }
.accent { color: var(--accent); }
.warn { color: var(--warn); }
.right { text-align: end; }
.link { cursor: pointer; }
.link-quiet { color: var(--muted); }
.link-quiet:hover { color: var(--accent); text-decoration: none; }
/* Flags keep their own emoji font so they render in colour on every OS. */
.flag, .flag-big {
    font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
    font-style: normal;
}

/* ==========================================================================
   Sidebar + shell
   ========================================================================== */
.sidebar {
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    width: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 22px 14px;
    background: linear-gradient(180deg, rgba(14, 22, 38, .96), rgba(9, 14, 26, .96));
    border-inline-end: 1px solid var(--line);
    backdrop-filter: blur(14px);
    z-index: 40;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px 18px;
    color: var(--text);
    font-weight: 800;
    font-size: 17px;
    letter-spacing: -.02em;
}
.brand:hover { text-decoration: none; }
/* Logo sizing depends on its shape: a wide wordmark gets the full sidebar
   width and stands alone; a square mark is an icon that sits beside the name. */
.brand-logo { object-fit: contain; display: block; }
.brand-logo.is-wide { max-width: 100%; max-height: 46px; }
.brand-logo.is-mark { width: 40px; height: 40px; flex: none; border-radius: 9px; }
.brand-text { font-weight: 800; letter-spacing: -.02em; }
.brand-mark {
    width: 30px; height: 30px; flex: none; border-radius: 9px;
    background: linear-gradient(135deg, var(--accent), var(--cyan));
    box-shadow: 0 8px 20px -8px var(--accent-glow);
    position: relative;
}
.brand-mark::after {
    content: ""; position: absolute; inset: 0; margin: auto;
    width: 0; height: 0;
    border-inline-start: 9px solid #fff;
    border-block: 6px solid transparent;
    inset-inline-start: 11px;
}
html[dir="rtl"] .brand-mark::after { transform: scaleX(-1); }

.sidenav { display: flex; flex-direction: column; gap: 3px; }
.sidenav a {
    display: flex; align-items: center; gap: 11px;
    padding: 10px 12px; border-radius: var(--radius-sm);
    color: var(--muted); font-weight: 600; font-size: 14.5px;
    border: 1px solid transparent;
    transition: background .16s, color .16s, border-color .16s;
}
.sidenav a:hover { background: var(--panel-2); color: var(--text); text-decoration: none; }
.sidenav a.active {
    background: linear-gradient(90deg, rgba(77, 139, 255, .18), rgba(77, 139, 255, .05));
    color: #fff; border-color: rgba(77, 139, 255, .32);
}
.sidenav .ico { width: 18px; height: 18px; flex: none; opacity: .95; }
html[dir="rtl"] .sidenav a.active {
    background: linear-gradient(270deg, rgba(77, 139, 255, .18), rgba(77, 139, 255, .05));
}

.side-foot { margin-block-start: auto; display: flex; flex-direction: column; gap: 10px; padding: 10px; }
.side-domain { font-size: 11.5px; color: var(--muted); word-break: break-all; }
.logout button {
    width: 100%; padding: 9px 12px; border-radius: var(--radius-sm);
    background: var(--panel-2); border: 1px solid var(--line);
    color: var(--muted); cursor: pointer; font: inherit; font-size: 13.5px;
}
.logout button:hover { color: var(--text); border-color: var(--line-2); }

.lang-switch { display: inline-flex; gap: 3px; padding: 3px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); }
.lang-switch a {
    padding: 4px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 700;
    color: var(--muted); line-height: 1.5;
}
.lang-switch a:hover { color: var(--text); text-decoration: none; }
.lang-switch a.on { background: var(--accent); color: #fff; box-shadow: 0 6px 16px -8px var(--accent-glow); }
.lang-switch-float { position: fixed; inset-block-start: 18px; inset-inline-end: 18px; z-index: 50; }

.wrap { max-width: 1140px; margin: 30px auto; padding: 0 26px; }
body.has-sidebar .wrap { margin-inline-start: var(--sidebar-w); }
.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 34px 0; }
body.has-sidebar .foot { margin-inline-start: var(--sidebar-w); }

/* Mobile top bar + drawer */
.navtoggle, .nav-scrim, .mobile-bar { display: none; }

/* ==========================================================================
   Flash / cards / buttons
   ========================================================================== */
.flash {
    padding: 13px 17px; border-radius: var(--radius-sm); margin-bottom: 18px; font-size: 14px;
    border: 1px solid; backdrop-filter: blur(8px);
}
.flash-success { background: rgba(46, 230, 168, .1); border-color: rgba(46, 230, 168, .35); color: #86f5cd; }
.flash-error { background: rgba(255, 95, 109, .1); border-color: rgba(255, 95, 109, .38); color: #ffb3b9; }
.flash ul { margin: 0; padding-inline-start: 18px; }

.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 22px;
    margin-bottom: 18px;
    backdrop-filter: blur(16px);
    box-shadow: var(--shadow);
    transition: border-color .2s;
}
.card.empty { text-align: center; }
.card-h { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: -.01em; }

.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 9px 16px; border-radius: var(--radius-sm);
    border: 1px solid var(--line); background: var(--panel-2);
    color: var(--text); cursor: pointer; font: inherit; font-size: 14px; font-weight: 600;
    transition: border-color .15s, background .15s, transform .06s, box-shadow .2s;
}
.btn:hover { border-color: var(--line-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    border-color: transparent; color: #fff;
    box-shadow: 0 12px 26px -12px var(--accent-glow);
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn-danger { color: #ffb3b9; border-color: rgba(255, 95, 109, .35); background: rgba(255, 95, 109, .08); }
.btn-danger:hover { border-color: rgba(255, 95, 109, .6); }
.btn-ghost { background: transparent; border: 1px dashed var(--line-2); color: var(--muted); align-self: flex-start; }
.btn-ghost:hover { border-style: solid; border-color: var(--accent); color: var(--text); }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 6px; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; }

/* ==========================================================================
   Live dot
   ========================================================================== */
.live-dot {
    display: inline-block; width: 7px; height: 7px; border-radius: 50%;
    background: var(--ok); box-shadow: 0 0 0 0 rgba(46, 230, 168, .6);
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(46, 230, 168, .55); }
    70% { box-shadow: 0 0 0 7px rgba(46, 230, 168, 0); }
    100% { box-shadow: 0 0 0 0 rgba(46, 230, 168, 0); }
}
@media (prefers-reduced-motion: reduce) { .live-dot { animation: none; } }

/* ==========================================================================
   Server heartbeat — radial dials
   ========================================================================== */
.hb-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.state-chip {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 5px 13px; border-radius: 999px; font-size: 12px; font-weight: 700;
    border: 1px solid;
}
.state-chip.ok { background: rgba(46, 230, 168, .1); border-color: rgba(46, 230, 168, .32); color: #86f5cd; }
.state-chip.bad { background: rgba(255, 95, 109, .1); border-color: rgba(255, 95, 109, .38); color: #ffb3b9; }
.state-chip.bad .live-dot { background: var(--bad); animation: none; }

.hb-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(146px, 1fr)); gap: 14px; }

.dial { text-align: center; position: relative; padding: 6px 0 2px; }
.dial-svg { width: 104px; height: 104px; display: block; margin: 0 auto; transform: rotate(-90deg); }
html[dir="rtl"] .dial-svg { transform: rotate(-90deg) scaleY(-1); }
.dial-bg { fill: none; stroke: rgba(255, 255, 255, .07); stroke-width: 7; }
.dial-fg {
    fill: none; stroke-width: 7; stroke-linecap: round;
    transition: stroke-dashoffset .7s cubic-bezier(.4, 0, .2, 1), stroke .3s;
}
.dial-fg.tone-ok { stroke: var(--ok); filter: drop-shadow(0 0 6px rgba(46, 230, 168, .45)); }
.dial-fg.tone-warn { stroke: var(--warn); filter: drop-shadow(0 0 6px rgba(255, 176, 32, .45)); }
.dial-fg.tone-bad { stroke: var(--bad); filter: drop-shadow(0 0 6px rgba(255, 95, 109, .5)); }
.dial-mid {
    position: absolute; inset-block-start: 34px; inset-inline: 0;
    font-variant-numeric: tabular-nums;
}
.dial-mid b { font-size: 25px; font-weight: 800; letter-spacing: -.03em; }
.dial-mid i { font-style: normal; font-size: 12px; color: var(--muted); margin-inline-start: 1px; }
.dial-label { font-size: 13px; font-weight: 700; margin-top: 6px; }
.dial-sub { margin-top: 2px; }

.tile {
    display: flex; flex-direction: column; justify-content: center;
    background: var(--panel-2); border: 1px solid var(--line);
    border-radius: var(--radius-sm); padding: 14px 16px; text-align: start;
}
.tile-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.tile-value { font-size: 24px; font-weight: 800; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.tile-value i { font-style: normal; font-size: 12px; color: var(--muted); font-weight: 600; }
.tile-sub { margin-top: 2px; }
html[lang="ar"] .tile-label { text-transform: none; letter-spacing: 0; }

/* Connected clients table */
.clients-block { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.clients-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.detail-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
html[lang="ar"] .detail-label { text-transform: none; letter-spacing: 0; font-size: 12px; }
.ctable { width: 100%; border-collapse: collapse; font-size: 13px; }
.ctable td { padding: 8px 4px; border-bottom: 1px solid var(--line); }
.ctable tr:last-child td { border-bottom: 0; }
.ctable td.right { white-space: nowrap; }
.ctable .mono { color: #cdd9f2; }
.pill {
    display: inline-block; padding: 2px 10px; border-radius: 999px;
    font-size: 12px; font-weight: 700; background: rgba(77, 139, 255, .15); color: #a6c4ff;
}

/* ==========================================================================
   Top countries — flag tiles
   ========================================================================== */
.flag-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 12px; }
.flag-tile {
    display: flex; flex-direction: column; gap: 3px;
    padding: 14px 12px; border-radius: var(--radius-sm);
    background: var(--panel-2); border: 1px solid var(--line);
    transition: border-color .18s, transform .18s;
}
.flag-tile:hover { border-color: var(--line-2); transform: translateY(-2px); }
.flag-big { font-size: 30px; line-height: 1.15; }
.flag-name { font-size: 12.5px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flag-req { font-size: 18px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.flag-bar { display: block; height: 4px; border-radius: 999px; background: rgba(255, 255, 255, .08); overflow: hidden; margin-top: 4px; }
.flag-bar i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--cyan)); transition: width .6s; }
html[dir="rtl"] .flag-bar i { background: linear-gradient(270deg, var(--accent), var(--cyan)); }

/* ==========================================================================
   Stat row + proxy cards
   ========================================================================== */
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 13px; margin-bottom: 22px; }
.stat {
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 16px 18px; display: flex; flex-direction: column;
    backdrop-filter: blur(12px); transition: border-color .2s, transform .2s;
}
.stat:hover { border-color: var(--line-2); transform: translateY(-2px); }
.stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
html[lang="ar"] .stat-label { text-transform: none; letter-spacing: 0; font-size: 12px; }
.stat-value { font-size: 28px; font-weight: 800; margin-top: 5px; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.stat-value.small { font-size: 16px; }
.stat-value.accent { text-shadow: 0 0 26px var(--accent-glow); }
.stat-hint { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

.card.proxy:hover { border-color: var(--line-2); }
.proxy-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.proxy-title { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.proxy-title h2 { margin: 0; font-size: 18px; font-weight: 700; }
.proxy-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.proxy-actions form { margin: 0; }

.badge { font-size: 11.5px; font-weight: 700; padding: 4px 11px; border-radius: 999px; }
.badge-ok { background: rgba(46, 230, 168, .13); color: #86f5cd; }
.badge-bad { background: rgba(255, 95, 109, .13); color: #ffb3b9; }
.badge-off { background: rgba(141, 155, 181, .13); color: var(--muted); }
.badge-wait { background: rgba(255, 176, 32, .13); color: #ffd68a; }
.badge-live { background: rgba(77, 139, 255, .16); color: #a6c4ff; }

.proxy-info { display: grid; grid-template-columns: 148px 1fr; gap: 6px 14px; margin: 18px 0 0; font-size: 14px; }
.proxy-info dt { color: var(--muted); }
.proxy-info dd { margin: 0; }
.url { display: block; font-size: 13px; font-weight: 600; color: #a6c4ff; user-select: all; word-break: break-all; }

.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.metric { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; }
.metric span { display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
html[lang="ar"] .metric span { text-transform: none; letter-spacing: 0; font-size: 11.5px; }
.metric b { display: block; font-size: 19px; margin-top: 4px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 18px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { font-size: 12px; padding: 3px 10px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); }
.chip-2 { color: #86f5cd; } .chip-3 { color: #a6c4ff; } .chip-4 { color: #ffd68a; } .chip-5 { color: #ffb3b9; }
.paths { list-style: none; margin: 8px 0 0; padding: 0; }
.paths li { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; padding: 4px 0; border-bottom: 1px solid var(--line); }
.paths li:last-child { border-bottom: 0; }
.week { margin: 16px 0 0; font-size: 12.5px; }

/* ==========================================================================
   Guard banner
   ========================================================================== */
.guard-banner {
    background: linear-gradient(135deg, rgba(255, 95, 109, .16), rgba(255, 95, 109, .07));
    border: 1px solid rgba(255, 95, 109, .45); color: #ffb3b9;
    border-radius: var(--radius); padding: 15px 18px; margin-bottom: 18px; font-size: 14px;
}
.guard-banner strong { color: #ffd5d9; }

/* ==========================================================================
   Forms
   ========================================================================== */
.form { display: flex; flex-direction: column; gap: 17px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field-label { font-size: 13.5px; font-weight: 700; }
.field-hint { font-size: 12.5px; color: var(--muted); }
.reco { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: rgba(46, 230, 168, .13); color: #86f5cd; margin-inline-start: 6px; }

input[type=text], input[type=number], input[type=password], select, textarea {
    background: rgba(8, 13, 24, .8); border: 1px solid var(--line); color: var(--text);
    border-radius: var(--radius-sm); padding: 11px 13px; font: inherit; font-size: 14px;
    transition: border-color .15s, box-shadow .15s;
    width: 100%;
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(77, 139, 255, .16);
}
input::placeholder { color: rgba(141, 155, 181, .6); }
label { display: block; }

.host-input { display: flex; align-items: stretch; }
.host-input input { border-start-end-radius: 0; border-end-end-radius: 0; }
.host-suffix {
    display: flex; align-items: center; padding: 0 13px; font-size: 13.5px; color: var(--muted);
    background: var(--panel-2); border: 1px solid var(--line); border-inline-start: 0;
    border-start-end-radius: var(--radius-sm); border-end-end-radius: var(--radius-sm);
}
.advanced { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 15px; background: var(--panel-2); }
.advanced summary { cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--muted); }
.advanced summary:hover { color: var(--text); }
.advanced > .field { margin-top: 14px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 4px; }

.switch-row {
    display: flex; align-items: center; gap: 14px; padding: 15px 17px;
    background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm); cursor: pointer;
    transition: border-color .18s;
}
.switch-row:hover { border-color: var(--line-2); }
.switch-row input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
.switch-row > span { display: flex; flex-direction: column; gap: 2px; }
.gate-state { margin-inline-start: auto; font-size: 10.5px; font-weight: 800; letter-spacing: .06em; padding: 4px 11px; border-radius: 999px; white-space: nowrap; }
.gate-state.on { background: rgba(46, 230, 168, .14); color: #86f5cd; }
.gate-state.off { background: rgba(141, 155, 181, .14); color: var(--muted); }

/* Settings: API rows */
.settings-intro { margin-bottom: 20px; }
.settings-intro p { margin: 8px 0 0; }
.settings-intro code { background: rgba(255, 255, 255, .07); padding: 2px 7px; border-radius: 6px; font-size: 12px; }
.apis-head { display: flex; flex-direction: column; gap: 3px; }
.apis { display: flex; flex-direction: column; gap: 11px; }
.api-row { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px; }
.api-grid { display: grid; grid-template-columns: 1fr 1.7fr 1.7fr auto auto; gap: 11px; align-items: end; }
.field.mini { gap: 4px; }
.row-enable { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 10.5px; color: var(--muted); text-transform: uppercase; font-weight: 700; }
.row-enable input { width: 18px; height: 18px; accent-color: var(--ok); }
.row-del { padding: 9px 12px; color: #ffb3b9; }

/* Whitelist */
.wl-add { display: flex; gap: 10px; align-items: center; }
.wl-add input { flex: 1; }
.table-scroll { overflow-x: auto; }
.wtable { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.wtable th {
    text-align: start; font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em;
    color: var(--muted); font-weight: 700; padding: 0 10px 10px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
html[lang="ar"] .wtable th { text-transform: none; letter-spacing: 0; font-size: 12px; }
.wtable th.right { text-align: end; }
.wtable td { padding: 10px; border-bottom: 1px solid var(--line); }
.wtable tr:last-child td { border-bottom: 0; }
.wtable tbody tr:hover { background: rgba(255, 255, 255, .02); }
.wtable form { margin: 0; }

/* Login */
.login-card {
    max-width: 400px; margin: 14vh auto; padding: 34px;
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
    backdrop-filter: blur(16px); box-shadow: var(--shadow);
}
.login-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; }
.login-brand h1 { margin: 0; font-size: 23px; }
.login-logo { object-fit: contain; display: block; }
.login-logo.is-mark { width: 60px; height: 60px; border-radius: 14px; flex: none; }
.login-logo.is-wide { max-width: 240px; max-height: 66px; }
.login-card form { display: flex; flex-direction: column; gap: 9px; margin-top: 22px; }
.login-card label { font-size: 13px; font-weight: 700; }
.login-card .btn { justify-content: center; margin-top: 10px; padding: 12px; }

/* ==========================================================================
   Statistics page
   ========================================================================== */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.chart-scroll { overflow-x: auto; margin-top: 14px; }
.chart { width: 100%; height: 210px; display: block; }
.chart-legend { display: flex; gap: 18px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 10px; }
.chart-legend i { display: inline-block; width: 13px; height: 3px; border-radius: 2px; margin-inline-end: 6px; vertical-align: middle; }
.empty-line { padding: 22px 0; text-align: center; color: var(--muted); }
.bars { list-style: none; margin: 0; padding: 0; }
.bars li { margin-bottom: 11px; }
.bar-row { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; margin-bottom: 5px; }
.bar-track { height: 6px; border-radius: 999px; background: rgba(255, 255, 255, .08); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--cyan)); transition: width .5s; }
html[dir="rtl"] .bar-fill { background: linear-gradient(270deg, var(--accent), var(--cyan)); }
.tone-ok { background: var(--ok); } .tone-warn { background: var(--warn); } .tone-bad { background: var(--bad); }
.rows { list-style: none; margin: 0; padding: 0; }
.rows li { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.rows li:last-child { border-bottom: 0; }

/* ==========================================================================
   Responsive — sidebar becomes a drawer
   ========================================================================== */
@media (max-width: 980px) {
    .sidebar {
        transform: translateX(calc(var(--sidebar-w) * -1));
        transition: transform .25s ease;
        box-shadow: var(--shadow);
    }
    html[dir="rtl"] .sidebar { transform: translateX(var(--sidebar-w)); }
    .navtoggle:checked ~ .sidebar { transform: translateX(0); }
    .navtoggle:checked ~ .nav-scrim {
        display: block; position: fixed; inset: 0; z-index: 35;
        background: rgba(3, 6, 12, .65); backdrop-filter: blur(2px);
    }
    .mobile-bar {
        display: flex; align-items: center; gap: 12px;
        padding: 12px 16px; position: sticky; top: 0; z-index: 30;
        background: rgba(10, 16, 28, .9); border-bottom: 1px solid var(--line);
        backdrop-filter: blur(12px);
    }
    .burger { display: flex; padding: 6px; cursor: pointer; color: var(--text); }
    .burger svg { width: 22px; height: 22px; }
    .mobile-title { font-weight: 700; font-size: 15px; }
    body.has-sidebar .wrap, body.has-sidebar .foot { margin-inline-start: 0; }
    .wrap { margin: 20px auto; padding: 0 16px; }
    .two-col, .detail-grid { grid-template-columns: 1fr; }
    .api-grid { grid-template-columns: 1fr 1fr; }
    .proxy-info { grid-template-columns: 1fr; gap: 2px 0; }
    .proxy-info dt { margin-top: 8px; font-size: 12px; }
}

@media (max-width: 560px) {
    h1 { font-size: 22px; }
    .card { padding: 17px; }
    .hb-grid { grid-template-columns: repeat(2, 1fr); }
    .dial-svg { width: 92px; height: 92px; }
    .dial-mid { inset-block-start: 29px; }
    .dial-mid b { font-size: 22px; }
    .flag-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
    .api-grid { grid-template-columns: 1fr; }
    .form-actions { flex-direction: column-reverse; }
    .form-actions .btn { justify-content: center; }
}

@media print { .sidebar, .mobile-bar, .lang-switch { display: none; } body.has-sidebar .wrap { margin: 0; } }

/* ==========================================================================
   Real flag images.
   Windows has no country-flag glyphs (Chrome renders the emoji as two plain
   letters), so flags are SVG images served from this box, with a 2-letter
   badge as the fallback when an image is missing.
   ========================================================================== */
img.flag {
    width: 21px; height: 15px; border-radius: 3px; object-fit: cover;
    vertical-align: -2px; display: inline-block;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, .14), 0 1px 3px rgba(0, 0, 0, .45);
    background: rgba(255, 255, 255, .06);
}
.flag-badge {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 25px; height: 16px; padding: 0 5px; border-radius: 4px;
    font-size: 9.5px; font-weight: 800; letter-spacing: .04em;
    background: rgba(77, 139, 255, .18); color: #a6c4ff;
    border: 1px solid rgba(77, 139, 255, .3);
    vertical-align: -2px; font-family: var(--font);
}
.flag-unknown { background: rgba(141, 155, 181, .16); color: var(--muted); border-color: var(--line); }

/* Bigger flag inside a country tile */
.flag-big img.flag { width: 44px; height: 31px; border-radius: 5px; }
.flag-big .flag-badge { min-width: 44px; height: 31px; font-size: 14px; border-radius: 5px; }
.flag-big { line-height: 1; display: block; margin-bottom: 4px; }

/* the "no heartbeat" chip */
.state-chip.unknown { background: rgba(141, 155, 181, .13); border-color: var(--line-2); color: var(--muted); }
.state-chip.unknown .live-dot { background: var(--muted); animation: none; }
/* live dot goes grey when the poller cannot reach the server */
.live-dot.stale { background: var(--muted); animation: none; }

/* ==========================================================================
   Background tasks (start/stop the collectors)
   ========================================================================== */
.task-row {
    display: flex; align-items: flex-start; gap: 16px;
    padding: 15px 0; border-top: 1px solid var(--line);
}
.task-row:first-of-type { border-top: 0; }
.task-main { flex: 1; min-width: 0; }
.task-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 3px; }
.task-main p { margin: 3px 0 0; }
.task-action { flex: none; margin: 0; }
.task-off {
    font-size: 12.5px; color: #ffd68a;
    background: rgba(255, 176, 32, .1); border: 1px solid rgba(255, 176, 32, .28);
    border-radius: var(--radius-sm); padding: 8px 11px; margin-top: 8px !important;
}
@media (max-width: 560px) {
    .task-row { flex-direction: column; gap: 10px; }
    .task-action .btn { width: 100%; justify-content: center; }
}
.flag-req .flag-unit {
    font-style: normal; font-size: 10.5px; font-weight: 600;
    color: var(--muted); margin-inline-start: 5px; letter-spacing: 0;
}

/* ==========================================================================
   Pro polish — tighter hierarchy, quieter chrome, sharper numbers
   ========================================================================== */

/* Numbers are the content here: keep them aligned and prominent. */
.stat-value, .tile-value, .dial-mid b, .flag-req, .metric b, .wtable td {
    font-variant-numeric: tabular-nums lining-nums;
    font-feature-settings: "tnum" 1, "lnum" 1;
}

/* Cards: a touch more depth, a cleaner edge, and a hairline top highlight
   so they read as raised surfaces rather than flat blocks. */
.card {
    position: relative;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, .035), rgba(255, 255, 255, 0) 120px),
        var(--panel);
}
.card::before {
    content: ""; position: absolute; inset-inline: 18px; inset-block-start: 0; height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .16), transparent);
    pointer-events: none;
}

/* Section headings sit quieter so the figures lead. */
.card-h {
    font-size: 12.5px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .09em; color: var(--muted);
}
html[lang="ar"] .card-h { text-transform: none; letter-spacing: 0; font-size: 14px; }
.hb-head { margin-bottom: 20px; }

/* Dials: thinner ring, softer track, larger figure. */
.dial-bg { stroke-width: 6; stroke: rgba(255, 255, 255, .06); }
.dial-fg { stroke-width: 6; }
.dial-mid b { font-size: 27px; }
.dial-label { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; }
html[lang="ar"] .dial-label { text-transform: none; letter-spacing: 0; font-size: 13px; }

/* Tiles line up with the dials instead of floating in their own boxes. */
.tile { background: transparent; border: 0; border-inline-start: 1px solid var(--line); border-radius: 0; padding-inline: 20px; }
html[dir="rtl"] .tile { border-inline-start: 1px solid var(--line); }
.tile-value { font-size: 27px; line-height: 1.15; }
.tile-value i { font-size: 12px; margin-inline-start: 3px; }
@media (max-width: 720px) { .tile { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px 16px; } }

/* Headline stats: bigger, with a quiet uppercase label. */
.stat-value { font-size: 32px; }
.stat { padding: 18px 20px; }

/* Country tiles: image-forward, with the flag framed. */
.flag-tile { padding: 16px 14px; }
.flag-big img.flag { width: 46px; height: 33px; border-radius: 6px; }
.flag-req { font-size: 22px; }
.flag-name { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 700; }
html[lang="ar"] .flag-name { text-transform: none; letter-spacing: 0; font-size: 13px; }

/* Sidebar: a clearer active state. */
.sidenav a.active { box-shadow: inset 3px 0 0 var(--accent); }
html[dir="rtl"] .sidenav a.active { box-shadow: inset -3px 0 0 var(--accent); }

/* Tables read better with a little more air. */
.wtable td, .ctable td { padding-block: 11px; }
.wtable thead th { padding-bottom: 12px; }

/* Focus visibility for keyboard users. */
a:focus-visible, button:focus-visible, input:focus-visible, summary:focus-visible {
    outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px;
}

/* Accounts-watching-now is its own card now; the inner wrapper no longer
   needs the divider it had inside the server card. */
.accounts-card .ctable { margin-top: 4px; }
.clients-inner { margin: 0; padding: 0; border: 0; }
