﻿/*
  VEFKapp Design System
  UI-Größen bitte ausschließlich über diese Tokens oder die zentralen App-Komponenten ändern.
  Diese Datei ist additiv und greift bewusst defensiv, damit bestehende Fachlogik und PDF-Ausgaben unverändert bleiben.
*/
:root {
  color-scheme: dark;
  --app-font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
  --app-accent: #f5a400;
  --app-accent-strong: #ffbf2f;
  --app-bg: #050505;
  --app-surface: rgba(10, 10, 8, 0.94);
  --app-surface-raised: linear-gradient(145deg, rgba(27, 23, 13, 0.96), rgba(4, 4, 4, 0.96));
  --app-text: #fff8e8;
  --app-text-muted: rgba(255, 248, 232, 0.72);
  --app-border: rgba(245, 164, 0, 0.42);
  --app-border-soft: rgba(245, 164, 0, 0.24);
  --app-shadow: 0 14px 34px rgba(0, 0, 0, 0.32);
  --app-glow: 0 0 20px rgba(245, 164, 0, 0.18);

  --app-text-xs: calc(0.68rem * var(--hub-ui-scale, 1));
  --app-text-sm: calc(0.78rem * var(--hub-ui-scale, 1));
  --app-text-md: calc(0.88rem * var(--hub-ui-scale, 1));
  --app-text-lg: calc(0.96rem * var(--hub-ui-scale, 1));
  --app-text-xl: calc(1.10rem * var(--hub-ui-scale, 1));
  --app-text-title: calc(1.36rem * var(--hub-ui-scale, 1));

  --app-space-1: 4px;
  --app-space-2: 7px;
  --app-space-3: 10px;
  --app-space-4: 14px;
  --app-space-5: 18px;
  --app-space-6: 22px;

  --app-radius-sm: 8px;
  --app-radius-md: 12px;
  --app-radius-lg: 16px;
  --app-icon-sm: calc(18px * var(--hub-ui-scale, 1));
  --app-icon-md: calc(24px * var(--hub-ui-scale, 1));
  --app-icon-lg: calc(38px * var(--hub-ui-scale, 1));
  --app-button-height: calc(34px * var(--hub-ui-scale, 1));
  --app-button-height-sm: calc(30px * var(--hub-ui-scale, 1));
  --app-header-height: clamp(58px, 8vw, 96px);
  --app-sidebar-width: clamp(190px, 18vw, 224px);
}

html { font-family: var(--app-font-family); }
body { font-family: var(--app-font-family); }

/* A 100% browser zoom is the desktop reference. Keep inherited app copy
   compact and consistent without changing print geometry or mobile inputs. */
@media screen and (min-width: 761px) {
  body.is-hub-embedded,
  body.hub-embedded,
  body.hub-shell-ready:not([data-view]) {
    font-size: calc(13px * var(--hub-ui-scale, 1)) !important;
  }
}

.app-card,
.hub-shell-card,
.hub-app-context-row,
.audit-shell-frame-card {
  border-radius: var(--app-radius-lg);
  border-color: var(--app-border-soft);
}

.app-section-title {
  margin: 0 0 var(--app-space-3);
  color: var(--app-text);
  font-size: var(--app-text-xl);
  line-height: 1.15;
  font-weight: 850;
}

.app-empty-state {
  padding: var(--app-space-5);
  border: 1px dashed var(--app-border);
  border-radius: var(--app-radius-md);
  background: rgba(245, 164, 0, 0.07);
  color: var(--app-text-muted);
}

button,
.button,
.primary,
.secondary,
.primary-button,
.secondary-button,
.hub-nav-item,
.nav-item {
  font-family: var(--app-font-family);
}

.primary,
.secondary,
.primary-button,
.secondary-button,
.app-primary-button,
.app-secondary-button {
  min-height: var(--app-button-height-sm);
  border-radius: var(--app-radius-sm);
  font-size: var(--app-text-sm);
}

.hub-shell-navigation,
.audit-shell-sidebar,
.sidebar {
  width: var(--app-sidebar-width);
}

.hub-nav-item,
.nav-item {
  min-height: calc(42px * var(--hub-ui-scale, 1));
  border-radius: var(--app-radius-md);
  font-size: var(--app-text-sm);
}

.hub-nav-item .icon,
.nav-item .icon {
  width: var(--app-icon-md);
  height: var(--app-icon-md);
  flex: 0 0 var(--app-icon-md);
}

.topbar,
.hub-shell-header,
.app-shell-header {
  min-height: var(--app-header-height);
  border-radius: var(--app-radius-lg);
}

.ai-usage-widget {
  position: relative;
  flex: 0 0 auto;
  min-width: 0;
}

.ai-usage-widget[hidden],
.ai-usage-popover[hidden] {
  display: none !important;
}

.ai-usage-trigger {
  position: relative;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  width: clamp(158px, 16vw, 220px);
  min-height: 36px;
  padding: 4px 9px 6px 6px;
  overflow: hidden;
  border: 1px solid rgba(183, 154, 255, 0.68);
  border-radius: 9px;
  background: linear-gradient(180deg, rgba(40, 31, 58, 0.96), rgba(15, 12, 22, 0.96));
  color: #f7f2ff;
  box-shadow: inset 0 0 0 1px rgba(214, 196, 255, 0.08), 0 4px 14px rgba(0, 0, 0, 0.28);
  cursor: pointer;
  text-align: left;
}

.ai-usage-trigger:hover,
.ai-usage-trigger:focus-visible {
  border-color: #d8c4ff;
  background: linear-gradient(180deg, rgba(57, 43, 82, 0.98), rgba(21, 16, 31, 0.98));
  outline: none;
}

.ai-usage-trigger__icon {
  display: grid;
  width: 28px;
  height: 26px;
  place-items: center;
  border-radius: 7px;
  background: #d8c4ff;
  color: #24163c;
  font-size: 10px;
  font-weight: 900;
}

.ai-usage-trigger__copy {
  display: grid;
  min-width: 0;
  gap: 1px;
}

.ai-usage-trigger__copy small {
  color: #cfc5dd;
  font-size: 9.5px;
  font-weight: 750;
  line-height: 1;
}

.ai-usage-trigger__copy strong {
  overflow: hidden;
  color: #fff;
  font-size: 10.5px;
  font-weight: 800;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-usage-trigger__copy [data-ai-usage-mobile] {
  display: none;
}

.ai-usage-trigger__meter {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.09);
}

.ai-usage-trigger__meter i,
.ai-usage-bar i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: #31b97c;
  transition: width 180ms ease, background-color 180ms ease;
}

.ai-usage-widget[data-state="warning"] .ai-usage-trigger,
.ai-usage-popover[data-state="warning"] {
  border-color: rgba(255, 194, 71, 0.82);
}

.ai-usage-widget[data-state="warning"] .ai-usage-trigger__meter i,
.ai-usage-popover[data-state="warning"] .ai-usage-bar i {
  background: #ffc247;
}

.ai-usage-widget:is([data-state="critical"], [data-state="exhausted"]) .ai-usage-trigger,
.ai-usage-popover:is([data-state="critical"], [data-state="exhausted"]) {
  border-color: rgba(239, 84, 84, 0.9);
}

.ai-usage-widget:is([data-state="critical"], [data-state="exhausted"]) .ai-usage-trigger__meter i,
.ai-usage-popover:is([data-state="critical"], [data-state="exhausted"]) .ai-usage-bar i {
  background: #ef5454;
}

.ai-usage-widget[data-state="disabled"] .ai-usage-trigger {
  border-color: rgba(148, 157, 171, 0.5);
  filter: saturate(0.3);
}

.ai-usage-popover {
  position: fixed;
  z-index: 10020;
  display: grid;
  gap: 9px;
  max-height: calc(100vh - 20px);
  padding: 12px;
  overflow: auto;
  border: 1px solid rgba(183, 154, 255, 0.62);
  border-radius: 8px;
  background: #181a1f;
  color: #f4f5f7;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.56);
}

.ai-usage-popover__head,
.ai-usage-period__title,
.ai-usage-popover__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.ai-usage-popover__head {
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.ai-usage-popover__head > div {
  display: grid;
  gap: 2px;
}

.ai-usage-popover__head small,
.ai-usage-values small,
.ai-usage-period__title span {
  color: #aeb5c0;
  font-size: 10px;
}

.ai-usage-popover__head strong {
  font-size: 14px;
}

.ai-usage-popover__head button {
  display: grid;
  width: 28px;
  height: 28px;
  min-height: 28px;
  padding: 0;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  background: #25282e;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
}

.ai-usage-period {
  display: grid;
  gap: 7px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 7px;
  background: #202329;
}

.ai-usage-period__title strong {
  font-size: 12px;
}

.ai-usage-values {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.ai-usage-values span {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 7px;
  border-radius: 6px;
  background: #292d34;
}

.ai-usage-values strong {
  overflow-wrap: anywhere;
  font-size: 12px;
}

.ai-usage-bar {
  height: 5px;
  overflow: hidden;
  border-radius: 5px;
  background: #343941;
}

.ai-usage-period p {
  margin: 0;
  color: #c7cbd2;
  font-size: 10px;
  line-height: 1.35;
}

.ai-usage-popover__footer {
  align-items: flex-start;
  color: #bec4ce;
  font-size: 10px;
}

.ai-usage-popover__footer strong {
  color: #fff;
  white-space: nowrap;
}

.ai-usage-popover[data-measurement="partial"] .ai-usage-popover__footer span {
  color: #ffc247;
}

@media (max-width: 760px) {
  .ai-usage-trigger {
    grid-template-columns: 24px minmax(0, 1fr);
    gap: 5px;
    width: min(142px, 42vw);
    min-height: 28px;
    padding: 3px 6px 5px 4px;
  }

  .ai-usage-trigger__icon {
    width: 24px;
    height: 21px;
    font-size: 9px;
  }

  .ai-usage-trigger__copy small {
    display: none;
  }

  .ai-usage-trigger__copy strong {
    font-size: 10px;
  }

  .ai-usage-trigger__copy [data-ai-usage-full] {
    display: none;
  }

  .ai-usage-trigger__copy [data-ai-usage-mobile] {
    display: inline;
  }
}

input,
select,
textarea {
  font-family: var(--app-font-family);
  font-size: var(--app-text-sm);
}

@media (max-width: 760px) {
  :root {
    --app-sidebar-width: 72px;
    --app-header-height: clamp(56px, 14vw, 82px);
    --app-button-height: 36px;
    --app-button-height-sm: 32px;
  }
  .hub-nav-item,
  .nav-item { min-height: 40px; }
}

/* 2026-06-06: verbindlicher Groessenvertrag fuer Hub und App-Inhalte. */
@media screen {
  :where(.view, .app-view, .content, .main-content, .dashboard, .page-content) {
    gap: var(--app-space-3);
  }

  :where(.panel, .card, .metric, .tile, .table-wrap, .section, .app-card, .dashboard-card, .customer-card) {
    border-radius: var(--app-radius-md);
  }

  :where(.panel, .card, .metric, .tile, .table-wrap, .section, .app-card, .dashboard-card, .customer-card):not(.report-page *) {
    padding: var(--app-space-3);
  }

  :where(h1):not(.report-page h1) {
    font-size: var(--app-text-title);
    line-height: 1.08;
  }

  :where(h2):not(.report-page h2) {
    font-size: var(--app-text-xl);
    line-height: 1.12;
  }

  :where(h3):not(.report-page h3) {
    font-size: var(--app-text-lg);
    line-height: 1.18;
  }

  :where(p, label, td, th, li, input, select, textarea):not(.report-page *) {
    font-size: var(--app-text-sm);
  }

  :where(small, .muted, .muted-text, .hint, .eyebrow):not(.report-page *) {
    font-size: var(--app-text-xs);
  }

  :where(.metrics-grid, .dashboard-metrics, .stat-grid) {
    gap: var(--app-space-2);
  }

  :where(.metric, .stat-card, .summary-card):not(.report-page *) {
    min-height: calc(64px * var(--hub-ui-scale, 1));
  }

  :where(.metric strong, .stat-card strong, .summary-card strong):not(.report-page *) {
    font-size: calc(1.24rem * var(--hub-ui-scale, 1));
    line-height: 1.04;
  }

  :where(.table, table):not(.report-page table) th,
  :where(.table, table):not(.report-page table) td {
    padding: var(--app-space-2) var(--app-space-3);
  }

  :where(button, .button, .primary, .secondary, .primary-button, .secondary-button):not(.report-page *) {
    min-height: var(--app-button-height-sm);
    padding: 0 var(--app-space-3);
    line-height: 1.15;
  }

  :where(input, select):not(.report-page *) {
    min-height: var(--app-button-height-sm);
  }

  :where(textarea):not(.report-page *) {
    min-height: calc(68px * var(--hub-ui-scale, 1));
  }

  :where(.app-brand-icon svg, .brand-logo svg, .icon svg):not(.report-page *) {
    max-width: var(--app-icon-lg);
    max-height: var(--app-icon-lg);
  }
}

/* 2026-06-06: harte Groessen-Sperre fuer normale App-Oberflaechen.
   Nicht fuer PDF-/Reportseiten verwenden. */
@media screen {
  :where(body.is-hub-embedded, html.is-hub-embedded body, body[data-hub-embedded="true"]):not(.print-mode) :is(.panel, .card, .metric, .tile, .table-wrap, .section, .app-card, .dashboard-card, .customer-card, .audit-point):not(.report-page *) {
    padding: var(--app-space-3) !important;
    border-radius: var(--app-radius-md) !important;
  }

  :where(body.is-hub-embedded, html.is-hub-embedded body, body[data-hub-embedded="true"]):not(.print-mode) :is(h1):not(.report-page *) {
    font-size: var(--app-text-title) !important;
    line-height: 1.08 !important;
  }

  :where(body.is-hub-embedded, html.is-hub-embedded body, body[data-hub-embedded="true"]):not(.print-mode) :is(h2):not(.report-page *) {
    font-size: var(--app-text-xl) !important;
    line-height: 1.12 !important;
  }

  :where(body.is-hub-embedded, html.is-hub-embedded body, body[data-hub-embedded="true"]):not(.print-mode) :is(h3):not(.report-page *) {
    font-size: var(--app-text-lg) !important;
    line-height: 1.18 !important;
  }

  :where(body.is-hub-embedded, html.is-hub-embedded body, body[data-hub-embedded="true"]):not(.print-mode) :is(p, label, td, th, li, input, select, textarea, button):not(.report-page *) {
    font-size: var(--app-text-sm) !important;
  }

  :where(body.is-hub-embedded, html.is-hub-embedded body, body[data-hub-embedded="true"]):not(.print-mode) :is(small, .muted, .muted-text, .hint, .eyebrow, .status-chip, .result-pill, .priority-chip):not(.report-page *) {
    font-size: var(--app-text-xs) !important;
  }

  :where(body.is-hub-embedded, html.is-hub-embedded body, body[data-hub-embedded="true"]):not(.print-mode) :is(.metrics-grid, .dashboard-metrics, .stat-grid, .dashboard-grid):not(.report-page *) {
    gap: var(--app-space-2) !important;
  }

  :where(body.is-hub-embedded, html.is-hub-embedded body, body[data-hub-embedded="true"]):not(.print-mode) :is(.metric, .stat-card, .summary-card):not(.report-page *) {
    min-height: calc(60px * var(--hub-ui-scale, 1)) !important;
  }

  :where(body.is-hub-embedded, html.is-hub-embedded body, body[data-hub-embedded="true"]):not(.print-mode) :is(.metric strong, .stat-card strong, .summary-card strong):not(.report-page *) {
    font-size: calc(1.18rem * var(--hub-ui-scale, 1)) !important;
    line-height: 1.02 !important;
  }

  :where(body.is-hub-embedded, html.is-hub-embedded body, body[data-hub-embedded="true"]):not(.print-mode) :is(.topbar, .hub-shell-header, .app-shell-header, .audit-page-header):not(.report-page *) {
    min-height: var(--app-header-height) !important;
  }

  :where(body.is-hub-embedded, html.is-hub-embedded body, body[data-hub-embedded="true"]):not(.print-mode) :is(.hub-shell-navigation, .audit-shell-sidebar, .sidebar):not(.report-page *) {
    width: var(--app-sidebar-width) !important;
  }

  :where(body.is-hub-embedded, html.is-hub-embedded body, body[data-hub-embedded="true"]):not(.print-mode) :is(.hub-nav-item, .nav-item):not(.report-page *) {
    min-height: calc(40px * var(--hub-ui-scale, 1)) !important;
    font-size: var(--app-text-sm) !important;
    border-radius: var(--app-radius-md) !important;
  }

  :where(body.is-hub-embedded, html.is-hub-embedded body, body[data-hub-embedded="true"]):not(.print-mode) :is(button, .button, .primary, .secondary, .primary-button, .secondary-button):not(.report-page *) {
    min-height: var(--app-button-height-sm) !important;
    border-radius: var(--app-radius-sm) !important;
    padding: 0 var(--app-space-3) !important;
  }

  :where(body.is-hub-embedded, html.is-hub-embedded body, body[data-hub-embedded="true"]):not(.print-mode) :is(input, select):not(.report-page *) {
    min-height: var(--app-button-height-sm) !important;
  }
}

/* 2026-06-06: mobile App-Shell-Navigation darf nicht auf Icon-Breite kollabieren. */
@media screen and (max-width: 760px) {
  body.hub-shell-ready[class*="-shell"]:not(.print-mode) :is(.hub-shell-navigation, .audit-shell-sidebar, .sidebar):not(.report-page *) {
    width: auto !important;
    max-width: none !important;
  }

  body.hub-shell-ready[class*="-shell"]:not(.print-mode) [class$="-shell-nav"] {
    width: 100% !important;
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 7px !important;
  }

  body.hub-shell-ready[class*="-shell"]:not(.print-mode) .hub-nav-item:not(.report-page *) {
    width: 100% !important;
    justify-content: flex-start !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    gap: 7px !important;
    padding-inline: 8px !important;
  }

  body.hub-shell-ready[class*="-shell"]:not(.print-mode) .hub-nav-item .icon {
    flex: 0 0 24px !important;
    width: 24px !important;
    height: 24px !important;
  }
}



