/* Xebra Invoicing */

@font-face { font-family: "IBM Plex Sans"; font-weight: 400; font-style: normal; font-display: swap; src: url("fonts/IBMPlexSans-400.ttf") format("truetype"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 500; font-style: normal; font-display: swap; src: url("fonts/IBMPlexSans-500.ttf") format("truetype"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 600; font-style: normal; font-display: swap; src: url("fonts/IBMPlexSans-600.ttf") format("truetype"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 700; font-style: normal; font-display: swap; src: url("fonts/IBMPlexSans-700.ttf") format("truetype"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 400; font-style: normal; font-display: swap; src: url("fonts/IBMPlexMono-400.ttf") format("truetype"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 500; font-style: normal; font-display: swap; src: url("fonts/IBMPlexMono-500.ttf") format("truetype"); }

:root {
	--paper: #f4f3ee;
	--surface: #ffffff;
	--surface-2: #faf9f5;
	--ink: #121212;
	--ink-2: #3b3b38;
	--muted: #6d6c66;
	--faint: #a09f97;
	--hair: #dfddd5;
	--hair-2: #c6c4ba;
	--accent: #ff5a1f;
	--accent-ink: #cf420b;
	--ok: #1c7c3a;
	--bad: #c4261b;
	--info: #2757c9;
	--warn: #a86a0f;
	--violet: #6a4fd0;
	--sans: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	--mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace;
	--r: 3px;
	--stripes: repeating-linear-gradient(135deg, #121212 0 1.5px, transparent 1.5px 7px);
	color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 14px/1.5 var(--sans); min-height: 100vh; }
[hidden] { display: none !important; }
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 2px; }
h1, h2, h3 { margin: 0; }
h1 { font-size: 1.7rem; font-weight: 600; letter-spacing: -0.02em; line-height: 1.15; display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap; }
h2 { font: 500 11px/1.3 var(--mono); text-transform: uppercase; letter-spacing: 0.14em; color: var(--ink); }
h2 .muted { text-transform: none; letter-spacing: 0; font-family: var(--sans); font-size: 12.5px; font-weight: 400; }
p { margin: 0.25rem 0 0; }
code { font-family: var(--mono); font-size: 0.86em; background: var(--surface-2); border: 1px solid var(--hair); padding: 0.05em 0.35em; border-radius: 2px; }
.pre { font-family: var(--mono); font-size: 12px; white-space: pre-wrap; word-break: break-word; background: var(--surface-2); border: 1px solid var(--hair); padding: 0.75rem 0.9rem; border-radius: var(--r); text-align: left; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.strong { font-weight: 600; }
.center { text-align: center; }
.danger { color: var(--bad); }
.ok { color: var(--ok); }
.inline { display: inline; }
ul.plain { margin: 0.35rem 0 0; padding-left: 1.2rem; }

/* Brand ribbon: the zebra stripe, top of every page */
.ribbon { height: 6px; background: var(--stripes); }

/* Topbar */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--ink); }
.topbar-inner { max-width: 1200px; margin: 0 auto; padding: 0 1.25rem; height: 56px; display: flex; align-items: stretch; gap: 1.5rem; }
.brand { display: flex; align-items: center; gap: 0.6rem; font: 500 11px var(--mono); letter-spacing: 0.18em; text-transform: uppercase; color: var(--ink); }
.brand img { width: 36px; height: auto; }
.brand:hover { text-decoration: none; }
.nav { display: flex; gap: 0.25rem; flex: 1; }
.nav a { display: inline-flex; align-items: center; padding: 0 0.7rem; font: 500 11.5px var(--mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.nav a:hover { color: var(--ink); text-decoration: none; }
.nav a.active { color: var(--ink); border-bottom-color: var(--accent); }
.topbar-actions { display: flex; align-items: center; gap: 0.6rem; }
.user-link { font: 500 11.5px var(--mono); letter-spacing: 0.08em; color: var(--muted); padding: 0.3rem 0.2rem; border-bottom: 2px solid transparent; }
.user-link:hover, .user-link.active { color: var(--ink); text-decoration: none; }
.user-link.active { border-bottom-color: var(--accent); }

/* Sandbox strip */
.sandbox-bar { background: var(--ink); color: var(--paper); font: 400 12.5px var(--sans); text-align: center; padding: 0.4rem 1rem; }
.sandbox-bar .sb-word { font: 500 11px var(--mono); letter-spacing: 0.16em; text-transform: uppercase; color: var(--accent); margin-right: 0.6rem; }
.sandbox-bar a { color: inherit; text-decoration: underline; text-decoration-color: var(--accent); }
.card-sandbox, .card-live { border-color: var(--hair-2); }
.card-live h2 { color: var(--bad); }
.confirm-word { font-family: var(--mono); letter-spacing: 0.15em; text-transform: uppercase; }

/* Layout */
.container { max-width: 1200px; margin: 0 auto; padding: 1.75rem 1.25rem 4rem; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1.25rem; margin-bottom: 1.1rem; flex-wrap: wrap; padding-bottom: 0.9rem; border-bottom: 1px solid var(--hair-2); }
.page-head .muted { max-width: 70ch; }
.page-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; }
.card { background: var(--surface); border: 1px solid var(--hair); border-radius: var(--r); padding: 1.05rem 1.2rem; margin-bottom: 1rem; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-bottom: 0.85rem; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.grid-2.wide-left { grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr); }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.grid-view { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(300px, 1fr); gap: 1rem; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 0.8rem; }
.stack > .card, .grid-2 > .card, .grid-3 > .card { margin-bottom: 0; }
.empty { color: var(--muted); padding: 0.8rem 0; }

/* Buttons */
.btn {
	display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
	padding: 0.5rem 0.95rem; border-radius: var(--r);
	border: 1px solid var(--ink); background: var(--surface); color: var(--ink);
	font: 500 11.5px/1.2 var(--mono); letter-spacing: 0.08em; text-transform: uppercase;
	cursor: pointer; white-space: nowrap; text-decoration: none;
	transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.btn:hover { background: var(--ink); color: var(--paper); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: var(--ink); color: var(--paper); }
.btn-primary:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-ghost { border-color: transparent; color: var(--muted); background: transparent; }
.btn-ghost:hover { color: var(--ink); background: transparent; border-color: var(--hair-2); }
.btn-danger { border-color: var(--bad); color: var(--bad); }
.btn-danger:hover { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 10.5px; }
.btn-block { width: 100%; }
.btn-icon { background: transparent; border: 0; color: var(--faint); font-size: 1.2rem; line-height: 1; cursor: pointer; padding: 0.3rem 0.45rem; border-radius: var(--r); }
.btn-icon:hover { color: var(--bad); }

/* Forms */
.field { display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; flex: 0 0 auto; }
.field-row > .field { flex: 1 1 0; }
.field > span { font-size: 12px; color: var(--ink-2); font-weight: 500; }
.field > span small { font-weight: 400; color: var(--muted); }
.field-row { display: flex; gap: 0.7rem; }
.field-row .w-30 { flex: 0 0 30%; }
.field-row .w-40 { flex: 0 0 40%; }
input, select, textarea {
	font: inherit; color: var(--ink);
	background: var(--surface); border: 1px solid var(--hair-2); border-radius: var(--r);
	padding: 0.5rem 0.65rem; width: 100%; min-width: 0;
	transition: border-color 0.12s, box-shadow 0.12s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(255, 90, 31, 0.22); }
input::placeholder, textarea::placeholder { color: var(--faint); }
input[type="number"], input[type="date"] { font-family: var(--mono); font-size: 13px; }
textarea { resize: vertical; line-height: 1.45; }
select { appearance: none; -webkit-appearance: none; padding-right: 2rem; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' fill='none' stroke='%23121212' stroke-width='1.6'/></svg>"); background-repeat: no-repeat; background-position: right 0.7rem center; }
.has-error input, .has-error select, .has-error textarea { border-color: var(--bad); }
.field-error { color: var(--bad); font-weight: 500; margin-left: 0.4rem; }
.check { display: inline-flex; align-items: center; gap: 0.45rem; color: var(--ink-2); font-size: 13px; white-space: nowrap; }
.check input { width: auto; accent-color: var(--ink); }
.form-actions { display: flex; justify-content: flex-end; gap: 0.5rem; align-items: center; }
.form-actions.sticky { position: sticky; bottom: 0; z-index: 10; background: rgba(244, 243, 238, 0.94); backdrop-filter: blur(6px); padding: 0.75rem 0; border-top: 1px solid var(--hair-2); }
.filters { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; }
.filters input[type="search"] { flex: 1; min-width: 220px; }
.filters select { width: auto; }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 0.3rem 1.1rem; margin: 0; font-size: 13.5px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; overflow-wrap: anywhere; }
.note-box { margin-top: 0.9rem; padding: 0.65rem 0.85rem; background: var(--surface-2); border-left: 3px solid var(--ink); font-size: 13px; white-space: pre-wrap; }
.label, .note-box .label { font: 500 10.5px var(--mono); text-transform: uppercase; letter-spacing: 0.14em; color: var(--muted); margin-bottom: 0.3rem; }

/* Flash */
.flash { padding: 0.65rem 0.9rem; margin-bottom: 0.9rem; border: 1px solid var(--hair); border-left: 3px solid var(--ink); background: var(--surface); border-radius: var(--r); }
.flash-success { border-left-color: var(--ok); }
.flash-error { border-left-color: var(--bad); }
.flash-warning { border-left-color: var(--accent); }
.flash a { text-decoration: underline; }

/* Tables */
.table-scroll { overflow-x: auto; margin: 0 -1.2rem; padding: 0 1.2rem; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font: 500 10.5px var(--mono); text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); padding: 0.45rem 0.6rem; border-bottom: 1px solid var(--ink); white-space: nowrap; }
.table td { padding: 0.55rem 0.6rem; border-bottom: 1px solid var(--hair); vertical-align: middle; }
.table tbody tr:nth-child(even) td { background: var(--surface-2); }
.table tfoot td { border-top: 1px solid var(--ink); border-bottom: 0; padding-top: 0.6rem; }
.table.compact td, .table.compact th { padding: 0.38rem 0.5rem; }
.table .num, th.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .truncate { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table .actions-col { text-align: right; width: 1%; }
.row-actions { display: inline-flex; gap: 0.3rem; justify-content: flex-end; }
.row-archived td { color: var(--faint); }
.pagination { display: flex; gap: 0.3rem; margin-top: 0.9rem; flex-wrap: wrap; }
.pagination a { padding: 0.25rem 0.6rem; border: 1px solid var(--hair-2); color: var(--muted); font: 500 11px var(--mono); border-radius: var(--r); }
.pagination a.active { background: var(--ink); color: var(--paper); border-color: var(--ink); }

/* Status */
.badge { display: inline-flex; align-items: center; gap: 0.4rem; font: 500 10.5px var(--mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-2); white-space: nowrap; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: 0 0 auto; }
.badge-draft { color: var(--faint); }
.badge-draft::before { background: transparent; box-shadow: inset 0 0 0 1.5px currentColor; }
.badge-issued { color: var(--ink); }
.badge-sent { color: var(--info); }
.badge-paid { color: var(--ok); }
.badge-overdue { color: var(--bad); }
.badge-credited { color: var(--violet); }
.tag { display: inline-block; padding: 0 0.35rem; border: 1px solid var(--hair-2); border-radius: 2px; font: 500 9.5px/1.6 var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); vertical-align: middle; }

/* Ledger strip (dashboard figures) */
.ledger { display: flex; background: var(--surface); border-top: 2px solid var(--ink); border-bottom: 1px solid var(--ink); margin-bottom: 1rem; overflow-x: auto; }
.ledger .cell { flex: 1 1 0; min-width: 150px; padding: 0.9rem 1.1rem 0.8rem; border-right: 1px solid var(--hair); }
.ledger .cell:last-child { border-right: 0; }
.ledger .k { font: 500 10.5px var(--mono); text-transform: uppercase; letter-spacing: 0.14em; color: var(--muted); }
.ledger .v { font: 500 1.55rem/1.1 var(--mono); letter-spacing: -0.02em; margin-top: 0.4rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ledger .s { font-size: 12px; color: var(--muted); margin-top: 0.25rem; }
.ledger .cell.attn .v { color: var(--accent-ink); }
.ledger .cell.bad .v { color: var(--bad); }

/* Range picker */
.range { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.segmented { display: inline-flex; border: 1px solid var(--ink); border-radius: var(--r); overflow: hidden; }
.segmented a { padding: 0.35rem 0.7rem; font: 500 10.5px var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); border-right: 1px solid var(--hair); }
.segmented a:last-child { border-right: 0; }
.segmented a:hover { color: var(--ink); text-decoration: none; }
.segmented a.active { background: var(--ink); color: var(--paper); }
.range-custom { display: flex; align-items: center; gap: 0.4rem; }
.range-custom input { width: 150px; padding: 0.3rem 0.55rem; }

/* Chart */
.chart-wrap { width: 100%; overflow: hidden; }
.chart { width: 100%; height: auto; display: block; }
.chart .bar-group .hit { cursor: crosshair; }
.chart .bar-group:hover .hit { fill: rgba(0, 0, 0, 0.035); }
.legend { display: flex; gap: 1rem; font-size: 12.5px; color: var(--muted); }
.legend-item { display: inline-flex; align-items: center; gap: 0.4rem; }
.swatch { width: 14px; height: 12px; display: inline-block; border: 1px solid var(--ink); }
.swatch-solid { background: var(--ink); }
.swatch-striped { background: repeating-linear-gradient(135deg, #121212 0 1.5px, transparent 1.5px 5px); }
.table-view { margin-top: 0.6rem; }
.table-view summary { cursor: pointer; font-size: 12.5px; }
.tooltip { position: fixed; z-index: 50; pointer-events: none; background: var(--ink); color: var(--paper); padding: 0.4rem 0.6rem; font: 400 12px var(--mono); max-width: 360px; border-radius: 2px; }

/* Invoice editor */
.lines-table th, .lines-table td { padding: 0.3rem 0.3rem; }
.lines-table td { vertical-align: top; }
.lines-table tbody tr:nth-child(even) td { background: transparent; }
.lines-table .col-desc { width: 40%; }
.lines-table .col-qty { width: 9%; }
.lines-table .col-unit { width: 10%; }
.lines-table .col-price { width: 13%; }
.lines-table .col-disc { width: 8%; }
.lines-table .col-vat { width: 9%; }
.lines-table .col-total { width: 11%; }
.lines-table .col-x { width: 1%; }
.lines-table textarea { min-height: 2.3rem; overflow: hidden; }
.lines-table input, .lines-table select { padding: 0.4rem 0.5rem; }
.lines-table input[type="number"] { text-align: right; }
.lines-table .line-total { padding-top: 0.8rem; }
.lines-foot { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-top: 0.8rem; flex-wrap: wrap; }
.totals-preview { border-collapse: collapse; min-width: 280px; font-size: 13.5px; }
.totals-preview td { padding: 0.28rem 0.55rem; }
.totals-preview td.k { color: var(--muted); }
.totals-preview td.v { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.totals-preview tr.grand td { border-top: 1px solid var(--ink); font-weight: 600; font-size: 15px; padding-top: 0.45rem; }
.totals-preview tr.grand td.v { font-weight: 500; }

/* Invoice view */
.preview-card { padding: 0; overflow: hidden; background: #e6e4dc; }
.pdf-preview { width: 100%; height: min(82vh, 1180px); border: 0; display: block; background: #e6e4dc; }
.dropdown { position: relative; display: inline-block; }
.dropdown summary { list-style: none; }
.dropdown summary::-webkit-details-marker { display: none; }
.dropdown-panel { position: absolute; right: 0; top: calc(100% + 6px); z-index: 15; background: var(--surface); border: 1px solid var(--ink); border-radius: var(--r); padding: 0.85rem; min-width: 260px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12); text-align: left; }
.timeline { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.timeline li { display: flex; gap: 0.5rem; flex-wrap: wrap; padding: 0.3rem 0; border-bottom: 1px solid var(--hair); }
.timeline li:last-child { border-bottom: 0; }
.timeline .when { font: 400 12px var(--mono); color: var(--faint); white-space: nowrap; }
.timeline .what { font-weight: 500; }

/* Dialog */
.dialog { background: var(--surface); color: var(--ink); border: 1px solid var(--ink); border-radius: var(--r); padding: 1.3rem 1.4rem; max-width: 440px; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.18); }
.dialog::backdrop { background: rgba(18, 18, 18, 0.4); }
.dialog p { margin: 0 0 1rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 0.5rem; }

/* Login and other bare pages */
body.bare { display: grid; grid-template-rows: auto 1fr; overflow-x: hidden; }
.bare-main { width: 100%; }
.auth-wrap { display: grid; place-items: center; min-height: calc(100vh - 6px); padding: 2rem 1rem; }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--ink); border-radius: var(--r); padding: 1.75rem 1.75rem 1.5rem; }
.auth-card.wide { max-width: 560px; }
.auth-logo { display: block; width: 120px; height: auto; margin: 0 0 1rem; }
.auth-title { text-align: left; font: 500 11px var(--mono); letter-spacing: 0.24em; text-transform: uppercase; color: var(--ink); margin-bottom: 1.25rem; padding-bottom: 0.9rem; border-bottom: 1px solid var(--ink); }
.auth-card .center { text-align: left; }
.auth-card .flash { margin-bottom: 1rem; }
.error-page { text-align: center; padding: 4rem 1rem; }
.error-code { font: 500 4rem/1 var(--mono); color: var(--hair-2); }
.error-page h1 { justify-content: center; margin: 0.5rem 0 1rem; }
.error-page .pre { text-align: left; margin: 0 auto 1.5rem; max-width: 800px; }

/* Responsive */
@media (max-width: 1024px) {
	.grid-3 { grid-template-columns: 1fr; }
	.grid-view { grid-template-columns: 1fr; }
	.grid-2.wide-left { grid-template-columns: 1fr; }
	.pdf-preview { height: 70vh; }
}
@media (max-width: 800px) {
	.topbar-inner { height: auto; flex-wrap: wrap; padding: 0.5rem 1rem; gap: 0.5rem; align-items: center; }
	.nav { order: 3; width: 100%; overflow-x: auto; }
	.nav a { padding: 0.6rem 0.6rem; }
	.topbar-actions { margin-left: auto; }
	.grid-2 { grid-template-columns: 1fr; }
	.field-row { flex-direction: column; gap: 0.8rem; }
	.field-row .w-30, .field-row .w-40 { flex: 1; }
	.container { padding: 1.1rem 1rem 3rem; }
	.lines-table { min-width: 760px; }
	.ledger { flex-wrap: wrap; }
	.ledger .cell { flex: 1 1 45%; border-bottom: 1px solid var(--hair); }
}
