:root {
  --ink: #1c1f26;
  --muted: #6b7280;
  --line: #e5e7eb;
  --paper: #ffffff;
  --bg: #f4f5f7;
  --accent: #1d4d6b;
  --accent-ink: #ffffff;
  --draft: #9ca3af;
  --sent: #b8860b;
  --paid: #1a7f4b;
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 960px; margin: 0 auto; padding: 32px 24px 80px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  padding: 14px 24px;
}
.topbar .brand { font-weight: 700; color: var(--ink); font-size: 17px; }
.topbar nav { display: flex; align-items: center; gap: 20px; }
.topbar nav a { color: var(--ink); font-weight: 500; }
.btn-nav {
  background: var(--accent);
  color: var(--accent-ink) !important;
  padding: 7px 14px;
  border-radius: var(--radius);
  font-weight: 600;
}
.btn-nav:hover { text-decoration: none; opacity: .9; }

h1 { font-size: 24px; margin: 0 0 20px; }
h2 { font-size: 17px; margin: 0 0 12px; }

.muted { color: var(--muted); }
.empty { color: var(--muted); padding: 24px 0; }

table.list {
  width: 100%;
  border-collapse: collapse;
  background: var(--paper);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
table.list th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
}
table.list td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
table.list tbody tr:hover { background: #fafafa; cursor: pointer; }
table.list tbody tr:last-child td { border-bottom: none; }
.right { text-align: right; }

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  text-transform: capitalize;
  color: #fff;
}
.badge-draft { background: var(--draft); }
.badge-sent { background: var(--sent); }
.badge-paid { background: var(--paid); }

.card {
  background: var(--paper);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.two-col { display: grid; grid-template-columns: 1.4fr 1fr; gap: 24px; align-items: start; }

.stacked-form { display: flex; flex-direction: column; gap: 12px; }
.stacked-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }

input, select, textarea, button {
  font: inherit;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
}
textarea { resize: vertical; }
button {
  background: var(--accent);
  color: #fff;
  border: none;
  font-weight: 600;
  cursor: pointer;
}
button:hover { opacity: .9; }
button.secondary {
  background: var(--paper);
  color: var(--accent);
  border: 1px solid var(--accent);
}
.link-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-weight: 400;
  padding: 4px 8px;
}
.link-btn:hover { color: #b91c1c; }
.inline { display: inline; }

.form-row { display: flex; gap: 20px; margin-bottom: 20px; }
.form-row label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); flex: 1; }

table.items { width: 100%; border-collapse: collapse; margin-bottom: 12px; }
table.items th { text-align: left; font-size: 12px; color: var(--muted); padding: 6px 8px; }
table.items td { padding: 4px 8px; }
table.items input { width: 100%; }
table.items td:nth-child(3) input, table.items td:nth-child(4) input { width: 90px; }

.total-line { font-size: 18px; margin: 8px 0 20px; }
.item-add-row { display: flex; gap: 10px; }
.rate-note { font-size: 12px; margin: 6px 0 20px; }

.login-body {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.login-card {
  background: var(--paper);
  padding: 40px;
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0,0,0,.08);
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 280px;
}
.login-card h1 { margin: 0; font-size: 20px; }
.login-card p.muted { margin: 0 0 8px; }
.error { color: #b91c1c; font-size: 13px; }

/* Printable invoice */
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.toolbar .spacer { flex: 1; }
.send-error { margin: -8px 0 20px; }

.invoice-sheet {
  background: var(--paper);
  padding: 48px;
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.invoice-head { display: flex; justify-content: space-between; margin-bottom: 32px; }
.invoice-head h1 { font-size: 20px; margin: 0 0 6px; }

.brand-logo {
  display: inline-block;
  background: linear-gradient(135deg, #0e2233 0%, #1d4d6b 100%);
  padding: 14px 20px;
  border-radius: 6px;
  margin-bottom: 10px;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
.brand-wordmark {
  display: block;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: .03em;
  color: #d9e04a;
  text-transform: uppercase;
}
.brand-tagline {
  display: block;
  font-size: 11px;
  color: #cfe3ee;
  margin-top: 4px;
  letter-spacing: .01em;
}
.invoice-meta { text-align: right; }
.invoice-meta h2 { color: var(--muted); letter-spacing: .08em; font-size: 14px; }
.rate-line { font-size: 12px; font-weight: 600; color: var(--accent); margin: 6px 0 0; }
.invoice-bill-to { margin-bottom: 32px; }
.invoice-payment { margin-bottom: 24px; }
.invoice-payment p { margin: 2px 0; }
.invoice-notes { margin-top: 8px; }
.label { text-transform: uppercase; font-size: 11px; letter-spacing: .06em; color: var(--muted); margin: 0 0 4px; }

table.invoice-items { width: 100%; border-collapse: collapse; margin-bottom: 24px; }
table.invoice-items th {
  text-align: left; font-size: 12px; text-transform: uppercase; color: var(--muted);
  padding: 8px 6px; border-bottom: 2px solid var(--ink);
}
table.invoice-items td { padding: 10px 6px; border-bottom: 1px solid var(--line); }
table.invoice-items tfoot td { border-bottom: none; border-top: 2px solid var(--ink); padding-top: 14px; }

@media print {
  body { background: #fff; }
  .no-print { display: none !important; }
  .container { max-width: none; padding: 0; }
  .invoice-sheet { box-shadow: none; padding: 0; }
}

@media (max-width: 600px) {
  .container { padding: 16px 12px 60px; }
  .topbar { flex-direction: column; align-items: flex-start; gap: 10px; padding: 12px 16px; }
  .topbar nav { flex-wrap: wrap; gap: 12px; }
  .two-col { grid-template-columns: 1fr; }
  .form-row { flex-direction: column; gap: 12px; }
  table.list, table.items, table.invoice-items { display: block; overflow-x: auto; white-space: nowrap; }
  .invoice-sheet { padding: 20px; }
  .invoice-head { flex-direction: column; gap: 20px; }
  .invoice-meta { text-align: left; }
  .toolbar { flex-wrap: wrap; }
  .toolbar .spacer { display: none; }
}
