:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --text: #172033;
  --muted: #68738a;
  --line: #dfe4ee;
  --primary: #111827;
  --primary-soft: #eef1f6;
  --success: #137a4b;
  --danger: #b42318;
  --warning: #a15c00;
  --radius: 14px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
a { color: inherit; }
.topbar { position: sticky; top: 0; z-index: 10; background: rgba(255,255,255,.96); border-bottom: 1px solid var(--line); backdrop-filter: blur(10px); }
.topbar-inner { max-width: 1180px; margin: auto; min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 20px; }
.brand { display: flex; flex-direction: column; text-decoration: none; }
.brand strong { letter-spacing: .02em; }
.brand span { color: var(--muted); font-size: 12px; }
.nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.container { max-width: 1180px; margin: 0 auto; padding: 26px 20px 56px; }
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 30px rgba(18, 31, 53, .05); }
.card-body { padding: 22px; }
.card-header { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 14px; align-items: center; }
h1,h2,h3 { margin: 0; }
h1 { font-size: clamp(25px, 4vw, 38px); }
h2 { font-size: 20px; }
p { line-height: 1.55; }
.muted { color: var(--muted); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.button, button { appearance: none; border: 1px solid transparent; background: var(--primary); color: white; border-radius: 10px; padding: 10px 15px; min-height: 42px; font-weight: 700; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.button.secondary, button.secondary { background: white; color: var(--text); border-color: var(--line); }
.button.danger, button.danger { background: var(--danger); }
.button.small, button.small { min-height: 34px; padding: 6px 10px; font-size: 13px; }
label { display: block; font-size: 13px; font-weight: 700; margin: 0 0 7px; }
input, select, textarea { width: 100%; border: 1px solid #ccd4e1; border-radius: 9px; padding: 10px 11px; background: white; color: var(--text); min-height: 42px; font: inherit; }
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(17,24,39,.10); border-color: var(--primary); }
.field { margin-bottom: 15px; }
.help { color: var(--muted); font-size: 12px; margin-top: 5px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 12px 11px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; background: #fafbfc; }
.amount { text-align: right; white-space: nowrap; }
.badge { display: inline-flex; align-items: center; padding: 5px 9px; border-radius: 999px; font-size: 12px; font-weight: 800; background: var(--primary-soft); }
.badge.issued { color: #174ea6; background: #e8f0fe; }
.badge.draft { color: var(--warning); background: #fff3d6; }
.badge.paid { color: var(--success); background: #dcfce7; }
.alert { padding: 13px 15px; border-radius: 10px; border: 1px solid; margin-bottom: 18px; }
.alert.error { color: var(--danger); background: #fff1f0; border-color: #f3b8b4; }
.alert.success { color: var(--success); background: #effaf4; border-color: #a9dec3; }
.kpi { padding: 20px; }
.kpi .value { font-size: 29px; font-weight: 900; margin-top: 8px; }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(450px, 100%); }
.invoice-lines input, .invoice-lines select { min-width: 85px; }
.invoice-lines .description { min-width: 240px; }
.summary { margin-left: auto; width: min(420px, 100%); }
.summary-row { display: flex; justify-content: space-between; gap: 20px; padding: 8px 0; }
.summary-row.total { font-size: 21px; font-weight: 900; border-top: 2px solid var(--text); margin-top: 8px; padding-top: 14px; }
.invoice-preview { background: white; width: min(900px, 100%); margin: 0 auto; padding: 42px; border: 1px solid var(--line); box-shadow: 0 10px 35px rgba(0,0,0,.07); }
.invoice-head { display: flex; justify-content: space-between; gap: 30px; margin-bottom: 38px; }
.invoice-meta { min-width: 260px; }
.invoice-addresses { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; margin-bottom: 28px; }
.invoice-note { white-space: pre-wrap; background: #f8fafc; padding: 14px; border-radius: 8px; }
.no-print { display: block; }
@media (max-width: 800px) {
  .grid-2, .grid-3, .invoice-addresses { grid-template-columns: 1fr; }
  .invoice-head { flex-direction: column; }
  .invoice-preview { padding: 22px; }
  .topbar-inner { align-items: flex-start; }
}
@media print {
  body { background: white; }
  .no-print, .topbar { display: none !important; }
  .container { padding: 0; max-width: none; }
  .invoice-preview { width: 100%; border: 0; box-shadow: none; padding: 10mm; }
}
