:root {
  --bg: #edf1f8; --card: #fff; --text: #19273e; --muted: #526078; --line: #dce3ef;
  --primary: #284da3; --primary-text: #fff; --danger: #a4262c; --ok: #1b6e3a; --warn: #8a5300;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--primary); }
.topbar { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; justify-content: space-between; padding: .75rem 1rem; background: #172842; color: var(--primary-text); }
.topbar a, .topbar .link { color: var(--primary-text); text-decoration: none; }
.topbar nav { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; font-size: .95rem; }
.brand { font-weight: 700; font-size: 1.15rem; }
.container { max-width: 720px; margin: 0 auto; padding: 1rem; }
.container-wide { max-width: 1400px; margin: 0 auto; padding: 1rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 1rem; margin-bottom: 1rem; }
.narrow { max-width: 420px; margin: 2rem auto; }
h1 { font-size: 1.4rem; margin: 0 0 1rem; } h2 { font-size: 1.15rem; }
label { display: block; font-weight: 600; margin: .75rem 0 .25rem; }
input, select, textarea { width: 100%; padding: .6rem .7rem; font: inherit; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
input[type=checkbox] { width: auto; }
button, .button-like { display: inline-block; padding: .7rem 1rem; font: inherit; font-weight: 600; border-radius: 10px; border: 1px solid var(--primary); cursor: pointer; text-align: center; text-decoration: none; }
.primary { background: var(--primary); color: var(--primary-text); }
.secondary { background: #fff; color: var(--primary); }
.danger { background: #fff; color: var(--danger); border-color: var(--danger); }
.link { background: none; border: 0; padding: 0; font-weight: 400; }
.wide { display: block; width: 100%; margin: .5rem 0; font-size: 1.1rem; padding: 1rem; }
.inline { display: inline; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.preview img { max-width: 100%; max-height: 50vh; display: block; margin: .5rem auto; border-radius: 8px; }
.messages { list-style: none; padding: 0; margin: 0 0 1rem; }
.msg { padding: .7rem 1rem; border-radius: 8px; margin-bottom: .5rem; background: #e8f0f8; }
.msg-success { background: #e3f3e8; color: var(--ok); } .msg-error { background: #fbe9ea; color: var(--danger); }
.error, .errorlist { color: var(--danger); }
.muted { color: var(--muted); }
.doc-list { list-style: none; padding: 0; margin: 0; }
.doc-row { display: flex; gap: .75rem; align-items: center; padding: .6rem; background: var(--card); border: 1px solid var(--line); border-radius: 10px; margin-bottom: .5rem; color: inherit; text-decoration: none; }
.thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; background: var(--line); flex: none; }
.doc-meta { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.doc-meta strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.amount { font-weight: 700; white-space: nowrap; }
.status { display: inline-block; font-size: .8rem; padding: .1rem .5rem; border-radius: 999px; background: #e8edf2; }
.status-ready_for_review { background: #fff1d6; color: var(--warn); }
.status-reviewed, .status-exported { background: #e3f3e8; color: var(--ok); }
.status-failed { background: #fbe9ea; color: var(--danger); }
.photo { max-width: 100%; border-radius: 8px; display: block; margin: .5rem 0; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: .25rem 1rem; }
.facts dt { color: var(--muted); } .facts dd { margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }
.pagination { display: flex; gap: 1rem; justify-content: center; margin: 1rem 0; }
table { width: 100%; border-collapse: collapse; background: var(--card); }
th, td { padding: .5rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { font-size: .85rem; color: var(--muted); }
td.num { text-align: right; white-space: nowrap; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .5rem 1rem; align-items: end; }
.filters label { margin: 0 0 .25rem; }
.review { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; }
.review .photo-pane img { width: 100%; border-radius: 8px; }
.review .photo-pane { position: sticky; top: 1rem; align-self: start; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 1rem; }
.field-warning { color: var(--warn); font-size: .85rem; }
.warnings { background: #fff7e6; border: 1px solid #f0d199; border-radius: 8px; padding: .5rem 1rem; }
.vat-table input { min-width: 6rem; }
pre.ocr { white-space: pre-wrap; background: #f7f7f7; padding: .75rem; border-radius: 8px; font-size: .85rem; }
@media (max-width: 900px) { .review { grid-template-columns: 1fr; } .review .photo-pane { position: static; } }
.month-nav { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.month-nav h1 { margin: 0; text-align: center; }
.month-nav a { font-size: 1.6rem; text-decoration: none; padding: .25rem .75rem; }
.day h2 { display: flex; justify-content: space-between; margin: 1.25rem 0 .5rem; }
.day .hours { color: var(--muted); font-weight: 600; }
.doc-meta small { overflow-wrap: anywhere; }

.billing-table { overflow-x: auto; margin-top: 1rem; }
.billing-table table { width: 100%; border-collapse: collapse; }
.billing-table th, .billing-table td {
  padding: .65rem .8rem;
  border-bottom: 1px solid #dce3eb;
  text-align: left;
  white-space: nowrap;
}
.billing-table th { background: #edf3f8; }
.billing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 19rem), 1fr));
  gap: 1rem 2rem;
  margin-top: 1rem;
}

.billing-page { width: 100%; margin: 0 auto; padding: 1rem clamp(1rem, 2.5vw, 3rem); }
.billing-editor td { vertical-align: top; }
.billing-editor td:first-child input { min-width: 16rem; }
.billing-editor input[type="number"] { min-width: 6rem; }
.billing-editor select { min-width: 5rem; }
.billing-editor input[type="checkbox"] { width: auto; }

/* Shared navigation and action controls */
.topbar { padding-inline: clamp(1rem, 4vw, 3rem); }
.topbar nav { gap: .25rem; }
.topbar nav a, .topbar nav button { display: inline-block; padding: .5rem .65rem; border-radius: 8px; }
.topbar nav [aria-current], .topbar nav a:hover, .topbar nav button:hover {
  background: #e4edff; color: #284da3;
}
.nav-toggle { background: transparent; color: white; border-color: #91a3bf; }
.nav-toggle[hidden], .topbar nav[hidden] { display: none; }
:focus-visible { outline: 2px solid #597ed2; outline-offset: 3px; }
.topbar :focus-visible { outline-color: #b6cdff; }
h1 { font-size: clamp(1.6rem, 3vw, 2.45rem); letter-spacing: -.035em; }
th, .billing-table th { background: #edf1f8; }
.secondary { background: #f6f8ff; border-color: #b8c9ea; }
.action-icon {
  display: inline-block; inline-size: 1.25rem; block-size: 1.25rem;
  vertical-align: -.25rem; margin-inline-end: .3rem;
  background: currentColor; mask: var(--action-icon) center / contain no-repeat;
}
.invoice-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; }
.invoice-heading h1, .invoice-heading .actions { margin: 0; }
.invoice-overview .num { text-align: right; font-variant-numeric: tabular-nums; }
.invoice-overview td:nth-child(3), .invoice-overview td:nth-child(4) { white-space: normal; overflow-wrap: anywhere; }
@media (max-width: 850px) {
  .topbar nav { width: 100%; }
  .invoice-overview table, .invoice-overview tbody { display: block; }
  .invoice-overview thead { position: absolute; clip-path: inset(50%); width: 1px; height: 1px; overflow: hidden; }
  .invoice-overview tbody tr { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .3rem .8rem; padding: .85rem; border-bottom: 1px solid var(--line); }
  .invoice-overview td { display: block; border: 0; padding: .15rem; white-space: normal; }
  .invoice-overview td[data-label]::before { content: attr(data-label); display: block; color: var(--muted); font-size: .75rem; }
  .invoice-overview td:nth-child(3), .invoice-overview td[colspan] { grid-column: 1/-1; }
  .invoice-overview .num { text-align: left; }
}
@media print { .topbar { display: none; } }
.icon-plus { --action-icon: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M12%205v14M5%2012h14%22%2F%3E%3C%2Fsvg%3E"); }
.icon-menu { --action-icon: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M4%206h16M4%2012h16M4%2018h16%22%2F%3E%3C%2Fsvg%3E"); }
.icon-edit { --action-icon: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22m4%2016%2012-12%204%204L8%2020H4v-4ZM14%206l4%204%22%2F%3E%3C%2Fsvg%3E"); }
.icon-download { --action-icon: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M12%203v12m-5-5%205%205%205-5M4%2016v5h16v-5%22%2F%3E%3C%2Fsvg%3E"); }
.icon-save { --action-icon: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M4%204h13l3%203v13H4zM8%204v6h8V4M8%2020v-6h8v6%22%2F%3E%3C%2Fsvg%3E"); }
.icon-trash { --action-icon: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M3%206h18M9%206V3h6v3M6%206l1%2015h10l1-15M10%2010v7m4-7v7%22%2F%3E%3C%2Fsvg%3E"); }
.icon-eye { --action-icon: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M2%2012s4-6%2010-6%2010%206%2010%206-4%206-10%206-10-6-10-6Zm13%200a3%203%200%201%201-6%200%203%203%200%200%201%206%200Z%22%2F%3E%3C%2Fsvg%3E"); }
.icon-exit { --action-icon: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M10%204H4v16h6m4-12%204%204-4%204m-6-4h12%22%2F%3E%3C%2Fsvg%3E"); }
.icon-upload { --action-icon: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M12%2016V4m-5%205%205-5%205%205M4%2016v5h16v-5%22%2F%3E%3C%2Fsvg%3E"); }
.icon-camera { --action-icon: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M3%207h4l2-3h6l2%203h4v13H3zM15%2013a3%203%200%201%201-6%200%203%203%200%200%201%206%200Z%22%2F%3E%3C%2Fsvg%3E"); }
.icon-back { --action-icon: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M19%2012H5m6-6-6%206%206%206%22%2F%3E%3C%2Fsvg%3E"); }
.icon-print { --action-icon: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M6%208V3h12v5M6%2017H3V8h18v9h-3M6%2014h12v7H6z%22%2F%3E%3C%2Fsvg%3E"); }
.icon-refresh { --action-icon: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M20%207v5h-5M4%2017v-5h5M5%208a8%208%200%200%201%2013-2l2%206M4%2012l2%206a8%208%200%200%200%2013-2%22%2F%3E%3C%2Fsvg%3E"); }
.icon-filter { --action-icon: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M3%204h18l-7%208v6l-4%202v-8z%22%2F%3E%3C%2Fsvg%3E"); }

.workspace-detail[hidden] { display: none; }
.workspace-split {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 1.25rem;
  padding: 1rem clamp(1rem, 3vw, 3rem);
  align-items: start;
}
.workspace-split > main { min-width: 0; width: 100%; max-width: none; margin: 0; padding: 0; }
.workspace-detail {
  min-width: 0;
  position: sticky;
  top: 1rem;
  max-height: calc(100dvh - 2rem);
  overflow: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.workspace-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: .5rem;
  padding: .75rem;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.workspace-content { padding: 1rem; overflow-wrap: anywhere; }
.workspace-status:not(:empty) { padding: 1rem; }
.workspace-content .review { grid-template-columns: minmax(0, 1fr); }
.workspace-content .review .photo-pane { position: static; }
.workspace-content img { max-width: 100%; }
[data-workspace-detail][aria-current] { background: #e4edff; outline: 2px solid var(--primary); }
@media print { .workspace-detail { display: none; } .workspace-split { display: block; } }
.workspace-split > main .table-wrap,
.workspace-split > main .billing-table { max-width: 100%; overflow-x: auto; }
.workspace-content .facts { grid-template-columns: minmax(0, max-content) minmax(0, 1fr); }

.invoice-description {
  white-space: normal;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}
.invoice-overview-action .action-icon { margin-inline-end: .35rem; }
.workspace-content .invoice-back { display: none; }
.workspace-content .invoice-detail-title { font-size: 1.5rem; margin-top: 0; }
.facts[hidden] { display: none; }

@media screen and (min-width: 1050px) {
  .workspace-split .invoice-overview { padding: 0; }
  .workspace-split .invoice-overview table { table-layout: fixed; }
  .workspace-split .invoice-overview-extra { display: none; }
  .workspace-split .invoice-overview th,
  .workspace-split .invoice-overview td { padding: .55rem .4rem; }
  .workspace-split .invoice-overview th:first-child,
  .workspace-split .invoice-overview td:first-child { padding-inline-start: .75rem; }
  .workspace-split .invoice-overview th:nth-child(2) { width: 5.2rem; }
  .workspace-split .invoice-overview th.invoice-overview-customer { width: 30%; }
  .workspace-split .invoice-overview-customer span {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .workspace-split .invoice-overview th:nth-child(8) { width: 25%; text-align: right; }
  .workspace-split .invoice-overview-action { width: 3.25rem; text-align: center; }
  .workspace-split .invoice-overview td:first-child,
  .workspace-split .invoice-overview .num { white-space: normal; overflow-wrap: anywhere; }
  .workspace-split .invoice-overview tr:has([aria-current]) { background: #edf3ff; }
  .workspace-split .invoice-overview-action a { padding: .45rem; }
  .workspace-split .invoice-overview-action .action-icon { margin: 0; }
  .workspace-split .invoice-action-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
}

.upload-pages { list-style: none; padding: 0; }
.upload-pages:empty { display: none; }
.upload-pages li {
  display: grid;
  grid-template-columns: 3rem 1fr auto;
  align-items: center;
  gap: .75rem;
  padding: .5rem 0;
  border-bottom: 1px solid var(--line);
}
.upload-pages img { width: 3rem; height: 3rem; object-fit: cover; border-radius: 4px; }
