/* Breidert – Design nach dem Vorbild shadcn/ui "dashboard-01" (new-york):
   Seitenleiste + abgesetzte Inhaltsfläche (inset), Karten mit feinem Rand, Kennzahl-Karten,
   Reiter als graue Leiste, Tabellen mit grauem Kopf, hell und dunkel. Orange nur als Markenakzent. */
:root {
  --bg: #ffffff;
  --fg: #0a0a0a;
  --card: #ffffff;
  --muted: #f5f5f5;
  --muted-fg: #737373;
  --border: #e5e5e5;
  --input: #e5e5e5;
  --primary: #171717;
  --primary-fg: #fafafa;
  --accent: #f5f5f5;
  --ring: #a3a3a3;
  --sidebar: #fafafa;
  --sidebar-active: #f0f0f0;
  --brand: #f26a45;
  --warn-bg: #fff4ec;
  --warn-fg: #b8461f;
  --chart-1: #262626;
  --chart-2: #a3a3a3;
  --chart-3: #f26a45;
  --chart-4: #d4d4d4;
  --radius: 10px;
  --shadow-xs: 0 1px 2px rgba(0,0,0,.05);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px -1px rgba(0,0,0,.1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0a0a; --fg: #fafafa; --card: #171717; --muted: #262626; --muted-fg: #a1a1a1;
    --border: rgba(255,255,255,.1); --input: rgba(255,255,255,.15); --primary: #e5e5e5; --primary-fg: #171717;
    --accent: #262626; --ring: #737373; --sidebar: #0a0a0a; --sidebar-active: #262626;
    --warn-bg: rgba(242,106,69,.15); --warn-fg: #ff9b7a;
    --chart-1: #e5e5e5; --chart-2: #737373; --chart-3: #f26a45; --chart-4: #404040;
    --shadow-xs: none; --shadow-sm: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0a0a0a; --fg: #fafafa; --card: #171717; --muted: #262626; --muted-fg: #a1a1a1;
  --border: rgba(255,255,255,.1); --input: rgba(255,255,255,.15); --primary: #e5e5e5; --primary-fg: #171717;
  --accent: #262626; --ring: #737373; --sidebar: #0a0a0a; --sidebar-active: #262626;
  --warn-bg: rgba(242,106,69,.15); --warn-fg: #ff9b7a;
  --chart-1: #e5e5e5; --chart-2: #737373; --chart-3: #f26a45; --chart-4: #404040;
  --shadow-xs: none; --shadow-sm: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: Geist, 'Segoe UI Variable Text', 'Segoe UI', -apple-system, BlinkMacSystemFont, Inter, Roboto, sans-serif;
       font-size: 14px; line-height: 1.45; color: var(--fg); background: var(--sidebar); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
h1 { font-size: 22px; font-weight: 600; letter-spacing: -.02em; margin: 0; }
p { margin: 0; }
.i { flex: none; }
.muted { color: var(--muted-fg); }
.small { font-size: 12px; }
.strong { font-weight: 500; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Rahmen: Seitenleiste + abgesetzte Inhaltsfläche ---------- */
.wrapper { display: flex; min-height: 100vh; }
.sidebar { width: 256px; flex: none; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
           gap: 4px; padding: 8px; background: var(--sidebar); overflow-y: auto; transition: margin .2s; }
body.nav-collapsed .sidebar { margin-left: -256px; }
.brand { display: flex; align-items: center; gap: 8px; padding: 8px; font-weight: 600; font-size: 15px; }
.brand-logo { width: 28px; height: 28px; display: grid; place-items: center; }
.brand-logo img { width: 24px; height: 24px; }
.side-group { display: flex; flex-direction: column; gap: 2px; padding: 6px 0; }
.side-label { font-size: 12px; font-weight: 500; color: var(--muted-fg); padding: 0 8px; height: 30px; display: flex; align-items: center; }
.quick { padding-bottom: 6px; }
.nav-item { display: flex; align-items: center; gap: 8px; height: 32px; padding: 0 8px; border-radius: 8px; font-size: 14px; color: var(--fg); }
.nav-item .i { color: var(--muted-fg); }
.nav-item:hover { background: var(--sidebar-active); }
.nav-item.active { background: var(--sidebar-active); font-weight: 500; }
.nav-item.active .i { color: var(--brand); }
.side-foot { margin-top: auto; padding-top: 8px; }
.user { display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: 8px; }
.user:hover { background: var(--sidebar-active); }
.avatar { width: 32px; height: 32px; border-radius: 8px; background: var(--muted); display: grid; place-items: center; font-size: 12px; font-weight: 600; }
.user-text { display: flex; flex-direction: column; line-height: 1.2; flex: 1; min-width: 0; }
.user-text small { color: var(--muted-fg); font-size: 12px; }
.user form { margin: 0; }

.inset { flex: 1; min-width: 0; overflow-x: clip; margin: 8px 8px 8px 0; background: var(--bg); border-radius: 14px; box-shadow: var(--shadow-sm);
         border: 1px solid transparent; }
:root[data-theme="dark"] .inset { border-color: var(--border); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .inset { border-color: var(--border); } }
.page-header { position: sticky; top: 0; z-index: 10; height: 48px; display: flex; align-items: center; gap: 8px; padding: 0 16px 0 12px;
               border-bottom: 1px solid var(--border); background: var(--bg); border-radius: 14px 14px 0 0; }
.sep { width: 1px; height: 16px; background: var(--border); margin: 0 4px; }
.crumbs { font-size: 15px; font-weight: 500; display: flex; align-items: center; gap: 6px; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumbs a { color: var(--muted-fg); font-weight: 400; }
.crumbs a:hover { color: var(--fg); }
.crumb-sep { color: var(--muted-fg); }
.header-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.today { color: var(--muted-fg); font-size: 13px; }
.show-dark { display: none; }
:root[data-theme="dark"] .show-dark { display: inline; } :root[data-theme="dark"] .show-light { display: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .show-dark { display: inline; } :root:not([data-theme="light"]) .show-light { display: none; } }
.page { padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.scrim { display: none; }

/* ---------- Knöpfe, Plaketten, Hinweise ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 8px;
       border: 1px solid var(--border); background: var(--bg); color: var(--fg); font: inherit; font-size: 14px; font-weight: 500;
       cursor: pointer; white-space: nowrap; box-shadow: var(--shadow-xs); }
.btn:hover { background: var(--accent); }
.btn.primary { background: var(--primary); color: var(--primary-fg); border-color: var(--primary); }
.btn.primary:hover { opacity: .9; }
.btn.block { width: 100%; justify-content: flex-start; }
.btn.small { height: 28px; padding: 0 10px; font-size: 13px; }
.icon-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; border: 0; background: none;
            color: var(--fg); cursor: pointer; }
.icon-btn:hover { background: var(--accent); }
.icon-btn.bordered { border: 1px solid var(--border); box-shadow: var(--shadow-xs); }
.icon-btn.disabled { opacity: .4; pointer-events: none; }
.badge { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 500;
         border: 1px solid var(--border); background: none !important; color: var(--fg) !important; white-space: nowrap; }
.badge[style*="--c"]::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.badge.warn { background: var(--warn-bg) !important; color: var(--warn-fg) !important; border-color: transparent; }
.pill { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--muted); font-size: 12px; font-weight: 500; }
.toast { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow-sm); font-weight: 500; transition: opacity .4s; }
.toast.gone { opacity: 0; height: 0; padding: 0; margin: -8px 0; overflow: hidden; border: 0; }
.alert { display: flex; gap: 8px; align-items: center; padding: 10px 14px; border-radius: var(--radius); background: var(--warn-bg); color: var(--warn-fg); }
.hint { display: flex; gap: 6px; align-items: center; color: var(--muted-fg); font-size: 13px; }
.err { color: #dc2626; font-size: 12px; }

/* ---------- Karten ---------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-xs); }
.card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 20px 24px 0; flex-wrap: wrap; }
.card-title { font-size: 16px; font-weight: 600; }

/* Kennzahl-Karten wie im Vorbild */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.kpi { display: flex; flex-direction: column; justify-content: space-between; gap: 20px; padding: 22px 24px;
       background: linear-gradient(to top, color-mix(in srgb, var(--primary) 4%, var(--card)), var(--card)); }
.kpi:hover { border-color: var(--ring); }
.kpi-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; flex-wrap: wrap-reverse; }
.kpi-head > div { min-width: 0; }
.kpi-value { font-size: 30px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; margin-top: 6px; line-height: 1.1; }
.kpi-foot { display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.kpi-foot .strong { display: flex; align-items: center; gap: 6px; }

/* Diagramm */
.chart-card { padding-bottom: 16px; }
.toggle { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; box-shadow: var(--shadow-xs); }
.toggle a { padding: 6px 12px; font-size: 13px; font-weight: 500; border-left: 1px solid var(--border); }
.toggle a:first-child { border-left: 0; }
.toggle a.on { background: var(--accent); }
.chart { padding: 12px 24px 0; }
.chart svg { width: 100%; height: 230px; display: block; overflow: visible; }
.gridline { stroke: var(--border); stroke-dasharray: 3 3; }
.chart rect.b1 { fill: var(--chart-1); } .chart rect.b2 { fill: var(--chart-2); } .chart rect.b3 { fill: var(--chart-3); } .chart rect.b4 { fill: var(--chart-4); }
.chart .bar:hover rect { opacity: .8; }
.chart-labels { display: grid; gap: 2px; padding: 6px 0 0; }
.chart-labels span { font-size: 10px; color: var(--muted-fg); text-align: center; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; writing-mode: vertical-rl; transform: rotate(180deg); max-height: 96px; justify-self: center; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; padding: 8px 24px 0; font-size: 12px; color: var(--muted-fg); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legend .b1 { background: var(--chart-1); } .legend .b2 { background: var(--chart-2); } .legend .b3 { background: var(--chart-3); } .legend .b4 { background: var(--chart-4); }

/* ---------- Reiter und Leisten ---------- */
.section-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.tabs-inline, .tabs { display: inline-flex; align-items: center; gap: 2px; padding: 3px; border-radius: 10px; background: var(--muted); max-width: 100%; overflow-x: auto; }
.tabs-inline a, .tabs .tab { display: inline-flex; align-items: center; gap: 6px; height: 29px; padding: 0 10px; border-radius: 8px; border: 1px solid transparent;
             font: inherit; font-size: 14px; font-weight: 500; color: var(--muted-fg); background: none; cursor: pointer; white-space: nowrap; }
.tabs-inline a.on, .tabs .tab.on { background: var(--bg); color: var(--fg); box-shadow: var(--shadow-sm); }
:root[data-theme="dark"] .tabs-inline a.on, :root[data-theme="dark"] .tabs .tab.on { background: var(--card); border-color: var(--input); }
.tabs-inline .pill { background: var(--border); height: 18px; }
.more-views select { height: 29px; border: 0; background: none; color: var(--muted-fg); font: inherit; font-weight: 500; padding: 0 6px; }
.tabs { margin-bottom: 16px; }

.page-title { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.page-title.sticky { position: sticky; top: 48px; z-index: 5; background: var(--bg); margin: -24px -24px 0; padding: 16px 24px; border-bottom: 1px solid var(--border); }
.title-with-back { display: flex; align-items: center; gap: 12px; }
.actions { display: flex; gap: 8px; }

.search { position: relative; display: flex; align-items: center; }
.search .i { position: absolute; left: 10px; color: var(--muted-fg); }
.search input { height: 32px; width: 260px; padding: 0 10px 0 32px; border: 1px solid var(--input); border-radius: 8px; background: var(--bg); color: var(--fg); font: inherit; box-shadow: var(--shadow-xs); }
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible, a:focus-visible { outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 45%, transparent); border-color: var(--ring); }

/* ---------- Tabellen ---------- */
.table-box { border: 1px solid var(--border); border-radius: 10px; overflow: auto; background: var(--card); }
table.grid { width: 100%; border-collapse: collapse; font-size: 14px; }
.grid thead th { position: sticky; top: 0; background: var(--muted); height: 40px; padding: 0 12px; text-align: left; font-weight: 500; white-space: nowrap; }
.grid th a:hover { text-decoration: underline; }
.grid td { padding: 10px 12px; border-top: 1px solid var(--border); vertical-align: middle; }
.grid tbody tr { cursor: pointer; transition: background .1s; }
.grid tbody tr:hover { background: color-mix(in srgb, var(--muted) 50%, transparent); }
.grid td:first-child a { font-weight: 500; }
.grid td a:hover { text-decoration: underline; }
.empty { color: var(--muted-fg); padding: 24px 12px; text-align: center; }
.table-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 0 4px; font-size: 14px; }
.pager { display: flex; align-items: center; gap: 8px; font-weight: 500; }

/* ---------- Formular ---------- */
.record { display: flex; flex-direction: column; gap: 16px; }
.tab-pane { display: flex; flex-direction: column; gap: 16px; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; padding: 16px 24px 24px; }
.fields.one { grid-template-columns: 1fr; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.wide, .sub.wide { grid-column: 1 / -1; }
.field > label { font-size: 14px; font-weight: 500; }
.field input:not([type=checkbox]), .field select, .field textarea {
  width: 100%; height: 36px; padding: 0 12px; border: 1px solid var(--input); border-radius: 8px; background: transparent;
  color: var(--fg); font: inherit; box-shadow: var(--shadow-xs); }
.field textarea { height: auto; min-height: 72px; padding: 8px 12px; resize: vertical; }
.field select { appearance: auto; }
.field.has-err input, .field.has-err select { border-color: #dc2626; }
.field .ro { min-height: 36px; display: flex; align-items: center; padding: 0 12px; border-radius: 8px; background: var(--muted); color: var(--muted-fg); }
.field.is-check { justify-content: flex-end; }
label.check { display: flex; align-items: center; gap: 10px; height: 36px; font-weight: 500; font-size: 14px; cursor: pointer; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--primary); margin: 0; }
.field > div:has(input[type=checkbox]) { display: flex; flex-wrap: wrap; gap: 8px 18px; padding-top: 2px; }
.field > div > div > label { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.sub { display: flex; flex-direction: column; gap: 10px; }
.sub-head { display: flex; align-items: center; gap: 8px; }
.sub-head .btn { margin-left: auto; }

/* Feld mit Maßeinheit (m², €, kWh …) */
.with-unit { position: relative; }
.with-unit input { padding-right: 48px !important; }
.with-unit .unit { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted-fg); font-size: 13px; pointer-events: none; }

/* ---------- Anmeldung ---------- */
.login-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; padding: 16px; background: var(--sidebar); }
.login-brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 16px; }
.login-brand img { width: 28px; }
.login { width: 100%; max-width: 380px; }
.login .fields { padding-top: 20px; }

/* ---------- Tablet / Handy ---------- */
@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 767px) {
  body { background: var(--bg); }
  .sidebar { position: fixed; z-index: 40; left: 0; top: 0; bottom: 0; width: 280px; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-sm); background: var(--sidebar); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,.4); }
  .inset { margin: 0; border-radius: 0; box-shadow: none; border: 0 !important; }
  .page-header { border-radius: 0; }
  .today { display: none; }
  .page { padding: 16px; }
  .page-title.sticky { margin: -16px -16px 0; padding: 12px 16px; }
  .page-title.sticky .actions { width: 100%; }
  .page-title.sticky .actions .btn { flex: 1; }
  .kpis { grid-template-columns: minmax(0, 1fr); }
  .chart-labels span { font-size: 9px; }
  .fields { grid-template-columns: 1fr; padding: 16px; }
  .card-top { padding: 16px 16px 0; }
  .chart { padding: 12px 16px 0; }
  .legend { padding: 8px 16px 0; }
  .search, .search input { width: 100%; }
  .section-bar { flex-direction: column; align-items: stretch; }
  /* Tabellenzeilen werden zu Karten */
  .table-box { border: 0; background: none; overflow: visible; display: flex; flex-direction: column; }
  .grid thead { display: none; }
  .grid, .grid tbody { display: block; }
  .grid tbody { display: flex; flex-direction: column; gap: 10px; }
  .grid tr { display: block; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--card); }
  .grid td { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; border: 0; text-align: right; }
  .grid td::before { content: attr(data-label); color: var(--muted-fg); text-align: left; flex: none; max-width: 45%; }
  .grid td:first-child { font-size: 15px; padding-bottom: 6px; }
  .grid td.empty { justify-content: center; }
  .grid td.empty::before { content: none; }
  .table-foot { flex-direction: column; align-items: stretch; gap: 8px; }
  .pager { justify-content: space-between; }
}
.qr { display: flex; justify-content: center; }
.qr svg { width: 220px; height: 220px; border-radius: 8px; }
.schluessel { display: block; margin-top: 6px; word-break: break-all; font-size: 13px; }
.stufe-test { background: #f59e0b; color: #111; font-size: 12px; font-weight: 600; text-align: center; padding: 3px 8px; }
