:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --ink: #17202a;
  --ink-soft: #5b6672;
  --ink-faint: #8a949f;
  --line: #dfe3e8;
  --line-soft: #eceef1;
  --accent: #1f5f8b;
  --accent-soft: #e8f1f8;
  --ok: #1a7f4b;
  --ok-soft: #e6f4ec;
  --warn: #9a6414;
  --warn-soft: #fdf3e2;
  --error: #a12a2a;
  --error-soft: #fbeaea;
  --radius: 7px;
  --shadow: 0 1px 2px rgba(23, 32, 42, .06), 0 1px 8px rgba(23, 32, 42, .04);
}

* { box-sizing: border-box; }

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

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; margin: 0 0 4px; }
h2 { font-size: 15px; margin: 0 0 12px; letter-spacing: .01em; }
h3 { font-size: 13px; margin: 0 0 8px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .06em; }

/* ---------- Layout ---------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 208px;
  flex: 0 1 208px;
  min-width: 168px;
  background: #16232e;
  color: #c9d3dc;
  padding: 18px 0;
  display: flex;
  flex-direction: column;
}
/* Marke im Seitenstreifen: Logo oben, Wortmarke darunter, beides am linken
   Rand ausgerichtet — in einer Spalte, deren Inhalte alle links beginnen, wirkt
   ein mittig gesetzter Block wie ein Versehen.
   Die Wortmarke in Versalien mit weiter Sperrung: das Bild eines gestempelten
   Aufdrucks, nicht das einer Software-Überschrift.
   Es darf nur *eine* .brand-Regel geben. Eine zweite weiter oben in der Datei
   hat schon einmal die Ausrichtung dieser hier stillschweigend überstimmt. */
.brand {
  display: flex; flex-direction: column; align-items: flex-start; gap: 9px;
  padding: 0 18px 18px; color: #fff;
}
.brand:hover { text-decoration: none; }
/* Weißes Feld hinter dem Logo: Bürologos sind meist dunkle Schrift auf
   Transparenz — auf dem dunklen Seitenstreifen wären sie sonst unsichtbar.
   So funktioniert jedes Logo, hell wie dunkel. */
.brand .mark {
  height: 56px; width: auto; max-width: 172px; object-fit: contain;
  align-self: flex-start;
  background: #fff; padding: 5px 7px; border-radius: 5px;
}
.brand.hell .mark { background: none; padding: 0; }
.brand span { font-weight: 600; font-size: 14px; letter-spacing: .14em; text-transform: uppercase; }
.brand small {
  display: block; font-weight: 400; font-size: 10px; color: #7f8f9d;
  letter-spacing: .08em; text-transform: uppercase; line-height: 1.4;
  margin-top: 2px;
}

/* Anmeldeseite */
.login-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.login-brand .mark { height: 46px; width: auto; max-width: 220px; flex: none;
                     object-fit: contain; color: var(--ink); }
.login-brand h1 { font-size: 22px; letter-spacing: .16em; text-transform: uppercase; margin: 0; }
.login-brand .tagline { margin: 2px 0 0; font-size: 12.5px; color: var(--ink-soft); }
.nav a {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 18px; color: #c9d3dc; font-size: 13.5px; border-left: 3px solid transparent;
}
.nav a:hover { background: #1e2f3d; text-decoration: none; color: #fff; }
.nav a.active { background: #1e2f3d; border-left-color: #4d9fd0; color: #fff; font-weight: 500; }
.nav .count { font-size: 11px; color: #7f8f9d; }
.sidebar-foot { margin-top: auto; padding: 14px 18px 0; border-top: 1px solid #24374a; font-size: 12px; color: #7f8f9d; }
.sidebar-foot a { color: #a9b8c4; }

.main { flex: 1; min-width: 0; padding: 22px 26px 60px; max-width: 1500px; }
.page-head { display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head .grow { flex: 1; min-width: 200px; }
.page-head .sub { color: var(--ink-soft); font-size: 13px; }

/* ---------- Karten & Grids ---------- */
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px;
}
.card.tight { padding: 12px 14px; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 2.1fr) minmax(260px, 1fr); gap: 16px; align-items: start; }
/* Rasterkinder haben von sich aus min-width:auto und weigern sich damit zu
   schrumpfen, sobald etwas Unteilbares darin steht — ein langer Dateiname
   genügt. Diese Zeile ist der Grund, warum die Seite nicht mehr breiter wird
   als das Fenster. */
.split > * { min-width: 0; }
.card, .grid > * { min-width: 0; }
/* Lange Dateinamen, Adressen und Aktenzeichen brechen notfalls im Wort. */
body { overflow-wrap: anywhere; }
/* Bei mittlerer Breite ist die zweite Spalte zu eng, um nützlich zu sein:
   dann besser untereinander als beides gequetscht. */
@media (max-width: 1150px) { .split { grid-template-columns: 1fr; } }
@media (max-width: 720px) {
  .layout { flex-direction: column; }
  .sidebar { width: auto; flex: none; min-width: 0; }
  .nav { display: flex; flex-wrap: wrap; }
  .main { padding: 16px; }
  /* Auf dem Telefon nimmt die Marke sonst ein Viertel des Bildschirms ein,
     bevor der erste Akteneintrag zu sehen ist: Logo und Text nebeneinander
     und kleiner. */
  .brand { flex-direction: row; align-items: center; gap: 10px; padding: 0 16px 12px; }
  .brand .mark { height: 34px; max-width: 116px; }
  .brand small { display: none; }
}

.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 13px 15px; }
.stat .label { font-size: 11.5px; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .06em; }
.stat .value { font-size: 22px; font-weight: 600; margin-top: 3px; font-variant-numeric: tabular-nums; }
.stat .hint { font-size: 12px; color: var(--ink-soft); }

/* ---------- Tabellen ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--ink-faint); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
td { padding: 7px 8px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbfc; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tfoot td { border-top: 1px solid var(--line); border-bottom: none; font-weight: 600; padding-top: 9px; }
/* Tabellen dürfen notfalls in sich rollen — aber nie die Seite mitziehen. */
.table-wrap { overflow-x: auto; max-width: 100%; }
/* Kennungen, Pfade und Aktenzeichen in Festbreitenschrift sind unteilbar lang;
   in einer Tabellenzelle sprengen sie sonst die Spalte. */
td.mono, .mono { overflow-wrap: anywhere; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }

/* ---------- Formulare ---------- */
label { display: block; font-size: 12px; color: var(--ink-soft); margin-bottom: 3px; font-weight: 500; }
input[type=text], input[type=email], input[type=password], input[type=date],
input[type=datetime-local], input[type=number], select, textarea {
  width: 100%; padding: 7px 9px; border: 1px solid #cfd6dd; border-radius: 5px;
  font: inherit; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { min-height: 84px; resize: vertical; line-height: 1.55; }
.field { margin-bottom: 11px; }
.field-row { display: flex; gap: 10px; flex-wrap: wrap; }
.field-row > .field { flex: 1; min-width: 140px; }
.hint { font-size: 11.5px; color: var(--ink-faint); margin-top: 3px; }
.check { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--ink); }
.check input { width: auto; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin: 0 0 14px; }
legend { font-size: 12px; color: var(--ink-soft); font-weight: 600; padding: 0 5px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px; border-radius: 5px;
  border: 1px solid #cfd6dd; background: #fff; color: var(--ink); font: inherit; font-size: 13px;
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: #f6f8fa; text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 500; }
.btn.primary:hover { background: #1a5177; }
.btn.danger { color: var(--error); border-color: #e3c2c2; }
.btn.danger:hover { background: var(--error-soft); }
.btn.small { padding: 4px 9px; font-size: 12px; }
.btn.link { border: none; background: none; color: var(--accent); padding: 2px 4px; }
.btn.link:hover { background: none; text-decoration: underline; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.toolbar .field { margin-bottom: 0; }

/* ---------- Badges & Meldungen ---------- */
.badge {
  display: inline-block; padding: 2px 7px; border-radius: 10px; font-size: 11px; font-weight: 600;
  letter-spacing: .02em; background: var(--line-soft); color: var(--ink-soft); white-space: nowrap;
}
.badge.open { background: var(--accent-soft); color: var(--accent); }
.badge.waiting { background: var(--warn-soft); color: var(--warn); }
.badge.closed { background: #eceef1; color: var(--ink-faint); }
.badge.due { background: var(--error-soft); color: var(--error); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.kind { background: #eef1f4; color: #4a5764; }

.flash { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; font-size: 13.5px; border: 1px solid; }
.flash.ok { background: var(--ok-soft); border-color: #bfe3cd; color: #14603a; }
.flash.warn { background: var(--warn-soft); border-color: #ecd9b4; color: var(--warn); }
.flash.error { background: var(--error-soft); border-color: #e8c3c3; color: var(--error); }

.empty { color: var(--ink-faint); font-size: 13px; padding: 14px 2px; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs a {
  padding: 8px 14px; font-size: 13.5px; color: var(--ink-soft); border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* ---------- Zeitstrahl ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
/* Die Trennung zwischen Vorgängen war beim Scrollen kaum zu sehen. Jetzt drei
   Mittel zusammen: kräftigere Linie, mehr Luft, und eine senkrechte Marke am
   linken Rand, die den Beginn eines Vorgangs auch im Vorbeiscrollen zeigt. */
.tl-item {
  display: flex; gap: 12px; padding: 16px 0 18px;
  border-bottom: 2px solid var(--line);
  position: relative;
}
.tl-item::before {
  content: ""; position: absolute; left: -16px; top: 16px; bottom: 18px;
  width: 3px; border-radius: 2px; background: var(--line);
}
.tl-item:hover::before { background: var(--accent); }
.tl-item:last-child { border-bottom: none; }
.tl-item:last-child::before { bottom: 4px; }
.tl-date {
  flex: 0 0 92px; font-size: 12px; color: var(--ink-soft); font-variant-numeric: tabular-nums;
  padding-top: 2px;
}
.tl-date .time { display: block; color: var(--ink-faint); font-size: 11.5px; }
.tl-body { flex: 1; min-width: 0; }
.tl-title { font-weight: 600; font-size: 14px; margin-bottom: 3px; display: flex; gap: 7px; align-items: baseline; flex-wrap: wrap; }
.tl-text { white-space: pre-wrap; font-size: 13.5px; color: #2c3742; margin: 4px 0 0; }

/* Eingeklappter langer Text: rund 20 Zeilen, darunter ein weicher Auslauf,
   damit man sieht, dass es weitergeht. */
.tl-text.folded {
  max-height: 21em; overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, #000 78%, transparent 100%);
          mask-image: linear-gradient(to bottom, #000 78%, transparent 100%);
}
.tl-fold {
  background: none; border: 0; padding: 2px 0; margin-top: 4px; cursor: pointer;
  color: var(--accent); font-size: 12.5px; font-family: inherit;
}
.tl-fold:hover { text-decoration: underline; }
.tl-meta { font-size: 12px; color: var(--ink-faint); margin-top: 5px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.tl-files { margin-top: 7px; display: flex; flex-direction: column; gap: 4px; }
/* Die Zeile einer Datei trägt bei offener Bearbeitung viel: Name, Größe,
   herunterladen, Text, „in Bearbeitung“, im Browser, in Word, zurück in die
   Akte, abbrechen. Ohne Umbruch war ihre Mindestbreite größer als die Spalte —
   und schob die ganze Seite über den Bildschirmrand hinaus. Genau daran lag es,
   dass rechts die Hochladen-Karte abgeschnitten war. */
.file-chip {
  display: flex; align-items: center; gap: 8px; padding: 5px 9px; background: #f7f9fa;
  border: 1px solid var(--line); border-radius: 5px; font-size: 12.5px;
  max-width: 100%; flex-wrap: wrap; row-gap: 5px;
}
/* Der Name darf schrumpfen, bevor irgendetwas anderes umbricht — aber nicht
   unter eine lesbare Länge. */
.file-chip .name {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  flex: 1 1 14em; min-width: 8em;
}
.file-chip .size { color: var(--ink-faint); font-size: 11.5px; white-space: nowrap; }

/* ---------- Timerleiste ---------- */
.timerbar {
  display: flex; align-items: center; gap: 12px; padding: 9px 14px; margin-bottom: 16px;
  background: #fff7e6; border: 1px solid #ecd9b4; border-radius: var(--radius); font-size: 13.5px;
  flex-wrap: wrap;
}
.timerbar .clock { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 16px; color: var(--warn); }
.timerbar form { display: flex; gap: 8px; align-items: center; margin-left: auto; flex-wrap: wrap; }

/* ---------- Suche ---------- */
.result { padding: 11px 0; border-bottom: 1px solid var(--line-soft); }
.result:last-child { border-bottom: none; }
.result .title { font-weight: 600; font-size: 14px; }
.result .path { font-size: 12px; color: var(--ink-faint); margin-top: 1px; }
.result .snippet { font-size: 13px; color: #2c3742; margin-top: 5px; line-height: 1.6; }
.result mark { background: #fdf0c4; color: inherit; padding: 0 1px; border-radius: 2px; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-box { width: 100%; max-width: 372px; }
.login-box .card { padding: 26px; }
.login-box h1 { margin-bottom: 18px; }

pre.doctext {
  white-space: pre-wrap; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px; line-height: 1.65; background: #fbfcfd; border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; max-height: 70vh; overflow: auto; margin: 0;
}
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.tl-meta form { display: inline; }
.tl-meta form .btn.link { padding: 0 2px; }
td.mono, td .mono { white-space: nowrap; }
.file-chip form { display: inline; }
.file-chip.locked { background: #fff7e6; border-color: #ecd9b4; }

/* ---------- Fortschrittsbalken (Soll-Stunden) ---------- */
.bar {
  height: 5px; background: var(--line-soft); border-radius: 3px; margin: 7px 0 4px;
  overflow: hidden;
}
.bar > span {
  display: block; height: 100%; background: var(--accent); border-radius: 3px;
  transition: width .3s;
}
.bar > span.full { background: var(--ok); }

/* ---------- Rückfrage-Fenster ---------- */
.modal {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  background: rgba(23, 32, 42, .45); padding: 20px;
}
/* Muss nach .modal stehen: eine Klassenregel mit display schlägt sonst das
   hidden-Attribut, und das Fenster wäre von Anfang an sichtbar. */
.modal[hidden] { display: none; }
.modal-box {
  background: var(--panel); border-radius: var(--radius); padding: 22px 24px;
  max-width: 480px; width: 100%; box-shadow: 0 8px 40px rgba(23, 32, 42, .25);
}
.modal-box h2 { margin-bottom: 8px; font-size: 16px; }
.modal-box p { margin: 0 0 16px; font-size: 13.5px; line-height: 1.55; }

/* Zahl der Fundstellen im Suchergebnis: sagt, ob das Gesuchte dort das Thema
   ist oder nur beiläufig vorkommt. */
.snippet .hits {
  display: inline-block; margin-left: 8px; padding: 1px 7px; border-radius: 9px;
  background: var(--accent-soft); color: var(--accent); font-size: 11.5px;
  white-space: nowrap;
}
