:root {
  --ink: #1b2430;
  --muted: #667085;
  --line: #e4e7ec;
  --bg: #f6f7f9;
  --card: #ffffff;
  --accent: #1f3a5f;
  --accent-ink: #ffffff;
  --orange: #e8730c;
  --orange-bg: #fff1e3;
  --green: #1a7f4b;
  --green-bg: #e6f5ec;
  --red: #b42318;
  --amber-bg: #fff7e0;
  --amber: #8a6100;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--accent); }
h1 { font-size: 1.6rem; margin: .4rem 0; }
h2 { font-size: 1.2rem; margin: 0; }
h3 { font-size: 1rem; margin: 1.2rem 0 .4rem; }
h4 { font-size: .9rem; margin: .8rem 0 .3rem; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, "SF Mono", Consolas, monospace; }
.big { font-size: 1.3rem; margin: .2rem 0 1rem; }
.error { color: var(--red); }
.warn { color: var(--amber); background: var(--amber-bg); padding: .5rem .7rem; border-radius: 6px; }

.topbar { display: flex; align-items: center; justify-content: space-between; padding: .7rem 1.5rem; background: var(--card); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: .7rem; text-decoration: none; color: var(--ink); font-weight: 600; }
.brand-logo { height: 36px; max-width: 160px; object-fit: contain; }
.topbar nav a { text-decoration: none; color: var(--muted); }
.landing .topbar { display: none; }

.hero { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; text-align: center; padding: 2rem; }
.hero-logo { max-height: 140px; max-width: 360px; object-fit: contain; margin-bottom: 1.2rem; }
.hero h1 { font-size: 2.4rem; }
.tagline { color: var(--muted); font-size: 1.15rem; margin: .3rem 0 2rem; }
.lang-switch { margin-top: 2rem; display: flex; gap: 1rem; }
.lang-switch a { color: var(--muted); text-decoration: none; }
.lang-switch a.active { color: var(--accent); font-weight: 600; text-decoration: underline; }
.landing .hero + * { display: none; }

.page { max-width: 960px; margin: 0 auto; padding: 1.5rem; }
.page.narrow { max-width: 560px; }
.page.wide { max-width: 1400px; }

.button { display: inline-block; border: 0; border-radius: 8px; background: var(--accent); color: var(--accent-ink); padding: .6rem 1.1rem; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.button:hover { filter: brightness(1.15); }
.button-large { padding: .9rem 2rem; font-size: 1.15rem; }
.button-secondary { background: #e9edf2; color: var(--ink); }
.link { background: none; border: 0; color: var(--accent); text-decoration: underline; cursor: pointer; font: inherit; padding: 0; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 1.2rem; margin-top: 1rem; }
.form { display: flex; flex-direction: column; gap: 1rem; }
.form label, .field { display: flex; flex-direction: column; gap: .3rem; font-weight: 600; }
.form input, .form select, .field input, .field textarea { font: inherit; font-weight: 400; padding: .5rem .6rem; border: 1px solid #cfd4dc; border-radius: 8px; }
.form small { font-weight: 400; }
.brand-preview { background: var(--bg); border: 1px dashed #cfd4dc; border-radius: 8px; padding: 1rem; text-align: center; }
.brand-preview img { max-height: 80px; max-width: 100%; }
.notice { background: var(--green-bg); color: var(--green); padding: .5rem .8rem; border-radius: 8px; }

.invoice-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; margin-top: 1.2rem; }
.invoice-card { display: block; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 1.1rem; text-decoration: none; color: var(--ink); }
.invoice-card:hover { border-color: var(--accent); box-shadow: 0 2px 10px rgba(31, 58, 95, .12); }
.invoice-number { font-family: ui-monospace, Consolas, monospace; color: var(--muted); font-size: .85rem; }
.invoice-customer { font-weight: 600; font-size: 1.1rem; }
.invoice-meta { display: flex; justify-content: space-between; margin-top: .9rem; font-size: .9rem; color: var(--muted); }
.invoice-meta strong { color: var(--ink); }

.declaration-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.head-meta { padding-top: .8rem; white-space: nowrap; }
.table-wrap { background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow-x: auto; margin-top: 1rem; }
table.lines { width: 100%; border-collapse: collapse; }
table.lines th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: .7rem .8rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.lines td { padding: .7rem .8rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.lines tr:last-child td { border-bottom: 0; }
.num { text-align: right; white-space: nowrap; }
th.num { text-align: right; }
.center { text-align: center; }
.item-text { cursor: pointer; }
.item-text:hover { color: var(--accent); text-decoration: underline dotted; }
.item-extra { font-size: .85rem; color: var(--muted); font-style: italic; margin-top: .2rem; }
.code { background: none; border: 0; padding: 0; font: inherit; font-family: ui-monospace, Consolas, monospace; font-weight: 700; color: var(--accent); cursor: pointer; text-decoration: underline dotted; }
.code-desc { font-size: .85rem; color: var(--muted); margin-top: .15rem; max-width: 380px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--green); cursor: pointer; margin-top: .2rem; }

.conf { border: 0; border-radius: 999px; padding: .15rem .6rem; font: inherit; font-weight: 600; font-size: .9rem; cursor: pointer; }
.conf-high { background: var(--green-bg); color: var(--green); }
.conf-low { background: var(--amber-bg); color: var(--amber); }
.chip { display: inline-block; border: 0; border-radius: 999px; padding: .15rem .65rem; font: inherit; font-size: .82rem; font-weight: 600; margin: 0 .25rem .25rem 0; }
.chip-flag { background: var(--orange-bg); color: var(--orange); border: 1px solid var(--orange); cursor: pointer; }
.chip-flag:hover { background: var(--orange); color: #fff; }
.chip-manual { background: #e9edf2; color: var(--ink); }
.chip-muted { background: #eef0f3; color: var(--muted); }

.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid #cfd4dc; border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }

.declaration-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 1rem; }
.footnote { font-size: .85rem; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(16, 24, 40, .5); display: flex; align-items: center; justify-content: center; padding: 1rem; z-index: 10; }
.modal-backdrop[hidden] { display: none; }
.modal { background: var(--card); border-radius: 14px; width: min(720px, 100%); max-height: 88vh; display: flex; flex-direction: column; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.3rem; border-bottom: 1px solid var(--line); }
.modal-close { background: none; border: 0; font-size: 1.8rem; line-height: 1; cursor: pointer; color: var(--muted); }
.modal-body { padding: 1.1rem 1.3rem 1.4rem; overflow-y: auto; }
.modal-body pre { white-space: pre-wrap; font: inherit; background: var(--bg); padding: .8rem; border-radius: 8px; }
.kv { border-collapse: collapse; width: 100%; }
.kv th, .kv td { text-align: left; padding: .35rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.kv th { width: 34%; text-transform: capitalize; font-weight: 600; color: var(--muted); }
.path { list-style: none; padding: 0; margin: 0; }
.path li { padding: .15rem 0; }
.flag-block { border-left: 4px solid var(--orange); padding-left: .9rem; margin-top: 1rem; }
.flag-block h3 { margin-top: 0; color: var(--orange); }
.alt { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; padding: .8rem 0; border-bottom: 1px solid var(--line); }
.inline { display: flex; gap: .6rem; }
.inline input { flex: 1; }
.actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1rem; }

@media (max-width: 700px) {
  .hero h1 { font-size: 1.8rem; }
  .declaration-head { flex-direction: column; }
}
