/* ===== Self-hosted Inter font ===== */
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 400; font-display: swap; src: url('../fonts/inter-400.woff2') format('truetype'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 500; font-display: swap; src: url('../fonts/inter-500.woff2') format('truetype'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 600; font-display: swap; src: url('../fonts/inter-600.woff2') format('truetype'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 700; font-display: swap; src: url('../fonts/inter-700.woff2') format('truetype'); }

/* ===== Design tokens: light ===== */
:root {
    --bg: #f4f6f8;
    --surface: #ffffff;
    --surface-elevated: #ffffff;
    --surface-hover: #f8fafc;
    --text: #111827;
    --text-secondary: #374151;
    --text-muted: #6b7280;
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-muted: rgba(79,70,229,0.08);
    --primary-light: rgba(79,70,229,0.12);
    --border: #e5e7eb;
    --border-light: #f3f4f6;
    --success: #059669;
    --success-bg: #ecfdf5;
    --error: #dc2626;
    --error-bg: #fef2f2;
    --warning: #d97706;
    --warning-bg: #fffbeb;
    --info: #2563eb;
    --info-bg: #eff6ff;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;
    --radius-full: 9999px;
    --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.04);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.08), 0 8px 10px -6px rgba(0,0,0,0.04);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --sidebar-w: 260px;
    --topbar-h: 60px;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --gradient-brand: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
}

/* ===== Dark theme ===== */
[data-theme="dark"] {
    --bg: #0c0e14;
    --surface: #13161e;
    --surface-elevated: #1a1d28;
    --surface-hover: #1f222f;
    --text: #f1f3f5;
    --text-secondary: #d1d5db;
    --text-muted: #9ca3af;
    --primary: #818cf8;
    --primary-hover: #a5b4fc;
    --primary-muted: rgba(129,140,248,0.1);
    --primary-light: rgba(129,140,248,0.15);
    --border: #262a36;
    --border-light: #1e212b;
    --success: #34d399;
    --success-bg: rgba(52,211,153,0.1);
    --error: #f87171;
    --error-bg: rgba(248,113,113,0.1);
    --warning: #fbbf24;
    --warning-bg: rgba(251,191,36,0.1);
    --info: #60a5fa;
    --info-bg: rgba(96,165,250,0.1);
    --shadow-xs: 0 1px 2px rgba(0,0,0,0.2);
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.35);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.4);
    --shadow-xl: 0 20px 25px rgba(0,0,0,0.45);
    --gradient-brand: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
}

/* ===== Base reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
body.invoice-app { color-scheme: light; }
[data-theme="dark"].invoice-app, [data-theme="dark"] body.invoice-app { color-scheme: dark; }
a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-hover); }
::selection { background: var(--primary-light); color: var(--text); }

/* ===== Typography ===== */
h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.025em; color: var(--text); line-height: 1.3; }
h2 { font-size: 1rem; font-weight: 600; color: var(--text); line-height: 1.4; margin-bottom: 0.75rem; }
h3 { font-size: 0.875rem; font-weight: 600; color: var(--text); line-height: 1.4; margin-bottom: 0.5rem; }
.muted { color: var(--text-muted); font-size: 0.8125rem; }

/* ===== App shell ===== */
.app-shell { display: flex; min-height: 100vh; }

/* ===== Sidebar ===== */
.sidebar {
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    position: fixed;
    top: 0; left: 0; bottom: 0;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 130;
    display: flex;
    flex-direction: column;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.sidebar-brand-wrap {
    padding: 1.25rem 1.125rem 1rem;
    border-bottom: 1px solid var(--border);
}
.sidebar-brand {
    display: block;
    font-size: 1.125rem;
    font-weight: 700;
    text-decoration: none;
    color: var(--text);
    letter-spacing: -0.02em;
}
.sidebar-role {
    display: inline-flex;
    align-items: center;
    margin-top: 0.5rem;
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    background: var(--primary-muted);
    color: var(--primary);
    border-radius: var(--radius-full);
    padding: 0.2rem 0.625rem;
}
.sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0.5rem 0.625rem;
    gap: 1px;
}
.sidebar-nav-label {
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 1rem 0.625rem 0.375rem;
    margin-top: 0.25rem;
}
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    color: var(--text-secondary);
    text-decoration: none;
    padding: 0.5rem 0.625rem;
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    font-weight: 500;
    transition: all 0.15s ease;
    position: relative;
}
.sidebar-nav a .nav-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    opacity: 0.6;
    transition: opacity 0.15s ease;
}
.sidebar-nav a:hover {
    background: var(--surface-hover);
    color: var(--text);
}
.sidebar-nav a:hover .nav-icon { opacity: 0.9; }
.sidebar-nav a.active {
    background: var(--primary);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(79,70,229,0.3);
}
[data-theme="dark"] .sidebar-nav a.active {
    box-shadow: 0 1px 3px rgba(129,140,248,0.2);
}
.sidebar-nav a.active .nav-icon { opacity: 1; }
.sidebar-bottom {
    padding: 0.75rem;
    border-top: 1px solid var(--border);
    margin-top: auto;
}
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    transition: background 0.15s ease;
    text-decoration: none;
    color: var(--text);
}
.sidebar-user:hover { background: var(--surface-hover); }
.sidebar-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    background: var(--gradient-brand);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
}
.sidebar-user-info { min-width: 0; }
.sidebar-user-name { font-size: 0.8125rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.sidebar-user-role { font-size: 0.6875rem; color: var(--text-muted); display: block; }

/* ===== Content shell ===== */
.content-shell { margin-left: var(--sidebar-w); flex: 1; min-width: 0; background: var(--bg); }
.auth-shell { margin-left: 0; }

/* ===== Topbar ===== */
.topbar {
    height: var(--topbar-h);
    position: sticky;
    top: 0;
    z-index: 120;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(8px);
}
.topbar-title { font-size: 0.875rem; color: var(--text-muted); font-weight: 500; }
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px; height: 36px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
}
.theme-toggle:hover { background: var(--primary-muted); color: var(--primary); border-color: var(--primary); }
.theme-toggle svg { width: 16px; height: 16px; }
.theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }

/* ===== Sidebar toggle (mobile) ===== */
.sidebar-toggle {
    display: none;
    position: fixed;
    left: 0.75rem; top: 0.875rem;
    z-index: 170;
    width: 36px; height: 36px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    transition: all var(--transition);
}
.sidebar-toggle:hover { background: var(--primary-muted); border-color: var(--primary); }
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    z-index: 140;
    transition: opacity 0.25s ease;
}

/* ===== Main content ===== */
.main {
    max-width: 1360px;
    margin: 0;
    padding: 1.5rem;
    min-height: calc(100vh - var(--topbar-h));
}

/* ===== Flash / Toast messages ===== */
.flash {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    max-width: none;
    margin: 0.75rem 1.5rem 0;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    font-weight: 500;
    animation: flashIn 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}
.flash::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
}
.flash-success {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(5,150,105,0.15);
}
.flash-success::before { background: var(--success); }
.flash-error {
    background: var(--error-bg);
    color: var(--error);
    border: 1px solid rgba(220,38,38,0.15);
}
.flash-error::before { background: var(--error); }
.flash-dismiss {
    margin-left: auto;
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    opacity: 0.5;
    font-size: 1.125rem;
    padding: 0 0.25rem;
    transition: opacity 0.15s;
}
.flash-dismiss:hover { opacity: 1; }
@keyframes flashIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}
.flash.flash-out {
    animation: flashOut 0.3s ease forwards;
}
@keyframes flashOut {
    to { opacity: 0; transform: translateY(-8px); height: 0; padding: 0; margin: 0; overflow: hidden; }
}

/* ===== Page head ===== */
.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.page-head h1 { margin: 0; }
.page-subtitle { margin: 0.125rem 0 0; font-size: 0.8125rem; color: var(--text-muted); }
.dashboard-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 0.5rem 0.875rem;
    font-size: 0.8125rem;
    font-weight: 500;
    font-family: inherit;
    border-radius: var(--radius-xs);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: all 0.15s ease;
    line-height: 1.4;
}
.btn:hover { background: var(--surface-hover); border-color: var(--text-muted); color: var(--text); }
.btn:active { transform: scale(0.98); }
.btn-primary, a.btn-primary {
    background: var(--primary);
    color: #fff !important;
    border-color: var(--primary);
    box-shadow: 0 1px 2px rgba(79,70,229,0.2);
}
.btn-primary:hover, a.btn-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    color: #fff !important;
    box-shadow: 0 2px 4px rgba(79,70,229,0.3);
}
.btn-sm { padding: 0.3125rem 0.625rem; font-size: 0.75rem; }
.btn-danger { background: var(--error); color: #fff; border-color: var(--error); }
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-hover); color: var(--text); border-color: var(--border); }

/* ===== Badges ===== */
.badge {
    display: inline-flex;
    align-items: center;
    font-size: 0.6875rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    line-height: 1.4;
}
.badge-draft { background: var(--warning-bg); color: var(--warning); }
.badge-sent { background: var(--success-bg); color: var(--success); }
.badge-paid { background: var(--success-bg); color: var(--success); }
.badge-unpaid { background: var(--error-bg); color: var(--error); }
.badge-overdue { background: var(--error-bg); color: var(--error); }
.badge-pending { background: var(--warning-bg); color: var(--warning); }
.badge-approved { background: var(--success-bg); color: var(--success); }
.badge-rejected { background: var(--error-bg); color: var(--error); }
.badge-credit { background: var(--info-bg); color: var(--info); }

/* ===== Cards ===== */
.card {
    background: var(--surface);
    padding: 1.25rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-xs);
    transition: all var(--transition);
}
.card:hover { box-shadow: var(--shadow); }
.card h2 {
    margin-top: 0;
    margin-bottom: 0.875rem;
    padding-bottom: 0.625rem;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.card .list { margin: -0.125rem 0; }
.card .list li { padding: 0.5rem 0; }

/* ===== KPI cards ===== */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}
.kpi-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.125rem 1.25rem;
    box-shadow: var(--shadow-xs);
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}
.kpi-card::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--gradient-brand);
    opacity: 0;
    transition: opacity var(--transition);
}
.kpi-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.kpi-card:hover::after { opacity: 1; }
.kpi-card h3, .kpi-card .label {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 0.375rem;
}
.kpi-card p, .kpi-card .value {
    font-size: 1.625rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
    margin: 0;
    line-height: 1.2;
}

/* ===== Dashboard ===== */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 1rem;
}
.dashboard-grid .card { min-height: 240px; }

/* ===== Tables ===== */
table {
    width: 100%;
    border-collapse: collapse;
}
.table {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
    box-shadow: var(--shadow-xs);
}
.table th, .table td {
    padding: 0.625rem 0.875rem;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.8125rem;
}
.table th {
    background: var(--bg);
    font-weight: 600;
    font-size: 0.6875rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.75rem 0.875rem;
}
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background var(--transition); }
.table tbody tr:hover td { background: var(--surface-hover); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); }

/* ===== Lists ===== */
.list { list-style: none; }
.list li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.8125rem;
    transition: background var(--transition);
}
.list li:last-child { border-bottom: 0; }
.list a { color: var(--primary); font-weight: 500; }
.list a:hover { text-decoration: underline; }
.sent-log .muted { font-size: 0.75rem; margin-left: 0.375rem; }

/* ===== Forms ===== */
.form { max-width: 640px; }
.form fieldset { border: 0; margin: 0 0 1.25rem; padding: 0; }
.form legend {
    font-weight: 600;
    font-size: 0.875rem;
    margin-bottom: 0.625rem;
    display: block;
    color: var(--text);
}
.form .field { margin-bottom: 0.625rem; }
.form label {
    display: block;
    font-weight: 500;
    font-size: 0.8125rem;
    margin-bottom: 0.25rem;
    color: var(--text-secondary);
}
.form input[type="text"], .form input[type="email"], .form input[type="password"],
.form input[type="number"], .form input[type="date"], .form select, .form textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
    font-family: inherit;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    background: var(--surface);
    color: var(--text);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.form input:focus, .form select:focus, .form textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-muted);
}
.form .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.form .row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.75rem; }
.form .hint, .hint { font-size: 0.75rem; color: var(--text-muted); }
.form label.block { display: block; margin-bottom: 0.25rem; }
.form-actions { margin-top: 1rem; display: flex; gap: 0.5rem; flex-wrap: wrap; }
.form-narrow .form-actions { margin-top: 0.875rem; }
.form-inline { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: flex-end; }
.form-inline .field { margin-bottom: 0; }

/* ===== Line items ===== */
.line-items { width: 100%; margin-bottom: 0.5rem; }
.line-items th, .line-items td { padding: 0.375rem 0.25rem; }
.line-items input { width: 100%; min-width: 0; }
.line-items .line-desc { min-width: 140px; }
.line-items select { width: 100%; min-width: 60px; }
.line-items .remove-line { margin: 0; }

/* ===== Invoice form layout ===== */
.form-and-preview { display: grid; grid-template-columns: 1fr 360px; gap: 1.5rem; align-items: start; }
@media (max-width: 960px) { .form-and-preview { grid-template-columns: 1fr; } }
.live-preview { position: sticky; top: calc(var(--topbar-h) + 1rem); }
.live-preview h3 { margin-bottom: 0.625rem; }
.preview-paper {
    background: var(--surface);
    padding: 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    font-size: 0.8125rem;
}
.preview-meta { margin-bottom: 0.625rem; }
.preview-meta strong { display: block; }
.preview-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; margin-bottom: 0.625rem; }
.preview-address { white-space: pre-wrap; color: var(--text-muted); font-size: 0.75rem; }
.preview-lines { width: 100%; font-size: 0.75rem; }
.preview-lines th, .preview-lines td { padding: 0.2rem; }
.preview-lines .num { text-align: right; }
.preview-totals { margin-top: 0.625rem; padding-top: 0.5rem; border-top: 1px solid var(--border); }
.preview-totals p { margin: 0.15rem 0; }

.send-section { margin-top: 1.5rem; }
.send-section .form-inline { display: grid; grid-template-columns: 1fr 1fr auto; gap: 0.75rem; align-items: end; }
.send-section .field.full { grid-column: 1 / -1; }
@media (max-width: 600px) { .send-section .form-inline { grid-template-columns: 1fr; } }

/* ===== Login page ===== */
.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 80vh;
    padding: 2rem;
}
.login-box {
    width: 400px;
    background: var(--surface);
    padding: 2.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-xl);
    position: relative;
    overflow: hidden;
}
.login-box::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: var(--gradient-brand);
}
.login-box h1 { margin-top: 0; margin-bottom: 0.25rem; font-size: 1.375rem; }
.login-box .muted { margin-bottom: 1.5rem; }
.login-box .form.form-narrow { max-width: none; width: 100%; }
.profile-page .form-narrow { max-width: 480px; }

/* ===== Invoices toolbar ===== */
.invoices-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: flex-end;
    margin-bottom: 1rem;
    padding: 0.875rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-xs);
}
.invoices-toolbar .field { margin-bottom: 0; display: flex; flex-direction: column; justify-content: flex-end; }
.invoices-toolbar .field-search { flex: 1; min-width: 220px; max-width: 400px; }
.invoices-toolbar label:not(.sr-only) { font-size: 0.6875rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 0.25rem; }
.invoices-toolbar input[type="search"] {
    width: 100%;
    height: 2.5rem;
    padding: 0 0.875rem;
    font-size: 0.8125rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.invoices-toolbar input[type="search"]:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-muted);
    outline: none;
}
.invoices-toolbar input[type="search"]::placeholder { color: var(--text-muted); }
.invoices-toolbar select {
    min-width: 130px;
    height: 2.5rem;
    padding: 0 2rem 0 0.625rem;
    font-size: 0.8125rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
}
.invoices-toolbar .btn { height: 2.5rem; padding: 0 1rem; }
.invoices-actions { margin-bottom: 0.5rem; }
.btn-delete-selected:not([form]) { display: none; }
.table .col-check { width: 2.25rem; vertical-align: middle; }
.table .col-actions { white-space: nowrap; }
.table .col-actions .btn { margin-right: 0.2rem; }
.form-delete-inline { display: inline; }
.form-delete-inline button { margin-left: 0.2rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* ===== Pagination ===== */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    margin-top: 1.25rem;
    flex-wrap: wrap;
}
.pagination .btn { min-width: 2rem; justify-content: center; }
.pagination-dots { padding: 0 0.25rem; color: var(--text-muted); font-size: 0.8125rem; }

/* ===== Empty states ===== */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-muted);
}
.empty-state h3 { color: var(--text); margin-bottom: 0.25rem; }
.empty-state p { margin: 0.375rem 0; font-size: 0.875rem; }
.empty-state .btn { margin-top: 0.875rem; }

/* ===== Scroll to top ===== */
.scroll-top {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: var(--primary);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.25s ease, transform 0.25s ease;
    z-index: 100;
    pointer-events: none;
}
.scroll-top.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}
.scroll-top:hover { background: var(--primary-hover); }
.scroll-top svg { width: 18px; height: 18px; }

/* ===== Mobile responsive ===== */
@media (max-width: 880px) {
    .sidebar {
        transform: translateX(-100%);
    }
    body.sidebar-open .sidebar {
        transform: translateX(0);
    }
    .content-shell { margin-left: 0; }
    .sidebar-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    body.sidebar-open .sidebar-overlay { display: block; }
    .topbar { padding-left: 3.25rem; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .page-head { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 600px) {
    .kpi-grid { grid-template-columns: 1fr; }
    .form .row2, .form .row3 { grid-template-columns: 1fr; }
    .invoices-toolbar { flex-direction: column; }
    .invoices-toolbar .field-search { max-width: none; }
}

/* ===== Print ===== */
@media print {
    .sidebar, .topbar, .sidebar-toggle, .sidebar-overlay, .scroll-top, .flash { display: none !important; }
    .content-shell { margin-left: 0 !important; }
    .main { padding: 0 !important; }
}

/* Legacy compat */
.site-header { display: none; }
.header-inner { display: none; }
.nav-toggle { display: none; }
.nav-main { display: none; }
.invoice-form-page .card { margin-top: 1rem; }
