/* Instandhaltung - Oberflaeche nach Main-Appstudio-Design-Norm.
   Farben und Masse kommen aus design-norm.css (laedt als letzte Datei). */

/* Wie in allen Plattform-Apps: Höhen und Breiten schließen Rahmen und Innenabstand ein,
   sonst wächst die Norm-Feldhöhe um Padding und Rahmen. */
*, *::before, *::after { box-sizing: border-box; }

body { margin: 0; background: var(--paper); color: var(--ink); font-family: "Inter", "Segoe UI", system-ui, sans-serif; }

.ih-kopf-zeile { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.ih-kopf-zeile h1 { margin: 0 0 4px; font-size: 24px; }
.ih-kopf-untertitel { margin: 0; opacity: 0.85; font-size: 14px; }
.ih-kopf-aktionen { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ih-rolle { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: color-mix(in srgb, var(--white) 16%, transparent); color: var(--white); }

.ih-main { max-width: 1400px; margin: 0 auto; padding: 18px 20px 60px; }
.tab { display: none; }
.tab.aktiv { display: block; }

.ih-meldung { padding: 10px 14px; border-radius: var(--ma-field-radius); margin-bottom: 14px; font-size: 14px; background: color-mix(in srgb, var(--aqua) 18%, white); border: 1px solid var(--aqua); }
.ih-meldung.fehler { background: color-mix(in srgb, var(--red) 10%, white); border-color: var(--red); color: var(--red); }
.ih-lade { padding: 30px; text-align: center; color: var(--muted); }

/* Knoepfe (Muster Feinplanung) */
button.knopf, a.knopf { border: none; border-radius: var(--ma-field-radius); padding: 8px 14px; font-size: 13px; font-weight: 600; cursor: pointer; background: var(--navy); color: var(--white); display: inline-block; text-decoration: none; line-height: 1.4; white-space: nowrap; }
button.knopf:hover, a.knopf:hover { background: var(--navy-2); }
button.knopf.aqua, a.knopf.aqua { background: var(--aqua); color: var(--navy); }
button.knopf.aqua:hover, a.knopf.aqua:hover { background: color-mix(in srgb, var(--aqua) 78%, white); color: var(--navy); }
button.knopf.hell, a.knopf.hell { background: var(--white); color: var(--navy); border: 1px solid var(--line); }
button.knopf.hell:hover, a.knopf.hell:hover { background: var(--paper); color: var(--navy); }
button.knopf.gefahr { background: var(--white); color: var(--red); border: 1px solid var(--red); }
button.knopf.gefahr:hover { background: color-mix(in srgb, var(--red) 10%, white); color: var(--red); }
button.knopf.mini { padding: 4px 9px; font-size: 12px; }
button.knopf:disabled { opacity: 0.5; cursor: not-allowed; }
button.knopf:focus-visible, a.knopf:focus-visible, .ih-kpi:focus-visible, .ih-tabelle.ih-klickbar tbody tr:focus-visible { outline: 3px solid var(--aqua); outline-offset: 2px; }
.ih-tabelle.ih-klickbar tbody tr:focus-visible { outline-offset: -3px; }
.ma-compact-form button.knopf { height: var(--ma-control-height); }
.ma-app-kopf .knopf.hell { border-color: transparent; }

/* Werkzeugleiste ueber Tabellen */
.ih-werkzeugleiste { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin: 6px 0 14px; }
.ih-werkzeugleiste .ih-hinweis { flex: 1 1 320px; }
.ih-suche, .ih-feld { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); min-width: 200px; }
.ih-suche input, .ih-feld select { height: var(--ma-control-height); border: 1px solid var(--line); border-radius: var(--ma-field-radius); padding: 0 14px; font-size: 15px; background: var(--white); color: var(--ink); -webkit-appearance: none; appearance: none; }
.ih-suche { min-width: 260px; }
.ih-suche input { width: 100%; }
.ih-werkzeugleiste .knopf { min-height: var(--ma-control-height); display: inline-flex; align-items: center; }
.ih-hinweis { margin: 0 0 12px; font-size: 13px; color: var(--muted); }
.ih-klein { margin: 8px 0 4px; font-size: 12px; color: var(--muted); }
.ih-leer { padding: 24px; text-align: center; color: var(--muted); background: var(--white); border: 1px dashed var(--line); border-radius: var(--ma-card-radius); }

/* Kennzahlen als Filter */
.ih-kpis { display: flex; gap: 10px; flex-wrap: wrap; }
.ih-kpi { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 120px; padding: 10px 14px; border-radius: var(--ma-card-radius); border: 2px solid var(--line); background: var(--white); cursor: pointer; text-align: left; font: inherit; color: var(--ink); }
.ih-kpi strong { font-size: 22px; line-height: 1; }
.ih-kpi span { font-size: 12px; color: var(--muted); }
.ih-kpi.rot strong { color: var(--red); }
.ih-kpi.gelb strong { color: var(--amber); }
.ih-kpi.gruen strong { color: var(--green); }
.ih-kpi.is-active { border-color: var(--navy); }

/* Tabellen */
.ih-tabellenrahmen { overflow-x: auto; background: var(--white); border: 1px solid var(--line); border-radius: var(--ma-card-radius); }
.ih-tabelle { width: 100%; border-collapse: collapse; font-size: 14px; }
.ih-tabelle th, .ih-tabelle td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; overflow-wrap: anywhere; }
.ih-tabelle th { position: sticky; top: 0; background: var(--paper); font-size: 12px; text-transform: uppercase; letter-spacing: 0; color: var(--muted); }
.ih-tabelle tbody tr:last-child td { border-bottom: none; }
.ih-tabelle.ih-klickbar tbody tr { cursor: pointer; }
.ih-tabelle.ih-klickbar tbody tr:hover { background: color-mix(in srgb, var(--aqua) 10%, white); }
.ih-tabelle tr.is-selected { background: color-mix(in srgb, var(--aqua) 18%, white); }
.ih-tabelle.ih-kompakt th, .ih-tabelle.ih-kompakt td { padding: 6px 10px; font-size: 13px; }
.ih-tabelle td.zahl { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ih-tabelle td.aktionen { white-space: nowrap; }
.ih-tabelle td.aktionen .knopf + .knopf { margin-left: 6px; }
.ih-tabelle tr.retired td { color: var(--muted); }
.ih-tabelle a, .ih-liste a { color: var(--navy); font-weight: 600; }

/* Ampel */
.ih-ampel { display: inline-block; width: 14px; height: 14px; border-radius: 50%; vertical-align: middle; border: 1px solid var(--line); }
.ih-sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.ih-ampel.rot { background: var(--ampel-rot); }
.ih-ampel.gelb { background: var(--ampel-gelb); }
.ih-ampel.gruen { background: var(--ampel-gruen); }
.ih-ampel.grau { background: var(--line); }
.ih-marke { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--paper); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.ih-marke.vorgeschrieben { background: color-mix(in srgb, var(--navy) 10%, white); color: var(--navy); border-color: transparent; }
.ih-marke.gesperrt, .ih-marke.retired { background: color-mix(in srgb, var(--red) 10%, white); color: var(--red); border-color: transparent; }
.ih-marke.aufbereitung { background: color-mix(in srgb, var(--ampel-gelb) 20%, white); color: var(--amber); border-color: transparent; }
.ih-marke.einsatzbereit, .ih-marke.aktiv { background: color-mix(in srgb, var(--green) 12%, white); color: var(--green); border-color: transparent; }
.ih-zaehler { display: inline-block; min-width: 18px; padding: 1px 6px; border-radius: 999px; font-size: 11px; font-weight: 700; background: var(--aqua); color: var(--navy); margin-left: 4px; }

/* Standzeit-Balken */
.ih-balken { position: relative; width: 120px; height: 10px; border-radius: 999px; background: var(--paper); border: 1px solid var(--line); overflow: hidden; display: inline-block; vertical-align: middle; margin-right: 6px; }
.ih-balken > span { display: block; height: 100%; background: var(--ampel-gruen); }
.ih-balken.gelb > span { background: var(--ampel-gelb); }
.ih-balken.rot > span { background: var(--ampel-rot); }
.ih-balken > span.p0 { width: 0%; }
.ih-balken > span.p5 { width: 5%; }
.ih-balken > span.p10 { width: 10%; }
.ih-balken > span.p15 { width: 15%; }
.ih-balken > span.p20 { width: 20%; }
.ih-balken > span.p25 { width: 25%; }
.ih-balken > span.p30 { width: 30%; }
.ih-balken > span.p35 { width: 35%; }
.ih-balken > span.p40 { width: 40%; }
.ih-balken > span.p45 { width: 45%; }
.ih-balken > span.p50 { width: 50%; }
.ih-balken > span.p55 { width: 55%; }
.ih-balken > span.p60 { width: 60%; }
.ih-balken > span.p65 { width: 65%; }
.ih-balken > span.p70 { width: 70%; }
.ih-balken > span.p75 { width: 75%; }
.ih-balken > span.p80 { width: 80%; }
.ih-balken > span.p85 { width: 85%; }
.ih-balken > span.p90 { width: 90%; }
.ih-balken > span.p95 { width: 95%; }
.ih-balken > span.p100 { width: 100%; }

/* Detailkarten */
.ih-detail { margin-top: 18px; padding: var(--ma-card-padding); }
.ih-detail-kopf { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: flex-start; margin-bottom: 12px; }
.ih-detail-kopf h2 { margin: 0; font-size: 20px; }
.ih-detail-unter { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.ih-detail-aktionen { display: flex; gap: 8px; flex-wrap: wrap; }
.ih-detail-raster { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; }
.ih-detail h3, .ma-card h3 { margin: 0 0 8px; font-size: 15px; }
.ih-dl { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 0 0 10px; font-size: 14px; }
.ih-dl dt { color: var(--muted); }
.ih-dl dd { margin: 0; }
.ih-abschnitt { margin-top: 18px; }
.ih-abschnitt-kopf { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; }
.ih-liste { list-style: none; margin: 0 0 8px; padding: 0; font-size: 14px; }
.ih-liste li { padding: 5px 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.ih-liste li:last-child { border-bottom: none; }
.ih-liste .ih-klein { margin: 0; }
.ih-klapp summary { cursor: pointer; font-weight: 600; font-size: 15px; margin-bottom: 8px; }
.ih-zeile { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-top: 8px; }
.ih-zeile label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); flex: 1 1 200px; }
.ih-anhaenge li button { margin-left: 6px; }

/* Dialoge: immer im Vordergrund (Plattformregel) */
.ih-dialog { border: none; border-radius: var(--ma-card-radius); padding: var(--ma-card-padding); width: min(720px, 94vw); box-shadow: var(--shadow); z-index: 100000; }
.ih-dialog-breit { width: min(960px, 96vw); }
.ih-dialog::backdrop { background: color-mix(in srgb, var(--navy) 45%, transparent); }
.ih-dialog h2 { margin: 0 0 12px; font-size: 20px; }
.ih-dialog form > label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); margin: 8px 0; }
.ih-dialog .ma-form-grid > label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.ih-dialog .ma-compact-form input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]):not([type="file"]), .ih-dialog textarea, .ih-dialog select, .ih-detail .ma-compact-form input:not([type="file"]) { border: 1px solid var(--line); background: var(--white); color: var(--ink); font: inherit; }
.ih-dialog textarea, .ih-dialog select[multiple] { border-radius: var(--ma-field-radius); padding: 8px 10px; font-size: 14px; }
/* Mehrfachauswahl bleibt nativ und mehrzeilig – die Norm-Feldhöhe gilt nur für Einzelfelder. */
.ih-dialog .ma-compact-form select[multiple] { height: auto !important; min-height: 120px !important; -webkit-appearance: listbox; appearance: auto; background-image: none; padding-right: 10px; }
.ih-check { flex-direction: row !important; align-items: flex-start; gap: 8px !important; font-size: 13px !important; color: var(--ink) !important; }
.ih-check input { margin-top: 3px; }
.ih-dialog-aktionen { display: flex; gap: 8px; align-items: center; margin-top: 14px; flex-wrap: wrap; }
.ih-spacer { flex: 1; }
.ih-erl-teil { display: grid; grid-template-columns: minmax(0, 1fr) 120px auto; gap: 8px; align-items: end; margin-bottom: 6px; }
.ih-erl-teil label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.ih-import-vorschau { margin-top: 10px; font-size: 13px; }
.ih-import-vorschau ul { margin: 6px 0; padding-left: 18px; color: var(--red); }
.ih-import-vorschau table { width: 100%; border-collapse: collapse; margin-top: 6px; }
.ih-import-vorschau th, .ih-import-vorschau td { padding: 4px 8px; border-bottom: 1px solid var(--line); text-align: left; }

/* Leserecht: Schreibknoepfe ausblenden */
body.ih-nur-lesen [data-schreibrecht] { display: none !important; }

@media (max-width: 720px) {
  .ih-main { padding: 12px 10px 40px; }
  .ih-suche, .ih-feld { flex: 1 1 100%; }
  .ih-dialog { padding: 14px; }
  .ih-erl-teil { grid-template-columns: 1fr; }
}

@media print {
  .ma-app-kopf, .ih-werkzeugleiste, .ih-detail-aktionen, .ih-dialog, .mainapp-global-header { display: none !important; }
  .tab { display: none; }
  .tab.aktiv { display: block; }
  .ih-tabellenrahmen { border: none; }
}
