:root {
    --ink: #1a2332;
    --ink-soft: #4a5568;
    --accent: #1d4ed8;
    --accent-dark: #1e40af;
    --ok: #15803d;
    --ok-bg: #f0fdf4;
    --err: #b91c1c;
    --err-bg: #fef2f2;
    --warn-bg: #fffbeb;
    --warn: #a16207;
    --line: #e2e8f0;
    --bg-soft: #f8fafc;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--ink);
    line-height: 1.55;
    background: #fff;
}

.container { max-width: 960px; margin: 0 auto; padding: 0 1.25rem; }

/* header */
.site-header { border-bottom: 1px solid var(--line); background: #fff; }
.header-inner { display: flex; align-items: center; gap: 2rem; padding: 0.9rem 1.25rem; flex-wrap: wrap; }
.logo { font-size: 1.25rem; font-weight: 700; text-decoration: none; color: var(--ink); display: inline-flex; align-items: center; }
.logo span { color: var(--accent); }
.logo-img { height: 26px; width: auto; display: block; margin-right: 0.45rem; }
.site-header nav { display: flex; gap: 1.25rem; flex: 1; flex-wrap: wrap; }
.site-header nav a { text-decoration: none; color: var(--ink-soft); font-weight: 500; padding: 0.25rem 0; border-bottom: 2px solid transparent; }
.site-header nav a:hover { color: var(--ink); }
.site-header nav a.active { color: var(--accent); border-bottom-color: var(--accent); }
.lang-switch { color: var(--ink-soft); font-size: 0.9rem; }
.lang-switch a { text-decoration: none; color: var(--ink-soft); padding: 0 0.15rem; }
.lang-switch a.active { color: var(--ink); font-weight: 700; }
/* phones: logo + language on the first row, the menu as one swipeable row below (was ~280px tall) */
@media (max-width: 720px) {
    .header-inner { gap: 0.35rem 1rem; padding: 0.6rem 1rem; justify-content: space-between; }
    .site-header nav { order: 3; flex: 0 0 100%; flex-wrap: nowrap; overflow-x: auto; gap: 1.1rem; padding-bottom: 0.15rem; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
    .site-header nav::-webkit-scrollbar { display: none; }
    .site-header nav a { white-space: nowrap; font-size: 0.95rem; }
    main { padding-top: 1.5rem; }
    .hero h1 { font-size: 1.7rem; }
    .invoice-sheet { padding: 1rem; }
    table.data { display: block; overflow-x: auto; }
}

main { padding: 2.5rem 1.25rem 4rem; min-height: 60vh; }

h1 { font-size: 1.8rem; margin: 0 0 0.5rem; }
h2 { font-size: 1.25rem; margin: 2rem 0 0.75rem; }
.lead { color: var(--ink-soft); font-size: 1.05rem; max-width: 44rem; margin-top: 0; }

/* hero (home) */
.hero { text-align: center; padding: 2rem 0 1rem; }
.hero h1 { font-size: 2.2rem; max-width: 40rem; margin: 0 auto 0.75rem; }
.hero .lead { margin: 0 auto 1.5rem; }
.cta-row { display: flex; gap: 0.75rem; justify-content: center; flex-wrap: wrap; margin-bottom: 1rem; }

/* two-column hero with invoice preview */
.hero-grid { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 2.5rem; align-items: center; text-align: left; }
.hero-grid h1, .hero-grid .lead { margin-left: 0; }
.hero-grid .cta-row { justify-content: flex-start; }
.trust-row { list-style: none; padding: 0; margin: 1.25rem 0 0; display: flex; flex-wrap: wrap; gap: 0.4rem 1.25rem; }
.trust-row li { color: var(--ink-soft); font-size: 0.88rem; }
.trust-row li::before { content: '✓'; color: var(--ok); font-weight: 700; margin-right: 0.4rem; }
.hero-preview { min-width: 0; }
.preview-label { font-size: 0.82rem; color: var(--ink-soft); margin-bottom: 0.5rem; text-align: center; }
.invoice-mock {
    background: #fff; border: 1px solid var(--line); border-radius: 10px;
    box-shadow: 0 10px 30px rgba(26, 35, 50, 0.12); padding: 1.25rem 1.4rem;
    font-size: 0.8rem; transform: rotate(0.6deg);
}
.im-sender { font-size: 0.62rem; color: var(--ink-soft); border-bottom: 1px solid var(--line); padding-bottom: 0.3rem; }
.im-title { font-weight: 700; font-size: 1rem; margin-top: 0.6rem; }
.im-meta { color: var(--ink-soft); font-size: 0.7rem; margin-bottom: 0.6rem; }
.im-table { width: 100%; border-collapse: collapse; margin: 0.4rem 0 0.6rem; }
.im-table th, .im-table td { border: 1px solid var(--line); padding: 0.25rem 0.4rem; text-align: left; font-size: 0.72rem; }
.im-table th { background: var(--bg-soft); }
.im-table th:nth-child(3), .im-table td:nth-child(3),
.im-table th:nth-child(4), .im-table td:nth-child(4) { text-align: right; }
.im-totals { max-width: 14rem; margin-left: auto; }
.im-totals div { display: flex; justify-content: space-between; padding: 0.1rem 0; font-size: 0.75rem; }
.im-grand { font-weight: 700; border-top: 2px solid var(--ink); margin-top: 0.2rem; padding-top: 0.25rem !important; }
.im-chips { display: flex; gap: 0.4rem; margin-top: 0.8rem; }
@media (max-width: 820px) {
    .hero-grid { grid-template-columns: 1fr; text-align: center; }
    .hero-grid .cta-row { justify-content: center; }
    .trust-row { justify-content: center; }
    .invoice-mock { max-width: 24rem; margin: 0 auto; }
}
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; margin: 2.5rem 0; }
.card { border: 1px solid var(--line); border-radius: 10px; padding: 1.25rem; background: var(--bg-soft); }
.card h3 { margin: 0 0 0.4rem; font-size: 1.05rem; }
.card p { margin: 0 0 0.75rem; color: var(--ink-soft); font-size: 0.95rem; }
.card a { font-weight: 600; }

/* buttons & forms */
.btn {
    display: inline-block; background: var(--accent); color: #fff; border: 0;
    padding: 0.65rem 1.4rem; border-radius: 8px; font-size: 1rem; font-weight: 600;
    text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--accent-dark); }
.btn.secondary { background: #fff; color: var(--accent); border: 1.5px solid var(--accent); }
.btn.secondary:hover { background: var(--bg-soft); }

form.stack { max-width: 46rem; }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 1rem 1.25rem 1.25rem; margin: 0 0 1.5rem; }
legend { font-weight: 700; padding: 0 0.4rem; }
label { display: block; font-weight: 500; font-size: 0.92rem; margin-bottom: 0.2rem; }
.hint { font-weight: 400; color: var(--ink-soft); font-size: 0.85rem; }
input[type=text], input[type=email], input[type=date], input[type=number], select, textarea {
    width: 100%; padding: 0.5rem 0.6rem; border: 1px solid #cbd5e1; border-radius: 6px;
    font-size: 0.95rem; font-family: inherit; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem; }
.grid3 { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 0.9rem; }
.field { margin-bottom: 0.9rem; }
@media (max-width: 640px) { .grid2, .grid3 { grid-template-columns: 1fr; } }

/* upload box */
.upload-box {
    border: 2px dashed #cbd5e1; border-radius: 12px; padding: 2rem; text-align: center;
    background: var(--bg-soft); max-width: 34rem;
}
.upload-box input[type=file] { margin: 0.75rem auto; }

/* alerts */
.alert { border-radius: 8px; padding: 0.9rem 1.1rem; margin: 1rem 0; }
.alert.ok { background: var(--ok-bg); color: var(--ok); border: 1px solid #bbf7d0; }
.alert.err { background: var(--err-bg); color: var(--err); border: 1px solid #fecaca; }
.alert.warn { background: var(--warn-bg); color: var(--warn); border: 1px solid #fde68a; }
.alert ul { margin: 0.4rem 0 0; padding-left: 1.2rem; }
.alert code { font-size: 0.85em; }

/* tables */
table.data { border-collapse: collapse; width: 100%; margin: 1rem 0; font-size: 0.95rem; }
table.data th, table.data td { border: 1px solid var(--line); padding: 0.5rem 0.65rem; text-align: left; }
table.data th { background: var(--bg-soft); }
table.data td.num, table.data th.num { text-align: right; white-space: nowrap; }

/* line-item rows in the create form */
.line-row { display: grid; grid-template-columns: 3fr 1fr 1fr 1fr 1fr auto; gap: 0.5rem; margin-bottom: 0.5rem; align-items: end; }
.line-row .rm { background: none; border: 0; color: var(--err); font-size: 1.2rem; cursor: pointer; padding: 0.4rem; }
@media (max-width: 720px) { .line-row { grid-template-columns: 1fr 1fr; } }
.line-item { padding-bottom: 0.75rem; margin-bottom: 0.75rem; border-bottom: 1px dashed var(--line); }
.line-item .line-row { margin-bottom: 0.4rem; }
input.line-desc { font-size: 0.88rem; color: var(--ink-soft); }
.live-totals { display: flex; flex-wrap: wrap; gap: 0.4rem 1.5rem; justify-content: flex-end; margin-top: 0.9rem; color: var(--ink-soft); font-size: 0.95rem; }
.live-totals strong { color: var(--ink); }
details.import-box, details.more-fields { border: 1px dashed #cbd5e1; border-radius: 10px; padding: 0.6rem 1rem; margin: 0 0 1.5rem; background: var(--bg-soft); max-width: 46rem; }
details.more-fields { margin: 0.5rem 0 0; background: #fff; }
details.import-box summary, details.more-fields summary { cursor: pointer; font-weight: 600; color: var(--accent); font-size: 0.95rem; }
details[open].import-box summary, details[open].more-fields summary { margin-bottom: 0.75rem; }
details.import-box input[type=file] { margin: 0.25rem 0.75rem 0.5rem 0; }

/* pagination & small action links in tables */
.pager { display: flex; gap: 1rem; align-items: center; margin: 1rem 0; font-size: 0.95rem; }
.row-actions a { white-space: nowrap; }
.findings { list-style: none; padding: 0; margin: 0.4rem 0 0; }
.findings li { padding: 0.25rem 0; }
.findings code { font-weight: 600; }

/* rendered invoice (viewer) */
.invoice-sheet { border: 1px solid var(--line); border-radius: 10px; padding: 2rem; max-width: 52rem; margin: 1rem 0; }
.invoice-head { display: flex; justify-content: space-between; gap: 2rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.invoice-head .party h3 { margin: 0 0 0.3rem; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-soft); }
.invoice-head .party p { margin: 0; }
.meta-list { list-style: none; padding: 0; margin: 0; font-size: 0.95rem; }
.meta-list li { display: flex; justify-content: space-between; gap: 1.5rem; }
.meta-list .k { color: var(--ink-soft); }
.totals-block { margin-left: auto; max-width: 20rem; }
.totals-block .row { display: flex; justify-content: space-between; padding: 0.2rem 0; }
.totals-block .grand { font-weight: 700; border-top: 2px solid var(--ink); margin-top: 0.3rem; padding-top: 0.4rem; }
.notes { background: var(--bg-soft); border-radius: 8px; padding: 0.75rem 1rem; margin-top: 1rem; font-size: 0.95rem; }

/* social login */
.social-login { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 0.75rem; }
.btn-social {
    display: flex; align-items: center; justify-content: center; gap: 0.6rem;
    border: 1.5px solid var(--line); border-radius: 8px; padding: 0.6rem 1rem;
    background: #fff; color: var(--ink); font-weight: 600; text-decoration: none; font-size: 0.95rem;
}
.btn-social:hover { background: var(--bg-soft); border-color: #94a3b8; }

/* stats dashboard */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.8rem; margin: 1.25rem 0; }
.stat-card { border: 1px solid var(--line); border-radius: 10px; padding: 0.8rem 1rem; background: var(--bg-soft); }
.stat-card .k { font-size: 0.78rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.03em; }
.stat-card .v { font-size: 1.7rem; font-weight: 700; line-height: 1.2; }
.stat-card .s { font-size: 0.82rem; color: var(--ink-soft); }
.stats-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; }
.stats-grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 2rem; }
@media (max-width: 760px) { .stats-grid2, .stats-grid3 { grid-template-columns: 1fr; } }

/* blog article */
.prose h2 { font-size: 1.3rem; margin-top: 2rem; }
.prose p, .prose li { font-size: 1rem; }
.prose table { border-collapse: collapse; width: 100%; margin: 1rem 0; font-size: 0.95rem; }
.prose th, .prose td { border: 1px solid var(--line); padding: 0.5rem 0.65rem; text-align: left; }
.prose th { background: var(--bg-soft); }
.prose blockquote { border-left: 3px solid var(--accent); margin: 1rem 0; padding: 0.25rem 1rem; color: var(--ink-soft); }
.prose code { background: var(--bg-soft); border-radius: 4px; padding: 0.1rem 0.35rem; font-size: 0.9em; }
.prose pre { background: var(--bg-soft); border: 1px solid var(--line); border-radius: 8px; padding: 0.75rem 1rem; overflow-x: auto; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2rem 0; }
.prose em:last-child { color: var(--ink-soft); }
.cta-box { border: 1.5px solid var(--accent); border-radius: 12px; padding: 1.1rem 1.4rem 1.3rem; margin: 2.5rem 0 1rem; background: #eff6ff; }
.cta-box h2 { margin: 0 0 0.3rem; font-size: 1.15rem; }
.cta-box p { margin: 0 0 0.9rem; color: var(--ink-soft); }
.related ul { padding-left: 1.2rem; }
.related li { margin: 0.3rem 0; }

/* footer */
.site-footer { border-top: 1px solid var(--line); padding: 2rem 0 2.5rem; color: var(--ink-soft); font-size: 0.9rem; background: var(--bg-soft); }
.site-footer a { color: var(--ink-soft); display: block; text-decoration: none; padding: 0.15rem 0; }
.site-footer a:hover { color: var(--ink); text-decoration: underline; }
.footer-grid { display: grid; grid-template-columns: 1.3fr 1fr 1fr 1.2fr; gap: 2rem; margin-bottom: 1.25rem; }
.footer-grid h4 { margin: 0 0 0.5rem; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink); }
.footer-grid p { margin: 0.25rem 0; }
@media (max-width: 720px) { .footer-grid { grid-template-columns: 1fr 1fr; } }
.disclaimer { font-size: 0.83rem; border-top: 1px solid var(--line); padding-top: 1rem; }

.badge { display: inline-block; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 999px; padding: 0.1rem 0.7rem; font-size: 0.82rem; color: var(--ink-soft); }

/* print: only the invoice sheet */
@media print {
    .no-print, .site-header, .site-footer, .result-actions { display: none !important; }
    main { padding: 0; }
    .invoice-sheet { border: 0; padding: 0; }
    body { font-size: 12pt; }
}
