:root {
  --brand: #342bed;
  --bg: #f7f7fb;
  --card: #ffffff;
  --line: #e5e7eb;
  --text: #1a202c;
  --muted: #666;
  --warn: #b8860b;
  --danger: #c0392b;
  --ok: #15803d;
  --pill-draft: #94a3b8;
  --pill-sent: #2563eb;
  --pill-paid: #15803d;
  --pill-overdue: #c0392b;
  --pill-void: #6b7280;
  --pill-accepted: #15803d;
  --pill-declined: #c0392b;
  --pill-converted: #7c3aed;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: 'Segoe UI', Arial, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--brand); text-decoration: none; }

header.topbar { background: var(--brand); color: white; padding: 12px 24px; display: flex;
  justify-content: space-between; align-items: center; }
header.topbar h1 { margin: 0; font-size: 16pt; }
header.topbar nav a { color: white; margin-left: 16px; opacity: 0.9; }
header.topbar nav a.active { opacity: 1; border-bottom: 2px solid white; padding-bottom: 4px; }
header.topbar .user { font-size: 10pt; opacity: 0.85; }

main { padding: 24px; max-width: 1200px; margin: 0 auto; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  padding: 20px; margin-bottom: 16px; }

.btn { background: var(--brand); color: white; border: none; padding: 8px 14px; border-radius: 6px;
  font-size: 11pt; cursor: pointer; }
.btn:hover { filter: brightness(1.05); }
.btn.secondary { background: white; color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: var(--danger); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; font-size: 10pt; }
table.list th { background: #f1f5f9; font-weight: 600; font-size: 9pt; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); }
table.list tr:hover { background: #f9fafb; }

input[type=text], input[type=email], input[type=password], input[type=date], input[type=number],
select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px;
  font-size: 11pt; font-family: inherit; background: white;
}
textarea { min-height: 160px; max-height: 60vh; resize: vertical; line-height: 1.5; overflow-y: auto; }
textarea.auto-grow { overflow-y: hidden; }
label.field { display: block; margin-bottom: 12px; }
label.field span { display: block; font-size: 9pt; color: var(--muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.5px; }

.row { display: flex; gap: 12px; }
.row > * { flex: 1; }

.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; color: white; font-size: 9pt; text-transform: uppercase; letter-spacing: 0.5px; }
.pill.draft     { background: var(--pill-draft); }
.pill.sent      { background: var(--pill-sent); }
.pill.paid      { background: var(--pill-paid); }
.pill.overdue   { background: var(--pill-overdue); }
.pill.void      { background: var(--pill-void); }
.pill.accepted  { background: var(--pill-accepted); }
.pill.declined  { background: var(--pill-declined); }
.pill.converted { background: var(--pill-converted); }

.error { color: var(--danger); font-size: 10pt; }
.muted { color: var(--muted); }

.toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.toolbar input[type=search] { max-width: 280px; }
.toolbar h2 { margin: 0; }
.pill { line-height: 1.4; white-space: nowrap; vertical-align: middle; }

dialog { border: none; border-radius: 8px; padding: 0; max-width: 600px; width: 90%; }
dialog::backdrop { background: rgba(0,0,0,0.4); }
dialog .head { padding: 16px 20px; border-bottom: 1px solid var(--line); font-weight: 600; }
dialog .body { padding: 20px; }
dialog .foot { padding: 16px 20px; border-top: 1px solid var(--line); text-align: right; }
dialog .foot .btn { margin-left: 8px; }
