/* ============================================================
 *  Material-Verwaltung – Stylesheet
 *  Helles, ruhiges Business-Design. Eine Akzentfarbe (--accent)
 *  unten anpassen, fertig.
 * ============================================================ */

:root {
  /* ---- Markenfarbe: hier auf eure Farbe aendern -------- */
  --accent:        #005aa0;          /* Arthur-Weber-Blau */
  --accent-hover:  #00457a;
  --accent-soft:   #e6f0f8;

  /* ---- Neutrale Palette -------------------------------- */
  --bg:        #f5f6f8;
  --surface:   #ffffff;
  --line:      #e6e8ec;
  --line-2:    #eef0f3;
  --text:      #1c1f23;
  --text-2:    #5b6470;
  --text-3:    #97a0ad;

  --ok:    #15803d;  --ok-soft:    #e8f6ed;
  --warn:  #b45309;  --warn-soft:  #fdf2e3;
  --bad:   #b91c1c;  --bad-soft:   #fdecec;
  --info:  #1d4ed8;  --info-soft:  #e9efff;

  --radius:   10px;
  --radius-s: 7px;
  --shadow:   0 1px 2px rgba(16,24,40,.04), 0 1px 3px rgba(16,24,40,.06);
  --shadow-lg:0 10px 30px rgba(16,24,40,.12);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ---------------------------------------------------------- */
/*  Header                                                    */
/* ---------------------------------------------------------- */
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 40;
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand-logo { display: inline-flex; align-items: center; }
.brand-logo img { height: 30px; width: auto; display: block; }
.brand-divider { width: 1px; height: 24px; background: var(--line); }
.brand-title { font-size: 17px; font-weight: 600; letter-spacing: -.01em; white-space: nowrap; }

.header-controls { display: flex; align-items: center; gap: 10px; }

/* ---------------------------------------------------------- */
/*  Buttons                                                   */
/* ---------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px;
  font-size: 13.5px; font-weight: 500; font-family: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  cursor: pointer;
  transition: background .12s, border-color .12s, box-shadow .12s;
  white-space: nowrap;
}
.btn:hover { background: #fafbfc; border-color: #d6dae0; }
.btn svg { width: 16px; height: 16px; flex: none; }

.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-icon { padding: 8px; }
.btn-small { padding: 6px 10px; font-size: 12.5px; }

.btn-danger-text {
  background: transparent; border-color: transparent; color: var(--bad);
  padding-left: 4px; padding-right: 8px;
}
.btn-danger-text:hover { background: var(--bad-soft); border-color: transparent; }

/* ---------------------------------------------------------- */
/*  Burger-Menue                                              */
/* ---------------------------------------------------------- */
.menu-wrap { position: relative; }
.menu-panel {
  position: absolute; right: 0; top: calc(100% + 8px);
  width: 268px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 8px;
  z-index: 50;
}
.menu-section { padding: 6px 4px; }
.menu-section + .menu-section { border-top: 1px solid var(--line-2); }
.menu-section-title {
  font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase;
  color: var(--text-3); padding: 4px 8px 6px;
}
.menu-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: left;
  padding: 9px 8px; border: none; background: none;
  font-size: 13.5px; font-family: inherit; color: var(--text);
  border-radius: var(--radius-s); cursor: pointer;
}
.menu-item:hover { background: var(--bg); }
.menu-item svg { width: 17px; height: 17px; color: var(--text-2); flex: none; }

/* ---------------------------------------------------------- */
/*  View-Leiste (Reiter + Filter)                             */
/* ---------------------------------------------------------- */
.view-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  padding: 10px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.view-tabs { display: flex; gap: 4px; }
.view-tab {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 13px;
  font-size: 13.5px; font-weight: 500; font-family: inherit;
  color: var(--text-2);
  background: none; border: none; border-radius: var(--radius-s);
  cursor: pointer;
}
.view-tab svg { width: 16px; height: 16px; }
.view-tab:hover { background: var(--bg); color: var(--text); }
.view-tab.active { background: var(--accent-soft); color: var(--accent); }

.filter-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.filter-bar input[type="search"], .filter-bar select {
  padding: 7px 10px; font-size: 13px; font-family: inherit;
  color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-s);
}
.filter-bar input[type="search"] { min-width: 300px; flex: 1 1 300px; }
.filter-bar input:focus, .filter-bar select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.filter-clear {
  padding: 7px 10px; font-size: 12.5px; color: var(--text-2);
  background: none; border: none; cursor: pointer; border-radius: var(--radius-s);
}
.filter-clear:hover { background: var(--bg); color: var(--text); }

/* ---------------------------------------------------------- */
/*  Main                                                      */
/* ---------------------------------------------------------- */
.main { padding: 24px; max-width: 1280px; margin: 0 auto; }
.loading { color: var(--text-3); padding: 40px; text-align: center; }

.empty {
  text-align: center; color: var(--text-3);
  padding: 60px 20px; font-size: 14px;
}
.empty strong { display: block; color: var(--text-2); font-size: 15px; margin-bottom: 4px; }

/* ---- Statistik-Streifen --------------------------------- */
.stat-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.stat {
  flex: 1; min-width: 140px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow);
}
.stat-num { font-size: 24px; font-weight: 650; letter-spacing: -.02em; }
.stat-label { font-size: 12.5px; color: var(--text-2); margin-top: 2px; }

/* ---------------------------------------------------------- */
/*  Tabelle (Material-Liste)                                  */
/* ---------------------------------------------------------- */
.table-wrap {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
}
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td { padding: 11px 16px; text-align: left; }
table.data thead th {
  font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  color: var(--text-3); border-bottom: 1px solid var(--line); background: #fbfcfd;
}
table.data tbody tr { border-bottom: 1px solid var(--line-2); cursor: pointer; }
table.data tbody tr:last-child { border-bottom: none; }
table.data tbody tr:hover { background: #fafbfc; }
.cell-name { font-weight: 550; }
.cell-name small { display: block; font-weight: 400; color: var(--text-3); font-size: 12px; }

.kat-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 7px; vertical-align: middle; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 500;
}
.badge.gut       { background: var(--ok-soft);   color: var(--ok); }
.badge.mittel    { background: var(--warn-soft); color: var(--warn); }
.badge.defekt    { background: var(--bad-soft);  color: var(--bad); }
.badge.reparatur { background: var(--info-soft); color: var(--info); }
.badge.geplant       { background: var(--info-soft); color: var(--info); }
.badge.laeuft        { background: var(--ok-soft);   color: var(--ok); }
.badge.abgeschlossen { background: var(--line-2);    color: var(--text-2); }
.badge.frei    { background: var(--ok-soft);  color: var(--ok); }
.badge.besetzt { background: var(--bad-soft); color: var(--bad); }

.muted { color: var(--text-3); }
.cell-einsatz { color: var(--text); }

.menge-pill {
  display: inline-block; padding: 2px 8px; border-radius: 6px;
  background: var(--bg); color: var(--text-2); font-variant-numeric: tabular-nums;
  font-size: 12.5px; font-weight: 550;
}

/* ---------------------------------------------------------- */
/*  Standorte (Karten)                                        */
/* ---------------------------------------------------------- */
.location-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px;
}
.loc-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 10px;
}
.loc-card h3 { margin: 0; font-size: 15.5px; display: flex; align-items: center; gap: 8px; }
.loc-card h3 svg { width: 16px; height: 16px; color: var(--accent); }
.loc-meta { font-size: 12.5px; color: var(--text-2); }
.loc-counts { display: flex; gap: 18px; margin-top: 4px; padding-top: 12px; border-top: 1px solid var(--line-2); }
.loc-count-num { font-size: 19px; font-weight: 650; }
.loc-count-label { font-size: 11.5px; color: var(--text-3); }

/* ---------------------------------------------------------- */
/*  Kalender (Wochen-Layout mit durchlaufenden Balken)        */
/* ---------------------------------------------------------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.cal-title { font-size: 17px; font-weight: 600; }
.cal-nav { display: flex; gap: 6px; }

.cal-dow-row { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-dow {
  padding: 8px; text-align: left; padding-left: 10px;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-3);
}
.cal-weeks {
  border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; background: var(--surface);
}
.cal-week { position: relative; }
.cal-week-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-cell {
  border-top: 1px solid var(--line-2);
  border-right: 1px solid var(--line-2);
  min-height: max(96px, calc(34px + var(--lanes, 2) * 24px));
  padding: 5px 6px; cursor: pointer; transition: background .1s;
}
.cal-week:first-child .cal-cell { border-top: none; }
.cal-cell:nth-child(7n) { border-right: none; }
.cal-cell:hover { background: #fafbfc; }
.cal-cell.other { background: #fbfcfd; }
.cal-cell.other .cal-num { color: var(--text-3); opacity: .6; }
.cal-num { font-size: 12.5px; color: var(--text-2); font-weight: 550; }
.cal-cell.today .cal-num {
  background: var(--accent); color: #fff; border-radius: 50%;
  width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center;
}

/* Balken-Ebene liegt über den Tageszellen */
.cal-bars {
  position: absolute; top: 30px; left: 0; right: 0;
  display: grid; grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: 21px; row-gap: 3px;
  pointer-events: none;
}
.cal-bar {
  pointer-events: auto; cursor: pointer;
  margin: 0 3px; padding: 0 8px;
  background: var(--accent); color: #fff;
  font-size: 11.5px; font-weight: 500; line-height: 21px;
  border-radius: 5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cal-bar:hover { background: var(--accent-hover); }
.cal-bar.cl { border-top-left-radius: 0; border-bottom-left-radius: 0; margin-left: 0; }
.cal-bar.cr { border-top-right-radius: 0; border-bottom-right-radius: 0; margin-right: 0; }

/* ---------------------------------------------------------- */
/*  Modals                                                    */
/* ---------------------------------------------------------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(16,24,40,.45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px; overflow-y: auto;
}
.modal {
  background: var(--surface); border-radius: 14px;
  width: 100%; max-width: 620px;
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  animation: pop .14s ease;
}
@keyframes pop { from { transform: translateY(6px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid var(--line);
}
.modal-header h2 { margin: 0; font-size: 17px; font-weight: 600; }
.modal-close {
  background: none; border: none; cursor: pointer; color: var(--text-3);
  padding: 4px; border-radius: 6px; display: inline-flex;
}
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-close svg { width: 20px; height: 20px; }
.modal-body { padding: 22px; }
.modal-footer {
  display: flex; align-items: center; gap: 10px; justify-content: flex-end;
  padding: 16px 22px; border-top: 1px solid var(--line);
}

/* ---- Formulare ------------------------------------------ */
.form-row { margin-bottom: 16px; }
.form-row:last-child { margin-bottom: 0; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.row-name { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; }
.field-label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.field-hint { font-size: 12px; color: var(--text-3); margin: -2px 0 8px; }
.modal input[type="text"], .modal input[type="number"], .modal input[type="date"],
.modal select, .modal textarea {
  width: 100%; padding: 9px 11px; font-size: 13.5px; font-family: inherit;
  color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-s);
}
.modal textarea { min-height: 72px; resize: vertical; }
.modal input:focus, .modal select:focus, .modal textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ---- Detail-Ansicht ------------------------------------- */
.detail-grid { display: grid; grid-template-columns: 120px 1fr; gap: 10px 16px; }
.detail-grid dt { font-size: 12.5px; color: var(--text-3); font-weight: 500; }
.detail-grid dd { margin: 0; font-size: 14px; }
.detail-section-title { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); margin: 20px 0 8px; }
.detail-mat-item { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--line-2); font-size: 13.5px; }

/* ---- Event-Material-Zeilen ------------------------------ */
.field-label-lg { font-size: 14px; color: var(--text); }
.material-block {
  background: var(--accent-soft);
  border: 1px solid #cfe0ef;
  border-radius: var(--radius); padding: 16px;
}
.event-material-rows { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.emr { display: grid; grid-template-columns: 1fr 40px; gap: 8px; align-items: center; }
.emr .emr-mat { height: 40px; font-size: 14px; background: var(--surface); }
.emr button {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-s);
  cursor: pointer; color: var(--text-3); height: 40px; display: inline-flex; align-items: center; justify-content: center;
}
.emr button:hover { color: var(--bad); border-color: var(--bad); }
.material-block .btn-small { background: var(--surface); }

.conflict-box {
  margin-top: 12px; padding: 11px 13px;
  background: var(--bad-soft); border: 1px solid #f3c2c2; border-radius: var(--radius-s);
  color: var(--bad); font-size: 13px; line-height: 1.6;
}
.conflict-box strong { display: block; margin-bottom: 4px; }

/* ---- Stammdaten-Liste ----------------------------------- */
.master-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.master-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; background: var(--bg); border-radius: var(--radius-s);
}
.master-item .mi-name { flex: 1; font-size: 13.5px; }
.master-item input[type="text"] { flex: 1; padding: 6px 9px; border: 1px solid var(--line); border-radius: 6px; font-family: inherit; }
.master-item input[type="color"] { width: 30px; height: 30px; padding: 0; border: 1px solid var(--line); border-radius: 6px; cursor: pointer; background: none; }
.master-item .mi-del { background: none; border: none; color: var(--text-3); cursor: pointer; padding: 4px; border-radius: 5px; }
.master-item .mi-del:hover { color: var(--bad); background: var(--bad-soft); }
.master-add { display: flex; gap: 8px; align-items: center; padding-top: 14px; border-top: 1px solid var(--line-2); }
.master-add input[type="text"] { flex: 1; padding: 9px 11px; border: 1px solid var(--line); border-radius: var(--radius-s); font-family: inherit; }
.master-add input[type="color"] { width: 38px; height: 38px; padding: 0; border: 1px solid var(--line); border-radius: var(--radius-s); cursor: pointer; background: none; }

/* ---- Material verwalten --------------------------------- */
.manage-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.manage-toolbar select {
  padding: 7px 10px; font-size: 13px; font-family: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-s);
}
.manage-actions { text-align: right; white-space: nowrap; }
.icon-btn {
  background: var(--surface); border: 1px solid var(--line); border-radius: 6px;
  padding: 5px; cursor: pointer; color: var(--text-2); margin-left: 5px;
  display: inline-flex; vertical-align: middle;
}
.icon-btn:hover { background: var(--bg); color: var(--text); }
.icon-btn.danger:hover { color: var(--bad); border-color: var(--bad); background: var(--bad-soft); }
#modal-matmanage .table-wrap tbody tr { cursor: default; }

/* Fenster-Stapelung: Bearbeiten-Fenster über den Verwalten-Listen */
#modal-matmanage, #modal-einsatzmanage { z-index: 90; }
#modal-material, #modal-event { z-index: 120; }

/* ---------------------------------------------------------- */
/*  Toasts                                                    */
/* ---------------------------------------------------------- */
.toast-wrap { position: fixed; bottom: 22px; right: 22px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--text); color: #fff; padding: 11px 16px; border-radius: var(--radius-s);
  font-size: 13.5px; box-shadow: var(--shadow-lg);
  animation: slidein .2s ease; max-width: 320px;
}
.toast.ok  { background: #16794a; }
.toast.err { background: #b91c1c; }
@keyframes slidein { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------------------------------------------------------- */
/*  Responsive                                                */
/* ---------------------------------------------------------- */
@media (max-width: 760px) {
  .app-header { padding: 10px 14px; }
  .brand-title { display: none; }
  .view-bar { padding: 10px 14px; }
  .filter-bar input[type="search"] { min-width: 130px; flex: 1; }
  .main { padding: 16px 14px; }
  .row-2, .row-3 { grid-template-columns: 1fr; }
  table.data thead { display: none; }
  table.data tbody tr { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 12px 14px; }
  table.data td { padding: 2px 0; }
  table.data td[data-col]::before { content: attr(data-col) ": "; color: var(--text-3); font-size: 11px; }
  .cal-dow { padding: 6px 4px; font-size: 10px; }
  .cal-bar { font-size: 10.5px; padding: 0 5px; }
  .btn-primary span, .btn-primary { font-size: 0; }
  .btn-primary svg { width: 18px; height: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
