:root {
    --text: #1d1d1f;
    --muted: #5f6368;
    --border: #d7d7db;
    --accent: #1f5fbf;
    --error: #b3261e;
    --bg: #ffffff;
    --success: #1e7a34;
    --accent-soft: #e8f0fb;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--text);
    background: var(--bg);
}

body { margin: 0; line-height: 1.5; overflow-wrap: break-word; }
.site-header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0.25rem 1rem; padding: 0.5rem 1.25rem; border-bottom: 1px solid var(--border); }
.site-header nav { display: flex; flex-wrap: wrap; gap: 0 0.25rem; align-items: center; }
.site-header nav a, .site-header nav .link { display: inline-flex; align-items: center; min-height: 2.75rem; padding: 0 0.6rem; }
.brand { font-weight: 600; color: var(--text); text-decoration: none; min-height: 2.75rem; display: inline-flex; align-items: center; }
.container { max-width: 56rem; margin: 0 auto; padding: 1.25rem; }
h1 { line-height: 1.25; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
a { color: var(--accent); }
.form { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.4rem; max-width: 28rem; }
.form label { margin-top: 0.5rem; font-weight: 500; }
.form input, .form select, .form textarea { font: inherit; padding: 0.5rem; border: 1px solid var(--border); border-radius: 4px; max-width: 100%; box-sizing: border-box; }
/* min-width: 0 lets a fieldset shrink below its widest option on narrow screens (D065). */
fieldset { border: 1px solid var(--border); border-radius: 4px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.4rem; margin-top: 1rem; min-width: 0; }
.checkbox { display: flex; gap: 0.5rem; align-items: center; font-weight: 400; }
.button { display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box; min-height: 2.75rem; margin-top: 1rem; padding: 0.55rem 1rem; border: 1px solid var(--accent); border-radius: 4px; background: var(--accent); color: #fff; font: inherit; text-decoration: none; cursor: pointer; }
.button.secondary { background: transparent; color: var(--accent); }
/* Destructive actions (D065): an outlined button that opens a confirmation page, and the filled button on that page. */
.button.danger-outline { background: transparent; color: var(--error); border-color: var(--error); margin-top: 0; }
.button.danger { background: var(--error); border-color: var(--error); color: #fff; }
.link { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; text-decoration: underline; }
.inline { display: inline; }
.notice { padding: 0.75rem; border: 1px solid var(--border); border-radius: 4px; }
.errors { color: var(--error); border: 1px solid var(--error); border-radius: 4px; padding: 0 0.75rem; }
.filters { display: flex; flex-wrap: wrap; gap: 0 0.25rem; margin-bottom: 1rem; }
.filters a { display: inline-flex; align-items: center; min-height: 2.75rem; padding: 0 0.5rem; }
.filters [aria-current="page"] { font-weight: 600; text-decoration: none; color: var(--text); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.5rem; border-bottom: 1px solid var(--border); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.hero { padding: 3rem 0; }
small { color: var(--muted); font-weight: 400; }
.pagination { display: flex; gap: 1rem; margin-top: 1rem; }
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 1rem; }
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.actions .button, .actions form .button { margin-top: 0; }
.notice.error { color: var(--error); border-color: var(--error); }
.form.wide { max-width: none; }
.grid { display: grid; gap: 0.75rem; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); }
.grid label, .line-item label { display: block; font-weight: 500; }
.grid input, .grid select { width: 100%; box-sizing: border-box; }
.line-item { border-bottom: 1px solid var(--border); padding: 0.5rem 0; display: grid; gap: 0.4rem; }
.line-main { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: flex-end; }
.line-main .grow { flex: 1 1 16rem; }
.line-main .grow input { width: 100%; box-sizing: border-box; }
.line-taxes { display: grid; gap: 0.3rem; padding-left: 1rem; }
.row-pair { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.label { display: block; font-size: 0.85em; color: var(--muted); }
.totals { display: grid; grid-template-columns: auto auto; justify-content: end; gap: 0.25rem 1.5rem; margin: 1rem 0; }
.totals dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.details { display: grid; grid-template-columns: max-content auto; gap: 0.25rem 1rem; }
.details dt { color: var(--muted); }
.details dd { margin: 0; }
.multiline { white-space: pre-line; }
.parties { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); margin-bottom: 1rem; }
.parties h2 { font-size: 1rem; color: var(--muted); margin-bottom: 0.25rem; }
/* Invoice statuses (D065): each differs in border style or fill, not only in colour, and always shows its name. */
.status { display: inline-block; font-size: 0.8rem; font-weight: 600; line-height: 1.3; padding: 0.1rem 0.5rem; border-radius: 999px; border: 1px solid var(--border); vertical-align: middle; white-space: nowrap; }
.status-draft { color: var(--muted); border-style: dashed; border-color: var(--muted); }
.status-issued { color: var(--accent); border-color: var(--accent); }
.status-sent { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.status-paid { color: #fff; border-color: var(--success); background: var(--success); }
.status-overdue { color: var(--error); border: 2px solid var(--error); }
.status-void { color: var(--muted); border-style: dotted; border-color: var(--muted); text-decoration: line-through; }
.is-void .num { color: var(--muted); }
.is-void .amount { text-decoration: line-through; }
.search { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.search input { flex: 1; min-width: 0; font: inherit; padding: 0.5rem; border: 1px solid var(--border); border-radius: 4px; }
.search .button { margin-top: 0; }
.danger-zone { margin-top: 2.5rem; padding-top: 1rem; border-top: 1px solid var(--border); display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }
.confirm { max-width: 36rem; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.logo-preview { max-height: 5rem; max-width: 16rem; border: 1px solid var(--border); padding: 0.25rem; }

/* Plan status and pricing (D055) */
.plan-banner { margin: 0 0 1rem; padding: 0.6rem 0.75rem; border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: 4px; }
.plan-banner.warning { border-left-color: var(--error); }
.plans { display: flex; flex-wrap: wrap; gap: 1rem; margin: 1rem 0; }
.plan { flex: 1 1 14rem; padding: 1rem; border: 1px solid var(--border); border-radius: 4px; }
.plan .price { font-size: 1.4rem; margin: 0.25rem 0; }
.button[disabled] { opacity: 0.5; cursor: not-allowed; }

/* Admin two-factor pages (D062). */
.break { word-break: break-all; }
.recovery-codes { columns: 2; list-style: none; padding: 0; font-size: 1.1rem; }

/* Narrow screens (D065): nothing makes the page scroll sideways. Tables turn
   each row into a block of labelled values (td data-label), so no column is
   cut off; form rows stack. */
@media (max-width: 40rem) {
    .container { padding: 1rem; }
    .site-header { padding: 0.25rem 1rem; }
    .site-header nav { margin-left: -0.6rem; }
    table.responsive thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    table.responsive, table.responsive tbody, table.responsive tr, table.responsive td { display: block; width: auto; }
    table.responsive tr { padding: 0.5rem 0; border-bottom: 1px solid var(--border); }
    table.responsive td { display: grid; grid-template-columns: 7.5rem minmax(0, 1fr); justify-items: start; gap: 0.75rem; padding: 0.2rem 0; border: 0; text-align: left; }
    table.responsive td::before { content: attr(data-label); color: var(--muted); }
    table.responsive td.num { text-align: left; }
    .line-main > div { flex: 1 1 100%; }
    .line-main input { width: 100%; box-sizing: border-box; }
    .line-taxes { padding-left: 0; }
    .row-pair input { flex: 1 1 8rem; min-width: 0; }
    .row-pair .num { flex: 1 1 100%; text-align: right; }
    .details { grid-template-columns: minmax(0, 1fr); gap: 0; }
    .details dd { margin-bottom: 0.4rem; }
    .actions .button, .actions form { flex: 1 1 auto; }
    .actions form .button { width: 100%; }
}
