/* ------------------------------------------------------------------
   Auftragsboard – Optik einer Werkstatt-Auftragskarte:
   Karteikarten auf Papier, Statusleiste am Rand, Stempel bei Erledigt.
------------------------------------------------------------------- */

:root {
  --ink:        #171c22;
  --ink-soft:   #5c6773;
  --ink-faint:  #8a949e;
  --paper:      #e3e7e4;
  --card:       #ffffff;
  --line:       #d2d8db;
  --line-soft:  #e6eaec;

  --blueprint:  #1b4468;
  --blueprint-d:#123049;
  --amber:      #b4690e;
  --green:      #1f7a54;
  --red:        #a3312b;

  --sans: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --cond: "IBM Plex Sans Condensed", "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --r: 3px;
  --shadow: 0 1px 0 rgba(23,28,34,.06), 0 6px 18px -12px rgba(23,28,34,.5);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}

button, input, textarea, select { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--blueprint);
  outline-offset: 2px;
}

[hidden] { display: none !important; }

/* --- Wiederkehrende Bausteine ------------------------------------ */

.stencil {
  font-family: var(--cond);
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
  font-size: 12px;
  margin: 0;
}

.btn {
  font-family: var(--cond);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: .04em;
  padding: 7px 14px;
  border-radius: var(--r);
  border: 1px solid transparent;
  background: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color .12s, border-color .12s, color .12s;
}
.btn--primary { background: var(--blueprint); color: #fff; }
.btn--primary:hover { background: var(--blueprint-d); }
.btn--ghost { border-color: currentColor; opacity: .85; }
.btn--ghost:hover { opacity: 1; }
.btn--quiet { border: 1px solid var(--line); color: var(--ink-soft); background: var(--card); }
.btn--quiet:hover { border-color: var(--ink-soft); color: var(--ink); }
.btn--danger { border: 1px solid var(--red); color: var(--red); }
.btn--danger:hover { background: var(--red); color: #fff; }
.btn--wide { width: 100%; padding: 11px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-family: var(--cond);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 5px;
}
.field input, .field textarea, .field select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--card);
}
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--blueprint); }
.field textarea { resize: vertical; min-height: 90px; }
.field--row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.error { color: var(--red); font-size: 14px; margin: 0 0 12px; }

/* --- Anmeldung ---------------------------------------------------- */

.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    repeating-linear-gradient(90deg, rgba(27,68,104,.05) 0 1px, transparent 1px 32px),
    repeating-linear-gradient(rgba(27,68,104,.05) 0 1px, transparent 1px 32px),
    var(--paper);
}
.login__card {
  width: 100%;
  max-width: 360px;
  background: var(--card);
  border: 1px solid var(--line);
  border-top: 4px solid var(--blueprint);
  border-radius: var(--r);
  padding: 28px;
  box-shadow: var(--shadow);
}
.login__card .stencil { color: var(--blueprint); }
.login__card h1 { font-size: 26px; margin: 6px 0 4px; font-weight: 600; letter-spacing: -.01em; }
.login__hint { color: var(--ink-soft); font-size: 14px; margin: 0 0 22px; }

/* --- Kopfzeile ---------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  background: var(--blueprint);
  color: #fff;
}
.topbar__brand { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.topbar__scope {
  font-family: var(--mono);
  font-size: 13px;
  color: #a9c4dc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar__right { display: flex; align-items: center; gap: 8px; }

.livedot {
  font-family: var(--cond);
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #a9c4dc;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.livedot::before {
  content: "";
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #6f8ba5;
}
.livedot.is-live::before { background: #4ade80; box-shadow: 0 0 0 3px rgba(74,222,128,.2); }

.menu { position: relative; }
.menu__list {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: var(--card);
  /* Muss sein: Das Menü sitzt in der blauen Kopfzeile und würde sonst
     deren weiße Schrift erben – weiß auf weiß. */
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  min-width: 180px;
  padding: 4px;
}
.menu__list button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 9px 11px;
  border: 0;
  background: none;
  color: var(--ink);
  border-radius: 2px;
  cursor: pointer;
  font-size: 14px;
}
.menu__list button:hover { background: var(--line-soft); color: var(--ink); }

/* --- Filterleiste -------------------------------------------------- */

.filters {
  position: sticky;
  top: 55px;
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 10px 20px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.filters__tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tab {
  font-family: var(--cond);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 6px 11px;
  border: 1px solid transparent;
  border-radius: var(--r);
  background: none;
  color: var(--ink-soft);
  cursor: pointer;
}
.tab:hover { color: var(--ink); }
.tab[aria-pressed="true"] {
  background: var(--card);
  border-color: var(--line);
  color: var(--ink);
}
.tab__count { font-family: var(--mono); font-size: 12px; opacity: .65; margin-left: 6px; }

.search {
  flex: 1;
  min-width: 180px;
  max-width: 320px;
  margin-left: auto;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--card);
}

/* --- Auftragsliste ------------------------------------------------- */

.list {
  max-width: 900px;
  margin: 0 auto;
  padding: 22px 20px 80px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.empty {
  text-align: center;
  padding: 64px 20px;
  color: var(--ink-soft);
}
.empty h2 { font-family: var(--cond); font-weight: 600; letter-spacing: .04em; margin: 0 0 6px; color: var(--ink); }
.empty p { margin: 0 0 18px; }

.card {
  position: relative;
  display: grid;
  grid-template-columns: 6px 1fr;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  overflow: hidden;
  cursor: pointer;
  transition: border-color .12s, transform .12s;
}
.card:hover { border-color: var(--ink-faint); }
.card:active { transform: translateY(1px); }

.card__rail { background: var(--ink-faint); }
.card--offen        .card__rail { background: var(--blueprint); }
.card--in_arbeit    .card__rail { background: #3f8fb8; }
.card--warten_kunde .card__rail { background: var(--amber); }
.card--erledigt     .card__rail { background: var(--green); }

.card__body { padding: 14px 16px; min-width: 0; }

.card__meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-faint);
  margin-bottom: 6px;
}
.card__num { color: var(--ink-soft); font-weight: 600; }
.card__company {
  font-family: var(--cond);
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--blueprint);
}

.card__title {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -.005em;
  margin: 0 0 4px;
  padding-right: 40px;
}
.card--erledigt .card__title { color: var(--ink-soft); text-decoration: line-through; text-decoration-thickness: 1px; }

.card__desc {
  margin: 0;
  color: var(--ink-soft);
  font-size: 14px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card__need {
  margin-top: 10px;
  padding: 8px 11px;
  background: #fdf6e9;
  border-left: 3px solid var(--amber);
  border-radius: 0 var(--r) var(--r) 0;
  font-size: 14px;
}
.card__need b {
  display: block;
  font-family: var(--cond);
  font-size: 11px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--amber);
  margin-bottom: 2px;
}

.card__foot {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line-soft);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-faint);
}
.card__foot .due--over { color: var(--red); font-weight: 600; }
.card__foot .due--soon { color: var(--amber); font-weight: 600; }

.pill {
  font-family: var(--cond);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: .09em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 2px;
  border: 1px solid currentColor;
}
.pill--dringend { color: var(--red); background: #fbeceb; }
.pill--hoch     { color: var(--amber); background: #fdf6e9; }
.pill--niedrig  { color: var(--ink-faint); }
.pill--normal   { display: none; }

/* Abhaken direkt in der Liste */
.check {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 26px;
  height: 26px;
  border: 1.5px solid var(--line);
  border-radius: var(--r);
  background: var(--card);
  cursor: pointer;
  display: grid;
  place-items: center;
  color: transparent;
  transition: border-color .12s, background-color .12s, color .12s;
}
.check:hover { border-color: var(--green); color: #b7c8c1; }
.check[aria-pressed="true"] { background: var(--green); border-color: var(--green); color: #fff; }
.check svg { width: 15px; height: 15px; }

/* Signatur: der Erledigt-Stempel */
.card--erledigt::after {
  content: "Erledigt";
  position: absolute;
  right: 46px;
  bottom: 10px;
  font-family: var(--cond);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--green);
  border: 2px solid var(--green);
  border-radius: 2px;
  padding: 2px 9px 2px 13px;
  opacity: .34;
  transform: rotate(-7deg);
  pointer-events: none;
}

/* Frisch eingetroffen oder geändert */
@keyframes flash {
  from { background: #eaf3fb; }
  to   { background: var(--card); }
}
.card.is-fresh { animation: flash 1.6s ease-out; }

/* --- Seitenpanel ---------------------------------------------------- */

.overlay { position: fixed; inset: 0; z-index: 40; }
.overlay__backdrop { position: absolute; inset: 0; background: rgba(23,28,34,.45); }

.panel {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: min(560px, 100%);
  background: var(--paper);
  border-left: 1px solid var(--line);
  overflow-y: auto;
  box-shadow: -12px 0 40px -20px rgba(23,28,34,.6);
  animation: slide .18s ease-out;
}
@keyframes slide { from { transform: translateX(24px); opacity: .4; } to { transform: none; opacity: 1; } }

.panel__head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 22px 14px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.panel__head h2 { font-size: 20px; font-weight: 600; margin: 4px 0 0; letter-spacing: -.01em; }
.panel__close {
  border: 0; background: none; cursor: pointer;
  font-size: 24px; line-height: 1; color: var(--ink-soft); padding: 2px 6px;
}
.panel__body { padding: 20px 22px 60px; }

.block {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 16px;
  margin-bottom: 14px;
}
.block > h3 {
  font-family: var(--cond);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 10px;
}
.block--need { border-left: 3px solid var(--amber); }
.block--need > h3 { color: var(--amber); }

.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.fact dt {
  font-family: var(--cond);
  font-size: 11px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.fact dd { margin: 2px 0 0; font-family: var(--mono); font-size: 13px; }

.statusbar { display: flex; gap: 6px; flex-wrap: wrap; }
.statusbar button {
  flex: 1 1 auto;
  font-family: var(--cond);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: .07em;
  text-transform: uppercase;
  padding: 8px 6px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--card);
  color: var(--ink-soft);
  cursor: pointer;
}
.statusbar button[aria-pressed="true"] { background: var(--blueprint); border-color: var(--blueprint); color: #fff; }

.thread { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.msg { padding: 10px 12px; border-radius: var(--r); background: var(--line-soft); font-size: 14px; }
.msg--mine { background: #e8f0f7; }
.msg__head {
  font-family: var(--cond);
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 3px;
}
.msg__body { white-space: pre-wrap; word-break: break-word; }

.prose { white-space: pre-wrap; word-break: break-word; margin: 0; }
.muted { color: var(--ink-faint); }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  font-family: var(--cond);
  font-size: 11px;
  letter-spacing: .1em;
  text-transform: uppercase;
  text-align: left;
  color: var(--ink-faint);
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
}
.table td { padding: 8px; border-bottom: 1px solid var(--line-soft); }
.table td:last-child { text-align: right; }

/* --- Kurzmeldung ---------------------------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 60;
  background: var(--ink);
  color: #fff;
  padding: 10px 18px;
  border-radius: var(--r);
  font-size: 14px;
  box-shadow: var(--shadow);
  max-width: calc(100vw - 40px);
}
.toast--error { background: var(--red); }

/* --- Schmale Bildschirme -------------------------------------------- */

@media (max-width: 640px) {
  .topbar { padding: 10px 14px; flex-wrap: wrap; }
  .topbar__scope { flex-basis: 100%; }
  .filters { top: auto; position: static; padding: 10px 14px; }
  .search { margin-left: 0; max-width: none; }
  .list { padding: 16px 14px 60px; }
  .panel { width: 100%; border-left: 0; }
  .facts { grid-template-columns: 1fr; }
  .card--erledigt::after { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* --- Schalter und Knopfreihen (Benachrichtigungen) ------------------- */

.switch {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 14px;
  cursor: pointer;
  user-select: none;
}
.switch input { width: 17px; height: 17px; accent-color: var(--blueprint); cursor: pointer; }

.rowbtns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

/* --- Dateianhänge ---------------------------------------------------- */

.files { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }

.file {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
}
.file__link {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  color: inherit;
  text-decoration: none;
}
.file__link:hover { background: var(--line-soft); }

.file__icon {
  flex: none;
  font-family: var(--cond);
  font-weight: 700;
  font-size: 10px;
  letter-spacing: .08em;
  color: #fff;
  background: var(--blueprint);
  padding: 3px 5px;
  border-radius: 2px;
}
.file__name {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file__size { flex: none; font-family: var(--mono); font-size: 12px; color: var(--ink-faint); }

.file__del {
  flex: none;
  border: 0;
  background: none;
  color: var(--ink-faint);
  font-size: 19px;
  line-height: 1;
  padding: 4px 10px;
  cursor: pointer;
}
.file__del:hover { color: var(--red); }

/* Nachrichten im Verlauf: Anhänge etwas eingerückt */
.msg .files { margin-top: 8px; }
.msg .file { background: rgba(255, 255, 255, .7); }

/* Auswahl vor dem Absenden */
.filepick { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.filepick__hint { font-size: 13px; }

.chosen { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  background: var(--line-soft);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 4px 9px;
  max-width: 100%;
}
.chip em { font-family: var(--mono); font-size: 11px; color: var(--ink-faint); font-style: normal; }
.chip--clear { cursor: pointer; color: var(--ink-soft); background: none; }
.chip--clear:hover { color: var(--red); border-color: var(--red); }

/* --- Fortschritt beim Hochladen -------------------------------------- */

.bar {
  height: 6px;
  background: var(--line);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 10px;
}
.bar__fill {
  height: 100%;
  background: var(--blueprint);
  transition: width .15s linear;
}
.bar__label {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 5px;
}
