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

:root {
  --amber:   #f59e0b;
  --amber-d: #d97706;
  --green:   #10b981;
  --red:     #ef4444;
  --navy:    #1e293b;
  --navy-l:  #334155;
  --bg:      #f1f5f9;
  --card:    #ffffff;
  --border:  #e2e8f0;
  --text:    #1e293b;
  --muted:   #64748b;
  --radius:  12px;
  --shadow:  0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.05);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

/* ── Header ─────────────────────────────────────── */
.app-header {
  background: var(--navy);
  color: #fff;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-header .logo {
  font-size: 1.2rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-header .user-info {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: .9rem;
  color: #94a3b8;
}

/* ── Buttons ─────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border: none;
  border-radius: 8px;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .1s;
  text-decoration: none;
}
.btn:active { transform: scale(.98); }

.btn-primary   { background: var(--amber);   color: #000; }
.btn-primary:hover { background: var(--amber-d); }
.btn-ghost     { background: transparent; color: #94a3b8; }
.btn-ghost:hover { color: #fff; }
.btn-danger    { background: #fef2f2; color: var(--red); }
.btn-danger:hover { background: #fee2e2; }
.btn-sm        { padding: 6px 12px; font-size: .8rem; }
.btn-full      { width: 100%; }

/* ── Cards ───────────────────────────────────────── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

/* ── Forms ───────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: .85rem; font-weight: 600; color: var(--navy-l); }

.form-group input,
.form-group select {
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: .95rem;
  outline: none;
  transition: border-color .15s;
  background: #fff;
}
.form-group input:focus,
.form-group select:focus { border-color: var(--amber); }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.radio-group { display: flex; gap: 8px; }
.radio-group label {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: .9rem;
  font-weight: 500;
  transition: border-color .15s, background .15s;
}
.radio-group input[type=radio] { display: none; }
.radio-group input[type=radio]:checked + label {
  border-color: var(--amber);
  background: #fffbeb;
  color: var(--amber-d);
}

.error-msg {
  background: #fef2f2;
  color: var(--red);
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: .875rem;
  display: none;
}
.error-msg.visible { display: block; }

/* ── Auth pagina ─────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--navy) 0%, #0f172a 100%);
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  overflow: hidden;
}

.auth-card-header {
  background: var(--navy);
  padding: 28px 28px 20px;
  text-align: center;
}

.auth-card-header .icon { font-size: 2.5rem; margin-bottom: 8px; }
.auth-card-header h1 { color: #fff; font-size: 1.4rem; }
.auth-card-header p { color: #94a3b8; font-size: .875rem; margin-top: 4px; }

.auth-tabs {
  display: flex;
  border-bottom: 1.5px solid var(--border);
  background: #f8fafc;
}

.auth-tab {
  flex: 1;
  padding: 14px;
  border: none;
  background: none;
  font-size: .9rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: color .15s;
  border-bottom: 2.5px solid transparent;
  margin-bottom: -1.5px;
}
.auth-tab.active {
  color: var(--amber-d);
  border-bottom-color: var(--amber);
  background: #fff;
}

.auth-form { padding: 24px; display: flex; flex-direction: column; gap: 16px; }

/* ── Dashboard layout ────────────────────────────── */
.app-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: calc(100vh - 60px);
}

.sidebar {
  background: var(--card);
  border-right: 1.5px solid var(--border);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-title {
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  padding: 0 8px;
  margin-bottom: 4px;
}

.inst-card {
  padding: 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background .15s;
  border: 1.5px solid transparent;
}
.inst-card:hover { background: var(--bg); }
.inst-card.active {
  background: #fffbeb;
  border-color: var(--amber);
}

.inst-card .inst-naam { font-weight: 600; font-size: .95rem; }
.inst-card .inst-meta { font-size: .8rem; color: var(--muted); margin-top: 2px; }
.inst-card .inst-kwp  { font-size: .85rem; color: var(--amber-d); font-weight: 600; }

.sidebar-add-btn {
  margin-top: auto;
  width: 100%;
}

/* ── Hoofd content ───────────────────────────────── */
.main-content {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
}

.content-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
}

/* ── Empty state ─────────────────────────────────── */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--muted);
  text-align: center;
  padding: 60px;
}
.empty-state .empty-icon { font-size: 3.5rem; }
.empty-state h2 { color: var(--text); }
.empty-state p { font-size: .95rem; max-width: 320px; }

/* ── Installatie header ──────────────────────────── */
.inst-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.inst-title { font-size: 1.25rem; font-weight: 700; }
.inst-subtitle { font-size: .875rem; color: var(--muted); margin-top: 2px; }

.stat-row { display: flex; gap: 20px; flex-wrap: wrap; }
.stat { text-align: center; }
.stat .stat-val { font-size: 1.5rem; font-weight: 700; color: var(--amber-d); }
.stat .stat-label { font-size: .75rem; color: var(--muted); }

/* ── Chart ───────────────────────────────────────── */
.chart-title {
  font-size: .95rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--navy-l);
}

/* ── Advies widget ───────────────────────────────── */
.advies-form { display: flex; flex-direction: column; gap: 12px; }

.advies-slot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  transition: border-color .15s;
}
.advies-slot.groen { border-color: var(--green); background: #f0fdf4; }

.slot-time { flex: 1; }
.slot-day  { font-size: .75rem; color: var(--muted); }
.slot-uur  { font-size: .9rem; font-weight: 600; }

.slot-badge {
  padding: 3px 8px;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 700;
  background: #f1f5f9;
  color: var(--muted);
}
.slot-badge.groen { background: #dcfce7; color: #15803d; }
.slot-badge.geel  { background: #fefce8; color: #a16207; }

/* ── Modal ───────────────────────────────────────── */
dialog {
  border: none;
  border-radius: 16px;
  padding: 0;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  max-width: 480px;
  width: 90%;
}
dialog::backdrop { background: rgba(0,0,0,.5); backdrop-filter: blur(2px); }

.modal-header {
  padding: 20px 24px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h2 { font-size: 1.1rem; }
.modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--muted);
  padding: 4px;
  line-height: 1;
}

.modal-body { padding: 20px 24px 24px; display: flex; flex-direction: column; gap: 14px; }

/* ── Richting knoppen ────────────────────────────── */
.richting-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.richting-btn {
  padding: 8px 4px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: #fff;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  text-align: center;
}
.richting-btn:hover   { border-color: var(--amber); }
.richting-btn.active  { border-color: var(--amber); background: #fffbeb; color: var(--amber-d); }

/* ── Loading spinner ─────────────────────────────── */
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--amber);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 40px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-state { display: flex; justify-content: center; align-items: center; min-height: 200px; }

/* ── Responsive ──────────────────────────────────── */
@media (max-width: 900px) {
  .app-layout { grid-template-columns: 1fr; }
  .sidebar {
    border-right: none;
    border-bottom: 1.5px solid var(--border);
    flex-direction: row;
    flex-wrap: wrap;
    padding: 12px;
  }
  .sidebar-title { display: none; }
  .sidebar-add-btn { margin-top: 0; width: auto; }
  .content-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .form-row { grid-template-columns: 1fr; }
  .main-content { padding: 16px; }
}
