:root {
  --bg: #f4f1ea;
  --panel: #ffffff;
  --ink: #2b2b2b;
  --muted: #7a7468;
  --accent: #2e7d32;       /* Wiesn-Grün */
  --accent-dark: #1b5e20;
  --accent2: #b71c1c;      /* Rot */
  --line: #e0dccf;
  --tile: #eef7ee;
  --tile-border: #bcd9bd;
  --warn: #c79100;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 14px rgba(0,0,0,.05);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.45;
}
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 15px; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  border: none; border-radius: 8px; padding: 10px 16px;
  font-size: 15px; font-weight: 600; background: var(--accent); color: #fff;
  transition: background .15s, transform .05s;
}
.btn:hover { background: var(--accent-dark); }
.btn:active { transform: translateY(1px); }
.btn.secondary { background: #efece4; color: var(--ink); border: 1px solid var(--line); }
.btn.secondary:hover { background: #e6e2d8; }
.btn.danger { background: var(--accent2); }
.btn.danger:hover { background: #8e1414; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.ghost { background: transparent; color: var(--accent-dark); padding: 4px 8px; }
.btn.ghost:hover { background: rgba(46,125,50,.08); }

.input, select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; color: var(--ink);
}
.input:focus, select:focus, textarea:focus { outline: 2px solid var(--tile-border); outline-offset: -1px; }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.pill { display:inline-block; font-size:12px; padding:2px 8px; border-radius:999px; background:#efece4; color:var(--muted); }
.pill.self { background:#fff3d6; color:#8a6d00; }

/* ── Login / Landing ── */
.landing {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1200px 400px at 50% -10%, rgba(46,125,50,.12), transparent),
    var(--bg);
}
.landing-card {
  width: 100%; max-width: 430px; background: var(--panel);
  border-radius: 16px; box-shadow: var(--shadow); padding: 32px 28px;
  border-top: 6px solid var(--accent);
}
.landing-card h1 { margin: 0 0 4px; font-size: 26px; }
.landing-card .sub { color: var(--muted); margin-bottom: 22px; }
.landing-card .btn { width: 100%; justify-content: center; margin-top: 10px; }
.divider { display:flex; align-items:center; gap:10px; color:var(--muted); font-size:13px; margin:20px 0; }
.divider::before, .divider::after { content:""; flex:1; height:1px; background:var(--line); }
.err { color: var(--accent2); font-size: 14px; margin-top: 8px; min-height: 18px; }
.ok  { color: var(--accent-dark); font-size: 14px; margin-top: 8px; }

/* ── Header ── */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: var(--accent-dark); color: #fff;
  display: flex; align-items: center; gap: 14px;
  padding: 10px 18px; box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.topbar h1 { font-size: 18px; margin: 0; font-weight: 700; }
.topbar .tag { font-size: 12px; opacity: .8; }
.topbar .btn { background: rgba(255,255,255,.15); }
.topbar .btn:hover { background: rgba(255,255,255,.28); }

/* ── Layout des Boards ── */
.board { display: flex; gap: 0; height: calc(100vh - 52px); }
.sidebar {
  width: 290px; min-width: 250px; background: var(--panel);
  border-right: 1px solid var(--line); display: flex; flex-direction: column;
}
.sidebar-head { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.sidebar-head h2 { margin: 0 0 8px; font-size: 15px; }
.helper-list { flex: 1; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 7px; }

.helper-tile {
  background: var(--tile); border: 1px solid var(--tile-border);
  border-radius: 8px; padding: 8px 10px; cursor: grab; user-select: none;
  display: flex; align-items: center; gap: 8px; font-size: 14px;
  transition: box-shadow .12s, transform .05s;
}
.helper-tile:hover { box-shadow: var(--shadow); }
.helper-tile.dragging { opacity: .5; }
.helper-tile .avail-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); flex: none; }
.helper-tile .name { flex: 1; font-weight: 600; }
.helper-tile .x { color: var(--muted); font-size: 16px; padding: 0 2px; }
.helper-tile .x:hover { color: var(--accent2); }

.main { flex: 1; overflow-y: auto; padding: 16px 18px; }

/* Tagewahl */
.day-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.day-tab {
  padding: 7px 13px; border-radius: 999px; border: 1px solid var(--line);
  background: #fff; font-size: 14px; font-weight: 600; color: var(--ink);
}
.day-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.day-tab .d { font-size: 12px; opacity: .85; font-weight: 500; }

/* Aufgaben-Karten */
.section-title { font-size: 14px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 18px 0 8px; }
.task-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }

.task-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden;
}
.task-card.area { border-top: 4px solid var(--accent); }
.task-card.task { border-top: 4px solid var(--warn); }
.task-card.over { outline: 3px dashed var(--accent); outline-offset: -3px; }
.task-head { padding: 10px 12px 8px; }
.task-head .t-title { font-weight: 700; font-size: 16px; display:flex; align-items:center; gap:8px; }
.task-head .t-meta { font-size: 13px; color: var(--muted); margin-top: 2px; display:flex; gap:10px; flex-wrap:wrap; }
.task-head .t-time { color: var(--accent-dark); font-weight: 600; }
.count {
  font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px;
  background: #eef7ee; color: var(--accent-dark);
}
.count.full { background: #e8f5e9; }
.count.over { background: #ffebee; color: var(--accent2); }
.count.under { background: #fff3d6; color: #8a6d00; }

.assigned-zone { padding: 6px 12px 12px; min-height: 46px; display: flex; flex-wrap: wrap; gap: 6px; }
.assigned-chip {
  background: #eef2ff; border: 1px solid #c9d4f5; color: #2a3b73;
  border-radius: 7px; padding: 4px 6px 4px 9px; font-size: 13px; font-weight: 600;
  display: flex; align-items: center; gap: 6px;
}
.assigned-chip .rm { cursor: pointer; color: #7080b8; font-weight: 700; }
.assigned-chip .rm:hover { color: var(--accent2); }
.empty-hint { color: #bbb; font-size: 13px; padding: 6px 0; }

.task-foot { border-top: 1px solid var(--line); padding: 6px 10px; display: flex; gap: 6px; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 480px; box-shadow: 0 10px 40px rgba(0,0,0,.3); max-height: 90vh; overflow-y: auto; }
.modal h3 { margin: 0; padding: 16px 18px; border-bottom: 1px solid var(--line); font-size: 18px; }
.modal-body { padding: 18px; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }

.slot-row { display: grid; grid-template-columns: 1.2fr .8fr .8fr auto; gap: 8px; margin-bottom: 8px; align-items: end; }

/* Read-only Plan */
.plan-wrap { max-width: 1000px; margin: 0 auto; padding: 18px; }
.plan-day { background: #fff; border:1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 18px; overflow:hidden; }
.plan-day h2 { margin: 0; padding: 12px 16px; background: var(--accent-dark); color: #fff; font-size: 17px; }
.plan-task { padding: 10px 16px; border-bottom: 1px solid var(--line); }
.plan-task:last-child { border-bottom: none; }
.plan-task .pt-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.plan-task .pt-title { font-weight: 700; }
.plan-task .pt-time { color: var(--accent-dark); font-weight: 600; font-size: 14px; }
.plan-task .pt-people { margin-top: 4px; color: var(--ink); }
.plan-task .pt-people .nm { display:inline-block; background:#eef2ff; border:1px solid #c9d4f5; border-radius:6px; padding:1px 7px; margin:2px 4px 0 0; font-size:13px;}
.plan-task .pt-need { font-size: 12px; }

.center-msg { text-align:center; padding:40px; color:var(--muted); }

/* ── Frei gestaltbares 4-Spalten-Raster ── */
.grid-hint { font-size: 13px; margin-bottom: 10px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pill.area-pill { background: #e8f5e9; color: var(--accent-dark); }
.pill.task-pill { background: #fff3d6; color: #8a6d00; }

.plan-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  align-items: stretch;
}
.grid-cell {
  min-height: 120px;
  border: 2px dashed transparent;
  border-radius: var(--radius);
  display: flex;
  transition: border-color .12s, background .12s;
}
.grid-cell.empty {
  border-color: var(--line);
  background: rgba(0,0,0,.012);
  align-items: center;
  justify-content: center;
}
.grid-cell.cell-over {
  border-color: var(--accent);
  background: rgba(46,125,50,.08);
}
.grid-cell > .task-card { width: 100%; }
.cell-placeholder { color: #cfcabc; font-size: 30px; font-weight: 300; user-select: none; pointer-events: none; }

.grid-controls { display: flex; gap: 8px; margin: 14px 0 4px; }

.unplaced-tray { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; }

/* Karten-Drag */
.task-head { cursor: grab; }
.task-head:active { cursor: grabbing; }
.drag-grip { color: var(--muted); margin-right: 6px; font-size: 13px; letter-spacing: -1px; }
.task-card.card-dragging { opacity: .45; }

@media (max-width: 900px) {
  .plan-grid, .unplaced-tray { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 720px) {
  .board { flex-direction: column; height: auto; }
  .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--line); max-height: 40vh; }
  .helper-tile { cursor: pointer; }
  .plan-grid, .unplaced-tray { grid-template-columns: 1fr; }
}
