/* ============================================================
   VPN Dashboard — Professional Admin UI
   ============================================================ */

:root {
    --bg:          #07111f;
    --bg2:         #0b1728;
    --surface:     #0f1e32;
    --surface2:    #162540;
    --surface3:    #1c2f50;
    --border:      rgba(255,255,255,0.07);
    --border2:     rgba(255,255,255,0.12);
    --text:        #e8f0fe;
    --text2:       #8899b4;
    --text3:       #4a5f7a;
    --accent:      #3b82f6;
    --accent-dim:  rgba(59,130,246,0.15);
    --green:       #22c55e;
    --green-dim:   rgba(34,197,94,0.14);
    --amber:       #f59e0b;
    --amber-dim:   rgba(245,158,11,0.14);
    --red:         #ef4444;
    --red-dim:     rgba(239,68,68,0.14);
    --purple:      #a78bfa;
    --purple-dim:  rgba(167,139,250,0.14);
    --teal:        #2dd4bf;
    --teal-dim:    rgba(45,212,191,0.14);
    --r:           10px;
    --r-lg:        14px;
    --r-xl:        18px;
    --shadow:      0 8px 32px rgba(0,0,0,0.45);
    --shadow-lg:   0 16px 56px rgba(0,0,0,0.6);
}

/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    min-height: 100vh;
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

button,
select,
input,
textarea,
a {
    max-width: 100%;
}

button,
a[class*="btn"],
.client-tab,
.chip {
    touch-action: manipulation;
}

.hidden { display: none !important; }

.toast-host {
    position: fixed;
    right: 18px;
    top: 78px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: min(380px, calc(100vw - 32px));
    pointer-events: none;
}

.toast {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border2);
    border-left: 3px solid var(--accent);
    border-radius: var(--r);
    padding: 10px 12px;
    box-shadow: var(--shadow);
    font-size: 13px;
    line-height: 1.35;
    opacity: 0.98;
    transform: translateY(0);
    transition: opacity 0.18s, transform 0.18s;
}

.toast-error { border-left-color: var(--red); }
.toast-hide {
    opacity: 0;
    transform: translateY(-6px);
}

/* ============================================================
   LAYOUT
   ============================================================ */
.app-wrap {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ============================================================
   HEADER
   ============================================================ */
.app-header {
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    padding: 0 28px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-brand-icon {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: linear-gradient(135deg, var(--accent), #6366f1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.header-brand-name {
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.3px;
}

.header-brand-sub {
    font-size: 11px;
    color: var(--text2);
    font-weight: 400;
    margin-top: 1px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.header-chat-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 34px;
    padding: 6px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.15;
    white-space: nowrap;
}

.header-chat-link:hover {
    background: var(--surface2);
    border-color: var(--border2);
}

.chat-unread-badge {
    display: none;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 1px 6px;
    background: var(--red);
    color: #fff;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
}

.username {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--text2);
    background: var(--surface);
    padding: 5px 12px;
    border-radius: 999px;
    border: 1px solid var(--border);
}

.btn-logout {
    padding: 6px 16px;
    background: transparent;
    color: var(--text2);
    border: 1px solid var(--border2);
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.15s;
    font-family: inherit;
}

.btn-logout:hover {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border2);
}

/* ============================================================
   STATS KPI BAR
   ============================================================ */
.stats-bar {
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    padding: 16px 28px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
}

.telegram-default-card {
    margin-top: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 12px 16px;
}

.telegram-default-title {
    color: var(--text);
    font-size: 14px;
    font-weight: 700;
}

.telegram-default-sub {
    margin-top: 3px;
    color: var(--text2);
    font-size: 12px;
}

.telegram-default-select {
    min-width: 250px;
    max-width: 100%;
    background: var(--bg2);
    border: 1px solid var(--border2);
    color: var(--text);
    border-radius: 8px;
    padding: 10px 12px;
    font: inherit;
    font-size: 13px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 14px 16px;
    cursor: default;
    transition: transform 0.15s, box-shadow 0.15s;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: var(--accent);
    opacity: 0;
    transition: opacity 0.15s;
}

.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-card:hover::before { opacity: 1; }
.stat-clickable { cursor: pointer; }
.stat-clickable:hover { border-color: rgba(59,130,246,.55); }
.stat-note {
    margin-top: 8px;
    color: var(--text2);
    font-size: 12px;
}

.stat-card.success::before { background: var(--green); }
.stat-card.warning::before { background: var(--amber); }
.stat-card.danger::before  { background: var(--red); }
.stat-card.info::before    { background: var(--accent); }

.stat-value {
    font-size: 26px;
    font-weight: 700;
    line-height: 1.1;
    color: var(--text);
    letter-spacing: -0.5px;
}

.stat-card.success .stat-value { color: var(--green); }
.stat-card.warning .stat-value { color: var(--amber); }
.stat-card.danger  .stat-value { color: var(--red); }
.stat-card.info    .stat-value { color: var(--accent); }

.stat-label {
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text2);
    margin-top: 6px;
}

.stat-meta {
    font-size: 11px;
    color: var(--text3);
    margin-top: 4px;
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.app-main {
    flex: 1;
    padding: 20px 18px 40px;
    max-width: none;
    width: 100%;
    margin: 0;
}

/* ============================================================
   TOOLBAR
   ============================================================ */
.toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.clients-toolbar {
    margin: 0;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    background: rgba(7,17,31,.42);
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    flex-wrap: wrap;
}

.toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.search-wrap {
    position: relative;
    flex: 1;
    min-width: 200px;
    max-width: 320px;
}

.search-icon {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text3);
    pointer-events: none;
    font-size: 14px;
}

#search {
    width: 100%;
    padding: 8px 12px 8px 34px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
    transition: border-color 0.15s;
}

#search:focus {
    outline: none;
    border-color: var(--accent);
}

#search::placeholder { color: var(--text3); }

.toolbar select {
    padding: 8px 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    color: var(--text2);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    transition: border-color 0.15s;
}

.toolbar select:focus { outline: none; border-color: var(--accent); }

.toolbar-sep {
    width: 1px;
    height: 28px;
    background: var(--border);
    flex-shrink: 0;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn-primary, .btn-secondary, .btn-export, .btn-danger-outline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 36px;
    padding: 8px 16px;
    border-radius: var(--r);
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s;
    white-space: nowrap;
    text-align: center;
    line-height: 1.2;
    text-decoration: none;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.btn-primary:hover { background: #2563eb; border-color: #2563eb; }

.btn-secondary {
    background: var(--surface2);
    color: var(--text);
    border-color: var(--border2);
}

.btn-secondary:hover { background: var(--surface3); }

.btn-export {
    background: var(--surface);
    color: var(--text2);
    border-color: var(--border);
}

.btn-export:hover { background: var(--surface2); color: var(--text); }

.btn-danger-outline {
    background: transparent;
    color: var(--red);
    border-color: var(--red);
}

.btn-danger-outline:hover { background: var(--red-dim); }

/* Small action buttons in table */
.btn-sm {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 28px;
    padding: 4px 8px;
    border-radius: 7px;
    font-size: 11px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    border: 1px solid var(--border);
    background: var(--surface2);
    color: var(--text2);
    transition: all 0.12s;
    white-space: nowrap;
    text-align: center;
    line-height: 1.2;
    text-decoration: none;
}

.btn-sm:hover { background: var(--surface3); color: var(--text); border-color: var(--border2); }

.btn-sm.success {
    background: var(--green-dim);
    color: var(--green);
    border-color: rgba(34,197,94,0.3);
}

.btn-sm.success:hover { background: rgba(34,197,94,0.22); }

.btn-sm.danger {
    background: var(--red-dim);
    color: var(--red);
    border-color: rgba(239,68,68,0.3);
}

.btn-sm.danger:hover { background: rgba(239,68,68,0.22); }

/* ============================================================
   CHARTS
   ============================================================ */
.chart-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    padding: 18px 20px 14px;
    margin-bottom: 16px;
}

.chart-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.chart-title h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    margin: 0;
}

.chart-meta {
    font-size: 11px;
    color: var(--text3);
    margin-top: 3px;
}

.chart-actions {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

.chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--bg2);
    border: 1px solid var(--border);
    color: var(--text2);
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.12s;
    font-family: inherit;
}

.chip:hover { background: var(--surface2); color: var(--text); }

.chip.active {
    background: var(--accent-dim);
    border-color: var(--accent);
    color: var(--accent);
}

.chart-summary {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.summary-item {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--bg2);
    border: 1px solid var(--border);
    color: var(--text2);
    font-weight: 500;
}

.summary-item.total  { border-color: rgba(59,130,246,0.3);  color: #93c5fd; }
.summary-item.paid   { border-color: rgba(34,197,94,0.3);   color: #86efac; }
.summary-item.pending{ border-color: rgba(245,158,11,0.3);  color: #fde68a; }
.summary-item.overdue{ border-color: rgba(239,68,68,0.3);   color: #fca5a5; }

#monthlyChart { max-height: 200px; }

.chart-footer {
    text-align: center;
    color: var(--text3);
    font-size: 10px;
    margin-top: 8px;
}

/* ============================================================
   NOTIFICATIONS & ALERTS SECTIONS
   ============================================================ */
.notifications-section,
.vpn-alerts-section {
    border-radius: var(--r-lg);
    padding: 16px 18px;
    margin-bottom: 14px;
    border: 1px solid;
}

.notifications-section {
    background: rgba(245,158,11,0.06);
    border-color: rgba(245,158,11,0.25);
}

.vpn-alerts-section {
    background: rgba(239,68,68,0.06);
    border-color: rgba(239,68,68,0.25);
}

.notification-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.notification-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--amber);
    margin: 0;
}

.vpn-alerts-section .notification-header h3 {
    color: var(--red);
}

.notifications-list,
.vpn-alerts-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.notification-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    background: var(--surface);
    padding: 12px 14px;
    border-radius: var(--r);
    border-left: 3px solid var(--amber);
}

.vpn-alert-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    background: var(--surface);
    padding: 12px 14px;
    border-radius: var(--r);
    border-left: 3px solid var(--red);
}

.notification-content strong {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--amber);
    margin-bottom: 4px;
}

.vpn-alert-item strong {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--red);
    margin-bottom: 4px;
}

.notification-content p {
    font-size: 13px;
    color: var(--text);
    margin: 4px 0;
}

.notification-content small {
    font-size: 11px;
    color: var(--text3);
}

/* ============================================================
   CLIENTS TABLE
   ============================================================ */
.clients-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    overflow: hidden;
}

.clients-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
}

.clients-panel-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.clients-count {
    font-size: 12px;
    color: var(--text3);
    margin-left: 8px;
    font-weight: 400;
}

.clients-table {
    overflow: auto;
    max-height: calc(100vh - 190px);
    position: relative;
}

table {
    min-width: 1720px;
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    color: var(--text);
    font-size: 13px;
}

thead {
    position: sticky;
    top: 0;
    z-index: 2;
}

th {
    padding: 11px 14px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text2);
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    transition: color 0.12s;
}

th:hover { color: var(--text); }

td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    background: var(--surface);
}

th:first-child,
td:first-child {
    position: sticky;
    left: 0;
    z-index: 3;
    width: 250px;
    min-width: 250px;
    max-width: 250px;
    background: var(--surface);
    box-shadow: 1px 0 0 var(--border);
}

th:first-child {
    z-index: 5;
    background: var(--bg2);
}

tbody tr:hover td { background: rgba(255,255,255,0.03); }
tbody tr:hover td:first-child { background: #13223a; }

tr:last-child td { border-bottom: none; }

tbody tr { transition: background 0.1s; }
tbody tr:hover { background: rgba(255,255,255,0.03); }

tr.overdue { background: rgba(239,68,68,0.05); }
tr.overdue:hover { background: rgba(239,68,68,0.08); }
tr.overdue td { background: rgba(239,68,68,0.05); }
tr.overdue:hover td,
tr.overdue:hover td:first-child { background: rgba(239,68,68,0.08); }

tr.vip-client td:first-child {
    border-left: 2px solid var(--amber);
}

.cell-stack {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.cell-stack small {
    font-size: 11px;
    color: var(--text3);
}

.cell-stack span { font-size: 13px; }

.endpoint-text {
    font-size: 10px;
    font-family: 'SF Mono', 'Fira Code', monospace;
    color: var(--text3);
}

.actions-cell {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
}

/* Compact table (used in modals) */
.table-compact th,
.table-compact td {
    padding: 9px 10px;
    font-size: 12px;
}

/* ============================================================
   BADGES
   ============================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    border: 1px solid transparent;
}

.badge.success  { background: var(--green-dim);  color: var(--green);  border-color: rgba(34,197,94,0.25); }
.badge.warning  { background: var(--amber-dim);  color: var(--amber);  border-color: rgba(245,158,11,0.25); }
.badge.danger   { background: var(--red-dim);    color: var(--red);    border-color: rgba(239,68,68,0.25); }
.badge.secondary{ background: var(--surface2);   color: var(--text2);  border-color: var(--border); }
.badge.info     { background: var(--accent-dim); color: var(--accent); border-color: rgba(59,130,246,0.25); }
.badge.vip      { background: var(--purple-dim); color: var(--purple); border-color: rgba(167,139,250,0.3); }

/* ============================================================
   MODALS
   ============================================================ */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    overflow-y: auto;
    padding: 12px;
}

.modal-content {
    background: var(--surface);
    border: 1px solid var(--border2);
    border-radius: var(--r-xl);
    margin: 0 auto;
    padding: 28px;
    width: 100%;
    max-width: 520px;
    box-shadow: var(--shadow-lg);
    position: relative;
}

.modal-content.modal-wide {
    max-width: 980px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 22px;
    gap: 12px;
}

.modal-content h2 {
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
    margin: 0;
}

.close {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text2);
    font-size: 18px;
    font-weight: 400;
    cursor: pointer;
    transition: all 0.12s;
    line-height: 1;
    flex-shrink: 0;
}

.close:hover { background: var(--surface3); color: var(--text); }

/* ============================================================
   FORMS
   ============================================================ */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text2);
    margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 9px 12px;
    background: var(--bg2);
    border: 1px solid var(--border2);
    border-radius: var(--r);
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
    transition: border-color 0.15s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.form-group input[readonly],
.form-group textarea[readonly] {
    color: var(--text2);
    cursor: default;
}

.form-group input::placeholder,
.form-group textarea::placeholder { color: var(--text3); }

.form-group textarea { resize: vertical; min-height: 80px; }

.form-group small {
    display: block;
    font-size: 11px;
    color: var(--text3);
    margin-top: 5px;
    line-height: 1.4;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--r);
    cursor: pointer;
}

.checkbox-row input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
    flex-shrink: 0;
}

.checkbox-row label {
    font-size: 13px;
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0;
    color: var(--text);
    cursor: pointer;
    margin: 0;
}

.helper-box {
    width: 100%;
    min-height: 52px;
    padding: 10px 12px;
    border: 1px solid var(--border2);
    border-radius: var(--r);
    background: var(--bg2);
    color: var(--text);
    font-size: 13px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

.modal-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 6px;
}

.modal-actions > .btn-primary,
.modal-actions > .btn-secondary,
.modal-actions > .btn-export,
.modal-actions > .btn-danger-outline {
    flex: 1 1 150px;
}

.modal-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 18px 0;
}

/* ============================================================
   PAYMENTS MODAL
   ============================================================ */
.payments-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 58vh;
    overflow-y: auto;
}

.payment-row {
    display: grid;
    grid-template-columns: 50px 1fr 90px 80px 100px auto;
    gap: 10px;
    align-items: center;
    padding: 10px 14px;
    background: var(--bg2);
    border-radius: var(--r);
    border: 1px solid var(--border);
    transition: border-color 0.1s;
}

.payment-row.pending { border-color: rgba(245,158,11,0.3); }

.payment-row .pr-id    { color: var(--text3); font-size: 11px; }
.payment-row .pr-client a { color: var(--text); text-decoration: none; font-weight: 500; font-size: 13px; }
.payment-row .pr-client a:hover { color: var(--accent); }
.payment-row .pr-amount { font-weight: 700; font-size: 15px; color: var(--green); }
.payment-row .pr-method { color: var(--text2); font-size: 12px; }
.payment-row .pr-date   { color: var(--text3); font-size: 11px; }
.payment-row .pr-actions { display: flex; gap: 5px; justify-content: flex-end; }

.payment-row .pr-actions .btn-primary,
.payment-row .pr-actions .btn-secondary {
    min-width: 40px;
    padding-inline: 12px;
}

.pr-status { font-size: 11px; padding: 3px 8px; border-radius: 6px; font-weight: 600; }
.pr-status.pending  { background: var(--amber-dim);  color: var(--amber); }
.pr-status.approved { background: var(--green-dim);  color: var(--green); }
.pr-status.rejected { background: var(--red-dim);    color: var(--red); }

.badge-counter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--red);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    margin-left: 4px;
}

/* ============================================================
   MODAL TABLE
   ============================================================ */
.modal-table { margin-top: 14px; }

.modal-table .clients-table {
    border-radius: var(--r);
    max-height: 280px;
    overflow-y: auto;
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text3);
}

.empty-state-icon { font-size: 36px; margin-bottom: 10px; }
.empty-state-text { font-size: 14px; }

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border2); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
    .app-header { padding: 0 16px; }
    .app-main   { padding: 14px 14px 40px; }
    .stats-bar  { padding: 12px 14px; }

    .toolbar { flex-direction: column; align-items: stretch; }
    .toolbar-left, .toolbar-right { flex-wrap: wrap; }
    .search-wrap { max-width: 100%; }

    .payment-row { grid-template-columns: 1fr 1fr; }
    .header-brand-sub { display: none; }
}

@media (max-width: 600px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .form-row { grid-template-columns: 1fr; }
    .modal { padding: 10px; }
    .modal-content { padding: 20px; }
    .payment-row { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
    body {
        font-size: 13px;
        overflow-x: hidden;
    }

    .app-header {
        height: auto;
        min-height: 54px;
        padding: 8px 10px;
        gap: 10px;
    }

    .header-brand {
        min-width: 0;
        gap: 8px;
    }

    .header-brand-icon {
        width: 30px;
        height: 30px;
        border-radius: 8px;
        font-size: 16px;
    }

    .header-brand-name { font-size: 15px; }
    .header-right { gap: 6px; }
    .username { padding: 4px 9px; font-size: 11px; }
    .btn-logout { padding: 5px 10px; font-size: 12px; }

    .stats-bar {
        padding: 10px;
    }

    .money-kpis {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        margin-bottom: 10px;
    }

    .kpi {
        padding: 11px 12px;
        min-width: 0;
    }

    .kpi-value {
        font-size: 18px;
        line-height: 1.15;
        overflow-wrap: anywhere;
    }

    .kpi-label {
        font-size: 10px;
        letter-spacing: 0.02em;
    }

    .kpi-note {
        font-size: 10px;
        margin-top: 5px;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .telegram-default-card {
        align-items: stretch;
        flex-direction: column;
        gap: 10px;
        margin-top: 10px;
        padding: 11px 12px;
    }

    .telegram-default-select {
        width: 100%;
        min-width: 0;
    }

    .stat-card {
        padding: 10px 11px;
        border-radius: 10px;
    }

    .stat-value {
        font-size: 19px;
    }

    .stat-label {
        font-size: 10px;
        letter-spacing: 0.02em;
    }

    .stat-note {
        font-size: 10px;
        margin-top: 4px;
        line-height: 1.25;
    }

    .app-main {
        padding: 10px 8px 26px;
    }

    .action-center,
    .infra-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .ac-card,
    .infra-section,
    .growth-section,
    .chart-section,
    .clients-panel {
        border-radius: 12px;
    }

    .chart-section,
    .growth-section,
    .infra-section {
        padding: 12px;
        margin-bottom: 12px;
    }

    .chart-header,
    .notification-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .chart-actions {
        width: 100%;
        overflow-x: auto;
        padding-bottom: 2px;
    }

    #monthlyChart {
        min-height: 180px;
    }

    .growth-bars {
        gap: 8px;
        height: 94px;
        overflow-x: auto;
        padding-bottom: 4px;
    }

    .g-bar-wrap {
        min-width: 54px;
    }

    .clients-panel-header {
        align-items: flex-start;
        gap: 10px;
        padding: 12px;
        flex-direction: column;
    }

    .client-tabs {
        width: 100%;
        overflow-x: auto;
        padding-bottom: 2px;
    }

    .client-tab {
        flex: 0 0 auto;
    }

    .clients-toolbar {
        padding: 10px;
        gap: 8px;
    }

    .toolbar,
    .toolbar-left,
    .toolbar-right {
        align-items: stretch;
        width: 100%;
    }

    .toolbar-left,
    .toolbar-right {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .search-wrap {
        grid-column: 1 / -1;
        min-width: 0;
        max-width: none;
    }

    .toolbar select,
    .btn-primary,
    .btn-secondary,
    .btn-export {
        width: 100%;
        justify-content: center;
        min-height: 36px;
        padding: 8px 10px;
        font-size: 12px;
    }

    .toolbar-sep {
        display: none;
    }

    .clients-panel > .clients-table {
        max-height: none;
        overflow: visible;
        background: var(--bg2);
        padding: 8px;
    }

    .clients-panel > .clients-table table,
    .clients-panel > .clients-table tbody,
    .clients-panel > .clients-table tr,
    .clients-panel > .clients-table td {
        display: block;
        width: 100%;
        min-width: 0;
        max-width: none;
    }

    .clients-panel > .clients-table table {
        min-width: 0;
        border-collapse: separate;
        border-spacing: 0;
    }

    .clients-panel > .clients-table thead {
        display: none;
    }

    .clients-panel > .clients-table tbody tr {
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: 12px;
        overflow: hidden;
        margin-bottom: 10px;
        box-shadow: 0 8px 24px rgba(0,0,0,0.18);
    }

    .clients-panel > .clients-table tbody tr:hover,
    .clients-panel > .clients-table tbody tr:hover td,
    .clients-panel > .clients-table tbody tr:hover td:first-child {
        background: var(--surface);
    }

    .clients-panel > .clients-table td,
    .clients-panel > .clients-table td:first-child {
        position: static;
        box-shadow: none;
        background: transparent;
        border-bottom: 1px solid var(--border);
        padding: 9px 10px;
    }

    .clients-panel > .clients-table td {
        display: grid;
        grid-template-columns: 92px minmax(0, 1fr);
        gap: 10px;
        align-items: start;
    }

    .clients-panel > .clients-table td::before {
        content: attr(data-label);
        color: var(--text3);
        font-size: 10px;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        padding-top: 2px;
    }

    .clients-panel > .clients-table td:nth-child(1)::before { content: 'Клиент'; }
    .clients-panel > .clients-table td:nth-child(2)::before { content: 'Телефон'; }
    .clients-panel > .clients-table td:nth-child(3)::before { content: 'Тариф'; }
    .clients-panel > .clients-table td:nth-child(4)::before { content: 'Создан'; }
    .clients-panel > .clients-table td:nth-child(5)::before { content: 'Оплата'; }
    .clients-panel > .clients-table td:nth-child(6)::before { content: 'Срок'; }
    .clients-panel > .clients-table td:nth-child(7)::before { content: 'VPN'; }
    .clients-panel > .clients-table td:nth-child(8)::before { content: 'Онлайн'; }
    .clients-panel > .clients-table td:nth-child(9)::before { content: 'Устройства'; }
    .clients-panel > .clients-table td:nth-child(10)::before { content: 'Трафик'; }
    .clients-panel > .clients-table td:nth-child(11)::before { content: 'Действия'; }

    .clients-panel > .clients-table td:first-child {
        background: rgba(59,130,246,0.08);
    }

    .clients-panel > .clients-table td:last-child {
        border-bottom: 0;
        grid-template-columns: 1fr;
    }

    .clients-panel > .clients-table td:last-child::before {
        margin-bottom: 2px;
    }

    .clients-panel > .clients-table .cell-stack {
        min-width: 0;
        gap: 4px;
    }

    .clients-panel > .clients-table .cell-stack span,
    .clients-panel > .clients-table .cell-stack small,
    .endpoint-text {
        overflow-wrap: anywhere;
    }

    .actions-cell {
        width: 100%;
    }

    .act-row-primary,
    .act-row-secondary {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 6px;
    }

    .act-row-secondary {
        border-top: 0;
        padding-top: 0;
    }

    .btn-sm,
    .act-row-secondary .btn-sm {
        min-height: 32px;
        padding: 6px 8px;
        font-size: 11px;
    }

    .modal-content {
        width: min(100%, 100vw - 16px);
        max-height: calc(100vh - 16px);
        padding: 14px;
    }

    .modal-wide,
    .modal-fullscreen {
        width: calc(100vw - 16px);
    }
}

/* ====== INFRASTRUCTURE ====== */
.infra-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 18px;
    margin-bottom: 18px;
}
.infra-alerts { margin: 6px 0 14px; }
.infra-alert {
    background: var(--amber-dim);
    color: var(--amber);
    border: 1px solid var(--amber);
    border-radius: var(--r);
    padding: 8px 12px;
    font-size: 13px;
    margin-bottom: 6px;
}
.infra-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 12px;
}
.infra-card {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 14px;
}
.infra-card-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}
.infra-name { font-weight: 600; color: var(--text); }
.infra-meta { color: var(--text2); font-size: 12px; margin-bottom: 10px; }
.infra-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 13px;
    color: var(--text2);
    margin-bottom: 12px;
}
.infra-stats b { color: var(--text); }
.status-dot {
    width: 9px; height: 9px;
    border-radius: 999px;
    display: inline-block;
    flex-shrink: 0;
}
.status-dot.success { background: var(--green); box-shadow: 0 0 8px var(--green); }
.status-dot.danger  { background: var(--red); }

/* ====== MONEY KPIs ====== */
.money-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 14px;
}
.kpi {
    background: linear-gradient(180deg, var(--surface2), var(--surface));
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: var(--r);
    padding: 16px 18px;
}
.kpi-clickable { cursor: pointer; }
.kpi-clickable:hover { border-color: rgba(59,130,246,.55); box-shadow: var(--shadow); }
.kpi-value { font-size: 24px; font-weight: 700; color: var(--text); }
.kpi-label { font-size: 12px; color: var(--text2); margin-top: 4px; text-transform: uppercase; letter-spacing: .04em; }
.kpi-note { margin-top: 8px; color: var(--text2); font-size: 12px; line-height: 1.35; }
.kpi-accent { border-left-color: var(--accent); }
.kpi-green  { border-left-color: var(--green); }
.kpi-green .kpi-value { color: var(--green); }
.kpi-red    { border-left-color: var(--red); }
.kpi-red .kpi-value { color: var(--red); }
.kpi-amber  { border-left-color: var(--amber); }
.kpi-amber .kpi-value { color: var(--amber); }

/* ====== ACTION CENTER ====== */
.action-center {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}
.ac-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 14px 16px;
}
.ac-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.ac-title { font-weight: 600; color: var(--text); font-size: 14px; }
.ac-view-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--border);
    background: var(--surface2);
    color: var(--text2);
    border-radius: 999px;
    padding: 4px 8px;
    font-size: 12px;
    cursor: pointer;
}
.ac-view-btn:hover { color: var(--text); border-color: rgba(59,130,246,.55); }
.ac-list { display: flex; flex-direction: column; gap: 4px; }
.ac-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 7px 9px; border-radius: 8px; cursor: pointer;
    background: var(--surface2); font-size: 13px;
}
.ac-row:hover { background: var(--surface3); }
.ac-name { color: var(--text); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 55%; }
.ac-right { color: var(--text2); display: flex; gap: 8px; align-items: center; }
.ac-right b { color: var(--text); }
.ac-tg { color: var(--accent); text-decoration: none; font-size: 12px; }
.tg-contact { color: var(--accent); text-decoration: none; font-weight: 700; margin-left: 4px; }
.tg-action { color: var(--accent) !important; border-color: rgba(59,130,246,0.28) !important; }
.ac-muted { color: var(--text2); font-size: 12px; }
.ac-empty { color: var(--text2); font-size: 13px; padding: 6px; }

/* ====== GROWTH ====== */
.growth-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 18px;
    margin-bottom: 18px;
}
.growth-stats { display: flex; gap: 28px; margin-bottom: 18px; flex-wrap: wrap; }
.growth-stats > div { display: flex; flex-direction: column; }
.g-val { font-size: 22px; font-weight: 700; color: var(--text); }
.g-lbl { font-size: 12px; color: var(--text2); }
.growth-bars { display: flex; gap: 14px; align-items: flex-end; height: 120px; }
.g-bar-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.g-bar { width: 70%; max-width: 48px; background: linear-gradient(180deg, var(--accent), rgba(59,130,246,.4)); border-radius: 6px 6px 0 0; min-height: 4px; transition: height .3s; }
.g-bar-val { font-size: 13px; font-weight: 600; color: var(--text); margin-top: 6px; }
.g-bar-lbl { font-size: 11px; color: var(--text2); }

/* ====== ACTION BUTTONS IN TABLE ====== */
.actions-cell {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 220px;
}

.act-row-primary {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.act-row-secondary {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    padding-top: 2px;
    border-top: 1px solid var(--border);
}

.act-row-secondary .btn-sm {
    font-size: 10px;
    padding: 3px 7px;
    color: var(--text3);
    background: var(--bg2);
}

.act-row-secondary .btn-sm:hover {
    color: var(--text);
    background: var(--surface2);
}

.act-row-secondary .btn-sm.danger {
    color: var(--red);
    background: var(--red-dim);
}

/* ====== CLIENT TABS ====== */
.clients-panel-header { display: flex; justify-content: space-between; align-items: center; }
.client-tabs { display: flex; gap: 6px; }
.client-tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--surface2); color: var(--text2);
    border: 1px solid var(--border); border-radius: 999px;
    padding: 6px 14px; font-size: 13px; cursor: pointer;
}
.client-tab:hover { color: var(--text); }
.client-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ====== CLIENT LIST MODAL ====== */
.modal-content.modal-fullscreen {
    width: calc(100vw - 24px);
    max-width: none;
    max-height: calc(100vh - 24px);
    overflow: hidden;
    padding: 24px;
}
.modal-subtitle {
    color: var(--text2);
    font-size: 13px;
    margin-top: 4px;
}
.client-list-modal-body {
    margin-top: 14px;
    max-height: calc(100vh - 132px);
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: var(--r);
}
.client-list-table table {
    min-width: 0;
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
}
.client-list-table th:first-child,
.client-list-table td:first-child {
    position: static;
    width: auto;
    min-width: 0;
    max-width: none;
    box-shadow: none;
}
.client-list-table th,
.client-list-table td {
    padding: 10px 10px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
    font-size: 13px;
    overflow-wrap: anywhere;
}
.client-list-table th:nth-child(1) { width: 17%; }
.client-list-table th:nth-child(2) { width: 18%; }
.client-list-table th:nth-child(3) { width: 12%; }
.client-list-table th:nth-child(4) { width: 13%; }
.client-list-table th:nth-child(5) { width: 14%; }
.client-list-table th:nth-child(6) { width: 18%; }
.client-list-table th:nth-child(7) { width: 150px; }
.client-list-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--surface);
    color: var(--text2);
    text-transform: uppercase;
    letter-spacing: .04em;
    font-size: 11px;
}
.client-list-table tr:hover td { background: rgba(59,130,246,.06); }
.client-list-empty {
    padding: 36px;
    color: var(--text2);
    text-align: center;
}

@media (max-width: 760px) {
    .clients-panel > .clients-table .actions-cell {
        display: flex;
        flex-direction: column;
        gap: 6px;
        min-width: 0;
        width: 100%;
    }

    .clients-panel > .clients-table .act-row-primary,
    .clients-panel > .clients-table .act-row-secondary {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 6px;
        width: 100%;
        padding-top: 0;
        border-top: 0;
    }

    .clients-panel > .clients-table .btn-sm,
    .clients-panel > .clients-table .act-row-secondary .btn-sm {
        min-height: 32px;
        padding: 6px 8px;
        font-size: 11px;
        color: var(--text2);
        background: var(--surface2);
    }

    .clients-panel > .clients-table .btn-sm.success {
        color: var(--green);
        background: var(--green-dim);
    }

    .clients-panel > .clients-table .btn-sm.danger {
        color: var(--red);
        background: var(--red-dim);
    }

    .client-list-modal-body {
        max-height: calc(100vh - 116px);
    }

    .client-list-table {
        overflow-x: auto;
    }

    .client-list-table table {
        min-width: 820px;
    }
}

/* ============================================================
   MOBILE BUTTON AND PANEL FIT
   ============================================================ */
@media (max-width: 760px) {
    .app-header {
        flex-wrap: wrap;
        align-items: flex-start;
    }

    .header-brand {
        flex: 1 1 auto;
    }

    .header-right {
        flex: 1 1 100%;
        width: 100%;
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
        gap: 8px;
    }

    .header-chat-link,
    .btn-logout,
    .username {
        min-height: 36px;
        justify-content: center;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .chat-unread-badge {
        flex: 0 0 auto;
    }

    .chart-actions,
    .chart-summary,
    .quick-action-row {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 6px;
        width: 100%;
        overflow: visible;
    }

    .chip,
    .summary-item,
    .client-tab {
        justify-content: center;
        min-height: 36px;
        white-space: normal;
        text-align: center;
    }

    .notification-item,
    .vpn-alert-item {
        flex-direction: column;
        align-items: stretch;
    }

    .notification-item .btn-sm,
    .vpn-alert-item .btn-sm {
        width: 100%;
        min-height: 34px;
    }

    .modal-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        width: 100%;
    }

    .modal-actions > .btn-primary,
    .modal-actions > .btn-secondary,
    .modal-actions > .btn-export,
    .modal-actions > .btn-danger-outline,
    .modal-actions > button {
        width: 100%;
        min-height: 40px;
        flex: 1 1 auto;
        white-space: normal;
    }

    .form-group .btn-primary,
    .form-group .btn-secondary,
    .form-group .btn-export,
    .form-group .btn-danger-outline {
        min-height: 40px;
        white-space: normal;
    }

    .payment-row {
        align-items: stretch;
    }

    .payment-row .pr-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        justify-content: stretch;
        width: 100%;
    }

    .payment-row .pr-actions .btn-primary,
    .payment-row .pr-actions .btn-secondary {
        width: 100%;
        min-height: 38px;
    }
}

@media (max-width: 520px) {
    .header-right {
        grid-template-columns: 1fr 1fr;
    }

    .username {
        grid-column: 1 / -1;
        order: -1;
    }

    .toolbar-left,
    .toolbar-right,
    .chart-actions,
    .chart-summary,
    .modal-actions,
    .payment-row .pr-actions {
        grid-template-columns: 1fr;
    }

    .client-tabs {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 6px;
        overflow: visible;
    }

    .client-tab {
        min-height: 38px;
        padding: 8px 10px;
    }

    .toolbar select,
    .btn-primary,
    .btn-secondary,
    .btn-export,
    .btn-danger-outline {
        min-height: 42px;
        white-space: normal;
    }

    .clients-panel > .clients-table .act-row-primary,
    .clients-panel > .clients-table .act-row-secondary {
        grid-template-columns: 1fr;
    }

    .clients-panel > .clients-table .btn-sm,
    .clients-panel > .clients-table .act-row-secondary .btn-sm {
        min-height: 38px;
        white-space: normal;
    }
}

/* ===================== Веб-трафик (Web Analytics) ===================== */
.wt-kpis {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 18px;
}
.wt-kpi {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 16px 14px;
    text-align: center;
}
.wt-kpi-val { font-size: 26px; font-weight: 800; color: var(--text); line-height: 1.1; }
.wt-kpi-label { font-size: 12px; color: var(--muted, #8aa0bd); margin-top: 6px; }

.wt-chart {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 130px;
    padding: 8px 2px 0;
    margin-bottom: 18px;
    border-bottom: 1px solid var(--border);
}
.wt-bar-wrap {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    height: 100%;
    min-width: 0;
}
.wt-bar {
    width: 70%;
    max-width: 26px;
    min-height: 3px;
    border-radius: 4px 4px 0 0;
    background: linear-gradient(180deg, var(--accent), #6366f1);
    transition: height .3s ease;
}
.wt-bar-label {
    font-size: 9px;
    color: var(--muted, #8aa0bd);
    margin-top: 5px;
    white-space: nowrap;
    transform: rotate(-45deg);
    transform-origin: center;
}
.wt-cols {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
}
.wt-col {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 12px 14px;
}
.wt-col-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}
.wt-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 5px 0;
    font-size: 13px;
    color: var(--text);
}
.wt-row span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.wt-row b { color: var(--accent); font-weight: 700; flex-shrink: 0; }
.wt-row.muted { color: var(--muted, #8aa0bd); justify-content: center; }

@media (max-width: 720px) {
    .wt-cols { grid-template-columns: 1fr; }
    .wt-kpi-val { font-size: 22px; }
    .wt-bar-label { display: none; }
}

/* ── Бизнес-аналитика (дашборд) ─────────────────────────────────── */
.biz-charts, .biz-tables {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-top: 18px;
    align-items: start;
}
.biz-tables .clients-table { max-height: 320px; overflow-y: auto; }
@media (max-width: 900px) {
    .biz-charts, .biz-tables { grid-template-columns: 1fr; }
}

/* Final responsive guardrails for mobile operations */
body {
    overflow-x: hidden;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 248px minmax(0, 1fr);
    background: var(--bg);
}

.app-body {
    min-width: 0;
}

.app-shell svg {
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    display: block;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 120;
    display: flex;
    flex-direction: column;
    background: #0a1322;
    border-right: 1px solid var(--border);
    overflow-y: auto;
}

.sidebar-head {
    min-height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 14px 10px;
    border-bottom: 1px solid var(--border);
}

.sidebar-brand,
.sidebar-user {
    display: flex;
    align-items: center;
    min-width: 0;
    gap: 10px;
}

.sidebar-brand-icon,
.sidebar-user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 34px;
    background: linear-gradient(135deg, var(--accent), #10b981);
    color: #fff;
    font-size: 16px;
    font-weight: 800;
}

.sidebar-brand-text,
.sidebar-user-info {
    min-width: 0;
}

.sidebar-brand-name,
.sidebar-user-name {
    color: var(--text);
    font-size: 14px;
    font-weight: 800;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-brand-sub,
.sidebar-user-role {
    margin-top: 2px;
    color: var(--text3);
    font-size: 11px;
    line-height: 1.2;
}

.sidebar-close {
    display: none;
    width: 34px;
    height: 34px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text2);
    font-size: 20px;
    line-height: 1;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 10px;
}

.nav-section-label {
    padding: 12px 10px 6px;
    color: var(--text3);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.nav-item {
    min-height: 40px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 8px;
    color: var(--text2);
    text-decoration: none;
    font-size: 13px;
    font-weight: 650;
    cursor: pointer;
}

.nav-item:hover,
.nav-item.active {
    background: var(--surface);
    color: var(--text);
}

.nav-badge {
    display: none;
    min-width: 18px;
    height: 18px;
    margin-left: auto;
    border-radius: 999px;
    background: var(--red);
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    align-items: center;
    justify-content: center;
}

.sidebar-foot {
    padding: 12px;
    border-top: 1px solid var(--border);
}

.sidebar-logout {
    width: 100%;
    min-height: 38px;
    margin-top: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text2);
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

.sidebar-overlay {
    display: none;
}

.app-shell .app-header {
    min-height: 60px;
    height: auto;
    padding: 10px 18px;
    gap: 12px;
}

.header-burger,
.header-icon-btn {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text2);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    text-decoration: none;
}

.header-burger {
    display: none;
}

.header-icon-btn svg,
.header-burger svg,
.sidebar-logout svg {
    width: 18px;
    height: 18px;
    flex-basis: 18px;
}

.header-title {
    min-width: 0;
    flex: 1;
}

.header-title h1 {
    margin: 0;
    color: var(--text);
    font-size: 18px;
    line-height: 1.2;
    font-weight: 800;
}

.header-sub {
    margin-top: 2px;
    color: var(--text3);
    font-size: 12px;
}

.dot-badge {
    display: none;
    position: absolute;
    right: 7px;
    top: 7px;
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: var(--red);
}

.stat-value,
.kpi-value,
.g-val,
.wt-kpi-val {
    overflow-wrap: anywhere;
}

.badge {
    max-width: 100%;
    min-height: 24px;
    justify-content: center;
    line-height: 1.2;
    text-align: center;
}

.endpoint-text,
.device-text,
.cell-stack span,
.cell-stack small {
    overflow-wrap: anywhere;
}

.clients-panel > .clients-table .actions-cell,
.clients-panel > .clients-table .act-row-primary,
.clients-panel > .clients-table .act-row-secondary {
    min-width: 0;
}

@media (max-width: 760px) {
    .app-shell {
        display: block;
    }

    .app-body {
        width: 100%;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        width: min(82vw, 280px);
        max-width: 280px;
        transform: translateX(-105%);
        transition: transform 0.18s ease;
        box-shadow: 18px 0 48px rgba(0,0,0,0.38);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-close {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .sidebar-overlay.open,
    .sidebar-overlay.show {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 110;
        background: rgba(0,0,0,0.48);
    }

    body.sidebar-open {
        overflow: hidden;
    }

    .sidebar-head {
        min-height: 58px;
        padding: 12px;
    }

    .sidebar-brand-icon,
    .sidebar-user-avatar {
        width: 30px;
        height: 30px;
        flex-basis: 30px;
        font-size: 14px;
    }

    .nav-item {
        min-height: 38px;
        padding: 8px 9px;
        font-size: 12px;
        gap: 9px;
    }

    .nav-section-label {
        padding: 10px 9px 5px;
        font-size: 9px;
    }

    .app-shell svg {
        width: 16px;
        height: 16px;
        flex-basis: 16px;
    }

    .app-shell .app-header {
        min-height: 52px;
        padding: 8px 10px;
        align-items: center;
        flex-wrap: nowrap;
    }

    .header-burger {
        display: inline-flex;
        width: 36px;
        height: 36px;
        flex: 0 0 36px;
    }

    .header-icon-btn {
        width: 34px;
        height: 34px;
        flex: 0 0 34px;
    }

    .header-title h1 {
        font-size: 16px;
    }

    .header-sub {
        display: none;
    }

    .app-shell .header-right {
        display: flex;
        flex: 0 0 auto;
        width: auto;
        gap: 6px;
    }

    .header-icon-btn svg,
    .header-burger svg,
    .sidebar-logout svg {
        width: 16px;
        height: 16px;
        flex-basis: 16px;
    }

    .stats-bar {
        padding: 8px;
    }

    .stats-grid,
    .money-kpis {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 7px;
    }

    .stat-card,
    .kpi {
        min-height: 74px;
        padding: 9px 10px;
        border-radius: 8px;
    }

    .stat-value,
    .kpi-value {
        font-size: 17px;
        line-height: 1.15;
        letter-spacing: 0;
    }

    .stat-label,
    .kpi-label {
        font-size: 9px;
        line-height: 1.2;
        margin-top: 5px;
    }

    .telegram-default-card {
        border-radius: 8px;
    }

    .badge {
        white-space: normal;
        border-radius: 8px;
        min-height: 22px;
        padding: 3px 7px;
        font-size: 10px;
    }

    .clients-panel > .clients-table {
        padding: 6px 5px;
    }

    .clients-panel > .clients-table td {
        grid-template-columns: 78px minmax(0, 1fr);
        padding: 7px 8px;
        gap: 8px;
    }

    .clients-panel > .clients-table td::before {
        font-size: 9px;
        letter-spacing: 0;
    }

    .clients-panel > .clients-table tbody tr.client-row {
        border-radius: 9px;
        margin-bottom: 8px;
    }

    .clients-panel > .clients-table .btn-sm,
    .clients-panel > .clients-table .act-row-secondary .btn-sm {
        min-height: 36px;
        padding: 7px 8px;
        white-space: normal;
        text-align: center;
    }

    .toolbar select,
    .toolbar button,
    .client-tab,
    .modal-actions > button {
        min-height: 42px;
    }
}

@media (max-width: 380px) {
    .money-kpis,
    .stats-grid,
    .toolbar-left,
    .toolbar-right,
    .clients-panel > .clients-table .act-row-primary,
    .clients-panel > .clients-table .act-row-secondary {
        grid-template-columns: 1fr;
    }

    .clients-panel > .clients-table td {
        grid-template-columns: 70px minmax(0, 1fr);
    }
}

/* ============================================================
   ADAPTIVE LAYOUT POLISH — desktop / laptop / tablet / phone
   ============================================================ */
html {
    min-width: 0;
    background: var(--bg);
}

img,
canvas,
svg,
video {
    max-width: 100%;
}

.app-shell {
    grid-template-columns: clamp(216px, 16vw, 248px) minmax(0, 1fr);
}

.app-main {
    max-width: 1840px;
    margin-inline: auto;
}

.clients-panel > .clients-table > table {
    min-width: 1480px;
}

.clients-panel > .clients-table > table > thead > tr > th:first-child,
.clients-panel > .clients-table > table > tbody > tr > td:first-child {
    width: 220px;
    min-width: 220px;
    max-width: 220px;
}

/* Вложенные аналитические и модальные таблицы компактные, а не 1720px. */
.biz-tables .clients-table,
.modal-table .clients-table {
    overflow-x: auto;
}

.biz-tables .clients-table table,
.modal-table .clients-table table {
    width: 100%;
    min-width: 620px;
    table-layout: auto;
}

.biz-tables .clients-table th:first-child,
.biz-tables .clients-table td:first-child,
.modal-table .clients-table th:first-child,
.modal-table .clients-table td:first-child {
    position: static;
    width: auto;
    min-width: 0;
    max-width: none;
    box-shadow: none;
}

.modal-content {
    max-height: calc(100dvh - 24px);
    overflow-y: auto;
    overscroll-behavior: contain;
}

.modal-content.modal-fullscreen {
    max-height: calc(100dvh - 24px);
}

/* На небольших ноутбуках и планшетах меню становится выдвижным,
   чтобы рабочая область и таблицы не были зажаты. */
@media (min-width: 761px) and (max-width: 1180px) {
    .app-shell {
        display: block;
    }

    .app-body {
        width: 100%;
    }

    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: 264px;
        height: 100dvh;
        transform: translateX(-105%);
        transition: transform 0.18s ease;
        box-shadow: 18px 0 48px rgba(0,0,0,0.42);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-close,
    .header-burger {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .sidebar-overlay.open,
    .sidebar-overlay.show {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 110;
        background: rgba(0,0,0,0.52);
    }

    body.sidebar-open {
        overflow: hidden;
    }

    .app-shell .app-header {
        padding-inline: 16px;
    }

    .app-main {
        padding-inline: 14px;
    }

    .stats-bar {
        padding-inline: 14px;
    }
}

@media (max-width: 900px) {
    .clients-panel > .clients-table > table {
        min-width: 1320px;
    }

    .chart-section,
    .growth-section,
    .infra-section {
        padding: 14px;
    }
}

@media (max-width: 760px) {
    .app-main {
        max-width: 100%;
        padding-inline: max(8px, env(safe-area-inset-left));
    }

    .app-shell .app-header {
        padding-left: max(10px, env(safe-area-inset-left));
        padding-right: max(10px, env(safe-area-inset-right));
    }

    .sidebar {
        height: 100dvh;
        padding-bottom: env(safe-area-inset-bottom);
    }

    .clients-panel > .clients-table table {
        min-width: 0;
    }

    .clients-panel > .clients-table td,
    .clients-panel > .clients-table td:first-child {
        width: 100%;
        min-width: 0;
        max-width: none;
    }

    .modal {
        padding:
            max(8px, env(safe-area-inset-top))
            max(8px, env(safe-area-inset-right))
            max(8px, env(safe-area-inset-bottom))
            max(8px, env(safe-area-inset-left));
    }

    .modal-content,
    .modal-content.modal-fullscreen {
        width: 100%;
        max-width: none;
        max-height: calc(100dvh - 16px);
        padding: 14px;
        border-radius: 14px;
    }

    .modal-header {
        margin-bottom: 16px;
    }

    .modal-content h2 {
        font-size: 16px;
        overflow-wrap: anywhere;
    }

    .form-group input,
    .form-group select,
    .form-group textarea,
    #search {
        font-size: 16px;
    }
}

@media (max-width: 420px) {
    .header-title h1 {
        font-size: 15px;
    }

    .header-icon-btn {
        width: 32px;
        height: 32px;
        flex-basis: 32px;
    }

    .stats-grid,
    .money-kpis {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .stat-card,
    .kpi {
        padding: 9px;
    }

    .clients-panel > .clients-table td {
        grid-template-columns: 72px minmax(0, 1fr);
    }
}
