:root { --ink: #1f2430; --muted: #6b7280; --line: #e3e0ee; --bg: #f6f5fa; --accent: #6538c7; --accent-soft: #f3effc; --danger: #b42318; }
* { 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: 24px; margin: 0 0 16px; }
h2 { font-size: 17px; margin: 32px 0 8px; }

.top { display: flex; align-items: center; gap: 20px; padding: 12px 24px; background: #fff; border-bottom: 1px solid var(--line); }
.top .brand { font-weight: 700; color: var(--ink); text-decoration: none; }
.top nav { display: flex; gap: 16px; flex: 1; }
.top nav a { color: var(--ink); text-decoration: none; }
.top nav a:hover { color: var(--accent); }
main { max-width: 1040px; margin: 0 auto; padding: 24px; }
main.narrow { max-width: 420px; padding-top: 12vh; }

.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row form { margin: 0; }
.grow { flex: 1; }
.stack > * + * { margin-top: 16px; }
.card { display: block; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 18px; margin-bottom: 12px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.grid .wide { grid-column: 1 / -1; }
details.card > summary { cursor: pointer; }
details.card[open] > summary { margin-bottom: 14px; }
details.card > .card { border: 0; padding: 0; margin: 0; }

label { display: block; font-size: 13px; color: var(--muted); }
label.check { display: flex; align-items: center; gap: 8px; align-self: end; color: var(--ink); }
label small, .muted { color: var(--muted); font-size: 13px; }
label small { display: block; margin-top: 3px; }
input, select, textarea { display: block; width: 100%; margin-top: 4px; padding: 8px 10px; font: inherit; color: var(--ink); background: #fff; border: 1px solid #cfcbdd; border-radius: 7px; }
input[type=checkbox] { width: auto; margin: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.row label input, .row select, .row input { width: auto; }
.filters { margin-bottom: 14px; }
.filters select { margin: 0; }

.btn { display: inline-block; padding: 8px 14px; font: inherit; font-weight: 500; color: var(--ink); background: #fff; border: 1px solid #cfcbdd; border-radius: 7px; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger, .link.danger { color: var(--danger); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--muted); cursor: pointer; }
.link:hover { color: var(--ink); }

table.list, table.items { width: 100%; border-collapse: collapse; }
table.list { background: #fff; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
table.list th, table.list td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--line); }
table.list tr:last-child td { border-bottom: 0; }
th { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
table.items th, table.items td { padding: 4px 6px; vertical-align: top; }
table.items td:first-child { width: 42%; }
table.items input { margin-top: 0; }
table.items textarea { margin-top: 4px; font-size: 13px; }
table.items .amount { padding-top: 12px; white-space: nowrap; }
.totals { text-align: right; font-variant-numeric: tabular-nums; }
.totals b { font-size: 18px; }

.pill { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; vertical-align: middle; background: #eceaf3; color: #4b5563; }
.pill.issued { background: #e6effd; color: #1d4ed8; }
.pill.paid { background: #e3f5e9; color: #18794e; }
.pill.overdue { background: #fde8e6; color: var(--danger); }
.pill.cancelled { text-decoration: line-through; }
.stat { text-align: right; font-weight: 600; font-size: 18px; }
.stat small { display: block; font-weight: 400; font-size: 12px; color: var(--muted); }

.alert { padding: 10px 14px; border-radius: 8px; background: #fde8e6; color: var(--danger); }
.alert.soft { background: var(--accent-soft); color: var(--ink); }
.alert.ok { background: #e3f5e9; color: #18794e; }
.empty { padding: 40px; text-align: center; color: var(--muted); background: #fff; border: 1px dashed #cfcbdd; border-radius: 10px; }
.preview { width: 100%; height: 1220px; border: 1px solid var(--line); border-radius: 10px; margin-top: 16px; background: #eceaf3; }

.alert.warn { background: #fff6e0; color: #7a4b00; }
.alert ul { margin: 4px 0 0; padding-left: 20px; }
.row.end { justify-content: flex-end; flex-wrap: nowrap; }
.summary { margin-bottom: 10px; }
.filters input[type=search] { min-width: 200px; margin: 0; }
.filters input { margin: 0; }
a.quiet { color: inherit; text-decoration: none; }
a.quiet:hover { color: var(--accent); text-decoration: underline; }
.link.accent { color: var(--accent); }
.email .tabs { margin-bottom: 10px; gap: 18px; }
.email label + label, .email .row { margin-top: 12px; }
.email textarea { font-size: 14px; }

/* Invoice form: the draft on the left, the page it will print as on the right. */
main.wide { max-width: 1500px; }
.split { display: grid; grid-template-columns: minmax(560px, 1fr) minmax(360px, 620px); gap: 24px; align-items: start; }
.live { position: sticky; top: 16px; }
.page-frame { margin-top: 8px; overflow: hidden; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 4px 18px rgba(31, 36, 48, .08); }
.page-frame iframe { display: block; width: 794px; height: 1123px; border: 0; transform-origin: 0 0; pointer-events: none; }
dialog { width: min(680px, 94vw); padding: 22px; border: 1px solid var(--line); border-radius: 12px; }
dialog::backdrop { background: rgba(31, 36, 48, .45); }
dialog h2 { margin-top: 0; }

@media (max-width: 1100px) { .split { grid-template-columns: 1fr; } .live { position: static; max-width: 620px; } }
@media (max-width: 700px) { .grid { grid-template-columns: 1fr; } .top { flex-wrap: wrap; } }
