:root {
  --bg: #0f1419;
  --bg2: #161d27;
  --bg3: #1c2533;
  --border: #2a3544;
  --text: #e8eef6;
  --muted: #8b9bb0;
  --accent: #3b82f6;
  --accent-h: #2563eb;
  --ok: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --radius: 10px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 1.5rem; background: radial-gradient(ellipse at top, #1a2740 0%, var(--bg) 60%);
}
.login-card {
  width: 100%; max-width: 380px; background: var(--bg2);
  border: 1px solid var(--border); border-radius: 14px; padding: 2rem;
  box-shadow: 0 20px 50px rgba(0,0,0,.35);
}
.login-card h1 { margin: 0 0 .25rem; font-size: 1.4rem; }
.login-card .sub { color: var(--muted); margin: 0 0 1.5rem; font-size: .9rem; }
.login-card .error {
  background: rgba(239,68,68,.15); color: #fca5a5; border: 1px solid rgba(239,68,68,.35);
  padding: .65rem .8rem; border-radius: 8px; margin-bottom: 1rem; font-size: .9rem;
}

.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; background: var(--bg2); border-right: 1px solid var(--border);
  padding: 1.25rem 0; flex-shrink: 0; display: flex; flex-direction: column;
}
.brand { padding: 0 1.25rem 1.25rem; border-bottom: 1px solid var(--border); margin-bottom: .75rem; }
.brand strong { display: block; font-size: 1.05rem; }
.brand span { color: var(--muted); font-size: .75rem; }
.nav { display: flex; flex-direction: column; gap: .2rem; padding: 0 .75rem; flex: 1; }
.nav button {
  appearance: none; border: 0; background: transparent; color: var(--muted);
  text-align: left; padding: .65rem .85rem; border-radius: 8px; cursor: pointer;
  font: inherit; font-size: .92rem;
}
.nav button:hover { background: var(--bg3); color: var(--text); }
.nav button.active { background: rgba(59,130,246,.15); color: #93c5fd; }
.sidebar-foot { padding: 1rem 1.25rem; border-top: 1px solid var(--border); font-size: .8rem; color: var(--muted); }
.sidebar-foot a, .sidebar-foot button.linkish {
  color: var(--muted); background: none; border: 0; cursor: pointer; font: inherit; padding: 0;
}
.sidebar-foot a:hover, .sidebar-foot button.linkish:hover { color: var(--text); }

.main { flex: 1; padding: 1.25rem 1.5rem 2rem; overflow-x: hidden; min-width: 0; }
.topbar { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; }
.topbar h2 { margin: 0; font-size: 1.25rem; font-weight: 600; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }

.btn {
  appearance: none; border: 1px solid var(--border); background: var(--bg3); color: var(--text);
  padding: .5rem .9rem; border-radius: 8px; cursor: pointer; font: inherit; font-size: .88rem;
}
.btn:hover { border-color: #3d4f66; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-h); }
.btn-danger { background: transparent; border-color: rgba(239,68,68,.4); color: #fca5a5; }
.btn-sm { padding: .3rem .55rem; font-size: .8rem; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .75rem; margin-bottom: 1.25rem; }
.card {
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem;
}
.card .label { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; }
.card .value { font-size: 1.6rem; font-weight: 650; margin-top: .25rem; }
.panel {
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem; margin-bottom: 1rem;
}
.panel h3 { margin: 0 0 .75rem; font-size: .95rem; color: var(--muted); font-weight: 600; }

table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { text-align: left; padding: .6rem .5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 550; font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; }
tr:hover td { background: rgba(255,255,255,.02); }
.muted { color: var(--muted); }
.badge {
  display: inline-block; padding: .15rem .45rem; border-radius: 999px; font-size: .72rem;
  background: var(--bg3); border: 1px solid var(--border); color: var(--muted);
}
.badge.nieuw { color: #93c5fd; border-color: rgba(59,130,246,.35); }
.badge.benaderd { color: #c4b5fd; border-color: rgba(139,92,246,.35); }
.badge.gesprek { color: #fcd34d; border-color: rgba(245,158,11,.35); }
.badge.voorstel { color: #fdba74; border-color: rgba(249,115,22,.35); }
.badge.won { color: #86efac; border-color: rgba(34,197,94,.35); }
.badge.lost { color: #fca5a5; border-color: rgba(239,68,68,.35); }
.badge.open { color: #fcd34d; }
.badge.done { color: #86efac; }

.form-grid { display: grid; gap: .75rem; grid-template-columns: 1fr 1fr; }
.form-grid .full { grid-column: 1 / -1; }
label { display: block; font-size: .78rem; color: var(--muted); margin-bottom: .3rem; }
input, select, textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: .55rem .7rem; font: inherit; font-size: .9rem;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(59,130,246,.45); border-color: var(--accent); }
textarea { min-height: 80px; resize: vertical; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.55); display: none;
  align-items: flex-start; justify-content: center; padding: 2rem 1rem; z-index: 50; overflow-y: auto;
}
.modal-backdrop.open { display: flex; }
.modal {
  width: 100%; max-width: 520px; background: var(--bg2); border: 1px solid var(--border);
  border-radius: 12px; padding: 1.25rem; margin-top: 1rem;
}
.modal h3 { margin: 0 0 1rem; }
.modal-actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: 1rem; }
.search { min-width: 180px; max-width: 260px; }

.pipeline { display: grid; grid-template-columns: repeat(6, minmax(120px, 1fr)); gap: .6rem; overflow-x: auto; }
.pipe-col {
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: .6rem; min-height: 180px;
}
.pipe-col h4 { margin: 0 0 .5rem; font-size: .75rem; color: var(--muted); text-transform: uppercase; }
.deal-card {
  background: var(--bg3); border: 1px solid var(--border); border-radius: 8px;
  padding: .55rem .6rem; margin-bottom: .45rem; font-size: .82rem; cursor: pointer;
}
.deal-card:hover { border-color: var(--accent); }
.deal-card .val { color: var(--muted); font-size: .75rem; margin-top: .2rem; }

.activity-item { padding: .55rem 0; border-bottom: 1px solid var(--border); font-size: .88rem; }
.activity-item:last-child { border-bottom: 0; }
.toast {
  position: fixed; bottom: 1rem; right: 1rem; background: var(--bg3); border: 1px solid var(--border);
  padding: .7rem 1rem; border-radius: 8px; display: none; z-index: 100; font-size: .88rem;
}
.toast.show { display: block; }
.toast.err { border-color: rgba(239,68,68,.5); color: #fca5a5; }

.menu-toggle {
  display: none; appearance: none; border: 1px solid var(--border); background: var(--bg3);
  color: var(--text); padding: .4rem .65rem; border-radius: 8px; cursor: pointer; font: inherit;
}

@media (max-width: 860px) {
  .app-shell { flex-direction: column; }
  .sidebar {
    width: 100%; border-right: 0; border-bottom: 1px solid var(--border);
    padding: .75rem 0; max-height: none;
  }
  .sidebar.collapsed .nav { display: none; }
  .sidebar.collapsed .sidebar-foot { display: none; }
  .brand { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0; border: 0; padding: 0 1rem; }
  .menu-toggle { display: inline-block; }
  .nav { flex-direction: row; flex-wrap: wrap; padding: .75rem; }
  .form-grid { grid-template-columns: 1fr; }
  .pipeline { grid-template-columns: repeat(2, minmax(140px, 1fr)); }
  .main { padding: 1rem; }
}
