:root {
    --brand-1: #ff8a00;
    --brand-2: #e63946;
    --brand-3: #2a9d8f;
    --brand-4: #264653;
    --glass-bg: rgba(255, 255, 255, 0.55);
    --glass-border: rgba(255, 255, 255, 0.35);
    --text-dark: #1f2937;
    --text-muted: #5b6472;
    --danger: #d92d20;
    --success: #16a34a;
    --warning: #d97706;
    --radius: 18px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Times New Roman', Times, serif;
    color: var(--text-dark);
    min-height: 100vh;
    background:
        radial-gradient(circle at 10% 10%, rgba(255,138,0,0.35), transparent 40%),
        radial-gradient(circle at 90% 20%, rgba(230,57,70,0.30), transparent 45%),
        radial-gradient(circle at 30% 90%, rgba(42,157,143,0.30), transparent 45%),
        radial-gradient(circle at 80% 85%, rgba(38,70,83,0.25), transparent 45%),
        linear-gradient(135deg, #fdf6e3 0%, #f1f5f9 100%);
    background-attachment: fixed;
}

a { text-decoration: none; color: inherit; }

.app-shell { display: flex; min-height: 100vh; }

/* ---- Mobile top bar (hidden on desktop) ---- */
.mobile-topbar {
    display: none;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(38, 70, 83, 0.96);
    backdrop-filter: blur(14px);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 200;
}
.mobile-brand { font-weight: bold; font-size: 16px; }
.hamburger-btn {
    background: none; border: none; padding: 8px; cursor: pointer;
    display: flex; flex-direction: column; gap: 5px; width: 34px;
}
.hamburger-btn span { display: block; height: 3px; width: 100%; background: #fff; border-radius: 2px; }
.sidebar-backdrop {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 250;
}
.sidebar-backdrop.open { display: block; }

/* ---- Sidebar ---- */
.sidebar {
    width: 250px;
    flex-shrink: 0;
    background: rgba(38, 70, 83, 0.92);
    backdrop-filter: blur(14px);
    color: #fff;
    padding: 24px 16px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}
.sidebar .brand {
    font-size: 20px;
    font-weight: bold;
    margin-bottom: 6px;
    line-height: 1.25;
}
.sidebar .brand small { display:block; font-size: 12px; opacity: .7; font-weight: normal; }
.sidebar nav { margin-top: 28px; display: flex; flex-direction: column; gap: 4px; }
.sidebar nav a {
    padding: 11px 14px;
    border-radius: 12px;
    font-size: 15px;
    opacity: .85;
    transition: all .15s ease;
}
.sidebar nav a:hover { background: rgba(255,255,255,0.12); opacity: 1; }
.sidebar nav a.active {
    background: linear-gradient(135deg, var(--brand-1), var(--brand-2));
    opacity: 1;
    font-weight: bold;
}
.sidebar .user-box {
    margin-top: 32px;
    padding: 14px;
    border-radius: var(--radius);
    background: rgba(255,255,255,0.08);
    font-size: 13px;
}
.sidebar .user-box img { width: 34px; height: 34px; border-radius: 50%; vertical-align: middle; margin-right: 8px; }
.sidebar .logout-link { display:block; margin-top: 10px; color: #ffd6d6; font-size: 13px; }

/* ---- Main content ---- */
.main { flex: 1; padding: 28px 32px; max-width: 1400px; }
.page-header { display:flex; align-items:center; justify-content: space-between; margin-bottom: 22px; flex-wrap: wrap; gap: 12px; }
.page-header h1 { margin: 0; font-size: 26px; }
.page-header p.subtitle { margin: 4px 0 0; color: var(--text-muted); font-size: 14px; }

/* ---- Glass card ---- */
.glass-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 8px 32px rgba(31, 41, 55, 0.12);
    padding: 22px;
}

/* ---- Bento stat grid ---- */
.bento-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px; margin-bottom: 26px; }
.stat-card { padding: 20px 22px; position: relative; overflow: hidden; }
.stat-card .stat-label { font-size: 13px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.stat-card .stat-value { font-size: 30px; font-weight: bold; margin-top: 6px; }
.stat-card .stat-icon { position:absolute; right: 16px; top: 14px; font-size: 30px; opacity:.5; }
.stat-card.brand-a { border-left: 5px solid var(--brand-1); }
.stat-card.brand-b { border-left: 5px solid var(--brand-2); }
.stat-card.brand-c { border-left: 5px solid var(--brand-3); }
.stat-card.brand-d { border-left: 5px solid var(--brand-4); }

/* ---- Buttons ---- */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 10px 18px;
    border-radius: 12px;
    border: none;
    font-family: inherit;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: transform .12s ease, box-shadow .12s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: linear-gradient(135deg, var(--brand-1), var(--brand-2)); color: #fff; box-shadow: 0 6px 16px rgba(230,57,70,0.35); }
.btn-secondary { background: linear-gradient(135deg, #2a9d8f, #264653); color: #fff; box-shadow: 0 6px 16px rgba(42,157,143,0.30); }
.btn-outline { background: rgba(255,255,255,0.6); border: 1px solid rgba(0,0,0,0.1); color: var(--text-dark); }
.btn-danger { background: linear-gradient(135deg, #ef4444, #b91c1c); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; border-radius: 9px; }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
table.data-table th {
    text-align: left; padding: 12px 14px; font-size: 12.5px; text-transform: uppercase;
    letter-spacing: .03em; color: var(--text-muted); border-bottom: 2px solid rgba(0,0,0,0.08);
}
table.data-table td { padding: 12px 14px; border-bottom: 1px solid rgba(0,0,0,0.06); vertical-align: middle; }
table.data-table tr:hover td { background: rgba(255,255,255,0.4); }

/* ---- Badges ---- */
.badge { padding: 4px 11px; border-radius: 999px; font-size: 12px; font-weight: bold; display:inline-block; }
.badge-paid { background: rgba(22,163,74,0.15); color: var(--success); }
.badge-partial { background: rgba(217,119,6,0.15); color: var(--warning); }
.badge-unpaid { background: rgba(217,45,32,0.15); color: var(--danger); }

/* ---- Forms ---- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 13px; font-weight: bold; color: var(--text-muted); }
.form-group input, .form-group select, .form-group textarea {
    padding: 12px; border-radius: 10px; border: 1px solid rgba(0,0,0,0.15);
    font-family: inherit; font-size: 16px; background: rgba(255,255,255,0.75);
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { outline: 2px solid var(--brand-3); }

/* ---- Modal ---- */
.modal-overlay {
    display: none; position: fixed; inset: 0; background: rgba(15,23,42,0.5);
    align-items: center; justify-content: center; z-index: 400; padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal-box {
    background: #fffdf8; border-radius: var(--radius); padding: 26px; width: 100%; max-width: 560px;
    max-height: 88vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.35);
}
.modal-box h2 { margin-top: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ---- Alerts ---- */
.alert { padding: 12px 16px; border-radius: 12px; margin-bottom: 18px; font-size: 14px; }
.alert-success { background: rgba(22,163,74,0.12); color: #166534; border: 1px solid rgba(22,163,74,0.3); }
.alert-error { background: rgba(217,45,32,0.12); color: #991b1b; border: 1px solid rgba(217,45,32,0.3); }

/* ---- Login page ---- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { text-align: center; padding: 46px 40px; max-width: 400px; }
.login-card .logo-emoji { font-size: 52px; }
.login-card h1 { margin: 10px 0 4px; font-size: 24px; }
.login-card p { color: var(--text-muted); font-size: 14px; margin-bottom: 26px; }
.google-btn {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    background: #fff; color: #3c4043; border: 1px solid #dadce0; border-radius: 12px;
    padding: 12px 20px; font-family: inherit; font-size: 15px; font-weight: bold; cursor: pointer; width: 100%;
}
.google-btn:hover { box-shadow: 0 4px 14px rgba(0,0,0,0.15); }

.text-muted { color: var(--text-muted); }
.mt-0 { margin-top: 0; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }

@media (max-width: 900px) {
    .mobile-topbar { display: flex; }

    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        height: 100vh;
        width: 250px;
        z-index: 300;
        transition: left .22s ease;
        box-shadow: 4px 0 24px rgba(0,0,0,0.3);
    }
    .sidebar.open { left: 0; }

    .app-shell { flex-direction: column; }
    .main { padding: 16px; max-width: 100%; }

    .page-header { flex-direction: column; align-items: stretch; }
    .page-header h1 { font-size: 21px; }
    .page-header > div:last-child,
    .page-header a.btn,
    .page-header button.btn { width: 100%; justify-content: center; }
    .page-header div[style*="flex"] { flex-direction: column; }

    .bento-grid,
    .bento-grid[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }

    .stat-card .stat-value { font-size: 24px; }

    .glass-card { padding: 16px; border-radius: 14px; }

    .form-grid { grid-template-columns: 1fr; }

    table.data-table { font-size: 13px; }
    table.data-table th, table.data-table td { padding: 10px 8px; }

    /* Responsive tables: turn into stacked cards instead of tiny horizontal-scroll grids */
    .table-wrap.responsive-cards table.data-table thead { display: none; }
    .table-wrap.responsive-cards table.data-table,
    .table-wrap.responsive-cards table.data-table tbody,
    .table-wrap.responsive-cards table.data-table tr,
    .table-wrap.responsive-cards table.data-table td { display: block; width: 100%; }
    .table-wrap.responsive-cards table.data-table tr {
        margin-bottom: 12px;
        border: 1px solid rgba(0,0,0,0.08);
        border-radius: 12px;
        padding: 10px 14px;
        background: rgba(255,255,255,0.5);
    }
    .table-wrap.responsive-cards table.data-table tr:hover td { background: transparent; }
    .table-wrap.responsive-cards table.data-table td {
        border-bottom: none;
        padding: 7px 0;
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 10px;
        text-align: right;
    }
    .table-wrap.responsive-cards table.data-table td[data-label]::before {
        content: attr(data-label);
        font-weight: bold;
        font-size: 11.5px;
        text-transform: uppercase;
        letter-spacing: .03em;
        color: var(--text-muted);
        text-align: left;
    }
    .table-wrap.responsive-cards table.data-table td:empty,
    .table-wrap.responsive-cards table.data-table td.card-hide { display: none; }

    .btn { width: 100%; justify-content: center; padding: 12px 16px; }
    .btn-sm { width: auto; padding: 8px 12px; }
    td .btn, td form { display: inline-block; width: auto; margin: 2px 2px 2px 0; }
    td .btn.btn-sm { display: inline-flex; }

    .modal-box { padding: 18px; max-height: 92vh; }
    .modal-actions { flex-direction: column-reverse; }
    .modal-actions .btn { width: 100%; }

    .login-card { padding: 32px 22px; }

    /* Toolbar rows with multiple filter buttons - let them wrap and shrink */
    div[style*="display:flex"][style*="gap:8px"] { flex-wrap: wrap; }
}

@media (max-width: 480px) {
    .main { padding: 12px; }
    .page-header h1 { font-size: 19px; }
    .stat-card .stat-value { font-size: 21px; }
    table.data-table { font-size: 12px; }
}
