/* app.css — 3-Column Dashboard Layout. Self-hosted Yekan Bakh typography. */

/* ---- self-hosted fonts (no external CDN) --------------------------------- */
@font-face { font-family:"Yekan Bakh"; src:url("../font/yekanbakh/YekanBakh-Light.woff2") format("woff2");     font-weight:300; font-style:normal; font-display:swap; }
@font-face { font-family:"Yekan Bakh"; src:url("../font/yekanbakh/YekanBakh-Regular.woff2") format("woff2");   font-weight:400; font-style:normal; font-display:swap; }
@font-face { font-family:"Yekan Bakh"; src:url("../font/yekanbakh/YekanBakh-SemiBold.woff2") format("woff2");  font-weight:600; font-style:normal; font-display:swap; }
@font-face { font-family:"Yekan Bakh"; src:url("../font/yekanbakh/YekanBakh-Bold.woff2") format("woff2");      font-weight:700; font-style:normal; font-display:swap; }
@font-face { font-family:"Yekan Bakh"; src:url("../font/yekanbakh/YekanBakh-ExtraBold.woff2") format("woff2"); font-weight:800; font-style:normal; font-display:swap; }
@font-face { font-family:"Yekan Bakh"; src:url("../font/yekanbakh/YekanBakh-Black.woff2") format("woff2");     font-weight:900; font-style:normal; font-display:swap; }

/* Force Latin digits everywhere. The Persian webfont renders ASCII digits
   (U+0030–0039) as Persian glyphs; by mapping ONLY that range to a Latin
   system font placed first in the stack, 0-9 are always Latin — independent
   of the document language, so "1234" never becomes "۱۲۳۴". */
@font-face {
    font-family: "LatinNum";
    src: local("Segoe UI"), local("Roboto"), local("Helvetica Neue"), local("Arial"),
         local("Tahoma"), local("DejaVu Sans"), local("Liberation Sans");
    unicode-range: U+0030-0039;
}

:root {
    --bg-root: #f4f7f9;
    --bg-panel: #ffffff;
    --bg-card: #f9fafb;
    --bg-inset: #e5e7eb;
    --border: #e5e7eb;
    --border-2: #d1d5db;
    --accent: #2563eb;
    --accent-soft: rgba(37, 99, 235, 0.08);
    --gold: #d97706;
    --text: #1f2937;
    --text-dim: #4b5563;
    --text-mute: #9ca3af;
    --success: #10b981;
    --danger: #ef4444;
    --warn: #f59e0b;
    --time: #6366f1;
    --radius: 8px;
    --mono: "LatinNum", "Cascadia Mono", Consolas, ui-monospace, monospace;
    --sans: "LatinNum", "Yekan Bakh", "Segoe UI", Tahoma, system-ui, sans-serif;
    --sh: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
}

:root[data-theme="dark"] {
    --bg-root: #0f172a;
    --bg-panel: #1e293b;
    --bg-card: #334155;
    --bg-inset: #0f172a;
    --border: #334155;
    --border-2: #475569;
    --accent: #3b82f6;
    --accent-soft: rgba(59, 130, 246, 0.15);
    --gold: #fbbf24;
    --text: #f8fafc;
    --text-dim: #cbd5e1;
    --text-mute: #94a3b8;
    --success: #34d399;
    --danger: #f87171;
    --time: #818cf8;
    --sh: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; }

html, body {
    margin: 0; padding: 0; width: 100vw; height: 100vh;
    overflow: hidden; background: var(--bg-root); color: var(--text);
    font-family: var(--sans); font-size: 13px; line-height: 1.5;
    -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility; font-feature-settings: "ss01", "cv01", "kern";
    letter-spacing: -0.003em;
}

.app-layout {
    display: flex; flex-direction: row; width: 100vw; height: 100vh; overflow: hidden;
}

/* ---------- Column 1: Left Sidebar ---------- */
.sidebar-left {
    width: 300px; 
    flex-shrink: 0; display: flex; flex-direction: column;
    background: var(--bg-panel); border-inline-end: 1px solid var(--border); z-index: 10;
}

.sidebar-header {
    padding: 20px 24px; border-bottom: 1px solid var(--border);
    display: flex; justify-content: center; align-items: center;
}

.brand { display: flex; align-items: center; gap: 12px; width: 100%; }
.brand-logo { width: 30px; height: 30px; color: var(--accent); }
.brand-name { font-size: 18px; font-weight: 800; color: var(--text); letter-spacing: -0.02em; display: block;}
.brand-sub { font-size: 10px; color: var(--text-mute); font-weight: 600; text-transform: uppercase; }

.sidebar-scroll {
    flex: 1; overflow-y: auto; padding: 24px; display: flex; flex-direction: column;
}

.status-pill {
    display: block; width: 100%; padding: 12px; border-radius: var(--radius);
    text-align: center; font-size: 12px; font-weight: 800; letter-spacing: 0.5px;
    margin-bottom: 24px; border: 1px solid transparent; font-family: var(--sans);
}
.status-pill.on { color: var(--success); background: rgba(16, 185, 129, 0.1); border-color: rgba(16, 185, 129, 0.2); }
.status-pill.off { color: var(--danger); background: rgba(239, 68, 68, 0.1); border-color: rgba(239, 68, 68, 0.2); }

.section-label {
    font-size: 11px; color: var(--accent); text-transform: uppercase;
    font-weight: 700; padding-bottom: 8px; margin-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.service-buttons { display: flex; flex-direction: column; gap: 12px; margin-bottom: 24px; }
.svc-btn {
    position: relative; width: 100%; padding: 14px 16px;
    border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--bg-card); color: var(--text);
    font-family: inherit; font-weight: 700; font-size: 13px; cursor: pointer;
    display: flex; align-items: center; justify-content: space-between;
    transition: all 0.2s ease;
}
.svc-btn:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-soft); }
.svc-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.svc-btn .crd {
    font-size: 11px; font-weight: 800; color: var(--text);
    background: var(--bg-panel); border: 1px solid var(--border-2);
    padding: 2px 8px; border-radius: 20px;
}
.svc-btn .crd.free { color: var(--success); border-color: var(--success); }

.help-badge {
    position: absolute; top: -8px; inset-inline-end: -8px; width: 22px; height: 22px; border-radius: 50%;
    background: var(--bg-panel); border: 1px solid var(--border-2); color: var(--text-mute);
    font-size: 11px; font-weight: 800; display: grid; place-items: center; cursor: help; z-index: 5; transition: 0.15s;
}
.help-badge:hover { background: var(--accent); border-color: var(--accent); color: #fff; }

.ad-banner {
    margin-top: auto; border-radius: var(--radius); overflow: hidden;
    background: var(--bg-card); border: 1px solid var(--border);
}
.ad-banner .ad-link { display: block; text-decoration: none; color: inherit; }
.ad-content { padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; text-align: start; }
.ad-label { font-size: 9px; color: var(--text-mute); text-transform: uppercase; letter-spacing: .6px; font-weight: 800; }
.ad-media { width: 100%; border-radius: 6px; display: block; margin: 2px 0; }
.ad-title { font-size: 13px; font-weight: 800; color: var(--text); margin: 0; }
.ad-desc { font-size: 11px; color: var(--text-dim); margin: 0; line-height: 1.6; }

.sidebar-footer { padding: 20px 24px; border-top: 1px solid var(--border); background: var(--bg-card); }
.user-card { margin-bottom: 12px; }
.add-credit-btn {
    width: 100%; padding: 10px; border: 1px solid rgba(16, 185, 129, 0.5);
    background: rgba(16, 185, 129, 0.1); color: var(--success); border-radius: var(--radius);
    font-weight: 700; cursor: pointer; transition: 0.2s; font-family: inherit; font-size: 12px;
}
.add-credit-btn:hover { background: var(--success); color: #fff; }
.side-foot { font-size: 11px; color: var(--text-mute); text-align: center; }

/* balance chip (click → add-credit) + mini action buttons */
.bal-chip { color: var(--gold); font-weight: 800; background: rgba(217,119,6,.12);
    padding: 5px 11px; border-radius: 20px; border: 1px solid rgba(217,119,6,.35);
    cursor: pointer; font-family: inherit; font-size: 12px; transition: .15s; }
.bal-chip:hover { background: var(--gold); color: #fff; }
.mini-btn { flex: 1; text-align: center; text-decoration: none; padding: 8px; border-radius: var(--radius);
    border: 1px solid var(--border-2); background: var(--bg-panel); color: var(--text-dim);
    font-weight: 700; font-size: 11.5px; transition: .15s; }
.mini-btn:hover { border-color: var(--accent); color: var(--accent); }
.mini-btn.danger:hover { border-color: var(--danger); color: var(--danger); }

/* add-credit modal methods */
.ac-method { border: 1px solid var(--border); border-radius: 12px; padding: 14px; margin-bottom: 12px; background: var(--bg-card); }
.ac-h { font-weight: 800; font-size: 13.5px; color: var(--text); margin-bottom: 4px; }
.ac-d { font-size: 12px; color: var(--text-mute); margin: 0 0 12px; line-height: 1.6; }
.ac-btn { display: block; text-align: center; text-decoration: none; padding: 10px; border-radius: 9px;
    background: var(--accent); color: #fff; font-weight: 800; font-size: 12.5px; transition: .15s; }
.ac-btn:hover { filter: brightness(1.08); }
.ac-btn.af { background: var(--success); }

/* ---------- Column 2: Center (Grid/Dashboard) ---------- */
.center-panel { flex: 1; display: flex; flex-direction: column; background: var(--bg-root); min-width: 0; }

.center-header {
    height: 70px; display: flex; align-items: center; justify-content: space-between;
    padding: 0 32px; background: var(--bg-root);
}
.center-title { font-size: 18px; font-weight: 700; color: var(--text); }

/* live server-status: compact summary in the header that expands into a list */
.srv-wrap { position: relative; }
.srv-head { display: flex; align-items: center; gap: 8px; }
.srv-summary { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 10px;
    border: 1px solid var(--border); background: var(--bg-panel); color: var(--text); font-family: inherit;
    font-size: 12px; font-weight: 700; cursor: pointer; transition: .15s; min-width: 0; max-width: 320px; }
.srv-summary #srvSummaryText { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* manual refresh — one click / 15s; disabled (dimmed) during cooldown */
.srv-refresh { flex-shrink: 0; width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center;
    border-radius: 10px; border: 1px solid var(--border); background: var(--bg-panel); color: var(--text-mute);
    cursor: pointer; transition: .15s; padding: 0; }
.srv-refresh svg { width: 15px; height: 15px; }
.srv-refresh:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.srv-refresh:disabled { opacity: .45; cursor: not-allowed; }
.srv-refresh.spin svg { animation: srv-spin .8s linear; }
@keyframes srv-spin { to { transform: rotate(360deg); } }
.srv-summary:hover { border-color: var(--accent); }
.srv-summary .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text-mute); flex-shrink: 0; }
.srv-summary.on .dot { background: var(--success); box-shadow: 0 0 8px var(--success); }
.srv-summary.down { border-color: rgba(239,68,68,.4); background: rgba(239,68,68,.06); color: var(--danger); cursor: pointer; }
.srv-summary.down .dot { background: var(--danger); }
.srv-summary.loading { color: var(--text-mute); }
.srv-caret { color: var(--text-mute); font-size: 10px; margin-inline-start: 2px; }
.srv-summary.down .srv-caret { display: none; }

.srv-drop { position: absolute; top: calc(100% + 6px); inset-inline-end: 0; inset-inline-start: auto; z-index: 60;
    width: 280px; max-width: 80vw; max-height: 320px; overflow-y: auto;
    background: var(--bg-panel); border: 1px solid var(--border); border-radius: 12px;
    box-shadow: 0 16px 40px -8px rgba(0,0,0,.28); padding: 6px; display: none; }
.srv-drop.show { display: block; }
.srv-item { display: flex; align-items: center; gap: 9px; padding: 9px 11px; border-radius: 8px; font-size: 12px; }
.srv-item:hover { background: var(--bg-card); }
.srv-item .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 6px var(--success); flex-shrink: 0; }
.srv-item.off .dot { background: var(--danger); box-shadow: none; }
.srv-item .nm { flex: 1; font-weight: 700; color: var(--text); }
.srv-item .sl { font-weight: 800; }
.srv-item.hi .sl { color: var(--success); } .srv-item.mid .sl { color: var(--warn); } .srv-item.low .sl { color: var(--danger); }

/* contact-admin modal rows */
.ct-row { display: flex; align-items: center; gap: 12px; padding: 13px 14px; border: 1px solid var(--border);
    border-radius: 12px; margin-bottom: 10px; background: var(--bg-card); text-decoration: none; color: var(--text); transition: .15s; }
.ct-row:hover { border-color: var(--accent); transform: translateY(-1px); }
.ct-ic { font-size: 20px; width: 26px; text-align: center; }
.ct-row b { font-size: 13px; } .ct-row .mini { color: var(--text-mute); }

.center-scroll { flex: 1; overflow-y: auto; padding: 0 32px 32px 32px; }

.info-section { margin-bottom: 24px; }
.info-section-title { font-size: 12px; color: var(--accent); font-weight: 800; text-transform: uppercase; margin-bottom: 12px; letter-spacing: 0.5px; }

.info-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.info-card {
    background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 16px; display: flex; flex-direction: column; gap: 6px; box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}
.info-card .lbl { font-size: 10px; color: var(--text-mute); text-transform: uppercase; font-weight: 700; letter-spacing: .3px; }
/* device values are technical codes → clean monospace (Latin digits, Yekan Bakh
   fallback for any Persian words); reads far better than the UI sans. */
.info-card .val { font-size: 13px; font-weight: 700; color: var(--text); word-break: break-word; letter-spacing: .2px;
    font-family: "LatinNum", "Cascadia Mono", "SF Mono", Consolas, "Yekan Bakh", ui-monospace, monospace; }

.center-footer { padding: 20px 32px; background: var(--bg-panel); border-top: 1px solid var(--border); }

.bb-meta { display: flex; justify-content: space-between; align-items: center; }
.bb-pct { font-size: 13px; font-weight: 800; color: var(--text-dim); flex-shrink: 0; }
.bb-track { flex: 1; height: 6px; background: var(--bg-inset); border-radius: 10px; overflow: hidden; }
.bb-fill { height: 100%; width: 0%; background: var(--accent); transition: width 0.3s ease; }

.bb-stop {
    width: 100px; padding: 10px; border-radius: var(--radius); border: none; flex-shrink: 0;
    background: rgba(239, 68, 68, 0.1); color: var(--danger); font-family: inherit;
    font-weight: 700; font-size: 12px; cursor: pointer; transition: 0.15s;
}
.bb-stop:hover:not(:disabled) { background: var(--danger); color: white; }
.bb-stop:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Column 3: Right Sidebar (Live Log) ---------- */
.sidebar-right {
    width: 380px; flex-shrink: 0; display: flex; flex-direction: column;
    background: var(--bg-panel); border-inline-start: 1px solid var(--border); z-index: 10;
}

.log-top {
    height: 70px; display: flex; align-items: center; justify-content: space-between;
    padding: 0 20px; border-bottom: 1px solid var(--border); position: relative;
}
.log-title { font-size: 12px; font-weight: 800; color: var(--text-mute); text-transform: uppercase; letter-spacing: 1px; }
.log-tools { display: flex; gap: 8px; position: relative; }

/* ---- settings dropdown (gear) with switch rows --------------------------- */
.menu-pop {
    position: absolute; top: calc(100% + 10px); inset-inline-end: 0; width: 264px;
    background: var(--bg-panel); border: 1px solid var(--border); border-radius: 14px;
    box-shadow: 0 16px 40px -8px rgba(0,0,0,.28); padding: 8px; z-index: 1000;
    opacity: 0; transform: translateY(-6px) scale(.98); pointer-events: none;
    transition: opacity .16s ease, transform .16s ease;
}
.menu-pop.show { opacity: 1; transform: none; pointer-events: auto; }
.menu-row {
    display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 12px;
    border-radius: 10px; cursor: pointer; border: none; background: none;
    font-family: inherit; text-align: start; transition: background .12s;
}
.menu-row:hover { background: var(--bg-card); }
.menu-row + .menu-row { margin-top: 2px; }
.menu-ic { font-size: 16px; width: 22px; text-align: center; flex-shrink: 0; }
.menu-dot { width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0; margin: 0 4px;
    background: conic-gradient(from 210deg, var(--accent), var(--success), var(--accent)); box-shadow: 0 0 0 3px var(--accent-soft); }
.menu-lbl { flex: 1; font-size: 12px; font-weight: 800; color: var(--text); text-transform: uppercase; letter-spacing: .3px; }
.menu-lbl b { color: var(--accent); font-weight: 800; }

/* on/off pill switch */
.sw { width: 44px; height: 24px; border-radius: 14px; background: var(--bg-inset);
    position: relative; flex-shrink: 0; transition: background .2s; border: 1px solid var(--border-2); }
.sw.on { background: var(--success); border-color: var(--success); }
.sw .sw-knob { position: absolute; top: 2px; inset-inline-start: 2px; width: 18px; height: 18px;
    border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.35); transition: inset-inline-start .2s ease; }
.sw.on .sw-knob { inset-inline-start: 22px; }
.tool-btn {
    width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border-2);
    background: var(--bg-panel); color: var(--text-dim); font-size: 14px; line-height: 1;
    cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
    transition: 0.15s; text-decoration: none; padding: 0; font-family: inherit;
}
.tool-btn:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }

/* ---- switch controls (theme + language) in the log toolbar --------------- */
.seg {
    display: inline-flex; align-items: center; height: 32px; border-radius: 8px;
    border: 1px solid var(--border-2); background: var(--bg-card); overflow: hidden; user-select: none;
}
.seg .seg-opt {
    padding: 0 10px; height: 100%; display: grid; place-items: center; cursor: pointer;
    font-size: 11px; font-weight: 800; color: var(--text-mute); transition: .15s; min-width: 30px;
}
.seg .seg-opt.active { background: var(--accent); color: #fff; }
.seg .seg-opt:not(.active):hover { color: var(--accent); }

.tswitch {
    position: relative; width: 56px; height: 32px; border-radius: 20px; cursor: pointer;
    border: 1px solid var(--border-2); background: var(--bg-card); flex-shrink: 0; padding: 0;
    transition: background .2s;
}
.tswitch .knob {
    position: absolute; top: 2px; inset-inline-start: 2px; width: 26px; height: 26px; border-radius: 50%;
    background: var(--bg-panel); box-shadow: 0 1px 3px rgba(0,0,0,.25); display: grid; place-items: center;
    font-size: 13px; transition: inset-inline-start .2s ease, transform .2s ease;
}
:root[data-theme="dark"] .tswitch { background: var(--accent-soft); }
:root[data-theme="dark"] .tswitch .knob { inset-inline-start: 28px; }

.log-box {
    /* The log keeps a stable LTR frame (timestamps always on the left); each
       message resolves its own direction from its content — see .log-msg. */
    flex: 1; overflow-y: auto; overflow-x: hidden; padding: 12px 20px;
    font-family: var(--sans); direction: ltr; text-align: start;
}

.log-line {
    display: flex; flex-direction: row; gap: 10px; padding: 6px 8px;
    color: var(--text); line-height: 1.5; border-bottom: 1px dashed var(--border-2);
    align-items: flex-start; transition: background 0.2s; border-radius: 4px;
    min-width: 0; direction: ltr;
}
.log-line:hover { background: var(--bg-root); }
.log-line:last-child { border-bottom: none; }
.log-time {
    color: var(--time); flex-shrink: 0; font-size: 10.5px;
    font-family: var(--mono); font-weight: 700; opacity: 0.85; padding-top: 1px;
    unicode-bidi: isolate;
}
.log-msg {
    font-size: 12px; font-weight: 600; word-break: break-word; font-family: var(--sans);
    white-space: pre-wrap; margin: 0; flex: 1; min-width: 0;
    /* mixed fa/en text orders correctly per line without garbling */
    unicode-bidi: plaintext;
}
/* device field lines: fixed label + value that ellipsises instead of overflowing */
.log-msg.kv { display: flex; gap: 8px; align-items: baseline; white-space: normal; unicode-bidi: normal; }
/* simple, plain project sans for the log fields (Latin digits via LatinNum) */
.log-k { color: var(--text-dim); font-weight: 700; white-space: nowrap; flex-shrink: 0; font-family: var(--sans); font-size: 12px; }
.log-v { color: var(--text); font-family: var(--sans); font-weight: 600; font-size: 12px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; unicode-bidi: plaintext; text-align: start; }

.log-box::-webkit-scrollbar { width: 6px; height: 6px; }
.log-box::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 8px; }

/* ---------- Bidirectional (fa + en) text isolation ----------
   Any element that can hold a mix of Persian and English (device values,
   toasts, server names, the balance chip) resolves its direction from its
   own content, so "سلام Dear رامین" is never reordered/garbled. */
.info-card .val, .toast, .srv-item .nm, .bal-chip, #uName,
.ct-row .mini, .ac-method .ac-d { unicode-bidi: plaintext; }

/* ---------- Modals, Popups & Toasts ---------- */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 100000;
    display: flex; justify-content: center; align-items: center; opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.modal-overlay.show { opacity: 1; pointer-events: auto; }
.modal-box {
    background: var(--bg-panel); width: 380px; max-width: calc(100vw - 24px); padding: 24px; border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.3); position: relative; transform: translateY(20px); transition: transform 0.2s;
    max-height: 90vh; overflow-y: auto;   /* long content (op details) scrolls */
}
.modal-overlay.show .modal-box { transform: translateY(0); }
/* keep the close button reachable while the modal body scrolls */
.modal-box > .pop-x { position: sticky; top: 0; float: inline-end; margin: -8px -8px 0 0; z-index: 2; }
.modal-actions { display: flex; flex-direction: column; gap: 12px; }

.pop {
    position: fixed; z-index: 10000; width: 400px; max-width: calc(100vw - 40px); max-height: calc(100vh - 60px); overflow: auto;
    background: var(--bg-panel); border: 1px solid var(--border); border-radius: 16px;
    box-shadow: 0 30px 60px -12px rgba(0,0,0,0.4); padding: 22px 24px 24px; display: none; left: 50%; top: 50%; transform: translate(-50%, -50%);
}
.pop.show { display: block; }
.pop-h { font-size: 16px; font-weight: 800; color: var(--accent); margin-bottom: 14px; padding-inline-end: 24px; }
.pop-l { font-size: 12.5px; color: var(--text-dim); line-height: 1.8; }
.pop-x { position: absolute; top: 14px; inset-inline-end: 14px; cursor: pointer; color: var(--text-mute); border: 0; background: var(--bg-card); width: 28px; height: 28px; border-radius: 50%; font-size: 15px; font-weight: 700; transition: .2s; display: grid; place-items: center; }
.pop-x:hover { color: #fff; background: var(--danger); }

/* structured help content */
.help-info { background: var(--accent-soft); border-inline-start: 3px solid var(--accent); border-radius: 8px;
    padding: 12px 14px; font-size: 12.5px; color: var(--text-dim); line-height: 1.75; margin-bottom: 16px; }
.help-info b { color: var(--text); }
.help-h { font-size: 13px; font-weight: 800; color: var(--text); text-transform: uppercase; letter-spacing: .4px; margin: 4px 0 10px; }
.help-steps { margin: 0 0 16px; padding-inline-start: 0; list-style: none; counter-reset: hs; display: flex; flex-direction: column; gap: 12px; }
.help-steps li { position: relative; padding-inline-start: 38px; font-size: 13px; color: var(--text-dim); line-height: 1.8; }
.help-steps li::before { counter-increment: hs; content: counter(hs); position: absolute; inset-inline-start: 0; top: 0;
    width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 800; font-size: 12px; display: grid; place-items: center; }
.help-steps b { color: var(--text); }
.help-ok { background: rgba(16,185,129,.12); color: var(--success); border-radius: 8px; padding: 11px 13px; font-size: 12.5px; line-height: 1.7; }
.help-ok b { color: var(--success); }
.help-warn { background: rgba(245,158,11,.14); color: var(--warn); border-radius: 8px; padding: 11px 13px; font-size: 12.5px; line-height: 1.7; }

#toasts { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 100002; display: flex; flex-direction: column; align-items: center; gap: 10px; width: 380px; max-width: calc(100vw - 32px); }
.toast { background: var(--bg-panel); border: 1px solid var(--border); border-inline-start: 5px solid var(--accent); border-radius: var(--radius); padding: 14px 16px; font-size: 13px; font-weight: 500; box-shadow: 0 4px 12px rgba(0,0,0,0.1); animation: sin 0.2s ease; color: var(--text); }
.toast.success { border-inline-start-color: var(--success); }
.toast.error { border-inline-start-color: var(--danger); }
.toast.out { opacity: 0; transform: translateY(-10px); transition: 0.25s; }
@keyframes sin { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }

/* ===== UI/UX polish ======================================================= */
/* refined focus rings */
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
    outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px;
}
/* service buttons: gentle lift + press */
.svc-btn { box-shadow: 0 1px 2px rgba(0,0,0,.03); }
.svc-btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 6px 16px -6px var(--accent-soft); }
.svc-btn:active:not(:disabled) { transform: translateY(0); }
.svc-btn.read:hover:not(:disabled)  { border-color: var(--success); }
.svc-btn.frp:hover:not(:disabled)   { border-color: var(--accent); }
.svc-btn.fdl:hover:not(:disabled)   { border-color: var(--gold); }
/* info cards: hover accent */
.info-card { transition: border-color .15s, box-shadow .15s, transform .15s; }
.info-card:hover { border-color: var(--border-2); box-shadow: 0 6px 18px -10px rgba(0,0,0,.18); }
.tool-btn:active { transform: scale(.94); }
.add-credit-btn { transition: .15s; }
.add-credit-btn:hover { transform: translateY(-1px); }
/* consistent thin scrollbars */
.sidebar-scroll, .center-scroll, .log-box {
    scrollbar-width: thin; scrollbar-color: var(--border-2) transparent;
}
.sidebar-scroll::-webkit-scrollbar, .center-scroll::-webkit-scrollbar { width: 8px; height: 8px; }
.sidebar-scroll::-webkit-scrollbar-thumb, .center-scroll::-webkit-scrollbar-thumb {
    background: var(--border-2); border-radius: 8px; border: 2px solid transparent; background-clip: content-box;
}
.status-pill { transition: .2s; }
.brand-name { letter-spacing: -0.02em; }
/* mobile chrome is hidden on desktop */
.hdr-mobile { display: none; }
.mobile-menu { display: none; }

/* ===== Mobile / responsive ================================================ */
@media (max-width: 900px) {
    html, body { height: auto; overflow-x: hidden; overflow-y: auto; width: 100%; }
    .app-layout { flex-direction: column; height: auto; width: 100%; overflow: visible; }
    .sidebar-left, .sidebar-right, .center-panel {
        width: 100%; flex-shrink: 1; border-inline: none; border-bottom: 1px solid var(--border);
    }
    /* order the whole page: brand + service buttons → live log → device cards */
    .sidebar-left  { order: 1; height: auto; }
    .sidebar-right { order: 2; min-height: 0; }
    .center-panel  { order: 3; min-width: 0; height: auto; }

    /* brand row: logo + name on the start, balance + hamburger on the end */
    .sidebar-header { padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
    .sidebar-header .brand { min-width: 0; }
    .brand-text { min-width: 0; overflow: hidden; }
    .brand-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .hdr-mobile { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
    .hamb { width: 40px; height: 40px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
        border-radius: 10px; border: 1px solid var(--border-2); background: var(--bg-card); color: var(--text); cursor: pointer; padding: 0; }
    .hamb svg { width: 20px; height: 20px; }
    .hamb:hover { border-color: var(--accent); color: var(--accent); }

    /* account menu (add credit / history / sign out) */
    .mobile-menu { display: none; flex-direction: column; gap: 4px; padding: 8px 16px 12px; border-bottom: 1px solid var(--border); }
    .mobile-menu.show { display: flex; }
    .mm-row { display: flex; align-items: center; gap: 10px; padding: 13px 14px; border-radius: 10px; text-decoration: none;
        border: 1px solid var(--border-2); background: var(--bg-card); color: var(--text); font-family: inherit;
        font-size: 14px; font-weight: 700; cursor: pointer; }
    .mm-row .mm-ic { width: 22px; text-align: center; flex-shrink: 0; font-size: 15px; }
    .mm-row:hover { border-color: var(--accent); color: var(--accent); }
    .mm-row.danger:hover { border-color: var(--danger); color: var(--danger); }

    /* hide desktop-only sidebar bits on mobile (moved into the menu / header) */
    .sidebar-footer { display: none; }
    .ad-banner { display: none; }

    .sidebar-scroll { padding: 14px 16px; overflow: visible; }
    .center-header { height: auto; padding: 14px 16px; flex-wrap: wrap; gap: 10px; }
    .srv-wrap { width: 100%; }
    .srv-summary { max-width: none; flex: 1; }
    .srv-drop { inset-inline-end: 0; width: 100%; max-width: none; }
    .center-scroll { padding: 0 16px 16px; overflow: visible; }
    .center-footer { padding: 14px 16px; }
    .log-top { height: 56px; padding: 0 16px; }
    .log-box { max-height: 320px; min-height: 200px; }
    .menu-pop { width: 240px; }
    /* keep device cards compact (2-up) instead of full-width blocks */
    .info-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
    .info-card { padding: 13px 14px; }
    .info-card .lbl { font-size: 10.5px; }
    .info-card .val { font-size: 13px; }
    .info-card#card-token { grid-column: 1 / -1; }   /* token stays full width */
    .section-label { margin-top: 4px; }
    .status-pill { font-size: 12px; }
    #toasts { width: calc(100vw - 24px); }
}
@media (max-width: 560px) {
    .center-title { font-size: 16px; }
    .brand-name { font-size: 15px; }
    .brand-sub { font-size: 10px; }
    .brand-logo { width: 26px; height: 26px; }
    .svc-btn { padding: 13px 14px; font-size: 13px; }
    .svc-btn .crd { font-size: 10.5px; }
    .log-tools { gap: 6px; }
    .log-msg, .log-time { font-size: 11.5px; }
    .modal-box, .pop { width: calc(100vw - 24px) !important; padding: 18px; }
    .center-footer { padding: 12px 16px; }
    .center-footer .bb-track { display: none; }
    .service-buttons { gap: 10px; }
    #emptyGridMsg { margin-top: 40px !important; font-size: 13px; }  /* 25% was huge on phones */
    .center-header .center-title { width: 100%; }   /* title on its own line, srv below */
    .bal-chip { max-width: 44vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
@media (max-width: 430px) {
    .info-grid { grid-template-columns: 1fr; }       /* single column only on tiny screens */
}
