/* North Star UI (Airtable robot helper style) */
@font-face {
  font-family: "Prestige Elite";
  src: url("/static/fonts/PrestigeElite-Regular.otf") format("opentype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Prestige Elite";
  src: url("/static/fonts/PrestigeElite-Bold.otf") format("opentype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #fff;
  --panel: #fff;
  --fg: #000;
  --muted: #444;
  --line: #b7b7b7;
  --soft: #f5f5f5;
  --danger: #b91c1c;
  --warn: #92400e;
  --ok: #166534;
}

html.dark {
  --bg: #000;
  --panel: #000;
  --fg: #f3f4f6;
  --muted: #c0c4cc;
  --line: #3f3f46;
  --soft: #0b0b0b;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 24px;
  background: var(--bg);
  color: var(--fg);
  font-family: "Prestige Elite Std", "Prestige Elite", "Courier New", Courier, monospace;
  font-size: 16px;
  line-height: 1.35;
}

a { color: var(--fg); text-decoration: underline; }
a:visited { color: var(--fg); }
a:hover { color: var(--fg); }

.wrap { max-width: 980px; margin: 0 auto; }

.appbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 22px;
}
.appbar-left { display: flex; align-items: center; gap: 10px; }
.app-logo { width: 42px; height: auto; }
.app-title { font-weight: 700; font-size: 18px; letter-spacing: 0; }
.app-subtitle { font-size: 13px; color: var(--muted); margin-top: 2px; }

.nav { display: flex; gap: 24px; align-items: baseline; }
.nav a { text-decoration: underline; font-weight: 400; font-size: 16px; font-family: inherit; line-height: 1.35; }

/* Make header links look like helper Home link */
.helper-home { font-weight: 400; font-size: 16px; font-family: inherit; line-height: 1.35; }
.appbar-adminlinks { display: inline-flex; gap: 24px; align-items: baseline; }

.h1 { font-weight: 700; font-size: 22px; margin: 0 0 6px; }
.h2 { font-weight: 700; font-size: 16px; margin: 0 0 10px; }
.p-muted { color: var(--muted); font-size: 13px; margin: 0 0 14px; }

.card {
  border: 1px solid var(--line);
  padding: 14px;
  background: var(--panel);
}

.row { display: flex; gap: 10px; align-items: center; }
.stack { display: grid; gap: 12px; }

label { display: block; margin: 12px 0 6px; font-weight: 700; }
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 10px;
  font-size: 16px;
  font-family: inherit;
  background: var(--panel);
  color: var(--fg);
  box-shadow: none;
}
textarea { resize: vertical; }

/* Buttons: mimic helper (Arial bold, square, black border) */
button, .btn {
  -webkit-appearance: none;
  appearance: none;
  background: var(--panel);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 12px 16px;
  font-size: 16px;
  font-family: Arial, Helvetica, sans-serif;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
button[disabled], .btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: default;
}

.btn-sm { padding: 8px 10px; font-size: 16px; line-height: 1; }
.actions-right .btn-sm { position: relative; top: -2px; }
.btn-block { width: 100%; }

.btn-primary {
  background: var(--panel);
  color: var(--fg);
}

.hint { color: var(--muted); font-size: 13px; margin-top: 12px; }

.alert {
  border: 1px solid var(--line);
  background: var(--soft);
  padding: 12px;
  font-size: 13px;
}
.alert-danger { border-color: var(--danger); color: var(--danger); background: #fff; }
.alert-warn { border-color: var(--warn); color: var(--warn); background: #fff; }

.badges { display: inline-flex; gap: 8px; align-items: center; }
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 3px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}
.badge-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  font-size: 11px;
}
.badge-arrow-end { margin-left: 2px; }
.badge-paid { background: #fff; color: var(--ok); border-color: var(--ok); }
.badge-sent { background: #fff; color: #1d4ed8; border-color: #1d4ed8; }
.badge-paid .badge-arrow,
.badge-sent .badge-arrow { color: inherit; }
html.dark .badge-paid,
html.dark .badge-sent { background: #000; }
html.dark .badge-paid { color: var(--ok); border-color: var(--ok); }
html.dark .badge-sent { color: #5b86ff; border-color: #5b86ff; }
html.dark .badge-paid .badge-arrow,
html.dark .badge-sent .badge-arrow { color: inherit; }

.table-wrap { border: 1px solid var(--line); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px; border-bottom: 1px solid #ddd; vertical-align: top; }
th { text-align: left; font-weight: 700; }
tr:last-child td { border-bottom: 0; }
.t-right { text-align: right; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 720px) { .grid-2 { grid-template-columns: 1fr; } }

.kv { display: grid; grid-template-columns: 120px 1fr; gap: 6px 12px; font-size: 14px; }
.kv .k { color: var(--muted); }

.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.actions-right { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; align-items: center; }

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; }
.small { font-size: 13px; }

/* Invoice layout */
.invoice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  align-items: stretch; /* make left/right bottom cards equal height */
}

.invoice-grid > .card { height: 100%; }
.span-2 { grid-column: 1 / -1; }

.invoice-public-head { padding: 0 0 2px; }
.invoice-top-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.invoice-number { font-weight: 700; font-size: 28px; line-height: 1.1; }

.invoice-top-meta {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.invoice-top-meta-right { min-width: 280px; }

.invoice-totals-wrap { display: flex; justify-content: flex-end; margin-top: 12px; }
/* Align totals with the Amount column by matching the table's right padding (10px). */
.invoice-totals { width: 280px; display: grid; gap: 6px; padding-right: 10px; font-size: 14px; }
.invoice-total-line { display: flex; justify-content: space-between; gap: 12px; }
.invoice-total-final { padding-top: 6px; border-top: 1px solid var(--line); }

@media (max-width: 720px) {
  .invoice-grid { grid-template-columns: 1fr; }
  .invoice-top-head { flex-direction: column; }
  .invoice-top-meta { flex-direction: column; }
  .invoice-top-meta-right { min-width: 0; }
  .invoice-totals { width: 100%; }
}

/* PDF + print: keep layout identical, just hide controls */
body.pdf .no-pdf { display: none !important; }
/* Reduce vertical chrome in PDF so it stays single-page when possible. */
body.pdf { margin: 0; padding: 10mm; }
body.pdf .wrap { max-width: 190mm; }
body.pdf .table-wrap { overflow-x: visible; }

@media print {
  .no-print { display: none !important; }
}

/* RUN control: match To-Dos Y/N (text with circle only when active) */
.run-line {
  display: flex;
  width: 100%;
  justify-content: space-between;
  align-items: baseline;
}
.run-label {
  font-weight: 700;
  font-family: inherit;
}
.run-choices {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}
.run-link {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font-family: inherit;
  font-weight: 700;
  font-size: 16px;
  color: var(--fg);
  -webkit-appearance: none;
  appearance: none;
  text-decoration: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  vertical-align: middle;
  position: relative;
  width: 24px;
  height: 24px;
}
.run-link::before {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 24px;
  height: 24px;
  border: 1px solid transparent;
  border-radius: 50%;
}
.run-link span { display: inline-block; line-height: 1; }
.run-link.active::before { border-color: var(--fg); }

@media (max-width: 720px) {
  .run-link { width: 32px; height: 32px; }
  .run-link::before { width: 32px; height: 32px; }
}
