:root { --bg:#f8fafc; --card:#fff; --line:#e2e8f0; --text:#0f172a; --muted:#64748b; --primary:#2563eb; --danger:#dc2626; }
* { box-sizing: border-box; }
body { margin:0; font-family: system-ui, -apple-system, "Segoe UI", sans-serif; background:var(--bg); color:var(--text); }
a { color: var(--primary); }
main { max-width: 1100px; margin: 0 auto; padding: 1rem; }
.topbar { display:flex; gap:1.5rem; align-items:center; padding:.75rem 1rem; background:var(--card); border-bottom:1px solid var(--line); }
.topbar nav a { text-decoration:none; color:var(--muted); padding:.3rem .6rem; border-radius:6px; }
.topbar nav a.active { background:#eff6ff; color:var(--primary); font-weight:600; }
.me { margin-left:auto; color:var(--muted); font-size:.9rem; }
.dot { display:inline-block; width:.7rem; height:.7rem; border-radius:50%; margin-right:.35rem; vertical-align:middle; }
.btn { border:1px solid var(--line); background:var(--card); padding:.45rem .8rem; border-radius:8px; cursor:pointer; font:inherit; color:inherit; text-decoration:none; }
.btn.primary { background:var(--primary); border-color:var(--primary); color:#fff; }
.btn.danger { color:var(--danger); border-color:#fecaca; }
.toolbar { display:flex; gap:.5rem; align-items:center; flex-wrap:wrap; margin-bottom:1rem; }
.toolbar h2 { font-size:1.1rem; margin:0 auto 0 .5rem; }
.now { display:flex; gap:.75rem; flex-wrap:wrap; margin-bottom:1rem; }
.now .card { background:var(--card); border:1px solid var(--line); border-radius:10px; padding:.6rem .9rem; min-width:200px; }
.now .free { color:#16a34a; font-weight:600; }
.now .busy { color:#b45309; font-weight:600; }
.grid-wrap { overflow-x:auto; }
.grid { width:100%; border-collapse:separate; border-spacing:0; background:var(--card); border:1px solid var(--line); border-radius:10px; overflow:hidden; }
.grid th, .grid td { border-bottom:1px solid var(--line); padding:.5rem; vertical-align:top; text-align:left; }
.grid th { background:#f1f5f9; font-size:.85rem; color:var(--muted); }
.grid td.day { width:110px; font-weight:600; white-space:nowrap; }
.grid tr.today td.day { color:var(--primary); }
.grid td.slot { min-width:220px; cursor:pointer; }
.grid td.slot:hover { background:#f8fafc; }
.chip { display:block; border-left:4px solid; background:#f8fafc; border-radius:6px; padding:.25rem .5rem; margin-bottom:.3rem; font-size:.85rem; cursor:pointer; }
.chip.mine { background:#eff6ff; }
.chip small { color:var(--muted); }
.mine-list { list-style:none; padding:0; }
.mine-list li { background:var(--card); border:1px solid var(--line); border-radius:8px; padding:.5rem .75rem; margin-bottom:.4rem; cursor:pointer; }
.muted { color:var(--muted); }
.error { color:var(--danger); min-height:1em; }
dialog { border:none; border-radius:12px; padding:1.25rem; width:min(480px, 95vw); box-shadow:0 20px 50px rgba(0,0,0,.2); }
dialog label { display:block; margin-bottom:.75rem; font-size:.9rem; }
dialog input, dialog select, dialog textarea { display:block; width:100%; margin-top:.25rem; padding:.45rem; border:1px solid var(--line); border-radius:8px; font:inherit; }
.row { display:flex; gap:.75rem; } .row label { flex:1; min-width:0; }
.actions { display:flex; gap:.5rem; align-items:center; } .spacer { flex:1; }
.login { text-align:center; margin-top:15vh; }

.seg { display:inline-flex; }
.seg .btn { border-radius:0; }
.seg .btn:first-child { border-radius:8px 0 0 8px; }
.seg .btn:last-child { border-radius:0 8px 8px 0; border-left:none; }
.seg .btn.on { background:#eff6ff; color:var(--primary); font-weight:600; }
.month { display:grid; grid-template-columns:repeat(7, minmax(0, 1fr)); background:var(--card); border:1px solid var(--line); border-radius:10px; overflow:hidden; }
.month .hd { background:#f1f5f9; font-size:.85rem; color:var(--muted); padding:.4rem .5rem; border-bottom:1px solid var(--line); }
.month .cell { min-height:105px; padding:.3rem .35rem; border-right:1px solid var(--line); border-bottom:1px solid var(--line); cursor:pointer; }
.month .cell:nth-child(7n) { border-right:none; }
.month .cell:hover { background:#f8fafc; }
.month .cell.out { background:#fafafa; color:#cbd5e1; }
.month .cell.today .num { background:var(--primary); color:#fff; border-radius:999px; padding:0 .4rem; }
.month .num { font-size:.8rem; font-weight:600; display:inline-block; margin-bottom:.2rem; }
.month .chip { font-size:.75rem; padding:.1rem .35rem; margin-bottom:.2rem; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.month .more { font-size:.75rem; color:var(--muted); }
.legend { font-size:.85rem; color:var(--muted); }
.legend span { margin-right:1rem; }
.daylist { display:none; }
.month .cell.sel { box-shadow: inset 0 0 0 2px var(--primary); }

@media (max-width: 640px) {
  main { padding:.75rem; padding-bottom:5rem; }
  .topbar { gap:.75rem; padding:.6rem .75rem; position:sticky; top:0; z-index:5; }
  .topbar strong { font-size:1rem; }
  .me-name { display:none; }
  .btn { min-height:40px; }
  input, select, textarea { font-size:16px !important; } /* voorkomt inzoomen op iPhone */

  .toolbar { gap:.4rem; }
  .toolbar h2 { order:-1; flex-basis:100%; margin:0 0 .25rem; font-size:1.05rem; }
  .seg { margin-left:auto; }
  .fab { position:fixed; right:1rem; bottom:calc(1rem + env(safe-area-inset-bottom)); z-index:10;
         width:56px; height:56px; border-radius:50%; font-size:1.8rem; line-height:1; padding:0;
         box-shadow:0 6px 18px rgba(37,99,235,.4); }
  .fab-label { display:none; }

  .now { display:grid; grid-template-columns:1fr 1fr; gap:.5rem; }
  .now .card { min-width:0; padding:.5rem .65rem; font-size:.9rem; }

  /* Week: elke dag als kaart, auto's onder elkaar */
  .grid, .grid tbody, .grid tr, .grid td { display:block; width:100%; }
  .grid { border:none; background:none; }
  .grid tr:first-child { display:none; }
  .grid tr { background:var(--card); border:1px solid var(--line); border-radius:10px; margin-bottom:.5rem; overflow:hidden; }
  .grid td { border-bottom:none; }
  .grid td.day { width:auto; padding:.5rem .75rem .25rem; }
  .grid td.slot { min-width:0; display:flex; gap:.5rem; align-items:flex-start; padding:.35rem .75rem; border-top:1px solid #f1f5f9; min-height:40px; }
  .grid td.slot::before { content:attr(data-carname); flex:0 0 72px; font-size:.8rem; color:var(--muted); padding-top:.3rem; }
  .grid td.slot .chip { flex:1; margin:0 0 .25rem; }
  .grid td.slot { flex-wrap:wrap; }
  .grid td.slot .chip + .chip { margin-left:80px; }

  /* Maand: gekleurde balkjes, details van de gekozen dag eronder */
  .month .hd { text-align:center; padding:.3rem 0; font-size:.75rem; }
  .month .cell { min-height:58px; padding:.2rem; text-align:center; }
  .month .num { font-size:.8rem; }
  .month .chip { font-size:0; height:5px; padding:0; margin:2px 1px; border-left:none; border-radius:3px; }
  .month .chip { background:var(--c); }
  .month .more { display:none; }
  .daylist { display:block; margin-top:.75rem; background:var(--card); border:1px solid var(--line); border-radius:10px; padding:.75rem; }
  .daylist[hidden] { display:none; }
  .daylist-hd { display:flex; align-items:center; justify-content:space-between; margin-bottom:.5rem; }
  .daylist-hd h3 { margin:0; font-size:1rem; }
  .daylist .chip { font-size:.9rem; padding:.45rem .6rem; }

  dialog { width:100vw; max-width:100vw; margin:auto 0 0; border-radius:16px 16px 0 0; padding:1rem 1rem calc(1rem + env(safe-area-inset-bottom)); max-height:92vh; overflow:auto; }
  .row { flex-direction:column; gap:0; }
  .legend { text-align:center; }
}
