/* Terzet house style (terzet.nl): Montserrat, dark grey text, red headings and links,
   orange accent, light blue-grey panels without borders, grey footer. */

@font-face {
  font-family: "Montserrat";
  font-style: normal;
  font-weight: 300 800;
  font-display: swap;
  src: url("fonts/montserrat-latin.woff2") format("woff2");
}

:root {
  --bg: #ffffff;
  --panel: #f6f9ff;
  --text: #444444;
  --text-strong: #575756;
  --muted: #7a7a79;
  --line: #e3e8f0;
  --red: #c00d0d;
  --red-dark: #9e0a0a;
  --orange: #e84e0f;
  --band: #df8686;
  --footer: #cccccc;
  --ok-bg: #e6f3ea;
  --ok-text: #1e6b34;
  --err-bg: #fbe7e7;
  --err-text: #9e0a0a;
  --warn-bg: #fdeee5;
  --warn-text: #9a3a0a;
  --font: "Montserrat", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 400 15px/1.6 var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--red); text-decoration: none; }
a:hover { color: var(--orange); }

/* --- header ------------------------------------------------------------- */
.topbar {
  background: #fff;
  box-shadow: 0 2px 15px rgba(0, 0, 0, .06);
  padding-top: env(safe-area-inset-top);
  position: sticky; top: 0; z-index: 20;
}
.topbar-inner {
  max-width: 1140px; margin: 0 auto; padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 24px;
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--text-strong); }
.brand:hover { color: var(--text-strong); }
.brand-logo { height: 40px; width: auto; display: block; }
.brand-app {
  font-size: .75rem; font-weight: 600; color: var(--red); text-transform: uppercase; letter-spacing: .08em;
  border-left: 2px solid var(--orange); padding-left: 10px; margin-left: 6px; line-height: 1.2;
}
nav { display: flex; align-items: center; gap: 4px 22px; flex-wrap: wrap; }
nav a, nav button.link {
  color: var(--red); font-weight: 500; font-size: 15px; padding: 6px 0; position: relative;
}
nav a::after {
  content: ""; position: absolute; left: 0; right: 100%; bottom: 0; height: 2px;
  background: var(--orange); transition: right .2s ease;
}
nav a:hover { color: var(--orange); }
nav a:hover::after, nav a.active::after { right: 0; }
nav button.link { color: var(--muted); }
nav button.link:hover { color: var(--orange); }
@media (max-width: 760px) {
  .brand-logo { height: 32px; }
  .topbar { position: static; }
  .topbar-inner { padding: 12px 16px 0; }
  nav {
    width: 100%; flex-wrap: nowrap; overflow-x: auto; gap: 18px; padding-bottom: 6px;
    scrollbar-width: none; -webkit-overflow-scrolling: touch;
  }
  nav::-webkit-scrollbar { display: none; }
  nav a, nav form { flex: none; }
}

/* --- layout ------------------------------------------------------------- */
main { width: 100%; max-width: 1140px; margin: 0 auto; padding: 36px 16px 96px; flex: 1; }

h1, h2, h3 { color: var(--red); font-weight: 700; line-height: 1.25; }
h1 { font-size: 1.85rem; margin: 0 0 20px; }
h2 { font-size: 1.3rem; margin: 0 0 14px; }
h3 { font-size: 1rem; margin: 22px 0 8px; color: var(--text-strong); }
strong { color: var(--text-strong); font-weight: 700; }
.muted { color: var(--muted); font-weight: 400; }
.small { font-size: 13px; }

.card {
  background: var(--panel); padding: 32px 36px; margin-bottom: 24px; overflow-x: auto;
}
.card.narrow { max-width: 440px; margin: 48px auto; }
@media (max-width: 640px) { .card { padding: 22px 18px; } }

/* --- forms -------------------------------------------------------------- */
form { display: flex; flex-direction: column; gap: 14px; }
form.inline, form.row { flex-direction: row; align-items: flex-end; }
form.row { gap: 10px; flex-wrap: wrap; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; color: var(--text-strong); }
label .small, label .muted { font-weight: 400; }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; color: var(--text); font-size: 15px; }
fieldset.plain { border: 0; padding: 0; margin: 0; min-width: 0; display: flex; flex-direction: column; gap: 14px; }

input, select, textarea {
  font: 400 15px/1.4 var(--font); padding: 10px 12px; border: 1px solid #d5dbe5; border-radius: 0;
  background: #fff; color: var(--text); min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--orange); outline-offset: 0; border-color: var(--orange); }
input:disabled, select:disabled { background: #eef1f6; }

button, a.button {
  font: 600 15px/1.2 var(--font); cursor: pointer; padding: 12px 22px; border: 0; border-radius: 0;
  background: var(--red); color: #fff; align-self: flex-start;
  display: inline-block; text-align: center; transition: background .15s ease;
}
button:hover, a.button:hover { background: var(--orange); color: #fff; }
button:disabled { opacity: .4; cursor: not-allowed; background: var(--red); }
button.link { background: none; padding: 0; font-weight: 500; }
button.link:hover { background: none; }
button.secondary, a.button.secondary { background: #fff; color: var(--red); box-shadow: inset 0 0 0 1px var(--red); }
button.secondary:hover, a.button.secondary:hover { background: var(--red); color: #fff; }
button.danger { background: #fff; color: var(--red); box-shadow: inset 0 0 0 1px var(--red); padding: 7px 14px; font-weight: 500; }
button.danger:hover { background: var(--red); color: #fff; }
a.button.big { font-size: 1.05rem; padding: 16px 26px; }

.alert { padding: 12px 16px; margin: 0 0 20px; border-left: 4px solid currentColor; }
.alert-ok { background: var(--ok-bg); color: var(--ok-text); }
.alert-error { background: var(--err-bg); color: var(--err-text); }
.alert-warn { background: var(--warn-bg); color: var(--warn-text); }
.alert a { color: inherit; text-decoration: underline; }

/* --- tables ------------------------------------------------------------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--text-strong); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; border-bottom: 2px solid var(--red); }
tfoot th { color: var(--text-strong); font-size: 15px; text-transform: none; letter-spacing: 0; border-bottom: 0; border-top: 2px solid var(--text-strong); }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
td.actions { text-align: right; white-space: nowrap; }
td.actions form { display: inline-flex; margin-left: 8px; }
tr.empty-row td { color: #a5a5a4; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1, .page-head h2 { margin: 0; }
.actions-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 14px; }
.actions-row.tight { margin-top: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 20px; }
@media (max-width: 640px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 3px 9px; background: #e7ebf2; color: var(--text-strong); white-space: nowrap; text-transform: uppercase; letter-spacing: .04em; }
.badge.big { font-size: 12px; padding: 5px 12px; }
.badge-ok, .badge-vergoed { background: var(--ok-bg); color: var(--ok-text); }
.badge-review { background: var(--warn-bg); color: var(--warn-text); }
.badge-ingediend { background: var(--err-bg); color: var(--red); }
.badge-open { background: #e7ebf2; color: var(--text-strong); }
.count { background: var(--red); color: #fff; padding: 0 8px; font-size: 12px; margin-left: 6px; vertical-align: middle; }

/* --- home --------------------------------------------------------------- */
.hero {
  background: var(--band); color: #fff; padding: 34px 36px; margin-bottom: 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap;
}
.hero h1 { color: #fff; margin-bottom: 6px; }
.hero p { margin: 0; max-width: 560px; color: #fff; }
.hero a.button { background: #fff; color: var(--red); }
.hero a.button:hover { background: var(--red); color: #fff; }
@media (max-width: 640px) { .hero { padding: 24px 18px; } }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 14px; }
.stats > div { display: flex; flex-direction: column; border-left: 3px solid var(--orange); padding-left: 12px; }
.stats strong { font-size: 1.35rem; font-variant-numeric: tabular-nums; }
@media (max-width: 640px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.receipt-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.receipt-row {
  display: grid; grid-template-columns: 56px 1fr auto; gap: 14px; align-items: center;
  padding: 10px; background: #fff; color: var(--text); border-left: 3px solid transparent;
}
.receipt-row:hover { color: var(--text); border-left-color: var(--orange); }
.receipt-row img { width: 56px; height: 56px; object-fit: cover; background: var(--line); }
.receipt-main { display: flex; flex-direction: column; min-width: 0; }
.receipt-main strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.receipt-amount { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; font-weight: 700; color: var(--text-strong); }

/* --- capture ------------------------------------------------------------ */
.capture { text-align: center; }
.capture p { max-width: 580px; margin-left: auto; margin-right: auto; }
.capture form { align-items: center; }
.camera-button {
  display: inline-flex; flex-direction: column; align-items: center; gap: 8px; cursor: pointer;
  background: var(--red); color: #fff; font-size: 1.1rem; font-weight: 700;
  padding: 30px 44px; margin: 14px auto; transition: background .15s ease;
}
.camera-button:hover { background: var(--orange); }
.camera-button span[aria-hidden] { font-size: 2.6rem; line-height: 1; }
.camera-button.secondary { padding: 12px 22px; font-size: 15px; flex-direction: row; background: #fff; color: var(--red); box-shadow: inset 0 0 0 1px var(--red); margin: 0; font-weight: 600; }
.camera-button.secondary:hover { background: var(--red); color: #fff; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.capture-result { margin-top: 18px; }
.capture-result img { max-width: min(320px, 100%); max-height: 360px; background: #fff; padding: 6px; }
.capture-result .actions-row { justify-content: center; }

/* --- receipt ------------------------------------------------------------ */
.receipt-layout { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: 24px; align-items: start; }
@media (max-width: 760px) { .receipt-layout { grid-template-columns: 1fr; } }
.receipt-photo { margin: 0; text-align: center; position: sticky; top: 90px; padding: 18px; }
.receipt-photo img { max-width: 100%; max-height: 70vh; }
@media (max-width: 760px) { .receipt-photo { position: static; } .receipt-photo img { max-height: 45vh; } }
.notes { margin: 0 0 18px; padding: 12px 16px 12px 32px; background: var(--warn-bg); color: var(--warn-text); border-left: 4px solid var(--orange); font-size: 14px; }
.amounts input { font-size: 1.1rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.delete-form { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 18px; }
.ocr pre { white-space: pre-wrap; font-size: 12px; background: #fff; padding: 12px; max-height: 300px; overflow: auto; }
details summary { cursor: pointer; margin-top: 14px; }

/* --- declaration -------------------------------------------------------- */
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 20px; margin: 0; }
.facts dt { color: var(--muted); font-size: 14px; }
.facts dd { margin: 0; overflow-wrap: anywhere; font-weight: 500; color: var(--text-strong); }
.log { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }

/* --- report ------------------------------------------------------------- */
.filters { align-items: flex-end; }
.bar-col { width: 22%; }
.bar { display: block; height: 10px; background: linear-gradient(90deg, var(--red), var(--orange)); min-width: 0; margin-top: 6px; }

/* responsive tables: stack rows on phones */
@media (max-width: 640px) {
  table.responsive thead { display: none; }
  table.responsive, table.responsive tbody, table.responsive tr, table.responsive td { display: block; width: 100%; }
  table.responsive tr { border-bottom: 1px solid var(--line); padding: 10px 0; }
  table.responsive td { border: 0; padding: 2px 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  table.responsive td::before { content: attr(data-label); color: var(--muted); font-size: 13px; text-align: left; }
  table.responsive td.actions { justify-content: flex-end; }
  table.responsive td.bar-col { display: none; }
  table.responsive tfoot tr { display: flex; flex-wrap: wrap; gap: 4px 12px; }
  table.responsive tfoot th { border: 0; padding: 4px 0; }
  table.months tr.empty-row { display: none; }
}

/* --- floating camera button and queue banner ---------------------------- */
.fab {
  position: fixed; right: 18px; bottom: max(18px, env(safe-area-inset-bottom)); z-index: 10;
  width: 62px; height: 62px; border-radius: 50%; display: grid; place-items: center;
  background: var(--red); color: #fff; box-shadow: 0 6px 18px rgba(192, 13, 13, .35);
  transition: background .15s ease;
}
.fab:hover { background: var(--orange); color: #fff; }
.queue-status { padding: 9px 16px; text-align: center; font-size: 14px; font-weight: 500; }
.queue-status.warn { background: var(--warn-bg); color: var(--warn-text); }
.queue-status.info { background: var(--panel); color: var(--red); }

/* --- footer ------------------------------------------------------------- */
.footer { background: var(--footer); color: var(--text-strong); padding: 26px 16px 90px; }
.footer-inner { max-width: 1140px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 12px 24px; flex-wrap: wrap; }
.footer-brand .brand-logo { height: 32px; }
.footer-links { display: flex; gap: 20px; font-size: 13px; font-weight: 700; }
.footer a { color: var(--text-strong); }
.footer a:hover { color: var(--red); }

/* --- admin -------------------------------------------------------------- */
.invite { background: #fff; padding: 12px; margin-bottom: 10px; }
.invite-link { width: 100%; font-family: ui-monospace, monospace; font-size: 12px; }
.invite-new { outline: 2px solid var(--orange); }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.prose p { line-height: 1.7; }
