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

:root {
    --bg: #0f172a; --bg-card: #1e293b; --bg-card-hover: #263348; --bg-input: #1a2332;
    --text: #f1f5f9; --text-muted: #94a3b8; --text-dim: #64748b;
    --primary: #3b82f6; --primary-hover: #2563eb;
    --success: #22c55e; --success-bg: #052e16;
    --warning: #f59e0b; --warning-bg: #451a03;
    --danger: #ef4444; --danger-bg: #450a0a;
    --border: #334155; --radius: 12px; --radius-sm: 8px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html { font-family: var(--font); font-size: 16px; background: var(--bg); color: var(--text);
    -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%; }
body { min-height: 100dvh; padding-top: var(--safe-top); padding-bottom: calc(60px + var(--safe-bottom)); }

/* ── Navbar ── */
.navbar { position: sticky; top: 0; z-index: 100; display: flex; align-items: center;
    justify-content: space-between; padding: 12px 16px; background: var(--bg-card);
    border-bottom: 1px solid var(--border); }
.navbar-brand { font-size: 18px; font-weight: 700; letter-spacing: -0.02em; }
.navbar-brand span { color: var(--primary); }
#user-info { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-muted); }

/* ── Bottom Nav Tabs ── */
#nav-tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
    display: flex; background: var(--bg-card); border-top: 1px solid var(--border);
    padding-bottom: var(--safe-bottom); }
.nav-tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 8px 4px; border: none; background: none; color: var(--text-dim);
    font-size: 11px; font-family: var(--font); cursor: pointer; transition: color 0.15s; }
.nav-tab svg { width: 22px; height: 22px; }
.nav-tab.active { color: var(--primary); }
.nav-tab:hover { color: var(--text-muted); }

/* ── Login Screen ── */
#login-screen { display: flex; flex-direction: column; align-items: center;
    justify-content: center; min-height: 80dvh; padding: 24px; text-align: center; }
#login-screen h2 { font-size: 28px; font-weight: 700; margin-bottom: 8px; letter-spacing: -0.03em; }
#login-screen p { color: var(--text-muted); margin-bottom: 32px; font-size: 15px; }

/* ── Content ── */
#app-content { padding: 16px; max-width: 640px; margin: 0 auto; }

/* ── View Header ── */
.view-header { display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 20px; gap: 12px; }
.view-header h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.03em; }
.detail-user { display: block; font-size: 14px; color: var(--text-muted); margin-top: 2px; }

/* ── Report Cards ── */
.reports-list { display: flex; flex-direction: column; gap: 10px; }
.report-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 16px; cursor: pointer; transition: background 0.15s, border-color 0.15s; }
.report-card:hover { background: var(--bg-card-hover); border-color: var(--primary); }
.report-card:active { transform: scale(0.985); }
.report-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.report-month { font-size: 16px; font-weight: 600; }
.report-user { font-size: 15px; font-weight: 600; }
.report-card-body { display: flex; justify-content: space-between; align-items: baseline; }
.report-total { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.report-count { font-size: 13px; color: var(--text-muted); }
.report-card-actions { display: flex; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }

/* ── Status badges ── */
.status-badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px;
    font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.status-draft { background: var(--border); color: var(--text-muted); }
.status-submitted { background: #1e3a5f; color: #60a5fa; }
.status-approved { background: var(--success-bg); color: var(--success); }
.status-rejected { background: var(--danger-bg); color: var(--danger); }

/* ── Report Detail ── */
.report-summary { text-align: center; padding: 24px 0; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.summary-amount { font-size: 36px; font-weight: 800; letter-spacing: -0.03em; }
.summary-label { font-size: 14px; color: var(--text-muted); margin-top: 4px; }
.action-bar { display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }

/* ── Expense Items ── */
.items-list { display: flex; flex-direction: column; gap: 8px; }
.item-card { display: flex; justify-content: space-between; align-items: center;
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; }
.item-card-main { flex: 1; min-width: 0; }
.item-category { font-weight: 600; font-size: 14px; margin-bottom: 2px; }
.item-desc { font-size: 13px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-meta { display: flex; align-items: center; gap: 10px; margin-top: 4px; }
.item-date { font-size: 12px; color: var(--text-dim); }
.receipt-link { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; color: var(--primary);
    text-decoration: none; }
.receipt-link:hover { text-decoration: underline; }
.item-card-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.item-amount { font-weight: 700; font-size: 16px; white-space: nowrap; }

/* ── Users List (Admin) ── */
.users-list { display: flex; flex-direction: column; gap: 8px; }
.user-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; }
.user-name { font-weight: 600; font-size: 15px; }
.user-email { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.user-meta { display: flex; gap: 8px; margin-top: 8px; }
.company-badge { font-size: 11px; padding: 2px 8px; border-radius: 12px; background: #1e3a5f; color: #60a5fa; }
.role-badge { font-size: 11px; padding: 2px 8px; border-radius: 12px; font-weight: 600; }
.role-employee { background: var(--border); color: var(--text-muted); }
.role-manager { background: var(--warning-bg); color: var(--warning); }
.role-admin { background: #1a0536; color: #a78bfa; }

/* ── Export ── */
.export-form { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 20px; }
.export-form .btn-lg { width: 100%; justify-content: center; padding: 14px; font-size: 16px; margin-top: 8px; }

/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 10px 18px; border: none;
    border-radius: var(--radius-sm); font-size: 14px; font-weight: 600; cursor: pointer;
    transition: background 0.15s, transform 0.1s; white-space: nowrap; font-family: var(--font); }
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-secondary:hover { background: var(--bg-card-hover); }
.btn-success { background: #166534; color: #bbf7d0; }
.btn-success:hover { background: #15803d; }
.btn-danger { background: #991b1b; color: #fecaca; }
.btn-danger:hover { background: #b91c1c; }
.btn-icon { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px;
    border: none; border-radius: 50%; background: transparent; color: var(--text-muted); cursor: pointer; }
.btn-icon:hover { background: var(--border); }
.btn-danger-icon { color: var(--danger); }
.btn-danger-icon:hover { background: var(--danger-bg); }

/* ── Receipt Upload ── */
.receipt-upload { position: relative; }
.form-input-file { position: absolute; width: 0; height: 0; opacity: 0; }
.btn-upload { width: 100%; justify-content: center; padding: 14px; border: 2px dashed var(--border);
    background: var(--bg-input); border-radius: var(--radius-sm); cursor: pointer; }
.btn-upload:hover { border-color: var(--primary); background: var(--bg-card); }
.receipt-filename { display: block; font-size: 13px; color: var(--success); margin-top: 6px; }

/* ── Forms ── */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--text-muted);
    margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.04em; }
.form-input { width: 100%; padding: 12px 14px; background: var(--bg-input); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text); font-size: 16px; font-family: var(--font);
    transition: border-color 0.15s; -webkit-appearance: none; }
.form-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59,130,246,0.15); }

/* ── Modal ── */
#modal-overlay { position: fixed; inset: 0; z-index: 200; display: flex; align-items: flex-end;
    justify-content: center; background: rgba(0,0,0,0.5); backdrop-filter: blur(4px);
    opacity: 0; pointer-events: none; transition: opacity 0.2s; }
#modal-overlay.active { opacity: 1; pointer-events: auto; }
.modal-content { background: var(--bg-card); border-radius: var(--radius) var(--radius) 0 0;
    padding: 24px 20px calc(20px + var(--safe-bottom)); width: 100%; max-width: 500px;
    max-height: 85dvh; overflow-y: auto; transform: translateY(100%); transition: transform 0.25s ease-out; }
#modal-overlay.active .modal-content { transform: translateY(0); }
.modal-content h2 { font-size: 18px; font-weight: 700; margin-bottom: 20px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* ── Alerts ── */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 16px; }
.alert-error { background: var(--danger-bg); color: #fca5a5; border: 1px solid rgba(239,68,68,0.2); }

/* ── Toast ── */
.toast { position: fixed; bottom: calc(70px + var(--safe-bottom)); left: 50%;
    transform: translateX(-50%) translateY(20px); padding: 12px 20px; border-radius: var(--radius-sm);
    font-size: 14px; font-weight: 500; z-index: 300; opacity: 0;
    transition: opacity 0.3s, transform 0.3s; max-width: calc(100% - 40px); text-align: center; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast-success { background: #166534; color: #bbf7d0; }
.toast-error { background: #991b1b; color: #fecaca; }
.toast-warning { background: #92400e; color: #fde68a; }
.toast-info { background: #1e3a5f; color: #93c5fd; }

/* ── PWA Install Banner ── */
#install-banner { position: fixed; top: 0; left: 0; right: 0; z-index: 150;
    background: var(--primary); color: #fff; padding: 10px 16px; }
.install-banner-content { display: flex; align-items: center; justify-content: space-between;
    max-width: 640px; margin: 0 auto; font-size: 14px; }
.install-banner-btns { display: flex; gap: 8px; align-items: center; }
#install-dismiss { color: rgba(255,255,255,0.7); background: none; font-size: 20px; width: 30px; height: 30px; }

/* ── Empty & Loading ── */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 48px 24px; text-align: center; color: var(--text-muted); }
.empty-state svg { margin-bottom: 16px; opacity: 0.4; }
.empty-state p { font-size: 16px; }
.empty-state .muted { font-size: 14px; color: var(--text-dim); margin-top: 4px; }
.empty-state.small { padding: 32px 16px; }
.loading-state { display: flex; flex-direction: column; align-items: center; padding: 48px; }
.spinner { width: 32px; height: 32px; border: 3px solid var(--border); border-top-color: var(--primary);
    border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Desktop ── */
@media (min-width: 768px) {
    #app-content { padding: 24px; max-width: 720px; }
    .modal-content { border-radius: var(--radius); margin-bottom: 10vh; }
    #modal-overlay { align-items: center; }
    body { padding-bottom: var(--safe-bottom); }
    #nav-tabs { position: static; border-top: none; border-bottom: 1px solid var(--border);
        max-width: 720px; margin: 0 auto; }
    .nav-tab { flex-direction: row; gap: 6px; font-size: 13px; padding: 12px 8px; }
}
