* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    background: #f4f5f7;
    color: #1f2430;
    font-size: 14px;
}
a { text-decoration: none; color: inherit; }

/* ---- App shell ---- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
    width: 220px;
    background: #1a2138;
    color: #cfd4e4;
    display: flex;
    flex-direction: column;
    padding: 20px 0;
    flex-shrink: 0;
}
.brand { font-size: 18px; font-weight: 700; color: #fff; padding: 0 20px 24px; }
.sidebar nav { display: flex; flex-direction: column; flex: 1; }
.sidebar nav a {
    padding: 11px 20px;
    font-size: 14px;
    border-left: 3px solid transparent;
}
.sidebar nav a:hover { background: #232b48; color: #fff; }
.sidebar nav a.active { background: #232b48; color: #fff; border-left-color: #4f7dfb; }
.nav-divider { padding: 16px 20px 6px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: #5b6488; }
.sidebar-footer {
    padding: 16px 20px 0;
    border-top: 1px solid #2b3354;
    margin-top: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
}
.sidebar-footer a { color: #8a93b8; }
.sidebar-footer a:hover { color: #fff; }

.content { flex: 1; padding: 28px 36px; max-width: 1200px; }

/* ---- Typography ---- */
h1 { font-size: 22px; margin-bottom: 4px; }
h2 { font-size: 17px; margin-bottom: 12px; }
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; }
.subtitle { color: #6b7280; font-size: 13px; margin-bottom: 20px; }

/* ---- Cards ---- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 28px; }
.card {
    background: #fff;
    border-radius: 10px;
    padding: 18px 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    border: 1px solid #eceef2;
}
.card .label { font-size: 12px; color: #6b7280; text-transform: uppercase; letter-spacing: .03em; }
.card .value { font-size: 24px; font-weight: 700; margin-top: 6px; }
.card.green .value { color: #16a34a; }
.card.red .value { color: #dc2626; }
.card.amber .value { color: #d97706; }
.card.blue .value { color: #2563eb; }

/* ---- Panel / table wrapper ---- */
.panel {
    background: #fff;
    border-radius: 10px;
    border: 1px solid #eceef2;
    padding: 20px;
    margin-bottom: 24px;
}
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid #f0f1f4; }
th { color: #6b7280; font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .02em; }
tr:hover td { background: #fafbfc; }

/* ---- Buttons ---- */
.btn {
    display: inline-block;
    padding: 9px 16px;
    background: #2563eb;
    color: #fff;
    border: none;
    border-radius: 7px;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
}
.btn:hover { background: #1d4ed8; }
.btn.secondary { background: #fff; color: #1f2430; border: 1px solid #d7dae1; }
.btn.secondary:hover { background: #f4f5f7; }
.btn.danger { background: #dc2626; }
.btn.danger:hover { background: #b91c1c; }
.btn.small { padding: 5px 10px; font-size: 12.5px; }

/* ---- Badges ---- */
.badge { padding: 3px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 600; text-transform: capitalize; }
.badge.paid, .badge.accepted, .badge.converted { background: #dcfce7; color: #16a34a; }
.badge.unpaid, .badge.sent, .badge.draft { background: #fef3c7; color: #b45309; }
.badge.partial { background: #dbeafe; color: #1d4ed8; }
.badge.overdue, .badge.rejected, .badge.void { background: #fee2e2; color: #dc2626; }

/* ---- Forms ---- */
form label { display: block; font-size: 13px; font-weight: 600; margin: 14px 0 5px; color: #374151; }
form input, form select, form textarea {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid #d7dae1;
    border-radius: 7px;
    font-size: 13.5px;
    font-family: inherit;
}
form input:focus, form select:focus, form textarea:focus { outline: none; border-color: #2563eb; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-actions { margin-top: 22px; display: flex; gap: 10px; }

/* ---- Line items table ---- */
.items-table input { padding: 6px 8px; }
.items-table td { vertical-align: top; }
.add-row-btn { margin-top: 8px; }

/* ---- Auth pages ---- */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: #1a2138; }
.auth-box { background: #fff; padding: 34px 32px; border-radius: 12px; width: 340px; }
.auth-box h2 { margin-bottom: 18px; }
.auth-box button { width: 100%; margin-top: 20px; padding: 10px; }
.alert { background: #fee2e2; color: #b91c1c; padding: 10px 12px; border-radius: 7px; font-size: 13px; margin-bottom: 14px; }

/* ---- Filters ---- */
.filters { display: flex; gap: 10px; margin-bottom: 16px; align-items: center; flex-wrap: wrap; }
.filters select, .filters input { padding: 7px 10px; border: 1px solid #d7dae1; border-radius: 7px; font-size: 13px; }

/* ---- Utility ---- */
.text-right { text-align: right; }
.muted { color: #6b7280; }
.mt-0 { margin-top: 0; }
.empty-state { text-align: center; padding: 40px 20px; color: #9ca3af; }

/* ---- SPA section switching ---- */
.section { display: none; }
.section.active-section { display: block; }

