/* ==============================
   AdsCar Hub — Design System
   ============================== */

:root {
    --bg:          #060d1a;
    --surface:     #0c1829;
    --surface-2:   #111f35;
    --border:      rgba(255,255,255,0.07);
    --border-hover:rgba(249,115,22,0.4);
    --accent:      #f97316;
    --accent-dim:  rgba(249,115,22,0.12);
    --text:        #f0f4ff;
    --text-muted:  rgba(240,244,255,0.5);
    --text-faint:  rgba(240,244,255,0.25);
    --success:     #10b981;
    --danger:      #ef4444;
    --danger-dim:  rgba(239,68,68,0.12);
    --blue:        #3b82f6;
    --blue-dim:    rgba(59,130,246,0.12);
    --green-dim:   rgba(16,185,129,0.12);
    --sidebar-w:   260px;
    --radius:      14px;
    --radius-sm:   8px;
    --shadow:      0 4px 24px rgba(0,0,0,0.4);
}

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

html, body {
    height: 100%;
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}

/* ==============================
   Toast Notifications
   ============================== */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 18px;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: var(--shadow);
    animation: slideIn 0.3s ease;
    min-width: 260px;
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.info    { border-left: 3px solid var(--accent); }

@keyframes slideIn {
    from { opacity:0; transform: translateX(20px); }
    to   { opacity:1; transform: translateX(0); }
}

/* ==============================
   Login Overlay
   ============================== */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(6,13,26,0.97);
    backdrop-filter: blur(12px);
    z-index: 5000;
    display: none;
    align-items: center;
    justify-content: center;
}
.overlay.active { display: flex; }

.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 48px 40px;
    width: 100%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 32px 64px rgba(0,0,0,0.5);
}

.login-logo {
    font-size: 32px;
    font-weight: 900;
    letter-spacing: -1px;
    margin-bottom: 4px;
}
.login-logo span { color: var(--accent); }

.login-sub {
    font-size: 11px;
    font-weight: 700;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 32px;
}

.login-card h2 {
    font-size: 22px;
    font-weight: 800;
    margin-bottom: 6px;
}

.login-hint {
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 28px;
}

.user-selection { display: flex; flex-direction: column; gap: 12px; }

.user-btn {
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 16px 20px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 14px;
    transition: all 0.2s ease;
}
.user-btn:hover {
    background: var(--accent-dim);
    border-color: var(--accent);
    color: var(--accent);
    transform: translateY(-1px);
}
.user-avatar {
    width: 36px; height: 36px;
    background: var(--accent-dim);
    color: var(--accent);
    border-radius: 50%;
    font-weight: 800;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ==============================
   App Layout
   ============================== */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ==============================
   Sidebar
   ============================== */
.sidebar {
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 28px 16px;
    flex-shrink: 0;
}

.sidebar-header { margin-bottom: 36px; padding: 0 8px; }

.logo {
    font-size: 22px;
    font-weight: 900;
    letter-spacing: -0.5px;
}
.logo span { color: var(--accent); }

.user-badge {
    margin-top: 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--accent);
    background: var(--accent-dim);
    padding: 3px 10px;
    border-radius: 100px;
    display: inline-block;
    letter-spacing: 0.5px;
}

.menu { flex: 1; display: flex; flex-direction: column; gap: 2px; }

.menu-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    padding: 16px 10px 6px;
}

.menu-item {
    width: 100%;
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.15s ease;
}
.menu-item:hover {
    background: rgba(255,255,255,0.04);
    color: var(--text);
}
.menu-item.active {
    background: var(--accent-dim);
    color: var(--accent);
    font-weight: 700;
}
.menu-icon {
    width: 18px; height: 18px;
    flex-shrink: 0;
    stroke: currentColor;
}

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

.logout-btn {
    width: 100%;
    background: none;
    border: 1px solid rgba(239,68,68,0.2);
    color: var(--danger);
    padding: 10px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
}
.logout-btn:hover { background: var(--danger-dim); }

/* ==============================
   Main Content
   ============================== */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 40px 44px;
}

.content-section { display: none; animation: fadeUp 0.25s ease; }
.content-section.active { display: block; }

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

/* ==============================
   Section Header
   ============================== */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 32px;
    gap: 20px;
    flex-wrap: wrap;
}
.section-header h1 {
    font-size: 28px;
    font-weight: 900;
    letter-spacing: -0.5px;
    line-height: 1.1;
}
.section-header p {
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 4px;
}
.header-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ==============================
   Buttons
   ============================== */
.btn-action {
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}
.btn-action:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn-action.outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}
.btn-action.outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-action.danger-outline {
    background: transparent;
    border: 1px solid rgba(239,68,68,0.3);
    color: var(--danger);
}
.btn-action.danger-outline:hover { background: var(--danger-dim); }

/* ==============================
   Dashboard KPIs
   ============================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px 24px;
    transition: border-color 0.2s;
}
.stat-card:hover { border-color: var(--border-hover); }
.stat-card.accent { border-color: rgba(249,115,22,0.25); background: var(--accent-dim); }
.stat-card.danger { border-color: rgba(239,68,68,0.2); background: var(--danger-dim); }

.stat-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 10px;
}
.stat-value {
    font-size: 26px;
    font-weight: 900;
    color: var(--accent);
    letter-spacing: -0.5px;
    line-height: 1;
}
.stat-card.danger .stat-value { color: var(--danger); }
.stat-sub {
    font-size: 11px;
    color: var(--text-faint);
    margin-top: 6px;
}

/* ==============================
   Dashboard Row
   ============================== */
.dashboard-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.chart-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
}
.chart-card h3 {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

/* Bar Chart */
.bar-chart {
    display: flex;
    align-items: flex-end;
    gap: 20px;
    height: 140px;
}
.bar-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    height: 100%;
    justify-content: flex-end;
}
.bar {
    width: 100%;
    background: var(--accent);
    border-radius: 6px 6px 0 0;
    min-height: 4px;
    transition: height 0.6s ease;
    position: relative;
}
.bar:hover::after {
    content: attr(data-value);
    position: absolute;
    top: -28px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
    color: var(--text);
}
.bar-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
}
.bar-empty {
    color: var(--text-faint);
    font-size: 13px;
    text-align: center;
    padding: 30px 0;
    width: 100%;
    align-self: center;
}

/* Event List */
.event-list { display: flex; flex-direction: column; gap: 10px; }
.event-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.02);
}
.event-date-badge {
    background: var(--accent-dim);
    color: var(--accent);
    border-radius: 8px;
    padding: 6px 10px;
    text-align: center;
    font-size: 11px;
    font-weight: 800;
    line-height: 1.3;
    min-width: 44px;
    flex-shrink: 0;
}
.event-info strong { font-size: 13px; display: block; }
.event-info span { font-size: 11px; color: var(--text-muted); }
.no-events { color: var(--text-faint); font-size: 13px; text-align: center; padding: 20px 0; }

/* ==============================
   Tabs
   ============================== */
.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
}
.tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    padding: 10px 18px;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
}
.tab:hover { color: var(--text); }
.tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

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

/* ==============================
   Tables
   ============================== */
.table-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

table { width: 100%; border-collapse: collapse; }

thead th {
    padding: 13px 18px;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    background: rgba(255,255,255,0.02);
    border-bottom: 1px solid var(--border);
    text-align: left;
    white-space: nowrap;
}

tbody td {
    padding: 14px 18px;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(255,255,255,0.015); }

.empty-row {
    text-align: center;
    color: var(--text-faint);
    padding: 40px !important;
    font-size: 13px;
}

.value-cell { color: var(--accent); font-weight: 700; }
.danger-cell { color: var(--danger); font-weight: 700; }

.delete-btn {
    background: none;
    border: none;
    color: var(--text-faint);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 16px;
    transition: all 0.15s;
    font-family: inherit;
}
.delete-btn:hover { background: var(--danger-dim); color: var(--danger); }

/* ==============================
   Expense Summary
   ============================== */
.expense-summary {
    background: var(--danger-dim);
    border: 1px solid rgba(239,68,68,0.2);
    border-radius: var(--radius);
    padding: 20px 24px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.expense-total-value {
    font-size: 28px;
    font-weight: 900;
    color: var(--danger);
    letter-spacing: -0.5px;
}

/* ==============================
   Documents Grid
   ============================== */
.docs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}

.doc-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    text-decoration: none;
    color: var(--text);
    transition: all 0.2s;
}
.doc-card:hover {
    border-color: var(--border-hover);
    background: var(--accent-dim);
    transform: translateY(-2px);
}
.doc-icon-wrap {
    width: 46px; height: 46px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.doc-icon-wrap.orange { background: var(--accent-dim); color: var(--accent); }
.doc-icon-wrap.blue   { background: var(--blue-dim);   color: var(--blue); }
.doc-icon-wrap.green  { background: var(--green-dim);  color: var(--success); }
.doc-info { flex: 1; }
.doc-info h4 { font-size: 14px; font-weight: 700; margin-bottom: 2px; }
.doc-info p  { font-size: 12px; color: var(--text-muted); }
.doc-arrow { color: var(--text-faint); flex-shrink: 0; }
.doc-card:hover .doc-arrow { color: var(--accent); }

/* ==============================
   Modals
   ============================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.75);
    backdrop-filter: blur(6px);
    z-index: 4000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-overlay.active { display: flex; }

.modal-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 24px 48px rgba(0,0,0,0.5);
    animation: modalIn 0.25s ease;
}
@keyframes modalIn {
    from { opacity:0; transform: scale(0.95) translateY(10px); }
    to   { opacity:1; transform: scale(1) translateY(0); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 22px 26px 0;
}
.modal-header h3 { font-size: 17px; font-weight: 800; }
.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 22px;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
    transition: color 0.15s;
}
.modal-close:hover { color: var(--text); }

form { padding: 20px 26px 0; }

.form-group { margin-bottom: 14px; }
.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}
.form-group input {
    width: 100%;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.15s;
    outline: none;
}
.form-group input:focus { border-color: var(--accent); }
.form-group input::placeholder { color: var(--text-faint); }

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

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 18px 26px 22px;
    border-top: 1px solid var(--border);
    margin-top: 16px;
}

.btn-cancel {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
}
.btn-cancel:hover { color: var(--text); border-color: rgba(255,255,255,0.2); }

.btn-submit {
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 10px 22px;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 120px;
}
.btn-submit:hover { filter: brightness(1.1); }
.btn-submit:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-submit.danger { background: var(--danger); }

/* ==============================
   Responsive — Mobile First
   ============================== */

/* Mobile Top Bar (hidden on desktop) */
.mobile-topbar {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 56px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    z-index: 3000;
    align-items: center;
    padding: 0 16px;
    gap: 12px;
}

.mobile-logo {
    flex: 1;
    font-size: 20px;
    font-weight: 900;
    letter-spacing: -0.5px;
}
.mobile-logo span { color: var(--accent); }

.mobile-user-badge {
    font-size: 11px;
    font-weight: 700;
    color: var(--accent);
    background: var(--accent-dim);
    padding: 3px 10px;
    border-radius: 100px;
}

/* Hamburger Button */
.hamburger {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    transition: background 0.15s;
}
.hamburger:hover { background: rgba(255,255,255,0.06); }
.hamburger span {
    display: block;
    height: 2px;
    width: 22px;
    background: var(--text);
    border-radius: 2px;
    transition: all 0.2s;
}

/* Sidebar Overlay Backdrop */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 2900;
    backdrop-filter: blur(2px);
}
.sidebar-overlay.active { display: block; }

/* ── Tables: always scrollable horizontally ── */
.table-card {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    min-width: 520px; /* force scroll before columns crush */
}

/* ── Dashboard chart row ── */
@media (max-width: 900px) {
    .dashboard-row { grid-template-columns: 1fr; }
    .form-row      { grid-template-columns: 1fr; }
    .main-content  { padding: 24px 16px; }
}

/* ── Mobile breakpoint ── */
@media (max-width: 768px) {

    /* Show the top bar */
    .mobile-topbar { display: flex; }

    /* Push content below topbar */
    .app-container { padding-top: 56px; }
    body           { overflow: auto; }

    /* Sidebar: off-screen by default, slides in */
    .sidebar {
        position: fixed;
        top: 56px; left: 0; bottom: 0;
        width: 260px;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        z-index: 3100;
        overflow-y: auto;
    }
    .sidebar.open { transform: translateX(0); }

    /* Main takes full width */
    .main-content {
        flex: 1;
        padding: 20px 14px 32px;
        min-height: calc(100vh - 56px);
        overflow-y: auto;
    }

    /* Stats: 2 cols on mobile */
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }
    .stat-value  { font-size: 20px; }

    /* Section header stack */
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 14px;
    }
    .header-actions {
        flex-wrap: wrap;
        gap: 8px;
    }
    .btn-action {
        font-size: 12px;
        padding: 8px 14px;
    }

    /* Tabs scroll on mobile */
    .tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .tabs::-webkit-scrollbar { display: none; }

    /* Docs single column */
    .docs-grid { grid-template-columns: 1fr; }

    /* Modal full-screen on mobile */
    .modal-box {
        max-width: 100%;
        margin: 0 8px;
        border-radius: 16px;
    }

    /* Section header font */
    .section-header h1 { font-size: 22px; }
}
