/* Reefy – Komponenten. Werte kommen aus tokens.css (data-theme="light" | "dark"). */

:root, [data-theme] {
  --status-gradient: linear-gradient(180deg, var(--status-crit-band) 0%, var(--status-warn-band) 25%, var(--status-ok-band) 40%, var(--status-ok-band) 60%, var(--status-warn-band) 75%, var(--status-crit-band) 100%);
  --status-gradient-h: linear-gradient(90deg, var(--status-crit-band) 0%, var(--status-warn-band) 25%, var(--status-ok-band) 40%, var(--status-ok-band) 60%, var(--status-warn-band) 75%, var(--status-crit-band) 100%);
}
.rf { font-family: var(--font-sans); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
sc-for { display: contents; }

/* Typografie */
.ty-title, .ty-heading, .hdr-title, .state-title {
  font-family: var(--font-display); font-weight: 400; font-synthesis: none; letter-spacing: 0.015em;
  color: var(--text); hyphens: auto; overflow-wrap: break-word;
}
.ty-title { font-size: 28px; line-height: 36px; }
.ty-heading { font-size: 20px; line-height: 28px; }
.ty-heading-s { font-family: var(--font-sans); font-size: 17px; line-height: 22px; font-weight: 700; }
.ty-body { font-family: var(--font-sans); font-size: 16px; line-height: 24px; font-weight: 400; }
.ty-label { font-family: var(--font-sans); font-size: 13px; line-height: 18px; font-weight: 700; letter-spacing: 0.01em; }
.ty-value { font-family: var(--font-sans); font-size: 34px; line-height: 40px; font-weight: 800; font-variant-numeric: tabular-nums lining-nums; letter-spacing: -0.01em; }
.ty-value-s { font-family: var(--font-sans); font-size: 17px; line-height: 22px; font-weight: 800; font-variant-numeric: tabular-nums lining-nums; }
.ty-unit { font-family: var(--font-sans); font-size: 13px; line-height: 18px; font-weight: 700; color: var(--text-muted); }

/* Icons */
.ic { width: 24px; height: 24px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ic-20 { width: 20px; height: 20px; } .ic-18 { width: 18px; height: 18px; } .ic-32 { width: 32px; height: 32px; }

/* Fokus */
.is-focus, .tile:focus-visible, .pcard:focus-visible, .btn:focus-visible, .select:focus-visible, .seg-opt:focus-visible,
.tab:focus-visible, .chip:focus-visible, .grp-head:focus-visible, .icon-btn:focus-visible, .fab:focus-visible {
  outline: var(--line-focus) solid var(--focus); outline-offset: 3px;
}

/* Plastik: alle Buttons, Kacheln, Fotokarten */
:is(.btn-primary, .btn-secondary, .fab, .pcard, .chip, .select, .seg-opt.is-on):not(.is-disabled):not(.is-pressed):not(:disabled) {
  background-image: linear-gradient(180deg, var(--raise-top) 0%, transparent 50%, var(--raise-bottom) 100%);
  box-shadow: var(--raise);
}
:is(.btn-primary, .btn-secondary, .fab, .pcard, .chip, .select, .seg-opt, .tile):is(.is-pressed, :active) { box-shadow: var(--sink); background-image: none; }

/* Kachel */
.tile-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4); }
.tile {
  box-sizing: border-box; width: 100%; aspect-ratio: 1 / 1; padding: 14px 12px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  border-radius: var(--radius-l); border: 1px solid var(--card-edge);
  background: linear-gradient(180deg, var(--tile-top) 0%, var(--tile-top) 55%, var(--tile-bottom) 100%); box-shadow: var(--raise);
  font: inherit; color: var(--text); text-align: center; cursor: pointer;
}
.tile img { width: 84px; height: 84px; display: block; }
.tile-label { font-family: var(--font-sans); font-size: 17px; line-height: 22px; font-weight: 800; overflow-wrap: break-word; hyphens: auto; }
.tile.is-pressed, .tile:active { background: var(--surface); transform: scale(0.97); }
.tile.is-disabled { background: var(--disabled-bg); box-shadow: none; color: var(--disabled-text); cursor: default; }
.tile.is-disabled img { opacity: 0.4; filter: grayscale(1); }

/* Karte mit Foto */
.pcard {
  box-sizing: border-box; width: 100%; padding: 0; overflow: hidden; display: flex; flex-direction: column;
  border-radius: var(--radius-l); background-color: var(--card); border: 1px solid var(--card-edge);
  font: inherit; color: var(--text); text-align: left; cursor: pointer;
}
.pcard-photo {
  height: 112px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  background: repeating-linear-gradient(135deg, var(--surface) 0 12px, var(--primary-soft) 12px 24px);
  color: var(--text); font-size: 13px; line-height: 18px; font-weight: 700;
}
.pcard-photo img { width: 100%; height: 100%; object-fit: cover; }
.pcard-photo.is-empty { background: var(--surface); color: var(--primary); }
.pcard-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 2px; }
.pcard-title { font-size: 16px; line-height: 21px; font-weight: 800; overflow-wrap: break-word; hyphens: auto; }
.pcard-meta { font-size: 13px; line-height: 18px; font-weight: 600; color: var(--text-muted); display: flex; align-items: center; gap: 4px; }
.pcard.is-pressed, .pcard:active { background-color: var(--surface); transform: scale(0.98); }

/* Buttons */
.btn {
  box-sizing: border-box; min-height: 48px; padding: 12px 20px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: var(--radius-m); border: 2px solid transparent; font-family: var(--font-sans); font-size: 16px; line-height: 22px; font-weight: 800;
  text-align: center; cursor: pointer; background-color: transparent; color: var(--primary);
}
.btn-block { width: 100%; }
.btn-primary { background-color: var(--primary); color: var(--on-primary); }
.btn-primary.is-pressed, .btn-primary:active { background-color: var(--primary-pressed); }
.btn-secondary { background-color: var(--card); border-color: var(--primary); color: var(--primary); }
.btn-secondary.is-pressed, .btn-secondary:active { background-color: var(--primary-soft); }
.btn-text { padding: 12px 14px; }
.btn-text.is-pressed, .btn-text:active { background-color: var(--pressed); }
.btn.is-disabled, .btn:disabled { background-color: var(--disabled-bg); border-color: transparent; color: var(--disabled-text); cursor: default; }
.btn-text.is-disabled { background-color: transparent; }
.fab {
  box-sizing: border-box; min-width: 56px; height: 56px; padding: 0 16px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 18px; background-color: var(--accent); color: var(--on-accent);
  font-family: var(--font-sans); font-size: 16px; line-height: 22px; font-weight: 800; cursor: pointer;
}
.fab.is-pressed, .fab:active { transform: scale(0.96); }

/* Eingabefeld mit Einheit */
.field { display: flex; flex-direction: column; gap: 6px; font-family: var(--font-sans); }
.field-label { font-size: 14px; line-height: 20px; font-weight: 700; color: var(--text); }
.field-box { box-sizing: border-box; min-height: 52px; display: flex; align-items: stretch; overflow: hidden; border: var(--line-ui) solid var(--border-strong); border-radius: var(--radius-m); background: var(--card); }
.field-input { flex: 1; min-width: 0; padding: 12px 14px; border: 0; outline: none; background: transparent; font: inherit; font-size: 20px; line-height: 26px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--text); }
.field-input::placeholder { color: var(--text-muted); font-weight: 600; }
.field-unit { display: flex; align-items: center; padding: 0 14px; white-space: nowrap; background: var(--surface); border-left: var(--line-hair) solid var(--border); font-size: 15px; line-height: 20px; font-weight: 800; color: var(--text-muted); }
.field-help { font-size: 13px; line-height: 18px; font-weight: 600; color: var(--text-muted); }
.field-msg { display: flex; align-items: flex-start; gap: 6px; font-size: 13px; line-height: 18px; font-weight: 700; color: var(--error); }
.field.is-focus { outline: none; }
.field.is-focus .field-box { border-color: var(--primary); box-shadow: 0 0 0 1.5px var(--primary); }
.field.is-error .field-box { border-color: var(--error); box-shadow: 0 0 0 1.5px var(--error); }
.field.is-disabled .field-box { background: var(--disabled-bg); border-color: var(--disabled-bg); }
.field.is-disabled .field-input, .field.is-disabled .field-unit, .field.is-disabled .field-label, .field.is-disabled .field-help { color: var(--disabled-text); }
.field.is-disabled .field-unit { background: var(--disabled-bg); border-left-color: var(--disabled-strong); }

/* Dropdown */
.select { box-sizing: border-box; width: 100%; min-height: 52px; padding: 0 12px 0 14px; display: flex; align-items: center; gap: 10px; border: var(--line-ui) solid var(--border-strong); border-radius: var(--radius-m); background-color: var(--card); font-family: var(--font-sans); font-size: 16px; line-height: 22px; font-weight: 700; color: var(--text); text-align: left; cursor: pointer; }
.select-value { flex: 1; min-width: 0; }
.select.is-open { border-color: var(--primary); box-shadow: 0 0 0 1.5px var(--primary); }
.select.is-open .select-chev { transform: rotate(180deg); }
.select.is-disabled { background-color: var(--disabled-bg); border-color: var(--disabled-bg); color: var(--disabled-text); cursor: default; }
.menu { margin-top: 6px; padding: 6px; display: flex; flex-direction: column; gap: 2px; border-radius: var(--radius-m); background: var(--card); border: 1px solid var(--border); box-shadow: var(--shadow-3); }
.menu-item { box-sizing: border-box; width: 100%; min-height: 44px; padding: 10px 10px 10px 12px; display: flex; align-items: center; gap: 10px; border: 0; border-radius: var(--radius-s); background: transparent; font-family: var(--font-sans); font-size: 16px; line-height: 22px; font-weight: 600; color: var(--text); text-align: left; cursor: pointer; }
.menu-item.is-selected { background: var(--primary-soft); font-weight: 800; }
.menu-item .ic { margin-left: auto; color: var(--primary); }
.menu-unit { font-size: 13px; font-weight: 700; color: var(--text-muted); }

/* Umschalter */
.seg { box-sizing: border-box; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; padding: 4px; border-radius: var(--radius-m); background: var(--surface); border: var(--line-ui) solid var(--border-strong); }
.seg-opt { box-sizing: border-box; min-height: 44px; padding: 8px 10px; display: flex; align-items: center; justify-content: center; border: 0; border-radius: var(--radius-s); background-color: transparent; font-family: var(--font-sans); font-size: 15px; line-height: 20px; font-weight: 700; color: var(--text-muted); text-align: center; cursor: pointer; }
.seg-opt.is-on { background-color: var(--primary); color: var(--on-primary); font-weight: 800; }
.seg-opt.is-on.is-pressed, .seg-opt.is-on:active { background-color: var(--primary-pressed); }
.seg.is-disabled { background: var(--disabled-bg); border-color: var(--disabled-bg); }
.seg.is-disabled .seg-opt { color: var(--disabled-text); cursor: default; }
.seg.is-disabled .seg-opt.is-on { background-color: var(--disabled-strong); }

/* Tabs */
.tabs { display: flex; border-bottom: var(--line-ui) solid var(--border); }
.tab { flex: 1; box-sizing: border-box; min-height: 48px; padding: 12px 8px 10px; margin-bottom: -1.5px; border: 0; border-bottom: 3px solid transparent; background: transparent; font-family: var(--font-sans); font-size: 15px; line-height: 20px; font-weight: 700; color: var(--text-muted); text-align: center; cursor: pointer; }
.tab.is-on { color: var(--primary); border-bottom-color: var(--primary); font-weight: 800; }
.tab.is-focus { outline-offset: -3px; border-radius: var(--radius-s) var(--radius-s) 0 0; }
.tab.is-pressed, .tab:active { background: var(--pressed); }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { box-sizing: border-box; min-height: 44px; padding: 0 14px 0 12px; display: inline-flex; align-items: center; gap: 6px; border: var(--line-ui) solid var(--border-strong); border-radius: var(--radius-full); background-color: var(--card); font-family: var(--font-sans); font-size: 15px; line-height: 20px; font-weight: 700; color: var(--text); cursor: pointer; }
.chip.is-on { background-color: var(--primary); border-color: var(--primary); color: var(--on-primary); font-weight: 800; }
.chip.is-on.is-pressed, .chip.is-on:active { background-color: var(--primary-pressed); }
.chip.is-disabled { background-color: var(--disabled-bg); border-color: var(--disabled-bg); color: var(--disabled-text); cursor: default; }

/* Einklappbare Gruppe */
.grp { border-radius: var(--radius-l); background: var(--card); border: 1px solid var(--card-edge); box-shadow: var(--shadow-1); overflow: hidden; font-family: var(--font-sans); }
.grp-head { box-sizing: border-box; width: 100%; min-height: 60px; padding: 12px 14px 12px 16px; display: flex; align-items: center; gap: 12px; border: 0; border-radius: var(--radius-l); background: transparent; font: inherit; color: var(--text); text-align: left; cursor: pointer; }
.grp-head.is-pressed, .grp-head:active { background: var(--pressed); }
.grp-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.grp-name { font-size: 17px; line-height: 22px; font-weight: 800; }
.grp-sub { font-size: 13px; line-height: 18px; font-weight: 700; color: var(--text-muted); }
.grp.is-open .grp-chev { transform: rotate(180deg); }
.grp-body { padding: 0 16px 6px; }
.kv { min-height: 52px; display: flex; align-items: center; gap: 10px; border-top: var(--line-hair) solid var(--border); }
.kv-name { flex: 1; min-width: 0; font-size: 16px; line-height: 22px; font-weight: 600; }
.kv-val { font-size: 17px; line-height: 22px; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kv-unit { font-size: 13px; font-weight: 700; color: var(--text-muted); margin-left: 3px; }

/* Badge */
.badge { display: inline-flex; align-items: center; gap: 6px; min-height: 28px; padding: 3px 10px 3px 8px; box-sizing: border-box; border-radius: var(--radius-full); font-family: var(--font-sans); font-size: 13px; line-height: 18px; font-weight: 800; white-space: nowrap; }
.badge svg { width: 14px; height: 14px; overflow: visible; flex: none; }
.badge-ok { background: var(--status-ok-band); color: var(--status-ok-text); }
.badge-warn { background: var(--status-warn-band); color: var(--status-warn-text); }
.badge-crit { background: var(--status-crit-band); color: var(--status-crit-text); }

/* Kopfzeile */
.hdr { box-sizing: border-box; min-height: 56px; padding: 4px; display: flex; align-items: center; gap: 4px; background: var(--bg); color: var(--text); }
.hdr-title { flex: 1; min-width: 0; margin: 0; padding: 0 4px; font-size: 20px; line-height: 28px; }
.icon-btn { width: 48px; height: 48px; flex: none; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: var(--radius-full); background: transparent; color: var(--text); cursor: pointer; }
.icon-btn.is-pressed, .icon-btn:active { background: var(--pressed); }
.icon-btn.is-danger { color: var(--error); }

/* Diagramm */
.chart-card { box-sizing: border-box; width: 100%; padding: 16px; border-radius: var(--radius-l); background: var(--card); border: 1px solid var(--card-edge); box-shadow: var(--shadow-1); display: flex; flex-direction: column; gap: 14px; font-family: var(--font-sans); }
.ch { position: relative; width: 318px; height: 204px; }
.ch-band { position: absolute; left: 34px; top: 10px; width: 192px; height: 160px; border-radius: var(--radius-xs); background: var(--status-gradient); }
.ch-svg { position: absolute; left: 0; top: 0; width: 318px; height: 204px; overflow: visible; }
.ch-grid { fill: none; stroke: var(--text-muted); stroke-width: 1; stroke-dasharray: 2 3; }
.ch-target { fill: none; stroke: var(--text); stroke-width: 2; stroke-dasharray: 6 4; }
.ch-casing { fill: none; stroke: var(--card); stroke-width: 7; stroke-linecap: round; stroke-linejoin: round; }
.ch-line { fill: none; stroke: var(--accent); stroke-width: var(--line-chart); stroke-linecap: round; stroke-linejoin: round; }
.ch-ax { fill: var(--text-muted); font-family: var(--font-sans); font-size: 12px; font-weight: 700; }
.ch-lbl { fill: var(--text); font-family: var(--font-sans); font-size: 12px; font-weight: 800; }
.ta-end { text-anchor: end; } .ta-mid { text-anchor: middle; }
.mk { stroke: var(--marker-stroke); stroke-width: 1.75; stroke-linejoin: round; }
.mk-ok { fill: var(--status-ok); } .mk-warn { fill: var(--status-warn); } .mk-crit { fill: var(--status-crit); }
.mk-line { fill: none; stroke: var(--accent); stroke-width: 3; stroke-linecap: round; }
.mk-target { fill: none; stroke: var(--text); stroke-width: 2; stroke-dasharray: 4 3; }
.ch-tip { position: absolute; white-space: nowrap; box-sizing: border-box; padding: 7px 10px 8px; border-radius: 10px; background: var(--card); border: 1px solid var(--border-strong); box-shadow: var(--shadow-2); display: flex; flex-direction: column; gap: 1px; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 13px; line-height: 18px; font-weight: 700; color: var(--text); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend svg { width: 18px; height: 16px; overflow: visible; flex: none; }

/* Zustände */
.state { box-sizing: border-box; display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 28px 22px 24px; border-radius: var(--radius-l); background: var(--card); border: 1px solid var(--card-edge); box-shadow: var(--shadow-1); text-align: center; font-family: var(--font-sans); }
.state-icon { width: 64px; height: 64px; border-radius: var(--radius-full); display: flex; align-items: center; justify-content: center; background: var(--error-soft); color: var(--error); }
.state-title { margin: 0; font-size: 20px; line-height: 28px; }
.state-text { margin: 0; font-size: 16px; line-height: 24px; color: var(--text-muted); }
.banner { box-sizing: border-box; display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; border-radius: var(--radius-m); background: var(--error-soft); border: var(--line-ui) solid var(--error); color: var(--text); font-family: var(--font-sans); font-size: 15px; line-height: 22px; }
.banner .ic { color: var(--error); }

/* Vorschau-Rahmen (nur im Design System) */
.pv { box-sizing: border-box; padding: 20px; display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.pv-col { width: 350px; display: flex; flex-direction: column; gap: 14px; }
.pv-cap { margin: 0 0 6px; font-family: var(--font-sans); font-size: 12px; line-height: 16px; font-weight: 700; color: var(--text-muted); }
