/* Capita Overflow Manager — "Klar"
 * Gleiche Design-Sprache wie die uebrigen Capita Web-Tools (Inter + JetBrains Mono,
 * heller SaaS-Look, Capita-Rot als Akzent), Dark/Light pro Nutzer. Keine Emojis.
 */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@500;600;700&display=swap');

:root {
  color-scheme: light;
  --bg:#f6f7f9; --surface:#ffffff; --surface-2:#fbfcfd;
  --ink:#191d25; --ink-2:#444b59; --muted:#7e8696; --faint:#aab0bd;
  --border:#e1e4ea; --line:#eef0f3; --hover:#f4f6fb;
  --accent:#d2232a; --accent-dark:#a81b21; --accent-soft:#fbe9ea; --accent-ink:#a81b21;
  --info:#3b6fd4; --info-bg:#e8edfb; --info-ink:#2f5cab;
  --ok:#1f9d57; --ok-bg:#e4f5ec; --ok-ink:#157a42;
  --mono:'JetBrains Mono', ui-monospace, 'SF Mono', Consolas, monospace;
  --radius:12px; --radius-lg:16px;
  --shadow:0 1px 2px rgba(25,29,37,.04), 0 4px 16px -8px rgba(25,29,37,.10);
  --shadow-lg:0 12px 36px -12px rgba(25,29,37,.22), 0 2px 6px rgba(25,29,37,.06);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg:#0f1421; --surface:#161d2b; --surface-2:#1a2230;
  --ink:#e8edf5; --ink-2:#aeb8c8; --muted:#828ea0; --faint:#5a6476;
  --border:#28313f; --line:#1f2733; --hover:#1c2533;
  --accent:#e2474d; --accent-dark:#c43a40; --accent-soft:#3a1d20; --accent-ink:#f08a8e;
  --info:#5a93e6; --info-bg:#1c2a4440; --info-ink:#8fb4f0;
  --ok:#3cba74; --ok-bg:#15301f; --ok-ink:#7ed6a3;
  --shadow:0 1px 2px rgba(0,0,0,.30), 0 6px 18px -10px rgba(0,0,0,.55);
  --shadow-lg:0 14px 40px -14px rgba(0,0,0,.65), 0 2px 6px rgba(0,0,0,.4);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
.hidden { display: none !important; }

/* ---------- Login / Denied ---------- */
.centered { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); padding: 44px 48px; text-align: center; max-width: 440px; }
.login-card p { color: var(--muted); margin: 14px 0 26px; }
.login-card code, .hint code { font-family: var(--mono); font-size: 12px; background: var(--bg);
  border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; }

/* ---------- Brand / Header ---------- */
.brand { font-size: 18px; font-weight: 800; letter-spacing: -.02em; }
.brand span { font-weight: 500; color: var(--faint); }
header { background: var(--surface); border-bottom: 1px solid var(--border); padding: 13px 30px;
  display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 40; }
.header-right { display: flex; align-items: center; gap: 12px; }
.user-name { color: var(--muted); font-size: 13px; }
.theme-toggle { padding: 7px 9px; display: inline-flex; align-items: center; }
.theme-toggle svg { width: 17px; height: 17px; display: block; }

/* ---------- Layout ---------- */
main { max-width: 1100px; margin: 26px auto; padding: 0 30px 60px; display: flex; flex-direction: column; gap: 18px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); padding: 22px 24px; }
.panel h2 { font-size: 16px; font-weight: 700; letter-spacing: -.01em; margin-bottom: 14px; }
.hint { color: var(--muted); font-size: 13px; margin-bottom: 12px; line-height: 1.5; }
.label-hint { font-weight: 400; color: var(--muted); }

/* ---------- Formular ---------- */
.form-field { display: flex; flex-direction: column; gap: 6px; }
label { font-weight: 600; font-size: 12.5px; color: var(--ink-2); }

input[type="text"], input[type="number"], select, textarea {
  border: 1px solid var(--border); border-radius: var(--radius); padding: 9px 12px; font-size: 13.5px;
  font-family: inherit; background: var(--surface); color: var(--ink); transition: border-color .15s, box-shadow .15s; }
input:hover, select:hover, textarea:hover { border-color: var(--faint); }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.form-actions { display: flex; align-items: center; gap: 12px; margin-top: 16px; flex-wrap: wrap; }
.status-text { color: var(--muted); font-size: 13px; }
.status-text.error { color: var(--accent); font-weight: 600; }

/* ---------- Buttons ---------- */
.btn { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--ink);
  padding: 9px 15px; font-size: 13.5px; font-weight: 600; font-family: inherit; cursor: pointer;
  transition: background .15s, border-color .15s; display: inline-flex; align-items: center; gap: 8px; }
.btn:hover { background: var(--bg); border-color: var(--faint); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--bg); color: var(--ink); border-color: var(--border); }
.btn-mini { padding: 5px 11px; font-size: 12.5px; border-radius: 8px; }
.btn-danger { color: var(--accent); border-color: var(--border); }
.btn-danger:hover { background: var(--accent-soft); border-color: var(--accent-soft); }
.btn-danger-solid { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-danger-solid:hover { background: var(--accent-dark); border-color: var(--accent-dark); }

/* ---------- Tabelle ---------- */
.table-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 14px; flex-wrap: wrap; }
.table-header h2 { margin: 0; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
  font-weight: 700; border-bottom: 1px solid var(--border); padding: 9px 10px; }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--hover); }
.cell-project { font-family: var(--mono); font-size: 13px; white-space: nowrap; }
.cell-actions { white-space: nowrap; text-align: right; }
.cell-meta { font-size: 12px; color: var(--faint); }
.empty { text-align: center; color: var(--muted); padding: 26px; }

/* ---------- Status Badges ---------- */
.badge { display: inline-block; font-size: 12px; font-weight: 600; border-radius: 7px; padding: 2px 9px; white-space: nowrap; }
.badge-on { color: var(--ok-ink); background: var(--ok-bg); }
.badge-off { color: var(--muted); background: var(--line); }

/* ---------- Overflow Manager: Add-Form ---------- */
.add-grid { display: grid; grid-template-columns: 2fr 1fr 1fr auto; gap: 14px 16px; align-items: end; }
.add-grid .form-field { gap: 6px; }

/* Combobox (Projekt-Auswahl: gestyltes, gruppiertes Dropdown statt nativem datalist) */
.combo { position: relative; }
.combo > input { width: 100%; }
.combo-panel { position: absolute; z-index: 60; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); max-height: 300px; overflow-y: auto; padding: 4px; }
.combo-group { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
  font-weight: 700; padding: 9px 10px 4px; position: sticky; top: 0; background: var(--surface); }
.combo-item { padding: 8px 10px; border-radius: 8px; cursor: pointer; font-family: var(--mono); font-size: 13px; color: var(--ink); }
.combo-item:hover { background: var(--hover); }
.combo-empty { padding: 12px 10px; color: var(--muted); font-size: 13px; }

/* ---------- Overflow Manager: Inline-Tabellensteuerung ---------- */
.cell-control select { padding: 6px 10px; font-size: 13px; min-width: 92px; }
td.cell-control { white-space: nowrap; }

/* Toggle-Switch (an/aus) */
.switch { position: relative; display: inline-block; width: 42px; height: 24px; vertical-align: middle; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; cursor: pointer; inset: 0; background: var(--line);
  border: 1px solid var(--border); border-radius: 999px; transition: background .15s, border-color .15s; }
.switch .slider::before { content: ""; position: absolute; height: 18px; width: 18px; left: 2px; top: 2px;
  background: var(--surface); border-radius: 50%; box-shadow: var(--shadow); transition: transform .15s; }
.switch input:checked + .slider { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(18px); }
.switch input:disabled + .slider { opacity: .5; cursor: not-allowed; }

/* unsaved-Markierung der Zeile */
tr.row-dirty td { background: var(--accent-soft) !important; }
tr.row-dirty td:first-child { box-shadow: inset 3px 0 0 var(--accent); }

/* ---------- Toast ---------- */
#toast, .toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(8px);
  z-index: 200; max-width: 90vw; padding: 12px 18px; border-radius: var(--radius); font-size: 13.5px; font-weight: 600;
  background: var(--surface); color: var(--ink); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
  opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast-ok { border-left: 4px solid var(--ok); }
.toast-error { border-left: 4px solid var(--accent); }

/* ---------- Bestaetigungs-Modal ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(25,29,37,.45); display: flex; align-items: center;
  justify-content: center; z-index: 100; padding: 22px; }
:root[data-theme="dark"] .modal-overlay { background: rgba(0,0,0,.62); }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); padding: 24px 28px; width: 100%; max-width: 440px; animation: modal-in .14s ease-out; }
@keyframes modal-in { from { opacity: 0; transform: translateY(6px) scale(.985); } }
.modal h2 { font-size: 16px; margin-bottom: 4px; }
.confirm-body { color: var(--ink-2); font-size: 14px; line-height: 1.55; margin: 8px 0 2px; }
.confirm-body b { color: var(--ink); font-family: var(--mono); font-size: 13px; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

/* ---------- Skeleton ---------- */
.sk { display: inline-block; background: var(--line); border-radius: 6px; position: relative; overflow: hidden; vertical-align: middle; height: 12px; }
.sk::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, var(--hover), transparent); animation: sk 1.3s infinite; }
@keyframes sk { 100% { transform: translateX(100%); } }

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  .add-grid { grid-template-columns: 1fr; }
  main { padding: 0 16px 50px; }
  header { padding: 12px 16px; }
  .user-name { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
