:root {
    --brand: #475569;
    --brand-dark: #334155;
    --bg: #f4f6f9;
    --card: #ffffff;
    --text: #1a1d29;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --green: #16a34a;
    --amber: #d97706;
    --red: #dc2626;
    --radius: 6px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 16px;
}

/* ---------- Top bar ---------- */
.topbar {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}
.topbar .brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; }
.topbar .brand img { height: 32px; border-radius: 6px; }
.topbar .user-menu { display: flex; align-items: center; gap: 10px; }
.topbar .user-menu img { width: 32px; height: 32px; border-radius: 50%; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 18px;
    border-radius: var(--radius);
    border: none;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: transform .05s ease, opacity .15s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-secondary { background: #eef1f6; color: var(--text); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-danger { background: #fde8e8; color: var(--red); }
.btn-block { width: 100%; }
.btn-lg { padding: 16px 20px; font-size: 16px; }
.btn-sm { padding: 8px 12px; font-size: 13px; }

/* ---------- Cards ---------- */
.card {
    background: var(--card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 20px;
    margin-bottom: 16px;
}

/* ---------- Dashboard tiles ---------- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}
.stat-tile {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    text-align: left;
}
.stat-tile .label { font-size: 12px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.stat-tile .value { font-size: 26px; font-weight: 800; margin-top: 4px; }
.stat-tile.wide { grid-column: span 2; }

.earn-banner {
    background: linear-gradient(135deg, var(--brand), var(--brand-dark));
    color: #fff;
    border-radius: var(--radius);
    padding: 15px 20px;
    margin-bottom: 16px;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}
.earn-banner .block .label { font-size: 12px; opacity: .85; text-transform: uppercase; letter-spacing: .04em; }
.earn-banner .block .value { font-size: 24px; font-weight: 800; margin-top: 2px; }

.earn-banner.stat-banner { justify-content: space-around; }
.earn-banner.stat-banner .block, .earn-banner.stat-banner.block a {
    flex: 1;
    text-align: center;
    color: #fff;
    text-decoration: none;
}
.earn-banner.stat-banner .block:active { opacity: .8; }

.action-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}
.action-btn {
    background: var(--card);
    border: 2px solid var(--brand);
    color: var(--brand);
    border-radius: var(--radius);
    padding: 20px 10px;
    text-align: center;
    font-weight: 700;
    font-size: 15px;
}
.action-btn.solid { background: var(--brand); color: #fff; }
.action-btn .icon { font-size: 26px; display: block; margin-bottom: 6px; }

/* ---------- Lists ---------- */
.list-item {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}
.list-item .main { min-width: 0; }
.list-item .main .name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .main .sub { font-size: 13px; color: var(--text-muted); }
.list-item .right { text-align: right; flex-shrink: 0; }
.list-item .right .amt { font-weight: 700; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge-draft { background: #eef1f6; color: #4b5563; }
.badge-sent { background: #dbeafe; color: #1d4ed8; }
.badge-accepted, .badge-paid { background: #dcfce7; color: #15803d; }
.badge-declined { background: #fee2e2; color: #b91c1c; }

/* ---------- Forms ---------- */
label { display: block; font-size: 13px; font-weight: 600; margin: 14px 0 6px; }
input[type=text], input[type=email], input[type=tel], input[type=number],
input[type=date], input[type=password], select, textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 15px;
    background: #fff;
    color: var(--text);
}
input[type=color] { width: 60px; height: 40px; border: 1px solid var(--border); border-radius: 8px; padding: 2px; }
textarea { min-height: 80px; resize: vertical; }
.form-row { display: flex; gap: 10px; }
.form-row > * { flex: 1; }

.line-item-row {
    display: grid;
    grid-template-columns: 1fr 60px 80px 30px;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
}
.line-item-row input { padding: 10px; font-size: 14px; }
.remove-line { background: none; border: none; color: var(--red); font-size: 20px; cursor: pointer; }

.totals-box { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); }
.totals-box .row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 14px; }
.totals-box .row.total { font-size: 18px; font-weight: 800; border-top: 1px solid var(--border); margin-top: 6px; padding-top: 10px; }

/* ---------- Login page ---------- */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.login-card {
    background: var(--card);
    border-radius: 16px;
    padding: 36px 28px;
    text-align: center;
    max-width: 380px;
    width: 100%;
    box-shadow: 0 10px 30px rgba(0,0,0,0.06);
}
.login-card h1 { font-size: 22px; margin-bottom: 6px; }
.login-card p { color: var(--text-muted); font-size: 14px; margin-bottom: 24px; }
.google-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: #fff;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
}
.google-btn img { height: 20px; }

/* ---------- Modal (onboarding) ---------- */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.5);
    display: flex; align-items: flex-end; justify-content: center; z-index: 200;
}
.modal-box {
    background: #fff; width: 100%; max-width: 480px;
    border-radius: 16px 16px 0 0; padding: 24px; max-height: 92vh; overflow-y: auto;
}
@media (min-width: 640px) {
    .modal-overlay { align-items: center; }
    .modal-box { border-radius: 16px; }
}

.logo-preview {
    width: 72px; height: 72px; border-radius: 12px; border: 1px solid var(--border);
    object-fit: contain; background: #fafafa;
}

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

.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin: 20px 0 14px;
}
.page-header h1 { font-size: 20px; margin: 0; }

.tabs { display: flex; gap: 8px; margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 8px 14px; border-radius: 999px; background: #eef1f6; font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; }
.tabs a.active { background: var(--brand); color: #fff; }

.bottom-actions {
    position: sticky; bottom: 0; background: var(--card);
    border-top: 1px solid var(--border); padding: 12px 16px;
    display: flex; gap: 10px; margin: 0 -16px;
}

@media (min-width: 700px) {
    .stat-tile.wide { grid-column: span 1; }
    .stat-grid { grid-template-columns: repeat(3, 1fr); }
}
