/* style.css — Core Design System cho Nền Tảng Cashback Web Platform */
:root {
    --bg-dark: #0a0910;
    --bg-surface: #13111c;
    --bg-surface-2: #1c182b;
    --bg-card: #181524;
    --border-color: #2b2540;
    --border-light: #3a3258;

    --pumpkin: #ff7518;
    --pumpkin-glow: rgba(255, 117, 24, 0.25);
    --pumpkin-hover: #ff8c38;
    --purple: #8b5cf6;
    --purple-glow: rgba(139, 92, 246, 0.25);
    --green-ghost: #22c55e;
    --green-glow: rgba(34, 197, 94, 0.25);
    --red-alert: #ef4444;

    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --text-sub: #6b7280;

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-sans);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* ─── Header ─── */
.app-header {
    background: rgba(19, 17, 28, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 12px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
}

.brand-icon {
    font-size: 28px;
    filter: drop-shadow(0 0 8px var(--pumpkin));
}

.brand-title {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #ff8c38, #ff7518, #c084fc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-tag {
    font-size: 10px;
    text-transform: uppercase;
    background: rgba(255, 117, 24, 0.15);
    color: var(--pumpkin);
    border: 1px solid rgba(255, 117, 24, 0.3);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    font-weight: 700;
}

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

/* Halloween Toggle Button */
.btn-halloween-toggle {
    background: var(--bg-surface-2);
    border: 1px solid var(--border-color);
    color: var(--pumpkin);
    padding: 6px 12px;
    border-radius: var(--radius-full);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition);
}

.btn-halloween-toggle:hover {
    border-color: var(--pumpkin);
    box-shadow: 0 0 12px var(--pumpkin-glow);
}

.btn-halloween-toggle.active {
    background: rgba(255, 117, 24, 0.2);
    border-color: var(--pumpkin);
}

/* Auth Pill & Role Switcher */
.user-pill {
    background: var(--bg-surface-2);
    border: 1px solid var(--border-color);
    padding: 6px 14px;
    border-radius: var(--radius-full);
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: var(--transition);
}

.user-pill:hover {
    border-color: var(--purple);
}

.user-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--purple);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
}

.view-mode-badge {
    background: rgba(139, 92, 246, 0.2);
    color: #c084fc;
    border: 1px solid rgba(139, 92, 246, 0.4);
    font-size: 11px;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
}

/* ─── Main Content Container ─── */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 20px;
    width: 100%;
    flex: 1;
}

/* ─── Balance Summary Widget (Khách hàng) ─── */
.balance-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.balance-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    position: relative;
    overflow: hidden;
    transition: var(--transition);
}

.balance-card:hover {
    border-color: var(--border-light);
    transform: translateY(-2px);
}

.balance-card.available {
    border-color: rgba(34, 197, 94, 0.4);
    background: linear-gradient(135deg, var(--bg-card), rgba(34, 197, 94, 0.05));
}

.balance-card.holding {
    border-color: rgba(255, 117, 24, 0.4);
    background: linear-gradient(135deg, var(--bg-card), rgba(255, 117, 24, 0.05));
}

.balance-card.pending {
    border-color: rgba(139, 92, 246, 0.4);
    background: linear-gradient(135deg, var(--bg-card), rgba(139, 92, 246, 0.05));
}

.balance-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.balance-amount {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -0.5px;
    font-family: var(--font-mono);
}

.balance-card.available .balance-amount { color: var(--green-ghost); }
.balance-card.holding .balance-amount { color: var(--pumpkin); }
.balance-card.pending .balance-amount { color: #c084fc; }

.balance-sub {
    font-size: 12px;
    color: var(--text-sub);
    margin-top: 6px;
}

.balance-action {
    margin-top: 14px;
}

/* ─── Navigation Tabs ─── */
.tabs-nav {
    display: flex;
    gap: 8px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 24px;
    overflow-x: auto;
    padding-bottom: 2px;
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 600;
    padding: 10px 16px;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    transition: var(--transition);
    position: relative;
}

.tab-btn:hover {
    color: var(--text-main);
    background: var(--bg-surface);
}

.tab-btn.active {
    color: var(--pumpkin);
    background: var(--bg-surface);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--pumpkin);
    box-shadow: 0 0 8px var(--pumpkin);
}

.tab-content {
    display: none;
    animation: fadeIn 0.25s ease-in-out;
}

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

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ─── Converter Section (Chuyển đổi Link) ─── */
.converter-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 28px;
    margin-bottom: 24px;
}

.converter-title {
    font-size: 20px;
    font-weight: 800;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.converter-desc {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.supported-badges {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.sup-badge {
    font-size: 12px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.sup-badge.tiktok { background: #000; color: #fff; border: 1px solid #333; }
.sup-badge.shopee { background: #ee4d2d; color: #fff; }
.sup-badge.lazada { background: #0f146d; color: #fff; }

.input-group {
    display: flex;
    gap: 10px;
}

.input-link {
    flex: 1;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 14px 18px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-family: inherit;
    transition: var(--transition);
}

.input-link:focus {
    outline: none;
    border-color: var(--pumpkin);
    box-shadow: 0 0 0 3px var(--pumpkin-glow);
}

.btn-convert {
    background: linear-gradient(135deg, #ff8c38, #ff7518);
    color: #fff;
    border: none;
    font-weight: 700;
    font-size: 15px;
    padding: 0 24px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.btn-convert:hover {
    box-shadow: 0 0 16px var(--pumpkin-glow);
    transform: scale(1.02);
}

/* Result Box */
.result-box {
    margin-top: 20px;
    background: var(--bg-surface-2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
}

.result-url-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin: 10px 0;
}

.result-url {
    flex: 1;
    background: var(--bg-dark);
    border: 1px solid var(--border-light);
    color: var(--pumpkin);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-copy {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    color: var(--text-main);
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition);
}

.btn-copy:hover {
    background: var(--pumpkin);
    border-color: var(--pumpkin);
}

.guidance-box {
    margin-top: 14px;
    padding: 14px;
    border-radius: var(--radius-sm);
    background: rgba(255, 117, 24, 0.08);
    border-left: 3px solid var(--pumpkin);
    font-size: 13px;
    color: var(--text-main);
    white-space: pre-line;
}

/* ─── Table Styles (Đơn hàng, Bảng hoa hồng) ─── */
.table-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    overflow: hidden;
}

.table-header-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 12px;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.filter-btn {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 13px;
    padding: 6px 14px;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: var(--transition);
}

.filter-btn:hover {
    color: var(--text-main);
}

.filter-btn.active {
    background: rgba(255, 117, 24, 0.15);
    border-color: var(--pumpkin);
    color: var(--pumpkin);
    font-weight: 600;
}

.search-input {
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 8px 14px;
    border-radius: var(--radius-md);
    font-size: 13px;
    width: 240px;
}

.custom-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
    text-align: left;
}

.custom-table th {
    background: var(--bg-surface);
    color: var(--text-muted);
    padding: 12px 14px;
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
}

.custom-table td {
    padding: 14px;
    border-bottom: 1px solid var(--border-color);
}

.custom-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 600;
}

.status-badge.approved { background: rgba(34, 197, 94, 0.15); color: #4ade80; border: 1px solid rgba(34, 197, 94, 0.3); }
.status-badge.pending  { background: rgba(139, 92, 246, 0.15); color: #c084fc; border: 1px solid rgba(139, 92, 246, 0.3); }
.status-badge.cancelled{ background: rgba(239, 68, 68, 0.15); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.3); }
.status-badge.holding  { background: rgba(255, 117, 24, 0.15); color: #ff8c38; border: 1px solid rgba(255, 117, 24, 0.3); }

/* ─── AI Chatbot Drawer & Widget ─── */
.chat-widget-button {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: linear-gradient(135deg, #ff7518, #8b5cf6);
    color: white;
    border: none;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(255, 117, 24, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    z-index: 1000;
    transition: var(--transition);
}

.chat-widget-button:hover {
    transform: scale(1.08) rotate(5deg);
    box-shadow: 0 6px 28px rgba(139, 92, 246, 0.6);
}

.chat-modal {
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: min(92vw, 420px);
    height: 580px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
    z-index: 1001;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: var(--transition);
}

.chat-modal.hidden {
    display: none;
}

.chat-header {
    background: var(--bg-surface-2);
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header-title {
    font-size: 15px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
}

.chat-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.msg-bubble {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.45;
}

.msg-bubble.user {
    align-self: flex-end;
    background: linear-gradient(135deg, #ff8c38, #ff7518);
    color: #fff;
    border-bottom-right-radius: 2px;
}

.msg-bubble.bot {
    align-self: flex-start;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    border-bottom-left-radius: 2px;
}

.msg-bubble.admin {
    align-self: flex-start;
    background: rgba(139, 92, 246, 0.15);
    border: 1px solid var(--purple);
    color: #e9d5ff;
}

.chat-input-row {
    padding: 12px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-surface-2);
    display: flex;
    gap: 8px;
}

.chat-input-text {
    flex: 1;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-size: 13px;
}

.btn-send-msg {
    background: var(--pumpkin);
    border: none;
    color: white;
    padding: 0 16px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 700;
}

.btn-escalate-human {
    background: transparent;
    border: 1px dashed var(--pumpkin);
    color: var(--pumpkin);
    font-size: 12px;
    padding: 6px 10px;
    border-radius: var(--radius-md);
    cursor: pointer;
    margin-top: 8px;
    width: 100%;
    text-align: center;
}

/* ─── Admin Portal UI ─── */
/* Update installation progress */
.update-progress {
    display: grid; gap: 9px; padding: 14px;
    border: 1px solid var(--border-color); border-radius: var(--radius-md);
    background: var(--bg-surface-2, var(--bg-card));
}
.update-progress.hidden { display: none !important; }
.update-progress-heading { display:flex; align-items:center; justify-content:space-between; gap:12px; color:var(--text-primary); }
.update-progress-heading span { color:var(--pumpkin); font:700 13px var(--font-mono, monospace); white-space:nowrap; }
.update-progress-track { height:10px; overflow:hidden; border-radius:999px; background:var(--bg-input, rgba(127,127,127,.22)); border:1px solid var(--border-color); }
.update-progress-fill { width:0%; height:100%; border-radius:inherit; background:linear-gradient(90deg,var(--pumpkin),#ffc06a); transition:width .18s ease; }
.update-progress.is-indeterminate .update-progress-fill { width:34%; animation:update-progress-slide 1.25s ease-in-out infinite; }
.update-progress.is-error { border-color:#dc5555; }
.update-progress.is-error .update-progress-fill { background:#dc5555; }
@keyframes update-progress-slide { 0% { transform:translateX(-110%); } 100% { transform:translateX(310%); } }
@media (prefers-reduced-motion: reduce) { .update-progress-fill { transition:none; } .update-progress.is-indeterminate .update-progress-fill { animation:none; width:60%; } }

.admin-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
}

.kpi-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.kpi-card {
    background: var(--bg-surface-2);
    border: 1px solid var(--border-color);
    padding: 16px;
    border-radius: var(--radius-md);
}

.kpi-num {
    font-size: 22px;
    font-weight: 800;
    color: var(--pumpkin);
    font-family: var(--font-mono);
}

.kpi-label {
    font-size: 12px;
    color: var(--text-muted);
}

.ai-copilot-box {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.1), rgba(255, 117, 24, 0.1));
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 24px;
}

.ai-copilot-title {
    font-size: 16px;
    font-weight: 700;
    color: #c084fc;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.ai-copilot-text {
    font-size: 13.5px;
    line-height: 1.6;
    color: var(--text-main);
    white-space: pre-line;
}

/* Admin Subnav, Subpanes & Inbox */
.admin-subnav {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
    overflow-x: auto;
}

.admin-subnav-btn {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.admin-subnav-btn:hover {
    color: var(--text-main);
    border-color: var(--purple);
}

.admin-subnav-btn.active {
    background: rgba(139, 92, 246, 0.2);
    border-color: var(--purple);
    color: #c084fc;
    font-weight: 700;
}

.admin-pane {
    display: none;
    animation: fadeIn 0.2s ease-in-out;
}

.admin-pane.active {
    display: block;
}

.inbox-split {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 0;
    min-height: 480px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

@media (max-width: 860px) {
    .inbox-split {
        grid-template-columns: 1fr;
    }
}

/* ─── Modals (Rút tiền, Đăng nhập) ─── */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-backdrop.hidden {
    display: none;
}

.modal-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    max-width: 480px;
    width: 100%;
    padding: 24px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7);
}

.modal-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-title {
    font-size: 18px;
    font-weight: 700;
}

.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-muted);
}

.form-control {
    width: 100%;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-family: inherit;
}

.form-control:focus {
    outline: none;
    border-color: var(--pumpkin);
}

.btn-primary {
    width: 100%;
    background: linear-gradient(135deg, #ff8c38, #ff7518);
    color: white;
    border: none;
    padding: 12px;
    border-radius: var(--radius-md);
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary:hover {
    box-shadow: 0 0 16px var(--pumpkin-glow);
}

/* ─── Footer ─── */
.app-footer {
    border-top: 1px solid var(--border-color);
    background: var(--bg-surface);
    padding: 20px;
    text-align: center;
    font-size: 13px;
    color: var(--text-sub);
    margin-top: auto;
}


/* Auth modal: three independent, accessible tabs */
.auth-tabs{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;margin:4px 0 22px;padding:5px;background:var(--surface-2,rgba(127,127,127,.10));border:1px solid var(--border-color);border-radius:12px}
.auth-tab{appearance:none;border:1px solid transparent;background:transparent;color:var(--text-muted);padding:11px 8px;border-radius:9px;font:inherit;font-size:13px;font-weight:750;cursor:pointer;transition:all .18s ease}
.auth-tab:hover{color:var(--text-main);background:rgba(127,127,127,.08)}
.auth-tab.active{color:var(--text-main);background:var(--card-bg,rgba(127,127,127,.16));border-color:var(--border-color);box-shadow:0 2px 8px rgba(0,0,0,.08)}
.auth-panel{animation:authPanelIn .18s ease}
.auth-hint{font-size:12px;line-height:1.55;color:var(--text-muted);margin:12px 0 0;text-align:center}
@keyframes authPanelIn{from{opacity:.55;transform:translateY(4px)}to{opacity:1;transform:translateY(0)}}
@media(max-width:420px){.auth-tabs{gap:4px}.auth-tab{font-size:12px;padding:10px 4px}}


/* Utility: hide inactive panels and controls reliably */
.hidden { display: none !important; }


/* Mobile navigation drawer */
.mobile-menu-toggle { display:none; border:1px solid var(--border-color); background:var(--bg-surface-2); color:var(--text-main); border-radius:12px; padding:8px 12px; font-weight:700; margin:0; cursor:pointer; }
.mobile-menu-backdrop { display:none; }
@media (max-width: 760px) {
  .mobile-menu-toggle { display:inline-flex; align-items:center; gap:8px; }
  .tabs-nav {
    position:fixed; z-index:10001; top:0; left:0; bottom:0; width:min(82vw,320px);
    margin:0; padding:72px 14px 24px; border:0; border-right:1px solid var(--border-color);
    background:var(--bg-surface); box-shadow:12px 0 32px rgba(0,0,0,.28);
    display:flex; flex-direction:column; align-items:stretch; gap:6px; overflow-y:auto;
    transform:translateX(-110%); transition:transform .22s ease;
  }
  .tabs-nav.mobile-open { transform:translateX(0); }
  .tabs-nav .tab-btn { width:100%; justify-content:flex-start; text-align:left; padding:14px 12px; border-radius:10px; white-space:normal; margin:0 !important; }
  .tabs-nav .tab-btn.active::after { display:none; }
  .mobile-menu-backdrop.visible { display:block; position:fixed; inset:0; z-index:10000; background:rgba(0,0,0,.48); }
  .app-header { gap:8px 10px; padding:10px 12px; position:relative; }
  .brand-title { font-size:16px; }
  .user-pill { max-width:100%; flex-wrap:wrap; justify-content:flex-end; }
  .user-pill #user-name-display { max-width:120px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
  .main-container { padding:14px 12px !important; }
  .balance-summary-grid { grid-template-columns:1fr !important; }
}


/* ─── V15 ─── */
.header-left { display:flex; flex-direction:column; align-items:flex-start; gap:8px; min-width:0; }
@media (min-width: 761px) { .header-left { flex-direction:row; align-items:center; } }

/* Bộ chọn giao diện */
.theme-picker { display:flex; align-items:center; gap:6px; background:var(--bg-surface-2); border:1px solid var(--border-color); border-radius:var(--radius-full); padding:4px 10px; font-size:13px; }
.theme-picker select { background:transparent; border:0; color:var(--text-main); font:inherit; max-width:140px; cursor:pointer; }
.theme-picker select option { background:var(--bg-surface); color:var(--text-main); }

/* Modal không bị tràn màn hình thấp / điện thoại */
.modal-card { max-height:calc(100dvh - 40px); overflow-y:auto; }
#auth-telegram-view .auth-hint { margin-bottom:14px; }

/* Toast glass: gọn, căn giữa, không tràn ngang và tránh vùng safe-area */
#toast-container {
  position:fixed !important;
  z-index:20000 !important;
  top:calc(env(safe-area-inset-top, 0px) + 12px) !important;
  left:50% !important;
  right:auto !important;
  transform:translateX(-50%);
  width:min(440px, calc(100vw - 28px)) !important;
  max-height:min(30dvh, 220px);
  display:flex !important;
  flex-direction:column;
  align-items:stretch !important;
  gap:8px;
  overflow:visible;
  pointer-events:none;
}
#toast-container > button.toast-notice {
  box-sizing:border-box;
  display:block;
  width:100%;
  max-width:100% !important;
  max-height:min(24dvh, 168px);
  overflow:auto;
  overflow-wrap:anywhere;
  white-space:normal;
  text-align:left;
  padding:11px 15px;
  border:1px solid color-mix(in srgb, var(--border-color, #8ba6c8) 72%, transparent);
  border-radius:16px;
  color:var(--text-main, #f8fafc);
  background:color-mix(in srgb, var(--bg-surface, #17243a) 76%, transparent);
  -webkit-backdrop-filter:blur(20px) saturate(145%);
  backdrop-filter:blur(20px) saturate(145%);
  box-shadow:0 12px 34px rgba(0,0,0,.30), inset 0 1px 0 rgba(255,255,255,.10);
  font:600 13px/1.45 inherit;
  font-family:inherit;
  font-size:13px;
  line-height:1.45;
  font-weight:600;
  cursor:pointer;
  pointer-events:auto;
  animation:toast-glass-in .22s ease-out both;
}
#toast-container > button.toast-notice[data-type="success"] { background:rgba(22,163,74,.78); border-color:rgba(134,239,172,.48); color:#f0fdf4; }
#toast-container > button.toast-notice[data-type="error"] { background:rgba(185,28,28,.80); border-color:rgba(252,165,165,.5); color:#fff1f2; }
#toast-container > button.toast-notice[data-type="warning"] { background:rgba(180,83,9,.80); border-color:rgba(253,186,116,.5); color:#fff7ed; }
#toast-container > button.toast-notice[data-type="info"] { background:color-mix(in srgb, var(--bg-surface-2, #263b5a) 78%, transparent); }
#toast-container > button.toast-notice.is-leaving { opacity:0; transform:translateY(-8px); transition:opacity .2s ease, transform .2s ease; }
@keyframes toast-glass-in { from { opacity:0; transform:translateY(-8px) scale(.98); } to { opacity:1; transform:translateY(0) scale(1); } }
@media (max-width:480px) {
  #toast-container { width:calc(100vw - 24px) !important; top:calc(env(safe-area-inset-top, 0px) + 8px) !important; }
  #toast-container > button.toast-notice { border-radius:14px; padding:10px 13px; font-size:12.5px; max-height:20dvh; }
}
@media (prefers-reduced-motion:reduce) {
  #toast-container > button.toast-notice { animation:none !important; transition:none !important; }
}

/* Khung chat: chế độ Admin */
.chat-mode-bar { padding:0 12px 4px; background:var(--bg-surface-2); }
.chat-confirm { margin-top:8px; padding:10px 12px; border:1px solid var(--pumpkin); border-radius:var(--radius-md); font-size:12.5px; line-height:1.5; }
.chat-confirm-actions { display:flex; gap:8px; margin-top:8px; }
.chat-confirm-actions .btn-convert { padding:8px 14px; font-size:13px; }
.chat-admin-bar { margin-top:8px; display:flex; flex-direction:column; gap:6px; font-size:12px; color:var(--text-muted); }
.chat-admin-bar .btn-copy:disabled { opacity:.55; cursor:not-allowed; }
.chat-unread-badge { position:absolute; top:-4px; right:-4px; min-width:20px; height:20px; padding:0 5px; border-radius:10px; background:var(--red-alert); color:#fff; font-size:12px; font-weight:700; display:flex; align-items:center; justify-content:center; }
.chat-widget-button { position:fixed; }
.msg-bubble .msg-action { margin-top:8px; }

/* V16 header/auth usability */
.app-header{position:relative;z-index:20}.header-controls{margin-left:auto;display:flex;align-items:center;justify-content:flex-end;gap:12px}.user-pill{display:flex;align-items:center;gap:8px;cursor:default;position:relative;z-index:22}.user-pill #btn-auth-trigger{position:relative;z-index:23;pointer-events:auto}.theme-picker{display:flex;align-items:center;gap:6px;white-space:nowrap}.theme-picker select{max-width:150px}.balance-summary-grid{width:100%}.tab-content#tab-finance.active{display:block}


/* V17: bố cục header mobile — tài khoản luôn ở góc phải trên cùng,
   danh mục nằm dưới thương hiệu và bộ chọn theme nằm dưới danh mục. */
@media (max-width: 760px) {
  .app-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "brand account"
      "menu menu"
      "theme theme";
    align-items: center;
    gap: 10px 8px;
    padding: 10px 12px;
  }
  .header-left { display: contents; }
  .header-left > .brand { grid-area: brand; min-width: 0; }
  .header-left > #mobile-menu-toggle { grid-area: menu; justify-self: start; }
  .header-left > #theme-picker { grid-area: theme; margin: 0 !important; justify-self: start; }
  .header-controls { grid-area: account; margin: 0; min-width: 0; }
  .user-pill { max-width: min(54vw, 250px); flex-wrap: nowrap; justify-content: flex-end; gap: 6px; }
  .user-pill #user-name-display { max-width: 100px; }
  .user-pill #btn-auth-trigger { white-space: nowrap; }
  .brand-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .brand-sub { display: none; }
}

/* Profile section controls: match the outline icon language used by admin navigation. */
.profile-section-toggle{display:flex;align-items:center;justify-content:center;gap:9px;}
.profile-section-toggle .profile-toggle-icon{width:17px;height:17px;flex:0 0 17px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round;}
.profile-section-toggle .profile-toggle-chevron{font-size:17px;line-height:1;opacity:.8;margin-left:2px;}


/* Independent contact-link manager: contacts can be saved first and verified on demand. */
.profile-contact-manager{display:grid;gap:14px;}
.profile-contact-row{padding:13px;border:1px solid var(--border-color);border-radius:14px;background:color-mix(in srgb,var(--card-bg, transparent) 82%, transparent);}
.profile-contact-heading{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:10px;flex-wrap:wrap;}
.profile-contact-heading strong{font-size:14px;color:var(--text-color);}
.profile-contact-state{font-size:12px;color:var(--text-sub);}
.profile-contact-state.is-pending{color:#f0b66b;}
.profile-contact-state.is-verified{color:#75d6a0;}
.profile-contact-actions{display:flex;gap:8px;margin-top:9px;}
.profile-contact-actions button{flex:1;min-width:0;padding:9px 10px;font-size:13px;}
.profile-contact-verify{border:1px solid rgba(245,177,99,.45);border-radius:10px;background:rgba(245,177,99,.17);color:#f5c48b;font-weight:700;}
.profile-contact-verify:disabled{opacity:1;cursor:default;}
.profile-contact-verify.is-verified{border-color:rgba(105,205,145,.4);background:rgba(105,205,145,.16);color:#83dba7;}
.profile-contact-otp{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:8px;margin-top:10px;}
.profile-contact-otp button{padding:9px 12px;}
@media(max-width:420px){.profile-contact-actions{flex-direction:column}.profile-contact-otp{grid-template-columns:1fr}}


/* Account is a first-class navigation page, not a modal. */
.profile-page{width:100%;}
.profile-page-card{max-width:860px;margin:0 auto;padding:clamp(16px,3vw,28px);border:1px solid var(--border-color);border-radius:var(--radius-lg);background:var(--bg-surface);box-shadow:0 10px 32px rgba(0,0,0,.16);}
.profile-page-card .form-group{margin-bottom:16px;}
.profile-page-divider{height:1px;background:var(--border-color);margin:24px 0 18px;}
.profile-page-section-title{font-size:18px;font-weight:800;margin:0 0 14px;color:var(--text-color);}
.profile-page-fields{padding-top:0;}
.profile-page-card > .btn-primary{width:100%;}
.profile-page-card > .btn-copy:last-child{width:100%;}
@media(max-width:600px){.profile-page-card{padding:16px;border-radius:16px;}.profile-page-section-title{font-size:16px;}}

.profile-contact-page-card{max-width:860px;}
.profile-contact-page-card .profile-contact-manager{padding-top:0!important;}

/* V36.7.16 linked contact cards and OTP feedback */
.profile-contact-current{padding:12px 14px;border:1px solid var(--border-color);border-radius:10px;background:var(--input-bg,rgba(0,0,0,.12));color:var(--text-color);font-weight:650;overflow-wrap:anywhere;}
.profile-contact-actions{display:flex;gap:8px;margin-top:9px;}
.profile-contact-actions button{flex:1;min-width:0;padding:8px 10px;font-size:13px;}
.profile-contact-delete{border-color:rgba(230,110,110,.38)!important;color:#f0a0a0!important;}
.profile-contact-verify-line{display:flex;align-items:center;gap:10px;margin-top:9px;flex-wrap:wrap;}
.profile-contact-verify-line .profile-contact-verify{padding:8px 14px;min-width:112px;}
.profile-contact-countdown{font-size:12px;color:var(--text-sub);font-variant-numeric:tabular-nums;}
.profile-contact-verify.is-unavailable,.profile-contact-verify:disabled.is-unavailable{background:rgba(150,150,160,.13);border-color:rgba(150,150,160,.25);color:#a4a4ad;opacity:1;}
.profile-contact-verify:disabled:not(.is-verified):not(.is-unavailable){opacity:.72;}
@media(max-width:420px){.profile-contact-actions{flex-direction:row}.profile-contact-otp{grid-template-columns:minmax(0,1fr) auto}}

/* V36.7.65: keep Admin navigation available while its content scrolls. */
#tab-admin > .admin-card { overflow: visible; }
.admin-subnav { position: sticky; top: 8px; z-index: 35; background: var(--bg-card, var(--bg-surface)); padding: 10px 8px 12px; border-radius: 12px; box-shadow: 0 8px 22px rgba(0,0,0,.12); }
.admin-auto-withdrawal-tag,.admin-bank-review-warning { margin-top:5px; font-size:11px; font-weight:700; }
.admin-auto-withdrawal-tag { color:#8b5cf6; }
.admin-bank-review-warning { color:#f59e0b; }

.admin-nav-section-label { flex: 0 0 100%; padding: 7px 8px 0; color: var(--text-sub); font-size: 10px; font-weight: 800; letter-spacing: .12em; }
@media (max-width: 700px) { .admin-subnav { top: 4px; max-height: 38vh; overflow-y: auto !important; overscroll-behavior: contain; } }
.admin-subnav { overflow: visible !important; flex-wrap: wrap !important; }
@media (max-width: 700px) { .admin-subnav { max-height: none !important; overflow: visible !important; } }


/* V36.7.67: mobile Admin navigation must scroll with the page, not stick over content. */
@media (max-width: 700px) {
  #tab-admin,
  #tab-admin > .admin-card {
    overflow: visible !important;
    min-height: 0;
  }
  #tab-admin .admin-subnav {
    position: static !important;
    top: auto !important;
    z-index: auto !important;
    max-height: none !important;
    height: auto !important;
    overflow: visible !important;
    overscroll-behavior: auto !important;
    -webkit-overflow-scrolling: auto;
    touch-action: pan-y;
    margin-bottom: 18px;
  }
  #tab-admin {
    padding-bottom: max(28px, env(safe-area-inset-bottom));
    scroll-padding-bottom: 28px;
  }
}
