:root {
    font-family: "Segoe UI", Arial, sans-serif;
    color: #17241f;
    background: #f5f7f5;
    --ink: #17241f;
    --muted: #718078;
    --line: #e4eae6;
    --green: #17684e;
    --green-dark: #104c3a;
    --mint: #e9f4ed;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: #f5f7f5; font-family: "Segoe UI", Arial, sans-serif; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
h1, h2, h3, strong { color: var(--ink); }
h1, h2 { letter-spacing: -.025em; }
h1 { margin: 6px 0 8px; font-size: clamp(1.75rem, 3vw, 2.4rem); font-weight: 750; }
h2 { margin: 0; font-size: 1.08rem; font-weight: 700; }
p { color: var(--muted); }

.app-shell { display: flex; min-height: 100vh; }
.sidebar { position: sticky; top: 0; display: flex; flex: 0 0 248px; flex-direction: column; height: 100vh; padding: 22px 15px 16px; background: #122d24; color: #d7e4dc; }
.main-content { min-width: 0; flex: 1; }
.topbar { height: 76px; padding: 0 36px; display: flex; align-items: center; justify-content: space-between; background: #fff; border-bottom: 1px solid var(--line); }
.topbar > div:first-child { display: flex; flex-direction: column; gap: 2px; }
.topbar strong { font-size: .92rem; }
.topbar-note, .small-muted { color: var(--muted); font-size: .77rem; }
.topbar-context { display: flex; align-items: flex-end; gap: 10px; }
.topbar-context label { display: flex; flex-direction: column; gap: 4px; color: #718078; font-size: .63rem; font-weight: 700; }
.topbar-context .form-select { width: auto; min-width: 145px; min-height: 34px; padding: 5px 28px 5px 9px; font-size: .74rem; }
.topbar-context label:last-child .form-select { min-width: 210px; }
.topbar-actions { display: flex; align-items: center; gap: 16px; }
.topbar-actions form { margin: 0; }
.company-actions { white-space: nowrap; }
.company-actions .button + .button { margin-left: 5px; }
.invoice-view-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.invoice-template-host { overflow-x: auto; border: 1px solid var(--line); background: #fff; }
.document-file-input input { min-height: 40px; padding: 8px; border: 1px solid #dfe7e1; border-radius: 7px; color: var(--ink); font-size: .75rem; }
.auth-page { display: grid; min-height: 100vh; place-items: center; padding: 24px; }
.auth-panel { width: min(440px, 100%); padding: 30px; }
.auth-brand { padding: 0 0 22px; color: var(--ink); }
.auth-panel > p { margin: 0 0 22px; font-size: .84rem; }
.auth-panel form { display: flex; flex-direction: column; gap: 16px; }
.auth-panel label { display: flex; flex-direction: column; gap: 7px; color: #56665d; font-size: .76rem; font-weight: 650; }
.auth-submit { width: 100%; margin-top: 5px; }
.auth-error { padding: 10px 12px; border: 1px solid #efc9c4; border-radius: 7px; background: #fff3f1; color: #943c32; font-size: .79rem; }
.content { max-width: 1600px; margin: 0 auto; padding: 32px 36px 60px; }
.brand { display: flex; align-items: center; gap: 11px; padding: 0 8px 26px; font-size: .94rem; font-weight: 800; color: #fff; }
.brand small { display: block; margin-top: 3px; color: #9fb6aa; font-size: .55rem; font-weight: 600; letter-spacing: .14em; }
.brand-mark { display: grid; width: 36px; height: 36px; place-items: center; border-radius: 11px; background: #d8ebdd; color: var(--green-dark); font-size: 1.2rem; }
.nav-menu { display: flex; flex-direction: column; gap: 3px; }
.nav-caption { margin: 18px 10px 6px; color: #84a095; font-size: .63rem; font-weight: 700; letter-spacing: .12em; }
.nav-menu .nav-link { display: flex; align-items: center; gap: 12px; min-height: 42px; padding: 0 11px; border-radius: 8px; color: #c1d0c8; font-size: .84rem; }
.nav-menu .nav-link span { width: 18px; color: #a7c7b5; font-size: 1rem; text-align: center; }
.nav-menu .nav-link:hover, .nav-menu .nav-link.active { background: #214638; color: #fff; }
.nav-menu .nav-link.active { box-shadow: inset 3px 0 #7acc9f; }
.sidebar-foot { display: flex; flex-direction: column; align-items: stretch; gap: 9px; margin-top: auto; padding: 12px 9px 3px; color: #9fb6aa; font-size: .7rem; }
.sidebar-view-label { display: flex; align-items: center; gap: 8px; padding: 0 2px; }
.view-switch { display: flex; min-height: 36px; align-items: center; justify-content: center; padding: 0 10px; border: 1px solid #49675a; border-radius: 7px; background: #193a2e; color: #e2eee7; cursor: pointer; font-size: .72rem; font-weight: 650; }
.view-switch:hover { background: #254c3c; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #79d19a; }

.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.page-heading p { max-width: 800px; margin: 0; font-size: .88rem; }
.eyebrow { color: #739083; font-size: .65rem; font-weight: 700; letter-spacing: .14em; }
.panel { padding: 23px 25px; border: 1px solid var(--line); border-radius: 12px; background: #fff; box-shadow: 0 2px 6px rgba(27, 55, 42, .025); }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-bottom: 20px; }
.panel-heading p { margin: 5px 0 0; font-size: .79rem; }
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card { display: flex; flex-direction: column; gap: 8px; padding: 20px; border: 1px solid var(--line); border-radius: 11px; background: #fff; }
.stat-card span { color: var(--muted); font-size: .78rem; font-weight: 600; }
.stat-card strong { font-size: 1.9rem; line-height: 1.1; }
.stat-card small { color: #89978f; font-size: .7rem; }
.panel-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(280px, .75fr); gap: 18px; }
.step-list { display: flex; flex-direction: column; gap: 0; padding: 0; margin: 0; list-style: none; }
.step-list li { display: grid; grid-template-columns: 35px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 14px 0; border-top: 1px solid #edf1ee; }
.step-list li:first-child { border-top: 0; }
.step-list li > span { display: grid; width: 30px; height: 30px; place-items: center; border-radius: 8px; background: var(--mint); color: var(--green); font-size: .7rem; font-weight: 700; }
.step-list strong { font-size: .83rem; }
.step-list p { margin: 3px 0 0; font-size: .75rem; }
.step-list a { color: var(--green); font-size: .75rem; font-weight: 650; }
.note-panel { background: #edf5f0; border-color: #dfebe3; }
.note-panel h2 { margin: 12px 0 9px; font-size: 1.28rem; line-height: 1.3; }
.note-panel > p { font-size: .82rem; line-height: 1.6; }
.notice { display: flex; align-items: flex-start; gap: 12px; padding: 13px 15px; margin-bottom: 18px; border-radius: 8px; font-size: .78rem; line-height: 1.5; }
.notice strong { white-space: nowrap; }
.notice-warning { border: 1px solid #efdfb5; background: #fff9e9; color: #6f5b2b; }
.notice-warning strong { color: #6f5318; }
.content-grid { display: grid; grid-template-columns: minmax(260px, .72fr) minmax(0, 1.28fr); align-items: start; gap: 18px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; margin-bottom: 18px; }
.form-grid-wide { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid label { display: flex; min-width: 0; flex-direction: column; gap: 7px; color: #56665d; font-size: .74rem; font-weight: 650; }
.form-control, .form-select { width: 100%; min-height: 40px; padding: 8px 11px; border: 1px solid #dfe7e1; border-radius: 7px; outline: 0; background-color: #fff; color: var(--ink); font-size: .82rem; }
.form-control:focus, .form-select:focus { border-color: #72a58a; box-shadow: 0 0 0 3px rgba(69, 143, 103, .12); }
.form-grid textarea { resize: vertical; }
.span-two { grid-column: span 2; }
.button { display: inline-flex; min-height: 38px; align-items: center; justify-content: center; gap: 7px; padding: 0 14px; border: 1px solid transparent; border-radius: 7px; cursor: pointer; font-size: .78rem; font-weight: 650; }
.button-primary { background: var(--green); color: white; }
.button-primary:hover { background: var(--green-dark); color: white; }
.button-primary:disabled { opacity: .5; cursor: not-allowed; }
.button-secondary { border-color: #d9e3dc; background: #fff; color: #345744; }
.button-small { min-height: 30px; padding: 0 10px; border-color: #e0e8e2; background: #fff; color: #53675b; font-size: .7rem; }
.form-message { display: inline-block; margin: 0 0 0 12px; color: #356b4e; font-size: .78rem; }
.required-marker { color: #a33b2f; }
.profile-details { display: grid; grid-template-columns: minmax(100px, .7fr) minmax(0, 1.3fr); gap: 10px 14px; margin: 0; font-size: .8rem; }
.profile-details dt { color: var(--muted); }
.profile-details dd { margin: 0; color: var(--ink); overflow-wrap: anywhere; }
.workspace-links { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.workspace-links + h3 { margin: 0 0 10px; font-size: .9rem; }
.modal-backdrop { position: fixed; inset: 0; z-index: 1100; display: grid; place-items: center; padding: 20px; background: rgba(15, 31, 23, .56); }
.product-modal { width: min(720px, 100%); max-height: calc(100vh - 40px); overflow-y: auto; padding: 24px; border: 1px solid var(--line); border-radius: 12px; background: #fff; box-shadow: 0 18px 60px rgba(15, 31, 23, .24); }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 20px; }
.inline-controls { display: flex; align-items: center; gap: 15px; margin-top: 10px; }
.options-row { margin: 14px 0; }
.check-label { display: inline-flex; align-items: center; gap: 8px; color: #46574d; font-size: .79rem; }
.check-label input { accent-color: var(--green); }
.mt-panel { margin-top: 18px; }
.data-table-wrap { width: 100%; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: .77rem; }
.data-table th { padding: 10px 12px; border-bottom: 1px solid var(--line); color: #809087; font-size: .64rem; font-weight: 700; letter-spacing: .06em; text-align: left; text-transform: uppercase; white-space: nowrap; }
.data-table td { padding: 12px; border-bottom: 1px solid #edf1ee; color: #56645c; vertical-align: middle; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table td strong { display: block; color: #263a2f; font-size: .78rem; }
.data-table td small { display: block; margin-top: 3px; color: #849188; font-size: .68rem; }
.data-table .group-header td { background: #f3f7f4; border-top: 1px solid var(--line); color: #345744; }
.sequence { display: inline-block; padding: 4px 8px; border-radius: 6px; background: #edf5ef; color: var(--green); font-size: .72rem; font-weight: 700; }
.pill { display: inline-flex; padding: 4px 8px; border-radius: 20px; font-size: .68rem; font-weight: 650; }
.pill-green { background: #e8f4eb; color: #31704a; }
.pill-neutral { background: #eef1ef; color: #6a756e; }
.empty-state { padding: 22px; color: #7d8b82; font-size: .82rem; text-align: center; }
.note-callout { padding: 12px 14px; border-radius: 8px; background: #f0f7f2; color: #365b48; font-size: .78rem; line-height: 1.5; }
.invoice-list { display: flex; flex-direction: column; gap: 20px; }
.invoice-paper { position: relative; width: 100%; min-height: 260mm; padding: 14mm 13mm; border: 1px solid #dde4de; background: white; color: #26372e; }
.invoice-top { display: flex; justify-content: space-between; gap: 20px; padding-bottom: 17px; border-bottom: 2px solid #234a36; }
.seller-identity { display: flex; align-items: flex-start; gap: 13px; }
.seller-identity h2 { margin-bottom: 5px; color: #234a36; font-size: 1.12rem; }
.seller-identity p, .invoice-parties p, .invoice-bank p { margin: 3px 0; color: #67756c; font-size: .69rem; }
.invoice-monogram { display: grid; width: 52px; height: 52px; place-items: center; border: 1px solid #d5e0d8; border-radius: 8px; color: var(--green); font-weight: 800; }
.invoice-label { display: flex; min-width: 180px; flex-direction: column; align-items: flex-end; gap: 5px; }
.invoice-label span { color: #956b19; font-size: .82rem; font-weight: 800; letter-spacing: .12em; }
.invoice-label strong { font-size: .79rem; }
.invoice-label small { color: #68766d; font-size: .67rem; }
.invoice-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; padding: 15px 0; }
.invoice-parties div { display: flex; flex-direction: column; align-items: flex-start; }
.invoice-parties span { margin-bottom: 5px; color: #718277; font-size: .62rem; font-weight: 750; letter-spacing: .1em; }
.invoice-parties strong { font-size: .78rem; }
.invoice-lines { width: 100%; border-collapse: collapse; font-size: .63rem; }
.invoice-lines th { padding: 8px 5px; background: #edf4ef; color: #355a43; text-align: left; }
.invoice-lines td { padding: 8px 5px; border-bottom: 1px solid #e8ede9; color: #4f5d54; }
.invoice-bottom { display: grid; grid-template-columns: 1fr 260px; gap: 20px; padding-top: 18px; }
.invoice-bank { font-size: .67rem; }
.invoice-bank strong { display: block; margin: 0 0 5px; color: #344d3c; }
.invoice-totals { width: 100%; border-collapse: collapse; font-size: .69rem; }
.invoice-totals td { padding: 5px 4px; color: #5f6c63; }
.invoice-totals td:last-child { text-align: right; white-space: nowrap; }
.invoice-totals .grand-total td { padding-top: 9px; border-top: 1px solid #cfdad2; color: #203d2c; font-size: .78rem; font-weight: 800; }
.invoice-footer { display: flex; align-items: flex-end; justify-content: space-between; min-height: 104px; padding-top: 12px; }
.invoice-status-watermark { color: #ad7d18; font-size: .85rem; font-weight: 800; letter-spacing: .12em; transform: rotate(-8deg); }
.signature { display: flex; min-width: 180px; flex-direction: column; align-items: center; gap: 27px; padding: 0 10px 5px; border-bottom: 1px solid #7d8a80; font-size: .67rem; }
.signature span { color: #66756b; }
code { color: #315a42; font-size: .75rem; }
#blazor-error-ui { display: none; }

@media (max-width: 950px) {
    .sidebar { flex-basis: 210px; }
    .content { padding: 26px 22px 45px; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .panel-grid, .content-grid { grid-template-columns: 1fr; }
    .form-grid-wide { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 650px) {
    .app-shell { flex-direction: column; }
    .sidebar { position: relative; width: 100%; height: auto; flex-basis: auto; padding-bottom: 10px; }
    .brand { padding-bottom: 12px; }
    .nav-menu { display: grid; grid-template-columns: repeat(2, 1fr); }
    .nav-caption { display: none; }
    .sidebar-foot { display: flex; flex-direction: row; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; padding: 8px 4px; }
    .view-switch { min-height: 32px; }
    .topbar { height: auto; min-height: 58px; flex-wrap: wrap; gap: 8px; padding: 8px 14px; }
    .topbar-actions { width: 100%; justify-content: flex-end; flex-wrap: wrap; gap: 8px; }
    .topbar-context { order: 0; width: auto; }
    .topbar-context label { flex: 0 1 200px; }
    .topbar-context .form-select, .topbar-context label:last-child .form-select { width: 100%; min-width: 0; }
    .topbar-note { display: none; }
    .content { padding: 22px 14px 35px; }
    .page-heading { align-items: flex-start; flex-direction: column; }
    .panel { padding: 18px 15px; }
    .form-grid, .form-grid-wide, .invoice-parties { grid-template-columns: 1fr; }
    .span-two { grid-column: auto; }
    .step-list li { grid-template-columns: 32px 1fr; }
    .step-list li a { grid-column: 2; }
    .invoice-top, .invoice-bottom { grid-template-columns: 1fr; flex-direction: column; }
}
@page { size: A4 portrait; margin: 10mm; }
@media print {
    html, body { background: #fff !important; color: #111; }
    .sidebar, .topbar, .no-print, #blazor-error-ui { display: none !important; }
    .app-shell, .main-content { display: block; min-height: 0; }
    .content { max-width: none; padding: 0; margin: 0; }
    .invoice-list { display: block; }
    .invoice-paper { width: 190mm; min-height: 277mm; padding: 5mm 4mm; margin: 0; border: 0; page-break-after: always; break-after: page; box-shadow: none; }
    .invoice-paper:last-child { page-break-after: auto; break-after: auto; }
    .invoice-template-host { overflow: visible; border: 0; }
    .invoice-lines { font-size: 7pt; }
    .invoice-lines th, .invoice-lines td { padding: 5px 4px; }
    .invoice-parties p, .seller-identity p, .invoice-bank p { font-size: 7pt; }
}
