:root {
    --bg: #f4f6f8;
    --surface: #ffffff;
    --text: #17202a;
    --muted: #667085;
    --line: #e4e7ec;
    --primary: #0b5cab;
    --primary-dark: #084986;
    --accent: #eaf3ff;
    --success: #067647;
    --danger: #b42318;
    --radius: 14px;
    --shadow: 0 8px 28px rgba(16, 24, 40, .07);
}
* { box-sizing: border-box; }
html { min-height: 100%; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
.topbar { position: sticky; top: 0; z-index: 20; min-height: 68px; display: flex; align-items: center; gap: 28px; padding: 0 32px; background: rgba(255,255,255,.96); border-bottom: 1px solid var(--line); backdrop-filter: blur(10px); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 750; white-space: nowrap; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; color: white; background: linear-gradient(135deg, #0b5cab, #3a8dde); }
.topnav { display: flex; gap: 4px; flex: 1; }
.topnav a { padding: 9px 11px; border-radius: 8px; color: #344054; font-size: .93rem; }
.topnav a:hover { background: #f2f4f7; color: var(--text); }
.nav-group { position: relative; }
.nav-group summary { list-style: none; padding: 9px 11px; border-radius: 8px; color: #344054; font-size: .93rem; cursor: pointer; white-space: nowrap; }
.nav-group summary::-webkit-details-marker { display: none; }
.nav-group summary::after { content: "▾"; margin-left: 7px; color: #98a2b3; font-size: .7rem; }
.nav-group[open] summary, .nav-group summary:hover { background: #f2f4f7; color: var(--text); }
.nav-menu { position: absolute; top: calc(100% + 8px); left: 0; z-index: 30; display: grid; min-width: 230px; padding: 7px; border: 1px solid var(--line); border-radius: 10px; background: white; box-shadow: var(--shadow); }
.nav-menu a { display: block; white-space: nowrap; }
.company-switcher select { min-width: 210px; }
.page-shell { width: min(1240px, calc(100% - 40px)); margin: 34px auto 60px; }
.footer { display: flex; justify-content: space-between; width: min(1240px, calc(100% - 40px)); margin: 0 auto; padding: 24px 0 36px; color: var(--muted); font-size: .85rem; }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.page-header h1 { margin: 3px 0 0; font-size: clamp(1.7rem, 3vw, 2.3rem); letter-spacing: -.04em; }
.page-header p { margin: 5px 0 0; color: var(--muted); }
.eyebrow { font-size: .74rem; color: var(--primary); font-weight: 800; letter-spacing: .12em; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; }
.hero { min-height: 390px; display: grid; align-items: center; background: radial-gradient(circle at 85% 20%, #dbeafe, transparent 34%), white; }
.hero > div { max-width: 690px; }
.hero h1 { margin: 10px 0 18px; font-size: clamp(2.2rem, 5vw, 4rem); line-height: 1.04; letter-spacing: -.06em; }
.hero p { max-width: 580px; margin: 0 0 28px; color: var(--muted); font-size: 1.1rem; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat-card { display: flex; min-height: 135px; flex-direction: column; justify-content: space-between; padding: 22px; background: white; border: 1px solid var(--line); border-radius: var(--radius); color: var(--text); box-shadow: var(--shadow); }
.stat-card:hover { transform: translateY(-1px); border-color: #c7d7ed; }
.stat-card strong { font-size: 1.75rem; letter-spacing: -.04em; }
.stat-label { color: var(--muted); font-size: .9rem; }
.stat-accent { background: linear-gradient(135deg, #0b5cab, #06477f); color: white; border-color: transparent; }
.stat-accent .stat-label { color: #cfe6ff; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.card-header h2 { margin: 0; font-size: 1.18rem; }
.card-header p { margin: 4px 0 0; color: var(--muted); font-size: .9rem; }
.button { appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 40px; padding: 9px 15px; border: 1px solid #cfd4dc; border-radius: 9px; background: white; color: #344054; font: inherit; font-weight: 650; cursor: pointer; }
.button:hover { border-color: #98a2b3; color: var(--text); }
.button-primary { color: white; border-color: var(--primary); background: var(--primary); }
.button-primary:hover { color: white; border-color: var(--primary-dark); background: var(--primary-dark); }
.button-secondary { background: #fff; }
.button-small { min-height: 32px; padding: 5px 10px; font-size: .84rem; }
.header-actions, .actions, .form-actions { display: flex; align-items: center; gap: 9px; }
.company-switcher, .send-form, .membership-row { display: flex; align-items: center; gap: 9px; }
.send-form input { width: 230px; }
.membership-row { max-width: 650px; margin: 9px 0; }
.membership-row label { flex: 1; }
.membership-row input[type=checkbox] { width: auto; }
.membership-row select { width: 220px; }
.auth-card { max-width: 520px; margin: 8vh auto; }
.correction-card { max-width: 980px; margin: 18px auto; }
.correction-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.correction-grid form { display: grid; align-content: start; gap: 10px; padding: 16px; border: 1px solid var(--line); border-radius: 10px; }
.payment-form { display: grid; grid-template-columns: 1fr 1fr 2fr auto; gap: 10px; align-items: center; }
.translation-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
.branding-preview { display: block; max-width: 220px; max-height: 90px; margin: 10px 0; object-fit: contain; }
.form-actions { justify-content: flex-end; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 11px 12px; color: var(--muted); background: #f8fafc; border-bottom: 1px solid var(--line); font-size: .79rem; text-align: left; text-transform: uppercase; letter-spacing: .05em; }
td { padding: 13px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfcfe; }
td small { display: block; margin-top: 3px; color: var(--muted); }
.numeric { text-align: right; white-space: nowrap; }
.badge { display: inline-flex; padding: 4px 8px; border-radius: 999px; background: #f2f4f7; color: #344054; font-size: .78rem; font-weight: 700; }
.badge-draft { background: #f2f4f7; }
.badge-issued { background: #fff4e5; color: #9a4f00; }
.badge-paid { background: #ecfdf3; color: #067647; }
.badge-cancelled { background: #fef3f2; color: #b42318; }
.form-card { padding: 28px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-wide { grid-column: 1 / -1; }
.field label { color: #344054; font-size: .87rem; font-weight: 650; }
input, select, textarea { width: 100%; border: 1px solid #cfd4dc; border-radius: 8px; background: white; color: var(--text); padding: 10px 11px; font: inherit; outline: none; }
input:focus, select:focus, textarea:focus { border-color: #5b9bd5; box-shadow: 0 0 0 3px rgba(11,92,171,.12); }
textarea { resize: vertical; }
.checkbox-field { justify-content: flex-end; }
.checkbox-field label { display: flex; align-items: center; gap: 8px; }
.checkbox-field input { width: auto; }
.field-validation-error, .validation-summary { color: var(--danger); font-size: .84rem; }
.validation-summary { margin-bottom: 14px; padding: 12px; border-radius: 8px; background: #fef3f2; }
.alert { margin-bottom: 18px; padding: 13px 15px; border-radius: 10px; transition: opacity .3s; }
.alert-success { color: #05603a; background: #ecfdf3; border: 1px solid #abefc6; }
.alert-error { color: #912018; background: #fef3f2; border: 1px solid #fecdca; }
.alert-hide { opacity: 0; }
.empty-state { padding: 48px 20px; color: var(--muted); text-align: center; }
.text-link { font-weight: 650; }
.invoice-form { display: grid; gap: 18px; }
.invoice-lines { display: grid; gap: 12px; }
.invoice-line { position: relative; display: grid; grid-template-columns: 36px 1.1fr 1.8fr .6fr .6fr .7fr .6fr .6fr 34px; gap: 10px; align-items: end; padding: 14px 8px 16px; border-bottom: 1px solid var(--line); }
.invoice-line:last-child { border-bottom: 0; }
.line-number { align-self: center; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: #eef4fb; color: var(--primary); font-size: .8rem; font-weight: 800; }
.icon-button { width: 32px; height: 40px; border: 0; border-radius: 8px; background: transparent; color: #98a2b3; font-size: 1.5rem; cursor: pointer; }
.icon-button:hover { color: var(--danger); background: #fef3f2; }
.document-preview { max-width: 980px; margin: 0 auto; padding: 48px; }
.document-top { display: flex; justify-content: space-between; gap: 40px; }
.document-top h2 { margin: 0 0 8px; }
.document-top p, .recipient { line-height: 1.55; color: #475467; }
.document-meta { width: 300px; padding: 20px; background: #f8fafc; border-radius: 10px; }
.document-meta > strong { font-size: 1.3rem; }
dl { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin: 14px 0 0; font-size: .87rem; }
dt { color: var(--muted); } dd { margin: 0; text-align: right; font-weight: 650; }
.recipient { margin: 48px 0 35px; }
.totals { width: 340px; margin: 24px 0 24px auto; }
.totals > div { display: flex; justify-content: space-between; padding: 6px 0; }
.grand-total { margin-top: 6px; padding-top: 12px !important; border-top: 2px solid var(--text); font-size: 1.15rem; }
.document-notes { margin-top: 28px; padding: 16px; background: #f8fafc; border-radius: 8px; white-space: pre-line; }
.back-row { max-width: 980px; margin: 18px auto; }
.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; }
@media (max-width: 1000px) {
    .topbar { flex-wrap: wrap; gap: 10px; padding: 12px 20px; }
    .topnav { order: 3; width: 100%; flex-wrap: wrap; overflow: visible; }
    .nav-menu { position: absolute; }
    .company-switcher { margin-left: auto; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .invoice-line { grid-template-columns: 36px repeat(2, minmax(0, 1fr)) 34px; align-items: end; }
    .description-field { grid-column: 2 / 4; }
}
@media (max-width: 700px) {
    .page-shell, .footer { width: min(100% - 24px, 1240px); }
    .page-header, .document-top { align-items: stretch; flex-direction: column; }
    .header-actions { flex-wrap: wrap; }
    .stats-grid, .form-grid { grid-template-columns: 1fr; }
    .field-wide { grid-column: auto; }
    .card, .form-card, .document-preview { padding: 18px; }
    .invoice-line { grid-template-columns: 32px 1fr 32px; }
    .invoice-line .field { grid-column: 2; }
    .invoice-line .remove-row { grid-column: 3; grid-row: 1; }
    .document-meta { width: 100%; }
    .totals { width: 100%; }
}
