:root {
    --bg: #0b0e14;
    --bg-soft: #101520;
    --surface: #141a26;
    --surface-2: #1b2232;
    --surface-hover: #212a3d;
    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.16);
    --text: #eef2f9;
    --text-dim: #9aa7bd;
    --text-muted: #66738a;

    --green: #22c55e;
    --green-soft: rgba(34, 197, 94, 0.15);
    --green-border: rgba(34, 197, 94, 0.42);

    --amber: #f59e0b;
    --amber-soft: rgba(245, 158, 11, 0.16);
    --amber-border: rgba(245, 158, 11, 0.42);

    --blue: #38bdf8;
    --blue-soft: rgba(56, 189, 248, 0.15);
    --blue-border: rgba(56, 189, 248, 0.42);

    --purple: #a78bfa;
    --purple-soft: rgba(167, 139, 250, 0.16);
    --purple-border: rgba(167, 139, 250, 0.42);

    --rose: #f43f5e;
    --rose-soft: rgba(244, 63, 94, 0.16);
    --rose-border: rgba(244, 63, 94, 0.44);

    --cyan: #22d3ee;
    --cyan-soft: rgba(34, 211, 238, 0.15);

    --radius: 10px;
    --radius-sm: 7px;
    --sidebar-w: 236px;
    --topbar-h: 54px;
    --tabbar-h: 60px;
    --font-sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
    --font-mono: ui-monospace, "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 13.5px;
    line-height: 1.4;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

.num, .stat-val, td, input[type="number"] {
    font-variant-numeric: tabular-nums;
}

/* Scrollbars */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.12); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.22); }

/* SVG Icons */
.ico { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; display: inline-block; vertical-align: middle; }
.ico-sm { width: 14px; height: 14px; }
.ico-xs { width: 12px; height: 12px; }

/* ===================== APP SHELL ===================== */
.app-shell {
    display: flex;
    height: 100vh;
    height: 100dvh;
    width: 100%;
    overflow: hidden;
}

.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-soft);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 30;
    user-select: none;
}

.brand-bar {
    height: var(--topbar-h);
    padding: 0 16px;
    display: flex;
    align-items: center;
    gap: 11px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.brand-logo {
    width: 34px;
    height: 34px;
    object-fit: contain;
    flex-shrink: 0;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.55));
}

.brand-meta { display: flex; flex-direction: column; min-width: 0; }
.brand-title { font-weight: 800; font-size: 14.5px; letter-spacing: 0.08em; color: var(--text); line-height: 1.1; }
.brand-sub { font-size: 10.5px; color: var(--green); font-weight: 600; letter-spacing: 0.04em; margin-top: 2px; }

.nav-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 12px 10px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.nav-group-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 0 10px 4px;
}

.nav-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    color: var(--text-dim);
    cursor: pointer;
    font-weight: 500;
    font-size: 13px;
    transition: background 0.15s, color 0.15s;
}

.nav-item:hover { background: rgba(255, 255, 255, 0.045); color: var(--text); }
.nav-item.active {
    background: var(--green-soft);
    color: var(--green);
    font-weight: 600;
    box-shadow: inset 2px 0 0 var(--green);
}
.nav-item .nav-text { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.nav-badge {
    background: var(--rose);
    color: #fff;
    font-size: 10.5px;
    font-weight: 800;
    padding: 1px 6px;
    border-radius: 99px;
    line-height: 1.3;
    min-width: 18px;
    text-align: center;
}

.sidebar-footer {
    padding: 12px 14px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.user-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 8px var(--green);
    flex-shrink: 0;
}

.user-name {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Main Column */
.content-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

.topbar {
    height: var(--topbar-h);
    padding: 0 22px;
    background: rgba(16, 21, 32, 0.88);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-shrink: 0;
    z-index: 25;
}

.topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.mobile-brand { display: none; align-items: center; gap: 8px; }
.mobile-brand img { width: 28px; height: 28px; object-fit: contain; }
.topbar-title {
    margin: 0;
    font-size: 15.5px;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.topbar-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; position: relative; }

/* Proxy Pill & Popover */
.proxy-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 5px 11px;
    border-radius: 99px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.proxy-pill:hover { border-color: var(--border-strong); background: var(--surface-2); }
.proxy-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 7px var(--green); }
.proxy-pill.direct .dot { background: var(--amber); box-shadow: 0 0 7px var(--amber); }
.proxy-pill.warn .dot { background: var(--rose); box-shadow: 0 0 7px var(--rose); }

.proxy-popover {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 310px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    box-shadow: 0 18px 42px rgba(0, 0, 0, 0.65);
    padding: 12px;
    display: none;
    flex-direction: column;
    gap: 10px;
    z-index: 200;
}
.proxy-popover.open { display: flex; }

.proxy-pop-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 9px;
    border-bottom: 1px solid var(--border);
}

.proxy-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
    max-height: 260px;
    overflow-y: auto;
}

.proxy-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 6px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    font-size: 12px;
}

.proxy-host {
    display: flex;
    align-items: center;
    gap: 7px;
    font-family: var(--font-mono);
    font-size: 11.5px;
    color: var(--text);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.proxy-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.proxy-dot.ok { background: var(--green); box-shadow: 0 0 6px var(--green); }
.proxy-dot.err { background: var(--rose); box-shadow: 0 0 6px var(--rose); }
.proxy-dot.wait { background: var(--amber); }

/* Main Scrollable Area */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 18px 22px 28px;
}

.section { display: none; }
.section.active { display: block; }

/* ===================== COMMON UI ===================== */
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 15px 16px;
    margin-bottom: 16px;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    padding-bottom: 10px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.panel-title {
    margin: 0;
    font-size: 13.5px;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 7px;
}

.section-subhead {
    font-size: 12.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dim);
    margin: 18px 0 10px;
    display: flex;
    align-items: center;
    gap: 7px;
}
.section-subhead:first-child { margin-top: 0; }

/* Buttons */
button, .btn {
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    padding: 6px 12px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background 0.15s, border-color 0.15s, color 0.15s, opacity 0.15s;
    white-space: nowrap;
}
button:hover:not(:disabled) { background: var(--surface-hover); border-color: var(--border-strong); }
button:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary, .btn-green {
    background: var(--green-soft);
    border-color: var(--green-border);
    color: #4ade80;
}
.btn-primary:hover:not(:disabled), .btn-green:hover:not(:disabled) {
    background: rgba(34, 197, 94, 0.25);
    border-color: var(--green);
}

.btn-solid-green {
    background: var(--green);
    border-color: var(--green);
    color: #07140c;
    font-weight: 700;
}
.btn-solid-green:hover:not(:disabled) { filter: brightness(1.08); background: var(--green); }

.btn-blue {
    background: var(--blue-soft);
    border-color: var(--blue-border);
    color: var(--blue);
}
.btn-blue:hover:not(:disabled) { background: rgba(56, 189, 248, 0.24); border-color: var(--blue); }

.btn-amber {
    background: var(--amber-soft);
    border-color: var(--amber-border);
    color: #fbbf24;
}
.btn-amber:hover:not(:disabled) { background: rgba(245, 158, 11, 0.25); border-color: var(--amber); }

.btn-purple {
    background: var(--purple-soft);
    border-color: var(--purple-border);
    color: #c4b5fd;
}
.btn-purple:hover:not(:disabled) { background: rgba(167, 139, 250, 0.25); border-color: var(--purple); }

.btn-red, .btn-danger {
    background: var(--rose-soft);
    border-color: var(--rose-border);
    color: #fb7185;
}
.btn-red:hover:not(:disabled), .btn-danger:hover:not(:disabled) {
    background: rgba(244, 63, 94, 0.26);
    border-color: var(--rose);
}

.btn-ghost {
    background: transparent;
    border-color: transparent;
    color: var(--text-dim);
    padding: 5px 8px;
}
.btn-ghost:hover:not(:disabled) { background: rgba(255, 255, 255, 0.06); color: var(--text); border-color: transparent; }

.btn-sm { padding: 4px 9px; font-size: 11.5px; }
.btn-xs { padding: 3px 7px; font-size: 11px; }
.btn-icon { padding: 5px; width: 28px; height: 28px; background: transparent; border-color: var(--border); color: var(--text-dim); }
.btn-icon:hover:not(:disabled) { color: var(--text); background: var(--surface-hover); }

.back-btn {
    background: transparent;
    border: none;
    color: var(--blue);
    padding: 0;
    margin-bottom: 12px;
    font-size: 13px;
    font-weight: 600;
}
.back-btn:hover { background: transparent; color: #7dd3fc; }

/* Inputs & Selects */
input[type="text"], input[type="password"], input[type="number"], input[type="datetime-local"], select {
    font-family: inherit;
    font-size: 12.5px;
    background: var(--bg-soft);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    outline: none;
    transition: border-color 0.15s;
}
input:focus, select:focus { border-color: var(--green); }
input:disabled, select:disabled { opacity: 0.45; cursor: not-allowed; }

.search-wrap {
    position: relative;
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 180px;
    max-width: 300px;
}
.search-wrap .ico { position: absolute; left: 9px; color: var(--text-muted); pointer-events: none; }
.search-wrap input { width: 100%; padding-left: 30px; }

/* Switches */
.switch {
    position: relative;
    display: inline-block;
    width: 32px;
    height: 18px;
    flex-shrink: 0;
    cursor: pointer;
}
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.slider {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.14);
    border-radius: 99px;
    transition: background 0.2s;
}
.slider:before {
    content: "";
    position: absolute;
    width: 12px;
    height: 12px;
    left: 3px;
    top: 3px;
    border-radius: 50%;
    background: #cbd5e1;
    transition: transform 0.2s, background 0.2s;
}
.switch input:checked + .slider { background: var(--green); }
.switch input:checked + .slider:before { transform: translateX(14px); background: #07140c; }

.switch-st {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    font-size: 12.5px;
    color: var(--text);
}
.switch-st input { opacity: 0; width: 0; height: 0; position: absolute; }
.slider-st {
    position: relative;
    width: 32px;
    height: 18px;
    border-radius: 99px;
    background: rgba(255, 255, 255, 0.13);
    border: 1px solid rgba(255, 255, 255, 0.12);
    transition: background 0.2s, border-color 0.2s;
    flex-shrink: 0;
}
.slider-st:before {
    content: "";
    position: absolute;
    width: 12px;
    height: 12px;
    left: 2px;
    top: 2px;
    border-radius: 50%;
    background: #94a3b8;
    transition: transform 0.2s, background 0.2s;
}
.switch-st input:checked + .slider-st {
    background: var(--green);
    border-color: var(--green);
}
.switch-st input:checked + .slider-st:before {
    transform: translateX(14px);
    background: #07140c;
}

/* Badges & Pills */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 7px;
    border-radius: 99px;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.3;
    white-space: nowrap;
}
.badge-green { background: var(--green-soft); color: #4ade80; border: 1px solid var(--green-border); }
.badge-amber { background: var(--amber-soft); color: #fbbf24; border: 1px solid var(--amber-border); }
.badge-blue { background: var(--blue-soft); color: var(--blue); border: 1px solid var(--blue-border); }
.badge-purple { background: var(--purple-soft); color: #c4b5fd; border: 1px solid var(--purple-border); }
.badge-rose { background: var(--rose-soft); color: #fb7185; border: 1px solid var(--rose-border); }
.badge-muted { background: rgba(255, 255, 255, 0.06); color: var(--text-dim); border: 1px solid var(--border); }

.vip-badge {
    background: linear-gradient(135deg, #f59e0b, #fb923c);
    color: #111;
    font-size: 9.5px;
    font-weight: 900;
    padding: 1px 5px;
    border-radius: 4px;
    letter-spacing: 0.04em;
    line-height: 1.25;
}

.bag-warn-badge {
    background: var(--rose-soft);
    color: #fb7185;
    border: 1px solid var(--rose-border);
    font-size: 9.5px;
    font-weight: 800;
    padding: 1px 5px;
    border-radius: 4px;
    line-height: 1.25;
}

/* Filter Chips & Tabs */
.chips-row, .seg-tabs {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.chip, .tab-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-dim);
    padding: 5px 11px;
    border-radius: 99px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}
.chip:hover, .tab-btn:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface-2); }
.chip.active, .tab-btn.active {
    background: var(--green-soft);
    border-color: var(--green-border);
    color: #4ade80;
}

.seg-control {
    display: inline-flex;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 2px;
    gap: 2px;
}
.seg-btn {
    border: none;
    background: transparent;
    color: var(--text-dim);
    padding: 5px 11px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 5px;
}
.seg-btn:hover { background: rgba(255, 255, 255, 0.05); color: var(--text); border: none; }
.seg-btn.active { background: var(--surface-2); color: #4ade80; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35); }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* Tables */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
    text-align: left;
}
.data-table th {
    padding: 8px 10px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    background: var(--bg-soft);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.data-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: rgba(255, 255, 255, 0.025); }
.data-table .tr-center { text-align: center; }
.data-table .tr-right { text-align: right; }

/* Progress Bars */
.bar-wrap {
    position: relative;
    width: 100%;
    height: 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 5px;
    overflow: hidden;
}
.bar-fill-xp {
    height: 100%;
    background: linear-gradient(90deg, #16a34a, #22c55e, #4ade80);
    transition: width 0.35s ease;
}
.bar-fill-job {
    height: 100%;
    background: linear-gradient(90deg, #0284c7, #38bdf8);
    transition: width 0.35s ease;
}
.bar-text {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10.5px;
    font-weight: 700;
    color: #f8fafc;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 4px;
}

/* Status Colors */
.status-ok { color: #4ade80; }
.status-pause { color: #fbbf24; }
.status-err { color: #fb7185; }
.text-green { color: #4ade80; }
.text-amber { color: #fbbf24; }
.text-blue { color: var(--blue); }
.text-purple { color: #c4b5fd; }
.text-rose { color: #fb7185; }
.text-cyan { color: var(--cyan); }
.text-dim { color: var(--text-dim); }
.text-muted { color: var(--text-muted); }

/* ===================== ACCOUNTS (ОВОЩИ) ===================== */
.accounts-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 7px;
    flex-wrap: wrap;
}

.accounts-filterbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 14px;
    padding: 9px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

/* Desktop Grid */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(192px, 1fr));
    gap: 10px;
    align-items: stretch;
}

.acc-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: border-color 0.15s, transform 0.12s, opacity 0.2s;
}
.acc-card:hover { border-color: var(--border-strong); }
.acc-card.inactive { opacity: 0.5; filter: saturate(0.4); }
.acc-card.has-warn { border-color: var(--rose-border); }

.acc-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 6px;
}

.acc-name-wrap { min-width: 0; flex: 1; }
.acc-name {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    line-height: 1.25;
    word-break: break-word;
}
.acc-name:hover { color: var(--blue); }
.acc-id { font-size: 10.5px; color: var(--text-muted); font-family: var(--font-mono); margin-top: 2px; display: block; }

.acc-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }

.acc-status-line {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11.5px;
    font-weight: 600;
    padding: 4px 7px;
    border-radius: 6px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.acc-status-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }

.acc-metrics {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
}

.metric-cell {
    background: var(--bg-soft);
    border-radius: 6px;
    padding: 5px 7px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
    min-width: 0;
}
.metric-cell .m-lbl { font-size: 10.5px; color: var(--text-muted); font-weight: 600; display: inline-flex; align-items: center; gap: 3px; }
.metric-cell .m-val { font-size: 12px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.acc-card-foot { display: flex; flex-direction: column; gap: 5px; margin-top: auto; }
.acc-xp-row { display: flex; align-items: center; gap: 6px; }
.acc-bonus-tag {
    font-size: 10.5px;
    font-weight: 700;
    color: #4ade80;
    background: var(--green-soft);
    border: 1px solid var(--green-border);
    border-radius: 5px;
    padding: 1px 5px;
    white-space: nowrap;
}

/* Add Account Card */
.add-card {
    border: 1px dashed var(--border-strong);
    background: rgba(255, 255, 255, 0.015);
    justify-content: center;
    align-items: stretch;
    text-align: center;
    padding: 12px;
    gap: 8px;
}
.add-card-title { font-size: 12.5px; font-weight: 700; color: #4ade80; display: flex; align-items: center; justify-content: center; gap: 5px; }

/* Mobile List Rows (hidden on desktop, shown on <= 820px) */
.accounts-mobile-list { display: none; flex-direction: column; gap: 7px; }
.acc-row-mobile {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 7px;
}
.acc-row-mobile.inactive { opacity: 0.52; }
.acc-row-mobile.has-warn { border-color: var(--rose-border); }
.acc-row-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.acc-row-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}
.acc-row-stat {
    background: var(--bg-soft);
    border-radius: 6px;
    padding: 4px 6px;
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.acc-row-stat span:first-child { font-size: 9.5px; color: var(--text-muted); text-transform: uppercase; font-weight: 700; }
.acc-row-stat span:last-child { font-size: 12px; font-weight: 700; }

/* Logs Panel */
.logs-panel { margin-top: 18px; }
.logs-box {
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 11px 13px;
    height: 310px;
    overflow-y: auto;
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.55;
}
.log-entry, .cw-log-entry { margin-bottom: 4px; word-break: break-word; }
.log-time, .cw-time { color: var(--text-muted); margin-right: 6px; }
.log-user, .cw-player { color: var(--blue); font-weight: 700; margin-right: 5px; }
.cw-clan { color: #c4b5fd; font-weight: 700; margin-right: 5px; }
.log-action, .cw-action { color: var(--text); }

/* ===================== PROFILE ===================== */
.profile-header {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 14px;
    display: flex;
    flex-direction: column;
    gap: 11px;
}

.profile-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.profile-title-block { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.profile-name { margin: 0; font-size: 18px; font-weight: 800; color: var(--text); }
.profile-meta-strip {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 12px;
}
.meta-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 6px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    color: var(--text-dim);
}

.profile-switches-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

.pill-switch {
    background: var(--bg-soft);
    border: 1px solid var(--border);
    padding: 5px 10px;
    border-radius: var(--radius-sm);
}

/* Profile Overview 2-col */
.profile-overview-grid {
    display: grid;
    grid-template-columns: minmax(320px, 0.95fr) minmax(420px, 1.35fr);
    gap: 14px;
    align-items: start;
}

/* Profile Settings 2-col Bento */
.profile-settings-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    align-items: start;
}
.span-full { grid-column: 1 / -1; }

.profile-mobile-subtabs { display: none; margin-bottom: 12px; overflow-x: auto; padding-bottom: 2px; }

/* Arena inside Profile */
.arena-inner-grid {
    display: grid;
    grid-template-columns: 0.85fr 1.15fr;
    gap: 12px;
}
.sub-box {
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 11px 12px;
}
.sub-box-title { font-size: 11.5px; font-weight: 700; color: var(--blue); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 9px; }

.arena-lim-row {
    display: grid;
    grid-template-columns: 1fr 78px auto;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
}
.arena-lim-row input { width: 100%; text-align: center; padding: 4px 6px; font-weight: 700; }
.arena-my-val { font-size: 11.5px; color: var(--text-muted); white-space: nowrap; }

/* Trips & Autoquests Compact */
.trip-mode-bar { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.trip-radio-card {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 9px 11px;
    border-radius: var(--radius-sm);
    background: var(--bg-soft);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.trip-radio-card:has(input:checked) { border-color: var(--green-border); background: var(--green-soft); }
.trip-radio-card input { margin-top: 2px; accent-color: var(--green); }

.meat-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    padding: 9px 11px;
    border-radius: var(--radius-sm);
    background: var(--bg-soft);
    border: 1px solid var(--border);
}

.quest-opts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.quest-opt-card {
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
}

/* Matrix Wardrobe (Переодевалка) */
.equip-matrix-wrap {
    max-height: 420px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-soft);
}
.equip-matrix { width: 100%; border-collapse: collapse; font-size: 12px; }
.equip-matrix th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--surface-2);
    padding: 7px 10px;
    font-size: 11px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border);
}
.equip-matrix td {
    padding: 6px 10px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.equip-matrix select { width: 100%; padding: 4px 8px; font-size: 12px; }
.equip-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-muted);
    display: inline-block;
    margin-right: 6px;
}
.equip-dot.active { background: var(--green); box-shadow: 0 0 6px var(--green); }

/* ===================== CLANS & WARS ===================== */
.clans-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
    gap: 12px;
}

.clan-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 13px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.clan-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}
.clan-card-name { font-weight: 700; font-size: 14px; color: #4ade80; }
.clan-kv { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-dim); gap: 8px; }
.clan-kv b { color: var(--text); }

.cw-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 16px; }
.cw-col { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }

/* ===================== TREASURY ACCORDIONS ===================== */
.treasury-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(460px, 1fr));
    gap: 10px;
    align-items: start;
}

.tr-acc {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.tr-acc.low-gold { border-color: var(--rose-border); }

.tr-acc-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 11px 14px;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
}
.tr-acc-head:hover { background: rgba(255, 255, 255, 0.025); }

.tr-acc-left { display: flex; align-items: center; gap: 9px; min-width: 0; }
.tr-chevron { transition: transform 0.2s; color: var(--text-muted); }
.tr-acc.open .tr-chevron { transform: rotate(90deg); color: var(--text); }

.tr-acc-body {
    display: none;
    padding: 0 14px 12px;
    border-top: 1px solid var(--border);
}
.tr-acc.open .tr-acc-body { display: block; }

.tr-member-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 7px 0;
    border-bottom: 1px solid var(--border);
    font-size: 12.5px;
}
.tr-member-row:last-child { border-bottom: none; }

/* ===================== STORAGE (СКЛАД ПОГОН) ===================== */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}
.kpi-card {
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.kpi-card.highlight { border-color: var(--blue-border); background: rgba(56, 189, 248, 0.07); }
.kpi-label { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); }
.kpi-val { font-size: 20px; font-weight: 800; line-height: 1.15; }

.storage-ops-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
    gap: 14px;
    margin-bottom: 16px;
    align-items: stretch;
}

.queue-box {
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px;
    min-height: 105px;
    max-height: 290px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.donors-box {
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px;
    height: 185px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* ===================== SETTINGS & USERS ===================== */
.settings-toggles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(195px, 1fr));
    gap: 9px;
    margin-bottom: 16px;
}
.toggle-tile {
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
}

.users-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr);
    gap: 14px;
    align-items: start;
}

.check-grid {
    max-height: 320px;
    overflow-y: auto;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 6px;
}
.check-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
}
.check-item input { accent-color: var(--green); }

/* ===================== MODALS, OVERLAYS & TOAST ===================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(4, 6, 10, 0.78);
    backdrop-filter: blur(4px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 16px;
}
.modal-content {
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: 12px;
    width: 100%;
    max-width: 420px;
    padding: 18px;
    box-shadow: 0 22px 60px rgba(0, 0, 0, 0.7);
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 12px;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--border);
}

#login-overlay {
    position: fixed;
    inset: 0;
    background: radial-gradient(circle at top, #131c2b 0%, var(--bg) 65%);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}
.login-card {
    width: 100%;
    max-width: 360px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: 14px;
    padding: 26px 24px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}
.login-logo { width: 84px; height: 84px; object-fit: contain; filter: drop-shadow(0 6px 18px rgba(0, 0, 0, 0.6)); }

#ban-overlay {
    position: fixed;
    inset: 0;
    background: #08090d;
    z-index: 10000;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 28px;
}

/* Auto-save Toast */
.toast {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 2500;
    background: var(--surface-2);
    border: 1px solid var(--green-border);
    color: var(--text);
    padding: 9px 14px;
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.err { border-color: var(--rose-border); color: #fb7185; }

/* ===================== MOBILE TAB BAR & SHEET (iPhone) ===================== */
.mobile-tabbar {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: rgba(14, 19, 29, 0.96);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--border);
    z-index: 80;
    grid-template-columns: repeat(5, 1fr);
}

.tabbar-item {
    border: none;
    background: transparent;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    font-size: 10px;
    font-weight: 600;
    padding: 6px 2px;
    border-radius: 0;
    position: relative;
}
.tabbar-item:hover { background: transparent; color: var(--text-dim); border: none; }
.tabbar-item.active { color: var(--green); }
.tabbar-badge {
    position: absolute;
    top: 5px;
    right: calc(50% - 17px);
    background: var(--rose);
    color: #fff;
    font-size: 9px;
    font-weight: 800;
    padding: 0 4px;
    border-radius: 99px;
    line-height: 14px;
    min-width: 14px;
}

.sheet-overlay {
    position: fixed;
    inset: 0;
    background: rgba(4, 6, 10, 0.72);
    z-index: 120;
    display: none;
    align-items: flex-end;
}
.sheet-overlay.open { display: flex; }

.sheet-panel {
    width: 100%;
    background: var(--surface);
    border-top: 1px solid var(--border-strong);
    border-radius: 16px 16px 0 0;
    padding: 12px 16px calc(20px + env(safe-area-inset-bottom, 0px));
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.sheet-handle {
    width: 38px;
    height: 4px;
    border-radius: 99px;
    background: rgba(255, 255, 255, 0.2);
    margin: 0 auto 8px;
}
.sheet-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 11px 12px;
    border-radius: var(--radius-sm);
    background: var(--bg-soft);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
}
.sheet-item-left { display: flex; align-items: center; gap: 10px; }

/* ===================== RESPONSIVE (iPhone / Mobile <= 820px) ===================== */
@media (max-width: 820px) {
    .sidebar { display: none; }
    .mobile-brand { display: flex; }
    .topbar {
        padding: 0 12px;
        padding-top: env(safe-area-inset-top, 0px);
        height: calc(52px + env(safe-area-inset-top, 0px));
    }
    .topbar-title { font-size: 14px; }
    .main-content {
        padding: 12px 12px calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 18px);
    }
    .mobile-tabbar { display: grid; }
    .toast {
        left: 12px;
        right: 12px;
        bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 10px);
        justify-content: center;
    }

    /* На телефоне: только список, сетку скрываем */
    #accounts-desktop-grid { display: none !important; }
    #accounts-mobile-list { display: flex !important; }

    .accounts-toolbar { gap: 6px; }
    .accounts-filterbar { padding: 8px 10px; }
    .search-wrap { max-width: none; width: 100%; }

    .profile-overview-grid,
    .profile-settings-grid,
    .arena-inner-grid,
    .storage-ops-grid,
    .cw-cols,
    .users-layout,
    .treasury-list,
    .trip-mode-bar,
    .quest-opts-grid {
        grid-template-columns: 1fr;
    }

    /* Подвкладки внутри настроек профиля на iPhone */
    .profile-mobile-subtabs { display: flex; gap: 6px; }
    .prof-mod-card { display: none; }
    .prof-mod-card.mob-active { display: block; }

    .proxy-popover { width: calc(100vw - 24px); right: -4px; }
    .clans-grid { grid-template-columns: 1fr; }
    .tr-member-row { flex-wrap: wrap; }
}
.log-gold { color: #fbbf24; font-weight: 700; }
.log-xp { color: #4ade80; font-weight: 700; }
