/* Oberfläche der ESTAYA Teams-App.
   Die Farben folgen dem Teams-Erscheinungsbild, damit sich die App nicht wie
   ein Fremdkörper anfühlt. Teams meldet sein Thema beim Start, wir setzen
   dann data-theme am Wurzelelement. */

:root {
  --bg: #ffffff;
  --bg-2: #f5f5f5;
  --bg-3: #ebebeb;
  --ink: #242424;
  --ink-2: #424242;
  --muted: #616161;
  --rule: #e0e0e0;
  --accent: #5b5fc7;
  --accent-hover: #4f52b2;
  --accent-wash: #e8ebfa;
  --ok: #0e700e;
  --warn: #bc4b09;
  --crit: #c4314b;
  --radius: 6px;
  --shadow: 0 2px 8px rgba(0, 0, 0, .12);
}

:root[data-theme="dark"] {
  --bg: #1f1f1f;
  --bg-2: #292929;
  --bg-3: #333333;
  --ink: #ffffff;
  --ink-2: #d6d6d6;
  --muted: #adadad;
  --rule: #3d3d3d;
  --accent: #7f85f5;
  --accent-hover: #9299f7;
  --accent-wash: #2b2f4a;
  --ok: #54b054;
  --warn: #e97548;
  /* Dunkler als der Textton, damit weisse Schrift darauf lesbar bleibt. */
  --crit: #a4262c;
  --shadow: 0 2px 8px rgba(0, 0, 0, .4);
}

/* Im Kontrast-Thema tragen die Signalflaechen schwarze Schrift. Weiss auf
   Gelb ergibt 1,07:1 und ist unlesbar, das WCAG-Minimum sind 4,5:1. */
:root[data-theme="contrast"] .btn-primary,
:root[data-theme="contrast"] .btn-danger,
:root[data-theme="contrast"] .btn-stop,
:root[data-theme="contrast"] .pill.done,
:root[data-theme="contrast"] .pill.late,
:root[data-theme="contrast"] .error,
:root[data-theme="contrast"] .toast { color: #000 !important; }

:root[data-theme="contrast"] {
  --bg: #000000;
  --bg-2: #000000;
  --bg-3: #1a1a1a;
  --ink: #ffffff;
  --ink-2: #ffffff;
  --muted: #ffffff;
  --rule: #ffffff;
  --accent: #ffff01;
  --accent-hover: #ffff01;
  --accent-wash: #000000;
  --ok: #3ff23f;
  --warn: #ffff01;
  --crit: #ff0000;
}

* { box-sizing: border-box; }

/* Das hidden-Attribut muss jede Klassenregel schlagen. Sonst bleiben
   Elemente sichtbar, die per JavaScript ausgeblendet wurden: .boot und
   .timer-chip setzen display:flex und würden das Attribut überstimmen. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}

.mono { font-variant-numeric: tabular-nums; font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.muted { color: var(--muted); }
h2 { font-size: 16px; margin: 0; font-weight: 600; }

/* ── Start ───────────────────────────────────────────────────────────── */
.boot {
  min-height: 70vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px; color: var(--muted);
}
.spinner {
  width: 26px; height: 26px; border: 2.5px solid var(--rule);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }

/* ── Kopfzeile ───────────────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; border-bottom: 1px solid var(--rule); background: var(--bg);
  position: sticky; top: 0; z-index: 10;
}
.ident { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.ident strong { font-size: 13px; font-weight: 600; }
.ident span { font-size: 11px; }

.timer-chip {
  display: flex; align-items: center; gap: 8px; flex: 0 0 auto;
  background: var(--accent-wash); border: 1px solid var(--accent);
  border-radius: 999px; padding: 4px 6px 4px 12px;
}
.timer-chip .dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--crit);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .timer-chip .dot { animation: none; } }
#timer-elapsed { font-size: 13px; font-weight: 600; }

/* ── Reiter ──────────────────────────────────────────────────────────── */
.tabs {
  display: flex; gap: 2px; padding: 0 12px; border-bottom: 1px solid var(--rule);
  background: var(--bg); position: sticky; top: 49px; z-index: 9;
  overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  appearance: none; background: none; border: none; cursor: pointer;
  padding: 10px 12px; font: inherit; font-weight: 600; font-size: 13px;
  color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap;
}
.tab[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.tab:hover { color: var(--ink); }

main { padding: 14px 16px 40px; max-width: 900px; margin: 0 auto; }

/* ── Woche ───────────────────────────────────────────────────────────── */
.week-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.week-head > div { flex: 1; text-align: center; }
.week-head p { margin: 2px 0 0; font-size: 12px; }

.days { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.day {
  border: 1px solid var(--rule); border-radius: var(--radius);
  background: var(--bg-2); overflow: hidden;
}
.day-head {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 8px 12px; font-size: 12px; font-weight: 600;
}
.day-head .hours { font-variant-numeric: tabular-nums; color: var(--accent); }
.day.empty .day-head .hours { color: var(--muted); font-weight: 400; }
.day.today { border-color: var(--accent); }

.entry {
  display: flex; justify-content: space-between; gap: 10px; align-items: flex-start;
  padding: 8px 12px; border-top: 1px solid var(--rule); background: var(--bg);
}
.entry-main { min-width: 0; flex: 1; }
.entry-desc { font-size: 13px; word-break: break-word; }
.entry-meta { font-size: 11px; color: var(--muted); margin-top: 1px; }
.entry-hours { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 13px; white-space: nowrap; }
.entry-actions { display: flex; gap: 4px; }

/* ── Aufgaben ────────────────────────────────────────────────────────── */
.group { margin-bottom: 18px; }
.group-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--muted); margin-bottom: 6px;
}
.list { display: flex; flex-direction: column; gap: 6px; }
.card {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 10px 12px; border: 1px solid var(--rule); border-radius: var(--radius);
  background: var(--bg-2); cursor: pointer; text-align: left; width: 100%;
  font: inherit; color: inherit;
}
.card:hover { background: var(--bg-3); }
.card-main { min-width: 0; }
.card-title { font-size: 13px; font-weight: 600; }
.card-sub { font-size: 11px; color: var(--muted); margin-top: 1px; }

.pill {
  font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 999px;
  background: var(--bg-3); color: var(--ink-2); white-space: nowrap;
}
.pill.done { background: var(--ok); color: #fff; }
.pill.late { background: var(--crit); color: #fff; }

/* ── Kanban ──────────────────────────────────────────────────────────── */
.kanban-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.kanban-cols { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 10px; }
.kanban-col {
  flex: 0 0 250px; background: var(--bg-2); border: 1px solid var(--rule);
  border-radius: var(--radius); padding: 8px; max-height: 65vh; overflow-y: auto;
}
.kanban-col h3 {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  margin: 2px 4px 8px; color: var(--muted); display: flex; justify-content: space-between;
}
.kanban-col .card { margin-bottom: 6px; background: var(--bg); }

/* ── Bedienelemente ──────────────────────────────────────────────────── */
.btn {
  appearance: none; font: inherit; font-size: 13px; font-weight: 600;
  border-radius: var(--radius); padding: 7px 14px; cursor: pointer;
  border: 1px solid transparent; background: var(--bg-3); color: var(--ink);
}
.btn:hover { filter: brightness(.96); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: transparent; border-color: var(--rule); }
.btn-stop { background: var(--crit); color: #fff; padding: 4px 10px; font-size: 12px; }
.btn-wide { width: 100%; padding: 11px; }
.btn-half { flex: 1; padding: 11px; }
.btn-danger { background: var(--crit); color: #fff; }
.week-actions { display: flex; gap: 8px; }
.btn-icon { padding: 4px 8px; font-size: 12px; background: transparent; border-color: var(--rule); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.input, select, input[type="date"], input[type="number"], input[type="text"] {
  font: inherit; font-size: 14px; padding: 9px 10px; width: 100%;
  border: 1px solid var(--rule); border-radius: var(--radius);
  background: var(--bg); color: var(--ink);
}
.input { margin-bottom: 12px; }
select:focus, input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* ── Dialoge ─────────────────────────────────────────────────────────── */
.dialog {
  border: none; border-radius: 10px; padding: 0; width: min(440px, 94vw);
  background: var(--bg); color: var(--ink); box-shadow: var(--shadow);
}
.dialog::backdrop { background: rgba(0, 0, 0, .45); }
.dialog form { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field > span { font-size: 12px; font-weight: 600; }
.field em { font-style: normal; font-weight: 400; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

.error {
  background: var(--crit); color: #fff; padding: 8px 10px;
  border-radius: var(--radius); font-size: 12px; margin: 0;
}

/* ── Störung ─────────────────────────────────────────────────────────── */
.fault { padding: 30px 20px; max-width: 620px; margin: 0 auto; text-align: center; }
.fault h2 { margin-bottom: 8px; }
.fault p { color: var(--ink-2); margin: 0 0 14px; }
.fault .dialog-actions { justify-content: center; }
.fault-detail {
  text-align: left; background: var(--bg-2); border: 1px solid var(--rule);
  border-radius: var(--radius); padding: 10px; font-size: 11px;
  overflow-x: auto; color: var(--muted); margin: 0 0 14px;
}

/* ── Hinweis ─────────────────────────────────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 9px 16px;
  border-radius: 999px; font-size: 13px; font-weight: 600;
  box-shadow: var(--shadow); z-index: 100; max-width: 90vw;
}
.toast.bad { background: var(--crit); color: #fff; }

.empty-note { text-align: center; color: var(--muted); padding: 28px 10px; font-size: 13px; }

@media (max-width: 480px) {
  main { padding: 12px 12px 32px; }
  .kanban-col { flex-basis: 82vw; }
}
