/* ===========================================================================
   RadPlan · Auswertungs-Hub – Shell, Navigation, Zeitraum, Dashboard
   + gemeinsame Bausteine (ah-*), die ALLE Module wiederverwenden, damit der
   Hub trotz paralleler Modulentwicklung konsistent aussieht (hell & dunkel).
   =========================================================================== */

/* ---- Modal-Rahmen ---- */
.modal-analytics {
  width: min(1280px, 96vw);
  height: min(860px, 92vh);
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}
.ah-hd {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--gray-200);
  flex-wrap: wrap;
}
.ah-hd-left { min-width: 0; margin-right: auto; }
.ah-close { flex: none; }

/* ---- Zeitraum-Leiste ---- */
.ah-range-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ah-range-pills { display: inline-flex; gap: 4px; background: var(--gray-100, rgba(148,163,184,.12)); padding: 3px; border-radius: 999px; }
.ah-range-pill {
  border: none; background: transparent; cursor: pointer;
  font: 600 11px/1 var(--font-sans); color: var(--text-3);
  padding: 6px 11px; border-radius: 999px; transition: background .15s, color .15s;
}
.ah-range-pill:hover { color: var(--text-1); }
.ah-range-pill.active { background: var(--surface-raised, #fff); color: var(--text-1); box-shadow: var(--shadow-sm, 0 1px 2px rgba(0,0,0,.12)); }
.ah-range-custom { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-3); }
.ah-range-custom input { font: inherit; padding: 4px 6px; border: 1px solid var(--gray-200); border-radius: 6px; background: var(--gray-50); color: var(--text-1); }
.ah-range-static { font-size: 11px; color: var(--text-faint); }

/* ---- Body: Navigation + Inhalt ---- */
.ah-body { display: flex; flex: 1; min-height: 0; }
.ah-nav {
  flex: none; width: 224px; padding: 12px 10px; gap: 2px;
  display: flex; flex-direction: column;
  border-right: 1px solid var(--gray-200);
  overflow-y: auto; background: var(--gray-50);
}
.ah-nav-item {
  display: flex; align-items: center; gap: 10px;
  border: none; background: transparent; cursor: pointer; text-align: left;
  padding: 10px 12px; border-radius: 10px;
  font: 600 12.5px/1.2 var(--font-sans); color: var(--text-2);
  transition: background .14s, color .14s;
}
.ah-nav-item:hover { background: var(--gray-100, rgba(148,163,184,.14)); color: var(--text-1); }
.ah-nav-item.active { background: var(--accent-soft, rgba(14,165,233,.14)); color: var(--accent, #0EA5E9); }
.ah-nav-ico { display: inline-flex; width: 18px; justify-content: center; flex: none; }
.ah-nav-ico svg { width: 16px; height: 16px; }

.ah-content { flex: 1; min-width: 0; overflow-y: auto; padding: 18px 20px 28px; }
.ah-content.ah-fade { animation: ahFade .22s ease; }
@keyframes ahFade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---- Gemeinsame Bausteine (von allen Modulen genutzt) ---- */
.ah-section-title { font-size: 12.5px; font-weight: 800; color: var(--text-1); margin: 18px 0 10px; letter-spacing: .01em; }
.ah-section-title:first-child { margin-top: 0; }
.ah-sub { font-size: 11px; color: var(--text-faint); font-weight: 600; }

.ah-kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.ah-kpi {
  background: var(--gray-50); border: 1px solid var(--gray-200);
  border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; gap: 3px;
}
.ah-kpi-label { font-size: 10.5px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; }
.ah-kpi-value { font-size: 24px; font-weight: 800; line-height: 1.05; font-variant-numeric: tabular-nums; }
.ah-kpi-sub { font-size: 11px; color: var(--text-faint); font-variant-numeric: tabular-nums; }

.ah-card { background: var(--gray-50); border: 1px solid var(--gray-200); border-radius: var(--radius); padding: 14px 16px; }
.ah-card + .ah-card { margin-top: 12px; }

/* Tabellen */
.ah-table-wrap { overflow-x: auto; border: 1px solid var(--gray-200); border-radius: var(--radius); }
.ah-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.ah-table th, .ah-table td { padding: 8px 10px; text-align: right; white-space: nowrap; }
.ah-table th { font-size: 10px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .03em; background: var(--gray-100, rgba(148,163,184,.10)); position: sticky; top: 0; }
.ah-table th:first-child, .ah-table td:first-child { text-align: left; }
.ah-table tbody tr { border-top: 1px solid var(--gray-200); }
.ah-table tbody tr.clickable { cursor: pointer; }
.ah-table tbody tr.clickable:hover { background: var(--gray-100, rgba(148,163,184,.12)); }
.ah-td-num { font-variant-numeric: tabular-nums; }

/* Pillen / Badges */
.ah-pill { display: inline-block; font-size: 10px; font-weight: 800; padding: 2px 9px; border-radius: 999px; border: 1px solid currentColor; line-height: 1.4; }
.ah-pill-good { color: #15803D; background: rgba(21,128,61,.10); }
.ah-pill-warn { color: #B45309; background: rgba(245,158,11,.12); }
.ah-pill-bad  { color: #B91C1C; background: rgba(239,68,68,.10); }

/* Fortschritts-/Wertbalken */
.ah-bar { position: relative; height: 8px; background: var(--gray-200); border-radius: 999px; overflow: hidden; }
.ah-bar > div { position: absolute; left: 0; top: 0; height: 100%; border-radius: 999px; transition: width .4s ease; }

/* Leerzustand / Fehler */
.ah-empty { font-size: 12.5px; color: var(--text-faint); font-style: italic; padding: 28px 8px; text-align: center; }
.ah-error { color: #B91C1C; font-style: normal; }
.ah-ok-banner { font-size: 12px; color: #15803D; background: rgba(21,128,61,.08); border: 1px solid rgba(21,128,61,.2); border-radius: var(--radius); padding: 12px 14px; font-weight: 600; }

/* ---- Dashboard (Modul „Übersicht") ---- */
.ah-dash-head { margin-bottom: 14px; }
.ah-dash-title { font-size: 16px; font-weight: 800; color: var(--text-1); }
.ah-dash-meta { font-size: 11.5px; color: var(--text-faint); margin-top: 2px; font-variant-numeric: tabular-nums; }
.ah-tile-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.ah-tile {
  text-align: left; cursor: pointer; border: 1px solid var(--gray-200);
  background: var(--gray-50); border-radius: var(--radius); padding: 14px 16px;
  display: flex; flex-direction: column; gap: 4px; transition: transform .14s, box-shadow .14s, border-color .14s;
}
.ah-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--gray-300); }
.ah-tile-label { font-size: 11px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .03em; }
.ah-tile-value { font-size: 30px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.ah-tile-unit { font-size: 14px; font-weight: 700; margin-left: 2px; opacity: .7; }
.ah-tile-sub { font-size: 11px; color: var(--text-faint); }
.ah-tile-bar { height: 5px; background: var(--gray-200); border-radius: 999px; overflow: hidden; margin-top: 6px; }
.ah-tile-bar > div { height: 100%; border-radius: 999px; transition: width .5s ease; }

.ah-dash-section { margin-top: 22px; }
.ah-alert-list { display: flex; flex-direction: column; gap: 6px; }
.ah-alert {
  display: flex; align-items: center; gap: 10px; cursor: pointer; text-align: left; width: 100%;
  border: 1px solid var(--gray-200); background: var(--gray-50); border-radius: 10px; padding: 10px 12px;
  font-size: 12.5px; color: var(--text-1); transition: background .14s;
}
.ah-alert:hover { background: var(--gray-100, rgba(148,163,184,.12)); }
.ah-alert-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.ah-alert-high .ah-alert-dot { background: #EF4444; }
.ah-alert-mid .ah-alert-dot { background: #F59E0B; }
.ah-alert-text { flex: 1; }
.ah-alert-go { color: var(--text-faint); font-size: 18px; }

/* ---- Responsive ---- */
@media (max-width: 720px) {
  .modal-analytics { width: 100vw; height: 100vh; border-radius: 0; }
  .ah-body { flex-direction: column; }
  .ah-nav {
    width: 100%; flex-direction: row; overflow-x: auto; border-right: none;
    border-bottom: 1px solid var(--gray-200); padding: 8px;
  }
  .ah-nav-item { white-space: nowrap; }
  .ah-nav-lbl { font-size: 11.5px; }
}

/* ---- Portrait-/Schmal-Mobile (Hochkant) ---- */
@media (max-width: 560px) {
  /* Header darf nicht überlappen: Titel links, Close rechts, Range-Bar in eigene Zeile umbrechen. */
  .ah-hd { gap: 8px 12px; padding: 12px 14px; }
  .ah-hd-left { flex: 1 1 100%; min-width: 0; }
  .ah-hd-left * { overflow-wrap: anywhere; }
  .ah-range-bar { flex: 1 1 100%; gap: 8px; min-width: 0; }
  /* Range-Pills horizontal scrollbar statt Überlappung. */
  .ah-range-pills {
    flex: 1 1 auto; max-width: 100%;
    overflow-x: auto; flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch; scrollbar-width: thin;
  }
  .ah-range-pill { flex: none; white-space: nowrap; }
  .ah-range-custom { flex-wrap: wrap; }
  .ah-range-custom input { min-width: 0; flex: 1 1 120px; }

  /* Inhalt: Padding reduzieren, kein horizontales Mitscrollen. */
  .ah-content { padding: 14px 12px 24px; }
  .ah-body { min-width: 0; }
  .ah-content > * { min-width: 0; }

  /* KPI-Grid: 2 Spalten, kompaktere Werte. */
  .ah-kpi-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .ah-kpi { padding: 10px 11px; }
  .ah-kpi-value { font-size: 20px; }
  .ah-kpi-label { font-size: 9.5px; }

  /* Tabellen: kompakter, Wrap begrenzt die Breite und kapselt Sticky-Header. */
  .ah-table-wrap {
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
    contain: paint;
  }
  .ah-table { font-size: 11px; }
  .ah-table th, .ah-table td { padding: 6px 7px; }
  .ah-table th { font-size: 9px; }

  /* Tiles + Alerts 1-spaltig / kompakter. */
  .ah-tile-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .ah-tile { padding: 12px 13px; }
  .ah-tile-value { font-size: 24px; }
  .ah-dash-title { font-size: 15px; }
  .ah-alert { font-size: 12px; padding: 9px 11px; align-items: flex-start; }
  .ah-alert-text { overflow-wrap: anywhere; min-width: 0; }
}

@media (max-width: 380px) {
  .ah-content { padding: 12px 10px 22px; }
  /* Sehr schmal: alles einspaltig, Werte weiter verkleinern. */
  .ah-kpi-grid { grid-template-columns: 1fr; }
  .ah-kpi-value { font-size: 22px; }
  .ah-tile-grid { grid-template-columns: 1fr; }
  .ah-tile-value { font-size: 26px; }
  .ah-table { font-size: 10.5px; }
  .ah-table th, .ah-table td { padding: 5px 6px; }
  .ah-section-title { font-size: 12px; }
}

