/* ── Cabinet Layout ──────────────────────────────────── */

:root {
    --cab-accent: #4f46e5;
    --cab-accent-2: #6366f1;
    --cab-accent-grad: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
    --cab-accent-soft: #eef2ff;
    --cab-bg: #f6f8fb;
    --cab-border: #e8edf3;
    --cab-text: #0f172a;
    --cab-text-2: #475569;
    --cab-muted: #94a3b8;
    --cab-sidebar: linear-gradient(180deg, #141d31 0%, #0b1120 100%);
    --cab-sb-line: rgba(255,255,255,.07);
    --cab-sb-w: 248px;
    --cab-sb-w-collapsed: 74px;
    --cab-hd-h: 60px;
}

.auth-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f9fafb;
}

.auth-page {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 24px;
}

.auth-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 36px 40px;
    width: 400px;
    box-shadow: 0 1px 4px rgba(0,0,0,.04);
}

.auth-logo {
    font-size: 20px;
    font-weight: 700;
    color: #111827;
    letter-spacing: -0.03em;
    margin-bottom: 4px;
}

.auth-tagline {
    font-size: 13px;
    color: #6b7280;
    margin-bottom: 24px;
}

/* ── Tabs ────────────────────────────────────────────── */

.auth-tabs {
    display: flex;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 24px;
    gap: 0;
}

.auth-tab {
    flex: 1;
    padding: 9px 0;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    font-size: 14px;
    font-weight: 500;
    color: #6b7280;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}

.auth-tab.active {
    color: #4f46e5;
    border-bottom-color: #4f46e5;
}

.auth-panel { display: none; }
.auth-panel.active { display: block; }

.auth-bonus-note {
    background: #eef2ff;
    border: 1px solid #c7d2fe;
    color: #4338ca;
    border-radius: 6px;
    padding: 10px 13px;
    font-size: 12px;
    margin-bottom: 16px;
    line-height: 1.5;
}

.form-optional {
    font-size: 11px;
    color: #9ca3af;
    font-weight: 400;
}

/* ── Cabinet main layout ─────────────────────────────── */

.cab-layout {
    display: flex;
    min-height: 100vh;
    background: var(--cab-bg);
}

/* Sidebar */
.cab-sidebar {
    width: var(--cab-sb-w);
    flex-shrink: 0;
    background: var(--cab-sidebar);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: hidden;
    transition: width 0.22s ease;
}

.cab-brand {
    display: flex;
    align-items: center;
    gap: 11px;
    height: var(--cab-hd-h);
    padding: 0 18px;
    border-bottom: 1px solid var(--cab-sb-line);
    flex-shrink: 0;
    text-decoration: none;
}
.cab-brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: var(--cab-accent-grad);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 800;
    font-size: 17px;
    flex-shrink: 0;
    background: url(/static/logo.jpg);
    background-size: cover;
    font-size: 0;
}
.cab-brand-name {
    color: #fff;
    font-weight: 700;
    font-size: 17px;
    letter-spacing: -0.02em;
    white-space: nowrap;
}
.cab-brand-name span { color: var(--cab-accent-2); }

.cab-nav {
    flex: 1;
    padding: 12px;
    overflow-y: auto;
}
.cab-nav::-webkit-scrollbar { width: 6px; }
.cab-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 6px; }

.cab-nav-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    margin: 2px 0;
    border-radius: 10px;
    font-size: 13.5px;
    font-weight: 500;
    color: rgba(255,255,255,.62);
    text-decoration: none;
    white-space: nowrap;
    transition: color 0.15s, background 0.15s;
}
.cab-nav-item > svg { width: 19px; height: 19px; flex-shrink: 0; stroke-width: 1.8; }
.cab-nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

.cab-nav-item:hover {
    color: #fff;
    background: rgba(255,255,255,.06);
}
.cab-nav-item.active {
    color: #fff;
    background: linear-gradient(90deg, rgba(99,102,241,.26), rgba(99,102,241,.07));
}
.cab-nav-item.active::before {
    content: "";
    position: absolute;
    left: -12px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 22px;
    border-radius: 0 3px 3px 0;
    background: var(--cab-accent-2);
}
.cab-nav-item.active > svg { color: #a5b4fc; }

.cab-nav-badge {
    margin-left: auto;
    background: #dc2626;
    color: #fff;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 7px;
    line-height: 1.6;
    flex-shrink: 0;
}
.cab-nav-dot {
    margin-left: auto;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #f59e0b;
    flex-shrink: 0;
}

.cab-nav-section {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255,255,255,.28);
    padding: 18px 12px 6px;
}

/* Tools submenu */
.cab-nav-tools-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 13.5px;
    font-weight: 500;
    color: rgba(255,255,255,.62);
    cursor: pointer;
    user-select: none;
    transition: color 0.15s, background 0.15s;
}
.cab-nav-tools-toggle:hover { color: #fff; background: rgba(255,255,255,.06); }
.cab-nav-tools-lead { width: 19px; height: 19px; flex-shrink: 0; }
.cab-nav-tools-toggle > span { flex: 1; }
.cab-nav-tools-toggle .tools-arrow {
    width: 13px;
    height: 13px;
    flex-shrink: 0;
    transition: transform 0.2s;
    transform: rotate(180deg);
}
.cab-nav-tools-sub { margin-top: 2px; }
.cab-nav-tools-sub .cab-nav-item { font-size: 12.5px; color: rgba(255,255,255,.5); }
.cab-nav-tools-sub .cab-nav-item > svg { width: 16px; height: 16px; }
.cab-free-badge {
    margin-left: auto;
    background: #dcfce7;
    color: #166534;
    border-radius: 8px;
    padding: 1px 7px;
    font-size: 9px;
    font-weight: 700;
    flex-shrink: 0;
}

/* ── Sidebar footer ──────────────────────────────────── */

.cab-sidebar-footer {
    border-top: 1px solid var(--cab-sb-line);
    padding: 12px;
    flex-shrink: 0;
}
.cab-user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 10px;
    transition: background 0.15s;
}
.cab-user-chip:hover { background: rgba(255,255,255,.06); }
.cab-user-ava {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    flex-shrink: 0;
    color: #fff;
    font-weight: 700;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #64748b, #475569);
}
.cab-user-meta { min-width: 0; flex: 1; }
.cab-user-email {
    font-size: 12px;
    color: rgba(255,255,255,.85);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cab-user-plan { font-size: 10.5px; color: rgba(255,255,255,.4); }
.cab-user-logout { color: rgba(255,255,255,.4); flex-shrink: 0; display: flex; }
.cab-user-logout:hover { color: #fff; }

/* ── Main wrap + topbar ──────────────────────────────── */

.cab-main-wrap {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: var(--cab-bg);
}

.cab-topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    height: var(--cab-hd-h);
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 24px;
    background: rgba(255,255,255,.82);
    backdrop-filter: saturate(180%) blur(10px);
    border-bottom: 1px solid var(--cab-border);
    box-shadow: 0 1px 2px rgba(16,24,40,.03);
}
.cab-hd-toggle {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    border: 1px solid var(--cab-border);
    border-radius: 9px;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--cab-text-2);
    cursor: pointer;
}
.cab-hd-toggle:hover { background: var(--cab-bg); }
.cab-hd-title { display: flex; flex-direction: column; min-width: 0; }
.cab-hd-title h1 {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
    color: var(--cab-text);
}
.cab-hd-sub { font-size: 12px; color: var(--cab-muted); }
.cab-hd-sub:empty { display: none; }
.cab-hd-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.cab-balance-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--cab-accent-soft);
    border: 1px solid #e0e7ff;
    border-radius: 30px;
    padding: 7px 14px;
    color: var(--cab-accent);
    font-weight: 700;
    font-size: 13px;
    white-space: nowrap;
}
.cab-balance-pill svg { width: 16px; height: 16px; }
.cab-balance-pill small { font-weight: 500; color: #818cf8; font-size: 11px; }

.cab-icon-btn {
    position: relative;
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border: 1px solid var(--cab-border);
    border-radius: 10px;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--cab-text-2);
    cursor: pointer;
    text-decoration: none;
}
.cab-icon-btn:hover { background: var(--cab-bg); }
.cab-bell-dot {
    position: absolute;
    top: 8px;
    right: 9px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #dc2626;
    border: 2px solid #fff;
}
.cab-hd-ava {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    flex-shrink: 0;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: #fff;
    font-weight: 700;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.cab-hd-topup svg { width: 16px; height: 16px; }

/* ── Buttons (cabinet override) ──────────────────────── */
.btn { border-radius: 10px; gap: 7px; }
.btn-primary {
    background: var(--cab-accent-grad);
    box-shadow: 0 4px 14px rgba(79,70,229,.32);
}
.btn-primary:hover {
    background: var(--cab-accent-grad);
    filter: brightness(1.06);
}

/* ── Main content ────────────────────────────────────── */

.cab-main {
    flex: 1;
    min-width: 0;
    background: var(--cab-bg);
    padding: 24px;
}

.cab-page-header {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    margin-bottom: 20px;
}
.cab-page-title { display: none; }
.cab-page-header:not(:has(> :not(.cab-page-title))) { display: none; margin: 0; }

/* ── Stat cards ──────────────────────────────────────── */

.cab-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 14px;
    margin-bottom: 28px;
}

.cab-stat {
    background: #fff;
    border: 1px solid var(--cab-border);
    border-radius: 12px;
    padding: 18px 20px;
    box-shadow: 0 1px 3px rgba(16,24,40,.05);
    transition: transform 0.15s, box-shadow 0.15s;
}
.cab-stat:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 22px rgba(16,24,40,.09);
}

.cab-stat-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: #9ca3af;
    margin-bottom: 8px;
}

.cab-stat-value {
    font-size: 28px;
    font-weight: 700;
    color: #111827;
    letter-spacing: -0.03em;
    line-height: 1;
}

.cab-stat-value.blue  { color: #4f46e5; }
.cab-stat-value.green { color: #16a34a; }

.cab-ref-code {
    font-size: 18px;
    letter-spacing: 0.05em;
    cursor: pointer;
    user-select: all;
}

/* ── Section ─────────────────────────────────────────── */

.cab-section {
    margin-bottom: 28px;
}

.cab-section-title {
    font-size: 14px;
    font-weight: 600;
    color: #111827;
    margin-bottom: 14px;
}

/* ── Action cards grid ───────────────────────────────── */

.cab-actions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.cab-action-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 18px 20px;
    text-decoration: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    display: block;
}

.cab-action-card:hover {
    border-color: var(--cab-accent-2);
    box-shadow: 0 0 0 3px rgba(99,102,241,.10);
}

.cab-action-title {
    font-size: 14px;
    font-weight: 600;
    color: #111827;
    margin-bottom: 4px;
}

.cab-action-desc {
    font-size: 12px;
    color: #6b7280;
    line-height: 1.4;
}

/* ── Stat card: icon chip + trend ────────────────────── */
.cab-stat-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}
.cab-stat-ico {
    width: 40px;
    height: 40px;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.cab-stat-ico svg { width: 21px; height: 21px; stroke-width: 1.9; }
.cab-ico-indigo { background: var(--cab-accent-soft); color: var(--cab-accent); }
.cab-ico-green  { background: #dcfce7; color: #16a34a; }
.cab-ico-amber  { background: #fef3c7; color: #d97706; }
.cab-ico-violet { background: #f3e8ff; color: #7c3aed; }
.cab-ico-blue   { background: #e0e7ff; color: #4f46e5; }
.cab-trend {
    font-size: 11.5px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 20px;
}
.cab-trend.up   { background: #dcfce7; color: #16a34a; }
.cab-trend.down { background: #fee2e2; color: #dc2626; }

/* When stat card uses icon-on-top, label sits under value */
.cab-stat-top + .cab-stat-value { line-height: 1; }
.cab-stat-top ~ .cab-stat-label { margin-top: 6px; margin-bottom: 0; }

/* ── Action card: icon ───────────────────────────────── */
.cab-action-row {
    display: flex;
    gap: 13px;
    align-items: flex-start;
}
.cab-action-ico {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: var(--cab-accent-soft);
    color: var(--cab-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.cab-action-ico svg { width: 20px; height: 20px; stroke-width: 1.8; }

/* ── Mini progress bar (tables) ──────────────────────── */
.cab-bar {
    height: 6px;
    border-radius: 6px;
    background: #eef2f7;
    overflow: hidden;
    width: 120px;
}
.cab-bar > i { display: block; height: 100%; background: var(--cab-accent-grad); border-radius: 6px; }

/* ── Cabinet table wrapper ───────────────────────────── */

.cab-table-wrap {
    background: #fff;
    border: 1px solid var(--cab-border);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(16,24,40,.05);
}

.cab-table-header {
    padding: 16px 20px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.cab-table-title {
    font-size: 14px;
    font-weight: 600;
    color: #111827;
}

/* ── Status badges ───────────────────────────────────── */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}

.badge-green  { background: #dcfce7; color: #16a34a; }
.badge-gray   { background: #f3f4f6; color: #6b7280; }
.badge-blue   { background: #e0e7ff; color: #4f46e5; }
.badge-red    { background: #fee2e2; color: #dc2626; }
.badge-amber  { background: #fef3c7; color: #d97706; }

/* ── Empty state ─────────────────────────────────────── */

.cab-empty {
    text-align: center;
    padding: 60px 20px;
    color: #9ca3af;
}

.cab-empty-title {
    font-size: 15px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 6px;
}

.cab-empty-desc {
    font-size: 13px;
    margin-bottom: 20px;
}

/* ── Card ────────────────────────────────────────────── */

.cab-card {
    background: #fff;
    border: 1px solid var(--cab-border);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(16,24,40,.05);
}

.cab-card-title {
    font-size: 15px;
    font-weight: 600;
    color: #111827;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f3f4f6;
}

/* ── Referral link block ─────────────────────────────── */

.ref-link-block {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 20px;
}

.ref-link-url {
    flex: 1;
    font-size: 13px;
    color: #374151;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Modal ───────────────────────────────────────────── */

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 100;
    align-items: center;
    justify-content: center;
}

.modal-overlay.open {
    display: flex;
}

.modal {
    background: #fff;
    border-radius: 12px;
    width: 520px;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0,0,0,.15);
}

.modal-header {
    padding: 20px 24px 16px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: 16px;
    font-weight: 600;
    color: #111827;
}

.modal-close {
    background: none;
    border: none;
    font-size: 20px;
    color: #9ca3af;
    cursor: pointer;
    line-height: 1;
    padding: 2px 6px;
}

.modal-close:hover { color: #374151; }

.modal-body {
    padding: 20px 24px;
}

.modal-footer {
    padding: 14px 24px;
    border-top: 1px solid #e5e7eb;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ── Tickets ─────────────────────────────────────────── */

.ticket-row {
    display: flex;
    align-items: center;
    padding: 14px 20px;
    border-bottom: 1px solid #f3f4f6;
    gap: 14px;
    text-decoration: none;
    color: inherit;
    transition: background 0.1s;
}

.ticket-row:last-child { border-bottom: none; }
.ticket-row:hover { background: #fafafa; }

.ticket-subject {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
    color: #111827;
}

.ticket-meta {
    font-size: 12px;
    color: #9ca3af;
}

/* ── Balance / transaction ───────────────────────────── */

.tx-type-label {
    font-size: 12px;
    color: #6b7280;
}

.tx-amount {
    font-weight: 600;
}

.tx-amount.positive { color: #16a34a; }
.tx-amount.negative { color: #dc2626; }

/* ── Responsive ──────────────────────────────────────── */

/* ── Collapsed sidebar (toggle) ──────────────────────── */
.cab-layout.cab-collapsed .cab-sidebar { width: var(--cab-sb-w-collapsed); }
.cab-layout.cab-collapsed .cab-brand-name,
.cab-layout.cab-collapsed .cab-nav-label,
.cab-layout.cab-collapsed .cab-nav-section,
.cab-layout.cab-collapsed .cab-nav-badge,
.cab-layout.cab-collapsed .cab-nav-dot,
.cab-layout.cab-collapsed .cab-free-badge,
.cab-layout.cab-collapsed .cab-nav-tools-toggle > span,
.cab-layout.cab-collapsed .cab-nav-tools-toggle .tools-arrow,
.cab-layout.cab-collapsed .cab-user-meta,
.cab-layout.cab-collapsed .cab-user-logout { display: none; }
.cab-layout.cab-collapsed .cab-nav-item,
.cab-layout.cab-collapsed .cab-nav-tools-toggle { justify-content: center; gap: 0; }
.cab-layout.cab-collapsed .cab-brand { justify-content: center; padding: 0; }
.cab-layout.cab-collapsed .cab-user-chip { justify-content: center; }

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 860px) {
    .cab-sidebar { width: var(--cab-sb-w-collapsed); }
    .cab-brand-name,
    .cab-nav-label,
    .cab-nav-section,
    .cab-nav-badge,
    .cab-nav-dot,
    .cab-free-badge,
    .cab-nav-tools-toggle > span,
    .cab-nav-tools-toggle .tools-arrow,
    .cab-user-meta,
    .cab-user-logout { display: none; }
    .cab-nav-item,
    .cab-nav-tools-toggle { justify-content: center; gap: 0; }
    .cab-brand { justify-content: center; padding: 0; }
    .cab-user-chip { justify-content: center; }
    .cab-main { padding: 16px; }
    .cab-stats { grid-template-columns: repeat(2, 1fr); }
    .cab-balance-pill small { display: none; }
    .cab-hd-topup span,
    .cab-hd-title p { display: none; }
}
