/* ═══════════════════════════════════════════════════════════════════════
   CENTIEM — Stylesheet
   Richting: het groene grootboek. Grootboekgroen als structuur, papiergrijze
   ondergrond, mono-cijfers voor alles wat geld is, statussen als rubberen
   stempels. Diepte via lijnen, niet via schaduwen.
   Fonts: Archivo (tekst en koppen) + Spline Sans Mono (bedragen, nummers).
   ═══════════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Archivo:wght@400;500;600;700;800&family=Spline+Sans+Mono:wght@400;500;600&display=swap');

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --green:      #1F5C40;
  --green-deep: #143D2B;
  --green-soft: #E4EDE7;
  --ink:        #18241E;
  --muted:      #5E6B63;
  --faded:      #93A099;
  --paper:      #EFEEE7;
  --surface:    #FFFFFF;
  --line:       #DCDDD2;
  --line-dark:  #B8BCAD;
  --stamp-red:  #C03A2B;
  --red-soft:   #F6E4E1;
  --amber:      #B07C10;
  --amber-soft: #F3EAD3;

  --font: 'Archivo', sans-serif;
  --mono: 'Spline Sans Mono', monospace;

  --r-sm: 3px;
  --r:    6px;
  --r-lg: 10px;
}

body {
  font-family: var(--font);
  background: var(--paper);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

button, input, select, textarea { font-family: var(--font); font-size: inherit; color: inherit; }

:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ── Stempel — het signatuurelement ───────────────────────────────────── */
.stamp {
  display: inline-block;
  font-family: var(--font);
  font-weight: 800;
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  padding: 0.22rem 0.6rem;
  border: 2px solid currentColor;
  border-radius: var(--r-sm);
  transform: rotate(-2deg);
  white-space: nowrap;
}

.stamp-draft     { color: var(--amber); }
.stamp-sent      { color: var(--green); border-style: dashed; }
.stamp-paid      { color: var(--green); }
.stamp-overdue   { color: var(--stamp-red); }
.stamp-cancelled { color: var(--faded); text-decoration: line-through; }

/* ── Auth-scherm ──────────────────────────────────────────────────────── */
#auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  /* Grootboeklijnen op de achtergrond */
  background-image: repeating-linear-gradient(
    180deg, transparent 0, transparent 31px, rgba(31, 92, 64, 0.06) 31px, rgba(31, 92, 64, 0.06) 32px
  );
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--line-dark);
  border-top: 4px solid var(--green);
  border-radius: var(--r-lg);
  padding: 2.5rem;
  width: 100%;
  max-width: 400px;
}

.brand {
  font-weight: 800;
  font-size: 1.6rem;
  letter-spacing: -0.04em;
  color: var(--ink);
}
.brand span { color: var(--green); }

.brand-sub {
  font-size: 0.82rem;
  color: var(--muted);
  margin: 0.2rem 0 1.75rem;
}

.auth-tabs {
  display: flex;
  border: 1px solid var(--line-dark);
  border-radius: var(--r);
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.auth-tab {
  flex: 1;
  padding: 0.55rem;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--paper);
  border: none;
  color: var(--muted);
  transition: background .14s, color .14s;
}
.auth-tab.active { background: var(--green); color: #fff; }

/* ── Formulieren ──────────────────────────────────────────────────────── */
label {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.3rem;
}

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], select, textarea {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--line-dark);
  border-radius: var(--r);
  background: var(--surface);
  font-size: 0.9rem;
  margin-bottom: 1rem;
  outline: none;
  transition: border-color .14s, box-shadow .14s;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(31, 92, 64, 0.12);
}

textarea { resize: vertical; min-height: 70px; line-height: 1.5; }
select { cursor: pointer; appearance: none; }

.field-row { 
  display: flex;
  flex-wrap: wrap;
  margin-top: 1rem;
  gap: 0.85rem;
  max-width: 100%;
}

.error-box {
  background: var(--red-soft);
  border: 1px solid rgba(192, 58, 43, 0.3);
  color: var(--stamp-red);
  border-radius: var(--r);
  padding: 0.6rem 0.85rem;
  font-size: 0.82rem;
  margin-bottom: 1rem;
  display: none;
}

/* ── Knoppen ──────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0.58rem 1.2rem;
  border-radius: var(--r);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background .14s, border-color .14s, color .14s;
  white-space: nowrap;
}

.btn-green { background: var(--green); color: #fff; }
.btn-green:hover { background: var(--green-deep); }

.btn-ink { background: var(--ink); color: #fff; }
.btn-ink:hover { background: #25342B; }

.btn-line { background: var(--surface); color: var(--ink); border-color: var(--line-dark); }
.btn-line:hover { border-color: var(--green); color: var(--green); }

.btn-red { background: transparent; color: var(--stamp-red); border-color: rgba(192,58,43,0.4); }
.btn-red:hover { background: var(--red-soft); }

.btn-block { width: 100%; }
.btn-sm { padding: 0.32rem 0.7rem; font-size: 0.76rem; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* ── App-schil ────────────────────────────────────────────────────────── */
#app { display: none; min-height: 100vh; }

.topbar {
  background: var(--green-deep);
  color: #fff;
  height: 54px;
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 2rem;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar .brand { font-size: 1.15rem; color: #fff; }
.topbar .brand span { color: #8FC4A8; }

.topnav { display: flex; gap: 0.25rem; margin-right: auto; }

.topnav button {
  background: none;
  border: none;
  color: rgba(255,255,255,0.65);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0.45rem 0.9rem;
  border-radius: var(--r);
  cursor: pointer;
  transition: background .14s, color .14s;
}
.topnav button:hover { color: #fff; background: rgba(255,255,255,0.08); }
.topnav button.active { color: #fff; background: var(--green); }

.topbar-user { font-family: var(--mono); font-size: 0.72rem; color: rgba(255,255,255,0.5); }

.logout-btn {
  background: none;
  border: 1px solid rgba(255,255,255,0.25);
  color: rgba(255,255,255,0.8);
  font-size: 0.76rem;
  font-weight: 600;
  padding: 0.3rem 0.75rem;
  border-radius: var(--r);
  cursor: pointer;
  transition: border-color .14s, color .14s;
}
.logout-btn:hover { border-color: #fff; color: #fff; }

.main { max-width: 1060px; margin: 0 auto; padding: 2rem 1.5rem 4rem; }

.page { display: none; }
.page.active { display: block; }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.page-head h1 {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.page-head .sub { font-size: 0.82rem; color: var(--muted); margin-top: 0.15rem; }

/* ── Kerncijfers (dashboard) ──────────────────────────────────────────── */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0;
  border: 1px solid var(--line-dark);
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--surface);
  margin-bottom: 2rem;
}

.kpi {
  padding: 1.25rem 1.4rem;
  border-right: 1px solid var(--line);
}
.kpi:last-child { border-right: none; }

.kpi-label {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.kpi-value {
  font-family: var(--mono);
  font-size: 1.45rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.kpi-value.pos { color: var(--green); }
.kpi-value.neg { color: var(--stamp-red); }

/* ── Panelen en tabellen ──────────────────────────────────────────────── */
.panel {
  background: var(--surface);
  border: 1px solid var(--line-dark);
  border-radius: var(--r-lg);
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--line);
}

.panel-title { font-size: 0.88rem; font-weight: 700; letter-spacing: -0.01em; }

table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }

th {
  text-align: left;
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0.6rem 1.25rem;
  border-bottom: 1px solid var(--line-dark);
  background: var(--green-soft);
  white-space: nowrap;
}

td {
  padding: 0.7rem 1.25rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tbody tr { cursor: pointer; transition: background .1s; }
tbody tr:hover { background: var(--green-soft); }
tbody tr.static { cursor: default; }
tbody tr.static:hover { background: transparent; }

.num { font-family: var(--mono); font-size: 0.82rem; text-align: right; white-space: nowrap; }
th.num { text-align: right; }
.mono { font-family: var(--mono); font-size: 0.8rem; }

.empty {
  padding: 2.5rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}

/* ── Factuureditor ────────────────────────────────────────────────────── */
.editor-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 1.5rem;
  align-items: start;
}

.lines-table th { background: var(--green); color: #fff; }
.lines-table input, .lines-table select { margin-bottom: 0; font-size: 0.84rem; padding: 0.42rem 0.6rem; }
.lines-table td { padding: 0.45rem 0.6rem; }
.lines-table td:first-child { padding-left: 1rem; width: 45%; }

.line-del {
  background: none;
  border: none;
  color: var(--faded);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0.3rem;
}
.line-del:hover { color: var(--stamp-red); }

.add-line {
  display: block;
  width: 100%;
  padding: 0.55rem;
  background: none;
  border: 1px dashed var(--line-dark);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.8rem;
  cursor: pointer;
  transition: color .14s, border-color .14s;
}
.add-line:hover { color: var(--green); border-color: var(--green); }

/* Totalenkaart — grootboekstijl */
.totals-card {
  background: var(--surface);
  border: 1px solid var(--line-dark);
  border-radius: var(--r-lg);
  padding: 1.25rem 1.4rem;
}

.tot-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.84rem;
  color: var(--muted);
  padding: 0.3rem 0;
}

.tot-row .num { color: var(--ink); }

.tot-row.grand {
  border-top: 2px solid var(--ink);
  margin-top: 0.5rem;
  padding-top: 0.6rem;
  font-weight: 700;
  color: var(--ink);
  font-size: 0.95rem;
}
.tot-row.grand .num { font-size: 1.05rem; font-weight: 600; }

.check-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.75rem 0 1rem;
  font-size: 0.82rem;
  color: var(--muted);
}
.check-row input { width: auto; margin: 0; }
.check-row label { margin: 0; text-transform: none; letter-spacing: 0; font-size: 0.82rem; font-weight: 500; }

/* ── Factuurdetail ────────────────────────────────────────────────────── */
.detail-head {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.detail-head .number { font-family: var(--mono); font-size: 1.3rem; font-weight: 600; }

.detail-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line-dark);
  border-radius: var(--r-lg);
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.detail-meta > div { background: var(--surface); padding: 0.85rem 1.1rem; }
.detail-meta .kpi-label { margin-bottom: 0.25rem; }
.detail-meta .val { font-size: 0.88rem; font-weight: 600; }
.detail-meta .val.mono { font-weight: 500; }

.action-bar { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-bottom: 1.5rem; }

/* ── Klantenkaarten ───────────────────────────────────────────────────── */
.client-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1rem;
}

.client-card {
  background: var(--surface);
  border: 1px solid var(--line-dark);
  border-radius: var(--r-lg);
  padding: 1.25rem 1.4rem;
  cursor: pointer;
  transition: border-color .15s;
}
.client-card:hover { border-color: var(--green); }

.client-card h3 { font-size: 0.95rem; font-weight: 700; letter-spacing: -0.01em; margin-bottom: 0.2rem; }
.client-card .vat { font-family: var(--mono); font-size: 0.74rem; color: var(--muted); }
.client-card .meta { font-size: 0.8rem; color: var(--muted); margin-top: 0.5rem; }

/* ── Modal ────────────────────────────────────────────────────────────── */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(24, 36, 30, 0.45);
  z-index: 50;
  align-items: flex-start;
  justify-content: center;
  padding: 4rem 1rem;
  overflow-y: auto;
}
.modal-backdrop.open { display: flex; }

.modal {
  background: var(--surface);
  border-radius: var(--r-lg);
  border-top: 4px solid var(--green);
  width: 100%;
  max-width: 520px;
  padding: 1.75rem;
}

.modal h2 { font-size: 1.1rem; font-weight: 800; letter-spacing: -0.02em; margin-bottom: 1.25rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.6rem; margin-top: 0.5rem; }

/* ── Toast ────────────────────────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: var(--ink);
  color: #fff;
  font-size: 0.85rem;
  padding: 0.7rem 1.3rem;
  border-radius: var(--r);
  border-left: 3px solid var(--green);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s, transform .18s;
  z-index: 100;
  max-width: 90vw;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error { border-left-color: var(--stamp-red); }

/* ── Instellingen ─────────────────────────────────────────────────────── */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: start;
}

.settings-card {
  background: var(--surface);
  border: 1px solid var(--line-dark);
  border-radius: var(--r-lg);
  padding: 1.5rem;
}

.settings-card h2 {
  font-size: 0.92rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin-bottom: 1.25rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--line);
}

/* ── Responsief ───────────────────────────────────────────────────────── */
@media (max-width: 880px) {
  .editor-grid { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .topbar { gap: 1rem; padding: 0 1rem; overflow-x: auto; }
  .topbar-user { display: none; }
  .main { padding: 1.25rem 1rem 3rem; }
  th, td { padding-left: 0.8rem; padding-right: 0.8rem; }
  .hide-mobile { display: none; }
}

@media (max-width: 560px) {
  .field-row { grid-template-columns: 1fr; }
  .kpi-row { grid-template-columns: 1fr 1fr; }
  .kpi { border-bottom: 1px solid var(--line); }
}

/* ── Abonnement & huisstijl ───────────────────────────────────────────── */
.auth-legal {
  margin-top: 1.1rem;
  font-size: 0.74rem;
  color: var(--faded);
  text-align: center;
  line-height: 1.5;
}
.auth-legal a { color: var(--muted); }

.pro-tag {
  display: inline-block;
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--green);
  border: 1.5px solid var(--green);
  border-radius: var(--r-sm);
  padding: 0.08rem 0.4rem;
  vertical-align: 2px;
  margin-left: 0.4rem;
}

.plan-info { margin-bottom: 1rem; font-size: 0.88rem; }
.plan-info .stamp { margin-right: 0.6rem; }
.plan-usage { font-family: var(--mono); font-size: 0.78rem; color: var(--muted); margin-top: 0.5rem; }

.hint { font-size: 0.76rem; color: var(--muted); line-height: 1.6; }

.color-row { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1rem; }
.color-row input[type=color] {
  width: 52px; height: 36px;
  padding: 2px;
  border: 1px solid var(--line-dark);
  border-radius: var(--r);
  background: var(--surface);
  cursor: pointer;
  margin: 0;
}

.logo-row { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.75rem; flex-wrap: wrap; }
.logo-row input[type=file] { border: none; padding: 0; margin: 0; width: auto; font-size: 0.78rem; }
#logo-preview {
  width: 52px; height: 52px;
  object-fit: contain;
  border: 1px solid var(--line-dark);
  border-radius: var(--r);
  background: var(--surface);
  padding: 3px;
}

.branding-lock {
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  background: var(--green-soft);
  border: 1px dashed var(--green);
  border-radius: var(--r);
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

#branding-card.locked input, #branding-card.locked button.btn-line { opacity: 0.45; pointer-events: none; }

/* ── Auth: code-stap, Google, links ───────────────────────────────────── */
.auth-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1rem 0;
  color: var(--faded);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }

.link-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.78rem;
  cursor: pointer;
  padding: 0;
  margin: -0.4rem 0 1rem;
  display: block;
  text-decoration: underline;
}
.link-btn:hover { color: var(--green); }
#code-back { margin: 0.85rem auto 0; }

.verify-info { font-size: 0.85rem; color: var(--muted); line-height: 1.6; margin-bottom: 1.25rem; }
.verify-info b { color: var(--ink); }

#code-input { font-family: var(--mono); font-size: 1.15rem; letter-spacing: 0.35em; text-align: center; }
