:root {
  --primary: #1a4d3e;
  --primary-dark: #12382d;
  --accent: #c4a35a;
  --bg: #f3f5f4;
  --surface: #ffffff;
  --text: #1c2421;
  --muted: #5b6b64;
  --border: #d7deda;
  --danger: #a33b2f;
  --success: #1f6b45;
  --warning: #9a6b12;
  --info: #2a5f7a;
  --sidebar: #142f27;
  --radius: 10px;
  --shadow: 0 10px 30px rgba(20, 47, 39, 0.08);
  --font: "Segoe UI", "Gill Sans", Candara, Calibri, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(196, 163, 90, 0.12), transparent 35%),
    linear-gradient(180deg, #eef3f0 0%, var(--bg) 40%, #e8eeeb 100%);
  min-height: 100vh;
}

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

.app-shell { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.sidebar {
  background: linear-gradient(180deg, var(--sidebar), #0f241e);
  color: #edf3f0;
  padding: 1.25rem 1rem 2rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
}
.brand {
  display: flex;
  flex-direction: column;
  gap: .2rem;
  padding: .5rem .75rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
  margin-bottom: 1rem;
}
.brand-name { font-size: 1.5rem; font-weight: 700; letter-spacing: .04em; color: #fff; }
.brand-sub { font-size: .8rem; color: rgba(237,243,240,.7); }

.nav a {
  display: block;
  color: rgba(237,243,240,.88);
  padding: .55rem .75rem;
  border-radius: 8px;
  margin-bottom: .15rem;
  text-decoration: none;
}
.nav a:hover, .nav a.active { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.nav a.disabled { opacity: .45; pointer-events: none; }
.nav .nav-section {
  margin: 1rem .75rem .35rem;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(237,243,240,.45);
}

.content { padding: 1.25rem 1.5rem 2.5rem; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.topbar h1 { margin: 0; font-size: 1.55rem; }
.user-meta { color: var(--muted); font-size: .9rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .9rem;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
}
.stat .label { color: var(--muted); font-size: .85rem; }
.stat .value { font-size: 1.35rem; font-weight: 700; margin-top: .35rem; color: var(--primary-dark); }

.table-wrap { overflow: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: .92rem;
}
table.data th, table.data td {
  text-align: left;
  padding: .65rem .55rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
table.data th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
table.data tr:hover td { background: #f7faf8; }

.badge {
  display: inline-block;
  padding: .15rem .5rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
  background: #e7eeea;
  color: var(--primary-dark);
}
.badge.verzonden, .badge.bekeken { background: #e3eef4; color: var(--info); }
.badge.geaccepteerd, .badge.ok { background: #e5f4eb; color: var(--success); }
.badge.afgewezen, .badge.geannuleerd, .badge.fail { background: #f8e8e6; color: var(--danger); }
.badge.concept { background: #eee; color: #555; }
.badge.warning { background: #fff3d6; color: var(--warning); }

.btn, button.btn {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  border: 1px solid transparent;
  background: var(--primary);
  color: #fff;
  padding: .55rem .9rem;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  text-decoration: none;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; color: #fff; }
.btn-secondary { background: #fff; color: var(--primary); border-color: var(--border); }
.btn-secondary:hover { background: #f4f7f5; color: var(--primary-dark); }
.btn-danger { background: var(--danger); }
.btn-sm { padding: .35rem .65rem; font-size: .85rem; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }

label { display: flex; flex-direction: column; gap: .35rem; font-size: .9rem; margin-bottom: .8rem; }
input, select, textarea {
  font: inherit;
  padding: .55rem .65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}
textarea { min-height: 90px; resize: vertical; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .8rem; }
.stack > * + * { margin-top: .5rem; }
.muted { color: var(--muted); }
.toolbar { display: flex; flex-wrap: wrap; gap: .6rem; justify-content: space-between; align-items: end; margin-bottom: 1rem; }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: end; }
.filters label { margin: 0; }
.filters input, .filters select { min-width: 140px; }

.alert { padding: .75rem 1rem; border-radius: 8px; margin-bottom: .8rem; border: 1px solid transparent; }
.alert-success { background: #e8f6ee; border-color: #b9e0c8; color: var(--success); }
.alert-error { background: #fbeeee; border-color: #efc5bf; color: var(--danger); }
.alert-warning { background: #fff7e6; border-color: #f0d59a; color: var(--warning); }
.alert-info { background: #eaf4f9; border-color: #bdd8e6; color: var(--info); }

.auth-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 1rem;
  background:
    linear-gradient(135deg, rgba(26,77,62,.92), rgba(20,47,39,.95)),
    radial-gradient(circle at 20% 20%, rgba(196,163,90,.35), transparent 40%);
}
.auth-card {
  width: min(440px, 100%);
  background: #fff;
  border-radius: 14px;
  padding: 1.5rem;
  box-shadow: 0 20px 50px rgba(0,0,0,.2);
}
.auth-card h1 { margin-top: 0; color: var(--primary); }
.install-card { width: min(720px, 100%); }
.check-list { list-style: none; padding: 0; }
.check-list li { padding: .4rem 0; border-bottom: 1px solid var(--border); }
.check-list .ok strong { color: var(--success); }
.check-list .fail strong { color: var(--danger); }

.quote-lines { width: 100%; }
.quote-lines .line-row {
  display: grid;
  grid-template-columns: 1.2fr .7fr .7fr .7fr .6fr .5fr auto;
  gap: .4rem;
  margin-bottom: .45rem;
  align-items: start;
  padding: .5rem;
  background: #f8faf9;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.quote-lines .line-row.heading-row { background: #eef3f0; }
.totals-box {
  max-width: 360px;
  margin-left: auto;
  background: #f7faf8;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
}
.totals-box .row { display: flex; justify-content: space-between; margin: .3rem 0; }
.totals-box .grand { font-weight: 700; font-size: 1.1rem; border-top: 1px solid var(--border); padding-top: .5rem; margin-top: .5rem; }
.warning-banner { background: #fff3d6; border: 1px solid #f0d59a; color: var(--warning); padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; }

.wysiwyg-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  margin-bottom: .35rem;
  align-items: center;
}
.wysiwyg-toolbar button {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 6px;
  padding: .25rem .55rem;
  cursor: pointer;
  font: inherit;
}
.wysiwyg-toolbar button:hover { background: #f4f7f5; }
.wysiwyg-sep {
  width: 1px;
  height: 1.2rem;
  background: var(--border);
  margin: 0 .15rem;
}
.wysiwyg-editor {
  min-height: 90px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .55rem .65rem;
  background: #fff;
}
.wysiwyg-editor:focus { outline: 2px solid rgba(26,77,62,.25); }
.wysiwyg-editor ul,
.wysiwyg-editor ol,
.richtext ul,
.richtext ol {
  margin: .4rem 0 .4rem 1.25rem;
  padding-left: 1rem;
}
.wysiwyg-editor li,
.richtext li {
  margin: .2rem 0;
}
details.cat-texts {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .65rem .85rem;
  margin-bottom: .65rem;
  background: #f8faf9;
}
details.cat-texts summary { cursor: pointer; margin-bottom: .5rem; }

.mobile-toggle { display: none; }

/* Busy / loading overlay */
.busy-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(15, 36, 30, 0.55);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  padding: 1.25rem;
}
.busy-overlay.is-visible {
  display: flex;
}
.busy-card {
  background: #fff;
  border-radius: 14px;
  padding: 1.5rem 1.75rem;
  min-width: min(320px, 92vw);
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(215, 222, 218, 0.9);
}
.busy-spinner {
  width: 42px;
  height: 42px;
  margin: 0 auto 1rem;
  border-radius: 50%;
  border: 3px solid #d7deda;
  border-top-color: var(--primary);
  animation: busy-spin .75s linear infinite;
}
.busy-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--primary-dark);
}
.busy-text {
  margin: .45rem 0 0;
  color: var(--muted);
  font-size: .92rem;
  line-height: 1.4;
}
@keyframes busy-spin {
  to { transform: rotate(360deg); }
}
body.is-busy {
  overflow: hidden;
}

@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .quote-lines .line-row { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(280px, 86vw); transform: translateX(-105%); transition: transform .2s ease; z-index: 30; }
  .sidebar.open { transform: translateX(0); }
  .mobile-toggle { display: inline-flex; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr; }
  .content { padding: 1rem; }
}

/* Print / PDF */
@media print {
  .sidebar, .no-print, .topbar .actions, .mobile-toggle { display: none !important; }
  .app-shell { display: block; }
  .content { padding: 0; }
  body { background: #fff; }
  .card { box-shadow: none; border: none; }
}
