/* Terminportal UI – Komponenten. Markup-Helfer dazu in src/ui/components.js. */

@layer components {

  /* ---------- Buttons ---------- */
  .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
    min-height: var(--control-h); padding: 0 var(--sp-4); border: 1px solid var(--border-strong); border-radius: var(--r-md);
    background: var(--surface); color: var(--text); box-shadow: var(--shadow-xs);
    font: 500 var(--fs-md)/1.2 var(--font); white-space: nowrap; text-decoration: none; cursor: pointer;
    transition: background-color .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease), box-shadow .15s var(--ease);
  }
  .btn:hover { background: var(--surface-hover); text-decoration: none; }
  .btn:active { transform: translateY(.5px); }
  .btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus); }
  .btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; pointer-events: none; }
  .btn-primary { border-color: transparent; background: var(--primary); color: var(--on-primary); box-shadow: var(--shadow-sm); }
  .btn-primary:hover { background: var(--primary-hover); }
  .btn-ghost { border-color: transparent; background: transparent; box-shadow: none; color: var(--text-muted); }
  .btn-ghost:hover { background: var(--surface-hover); color: var(--text); }
  .btn-danger { border-color: var(--danger-border); background: var(--surface); color: var(--danger-text); }
  .btn-danger:hover { background: var(--danger-bg); }
  .btn-danger-solid { border-color: transparent; background: var(--danger); color: #fff; }
  .btn-sm { min-height: var(--control-h-sm); padding: 0 var(--sp-3); font-size: var(--fs-sm); }
  .btn-lg { min-height: var(--control-h-lg); padding: 0 var(--sp-5); font-size: var(--fs-base); }
  .btn-block { display: flex; width: 100%; }
  .btn-icon { width: var(--control-h); padding: 0; }
  .btn-icon.btn-sm { width: var(--control-h-sm); }
  .btn-link { padding: 0; min-height: 0; border: 0; background: none; box-shadow: none; color: var(--primary-text); font-weight: 500; }
  .btn-link:hover { background: none; text-decoration: underline; }

  .actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); margin-top: var(--sp-4); }
  .actions:first-child { margin-top: 0; }
  .actions-end { justify-content: flex-end; }
  form.inline { display: inline; margin: 0; }

  /* ---------- Formulare ---------- */
  .field { display: grid; gap: 6px; margin: 0 0 var(--sp-4); min-width: 0; }
  .field > span, .field > label, .label { color: var(--text); font-size: var(--fs-md); font-weight: 500; }
  .field-hint, .field small { color: var(--text-muted); font-size: var(--fs-sm); font-weight: 400; }
  .field-error { color: var(--danger-text); font-size: var(--fs-sm); font-weight: 500; }
  .input, .field input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=hidden]),
  .field select, .field textarea, .select, .textarea {
    width: 100%; min-height: var(--control-h); padding: 7px var(--sp-3); border: 1px solid var(--border-strong); border-radius: var(--r-md);
    background: var(--surface); color: var(--text); box-shadow: var(--shadow-xs); font-size: var(--fs-base);
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
  }
  .field textarea, .textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
  .field select, .select { appearance: none; padding-right: 34px;
    background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%), linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
    background-position: calc(100% - 17px) 55%, calc(100% - 12px) 55%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
  .input:focus, .field input:focus, .field select:focus, .field textarea:focus, .select:focus, .textarea:focus {
    outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--focus); }
  .field input[disabled], .field select[disabled], .field textarea[disabled], .input[disabled] { background: var(--surface-2); color: var(--text-muted); cursor: not-allowed; }
  .field input[readonly] { background: var(--surface-2); }
  .field input[aria-invalid="true"], .field select[aria-invalid="true"] { border-color: var(--danger); }
  input[type=file] { font-size: var(--fs-sm); color: var(--text-muted); }
  input[type=file]::file-selector-button { margin-right: var(--sp-3); padding: 6px var(--sp-3); border: 1px solid var(--border-strong); border-radius: var(--r-md);
    background: var(--surface); color: var(--text); font: 500 var(--fs-sm) var(--font); cursor: pointer; }
  input[type=checkbox], input[type=radio] { width: 16px; height: 16px; margin: 0; accent-color: var(--primary); flex: none; }
  input[type=color] { width: 44px; height: var(--control-h); padding: 2px; border: 1px solid var(--border-strong); border-radius: var(--r-md); background: var(--surface); }

  .check { display: flex; align-items: flex-start; gap: var(--sp-2); margin: 0 0 var(--sp-3); color: var(--text); font-size: var(--fs-md); line-height: 1.45; cursor: pointer; }
  .check input { margin-top: 2px; }
  .check > span { flex: 1; min-width: 0; overflow-wrap: anywhere; hyphens: auto; }
  .switch { display: inline-flex; align-items: center; gap: var(--sp-2); cursor: pointer; font-size: var(--fs-md); }
  .switch input { appearance: none; position: relative; width: 34px; height: 20px; border-radius: var(--r-full); background: var(--gray-7); transition: background .15s; cursor: pointer; }
  .switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .15s var(--ease); }
  .switch input:checked { background: var(--primary); }
  .switch input:checked::after { transform: translateX(14px); }

  .form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--sp-4); }
  .form-grid > .form-full, .form-grid > .full, .form-grid > .actions, .form-grid > button, .form-grid > div:has(> button[type=submit]) { grid-column: 1 / -1; }
  .form-grid > .field { margin-bottom: var(--sp-4); }
  .form-row { display: flex; flex-wrap: wrap; gap: 0 var(--sp-4); }
  .form-row > .field { flex: 1; min-width: 160px; }
  .filter-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--sp-3); }
  .filter-row .field { min-width: 180px; margin-bottom: 0; }
  label.label { display: block; margin: var(--sp-3) 0 6px; }
  .form-section + .form-section { margin-top: var(--sp-6); padding-top: var(--sp-6); border-top: 1px solid var(--border); }
  .form-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: var(--sp-2);
    margin: var(--sp-5) calc(-1 * var(--sp-6)) calc(-1 * var(--sp-6)); padding: var(--sp-3) var(--sp-6);
    border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }
  .form-footer .hint { margin-right: auto; }
  .form-grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 var(--sp-4); }
  .field input.is-locked, input.is-locked { background: var(--surface-2); color: var(--text-muted); }
  .code-input { font-family: var(--font-mono); font-size: var(--fs-xl) !important; letter-spacing: .3em; }
  .textarea-tall { min-height: 180px !important; }
  @media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

  /* ---------- Karten ---------- */
  .card { position: relative; padding: var(--sp-6); border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-xs); min-width: 0; }
  .card + .card { margin-top: var(--sp-4); }
  .card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-4); margin-bottom: var(--sp-4); }
  .card-header h2, .card-header h3 { margin: 0; font-size: var(--fs-lg); }
  .card-header p { margin: 4px 0 0; color: var(--text-muted); font-size: var(--fs-md); }
  .card-flush { padding: 0; overflow: hidden; }
  .card-flush > .card-header { padding: var(--sp-5) var(--sp-6) 0; }
  .card-flush > .table-wrap { margin: 0; border-top: 1px solid var(--border); }
  .card-body-pad { padding: 0 var(--sp-6) var(--sp-5); }
  a.card-link { display: block; color: inherit; text-decoration: none; transition: border-color .15s, box-shadow .15s; }
  a.card-link:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); }
  .card-danger { border-color: var(--danger-border); }
  .card-highlight { border-color: var(--primary-soft-border); box-shadow: 0 0 0 3px var(--primary-soft); }

  .overline, .eyebrow { display: block; margin: 0 0 4px; color: var(--text-muted); font-size: var(--fs-xs); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
  .hint, .muted { color: var(--text-muted); font-size: var(--fs-md); }
  .hint { line-height: 1.5; }
  .text-sm { font-size: var(--fs-sm); }
  .text-danger { color: var(--danger-text); }
  .text-success { color: var(--success-text); }

  /* ---------- Badges & Status ---------- */
  .badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border: 1px solid var(--border); border-radius: var(--r-full);
    background: var(--surface-2); color: var(--text-muted); font-size: var(--fs-xs); font-weight: 500; line-height: 1; white-space: nowrap; vertical-align: middle; }
  .badge .i { width: 12px; height: 12px; }
  .badge-ok, .badge-success { border-color: var(--success-border); background: var(--success-bg); color: var(--success-text); }
  .badge-warn { border-color: var(--warning-border); background: var(--warning-bg); color: var(--warning-text); }
  .badge-err, .badge-danger { border-color: var(--danger-border); background: var(--danger-bg); color: var(--danger-text); }
  .badge-blue, .badge-info { border-color: var(--primary-soft-border); background: var(--primary-soft); color: var(--primary-text); }
  .badge-ai { border-color: var(--ai-border); background: var(--ai-bg); color: var(--ai-text); }
  .badge-muted { color: var(--text-subtle); }
  .badge-dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
  .badge-spin::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: tp-pulse 1.1s ease-in-out infinite; }
  .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--gray-8); flex: none; }
  .dot-ok { background: var(--success); } .dot-warn { background: var(--warning); } .dot-err { background: var(--danger); } .dot-primary { background: var(--primary); }

  /* ---------- Meldungen ---------- */
  .alert, .notice { display: flex; align-items: flex-start; gap: var(--sp-3); margin: 0 0 var(--sp-4); padding: var(--sp-3) var(--sp-4);
    border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-2); color: var(--text); font-size: var(--fs-md); line-height: 1.5; }
  .alert > .i { margin-top: 2px; }
  .alert-body { flex: 1; min-width: 0; }
  .alert-body > :last-child { margin-bottom: 0; }
  .notice:not(.alert) { display: block; }
  .alert a, .notice a { color: inherit; font-weight: 600; text-decoration: underline; }
  .alert-ok, .notice-ok, .alert-success { border-color: var(--success-border); background: var(--success-bg); color: var(--success-text); }
  .alert-error, .notice-error, .alert-danger { border-color: var(--danger-border); background: var(--danger-bg); color: var(--danger-text); }
  .alert-warn, .notice-warn, .alert-warning { border-color: var(--warning-border); background: var(--warning-bg); color: var(--warning-text); }
  .alert-info, .notice-info { border-color: var(--info-border); background: var(--info-bg); color: var(--info-text); }
  .alert-ai { border-color: var(--ai-border); background: var(--ai-bg); color: var(--ai-text); }

  .toast-region { position: fixed; z-index: 900; right: var(--sp-5); bottom: var(--sp-5); display: grid; gap: var(--sp-2); width: min(380px, calc(100vw - 32px)); }
  .toast { display: flex; align-items: flex-start; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); border: 1px solid var(--border); border-radius: var(--r-lg);
    background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); font-size: var(--fs-md); animation: tp-toast .25s var(--ease); }
  .toast-ok .i:first-child { color: var(--success); } .toast-error .i:first-child { color: var(--danger); }
  .toast p { flex: 1; margin: 0; }
  .toast button { padding: 2px; border: 0; background: none; color: var(--text-muted); }

  /* ---------- Tabellen ---------- */
  .table-wrap { overflow-x: auto; margin: 0 calc(-1 * var(--sp-6)); }
  .table-wrap > .table { min-width: 560px; }
  .table, .data-table { width: 100%; border-collapse: collapse; font-size: var(--fs-md); }
  .table th, .data-table th { padding: var(--sp-2) var(--sp-3); border-bottom: 1px solid var(--border); background: var(--surface-2); color: var(--text-muted);
    font-size: var(--fs-xs); font-weight: 600; letter-spacing: .03em; text-align: left; text-transform: uppercase; white-space: nowrap; }
  .table td, .data-table td { padding: var(--sp-3); border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
  .table tr:last-child td { border-bottom: 0; }
  .table tbody tr:hover td { background: var(--surface-2); }
  .table-wrap .table th:first-child, .table-wrap .table td:first-child { padding-left: var(--sp-6); }
  .table-wrap .table th:last-child, .table-wrap .table td:last-child { padding-right: var(--sp-6); }
  .table-narrow { width: 100%; max-width: 520px; margin: var(--sp-3) 0 var(--sp-5); border-collapse: collapse; }
  .table-narrow td { padding: var(--sp-2) 0; }
  .td-line { border-top: 1px solid var(--border) !important; }
  .mail-body { padding: var(--sp-4); border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-2); font: inherit; white-space: pre-wrap; word-break: break-word; }
  .step-row { display: grid; grid-template-columns: 32px 1fr auto; align-items: center; gap: var(--sp-3); padding: var(--sp-3) 0; border-top: 1px solid var(--border); }
  .step-dot { display: grid; width: 28px; height: 28px; place-items: center; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--text-muted); font-size: var(--fs-sm); font-weight: 600; }
  .step-dot.done { border-color: var(--success); background: var(--success); color: #fff; }
  .qr-small { max-width: 220px; margin: var(--sp-3) auto; padding: var(--sp-2); border-radius: var(--r-md); background: #fff; }
  .num { text-align: right !important; font-variant-numeric: tabular-nums; }

  /* ---------- Reiter ---------- */
  .tabs, .settings-tabs { display: flex; gap: var(--sp-1); margin: 0 0 var(--sp-6); border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
  .tabs a, .settings-tabs a { position: relative; display: inline-flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2) var(--sp-3) 10px; color: var(--text-muted);
    font-size: var(--fs-md); font-weight: 500; text-decoration: none; white-space: nowrap; }
  .tabs a:hover, .settings-tabs a:hover { color: var(--text); text-decoration: none; }
  .tabs a.active, .tabs a[aria-current="page"], .settings-tabs a.active { color: var(--text); }
  .tabs a.active::after, .tabs a[aria-current="page"]::after, .settings-tabs a.active::after { content: ""; position: absolute; left: var(--sp-2); right: var(--sp-2); bottom: -1px; height: 2px; border-radius: 2px; background: var(--primary); }
  .segmented { display: inline-flex; gap: 2px; padding: 3px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-2); }
  .segmented a, .segmented button { display: inline-flex; align-items: center; gap: 6px; min-height: 28px; padding: 0 var(--sp-3); border: 0; border-radius: var(--r-sm);
    background: none; color: var(--text-muted); font-size: var(--fs-sm); font-weight: 500; text-decoration: none; white-space: nowrap; }
  .segmented a:hover { color: var(--text); text-decoration: none; }
  .segmented .active, .segmented [aria-current="page"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

  /* ---------- Leere Zustände, Kennzahlen, Listen ---------- */
  .empty-state { display: grid; justify-items: center; gap: var(--sp-2); padding: var(--sp-10) var(--sp-6); border: 1px dashed var(--border-strong); border-radius: var(--r-lg);
    color: var(--text-muted); font-size: var(--fs-md); text-align: center; }
  .empty-state .empty-icon { display: grid; width: 40px; height: 40px; place-items: center; margin-bottom: var(--sp-1); border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--border); color: var(--text-muted); }
  .empty-state h3 { margin: 0; color: var(--text); font-size: var(--fs-base); }
  .empty-state p { max-width: 420px; margin: 0; }
  .empty-state .actions { justify-content: center; margin-top: var(--sp-2); }
  .card > .empty-state:only-child, .card-body > .empty-state { border: 0; padding: var(--sp-8) var(--sp-4); }

  .stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--sp-4); margin: 0 0 var(--sp-6); }
  @media (max-width: 640px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); } .stat { padding: var(--sp-3) var(--sp-4); } .stat-value { font-size: var(--fs-xl); } }
  .stat { display: grid; gap: 2px; padding: var(--sp-4) var(--sp-5); border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); color: inherit; text-decoration: none; box-shadow: var(--shadow-xs); }
  a.stat:hover { border-color: var(--border-strong); text-decoration: none; }
  .stat-label { display: flex; align-items: center; gap: var(--sp-2); color: var(--text-muted); font-size: var(--fs-sm); font-weight: 500; }
  .stat-value { font-size: var(--fs-2xl); font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
  .stat-meta { color: var(--text-muted); font-size: var(--fs-sm); }

  .list { display: grid; margin: 0; padding: 0; list-style: none; }
  .list > li, .list-item { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) 0; border-top: 1px solid var(--border); margin: 0; }
  .list > li:first-child, .list-item:first-child { border-top: 0; }
  a.list-item { color: inherit; text-decoration: none; }
  a.list-item:hover { background: var(--surface-2); }
  .list-main { flex: 1; min-width: 0; }
  .list-main b, .list-main strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .list-main span, .list-main small { display: block; color: var(--text-muted); font-size: var(--fs-sm); }

  .dl, .review { display: grid; grid-template-columns: max-content 1fr; gap: var(--sp-2) var(--sp-6); margin: 0 0 var(--sp-4); }
  .dl dt, .review dt { color: var(--text-muted); font-size: var(--fs-md); }
  .dl dd, .review dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
  @media (max-width: 560px) { .dl, .review { grid-template-columns: 1fr; gap: 0; } .dl dd, .review dd { margin-bottom: var(--sp-3); } }

  .avatar { display: grid; width: 32px; height: 32px; flex: none; place-items: center; border-radius: 50%; background: var(--primary-soft); color: var(--primary-text);
    font-size: var(--fs-xs); font-weight: 600; letter-spacing: .02em; }
  .avatar.big, .avatar-lg { width: 48px; height: 48px; font-size: var(--fs-base); }

  /* ---------- Menü (details/summary) & Dialog ---------- */
  .menu { position: relative; }
  .menu > summary { list-style: none; }
  .menu-panel { position: absolute; z-index: 80; min-width: 220px; padding: var(--sp-1); border: 1px solid var(--border); border-radius: var(--r-lg);
    background: var(--surface); box-shadow: var(--shadow-lg); animation: tp-pop .12s var(--ease); }
  .menu-panel.up { bottom: calc(100% + 6px); left: 0; }
  .menu-panel.down { top: calc(100% + 6px); right: 0; }
  .menu-panel a, .menu-panel button { display: flex; width: 100%; align-items: center; gap: var(--sp-2); padding: 7px var(--sp-2); border: 0; border-radius: var(--r-sm);
    background: none; color: var(--text); font-size: var(--fs-md); text-align: left; text-decoration: none; }
  .menu-panel a:hover, .menu-panel button:hover { background: var(--surface-hover); text-decoration: none; }
  .menu-panel .i { color: var(--text-muted); }
  .menu-panel hr { margin: var(--sp-1) 0; }
  .menu-label { padding: 6px var(--sp-2) 2px; color: var(--text-subtle); font-size: var(--fs-xs); font-weight: 500; }
  .menu-panel .danger { color: var(--danger-text); }
  .menu-panel .danger .i { color: var(--danger-text); }
  .theme-switch { display: flex; gap: 2px; padding: 3px; margin: 2px var(--sp-1) var(--sp-1); border-radius: var(--r-md); background: var(--surface-2); }
  .theme-switch button { justify-content: center; padding: 5px; border-radius: var(--r-sm); color: var(--text-muted); }
  .theme-switch button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

  dialog.dialog { width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; border: 1px solid var(--border); border-radius: var(--r-xl);
    background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
  dialog.dialog.dialog-wide { width: min(680px, calc(100vw - 32px)); }
  .dialog-head h2 { margin: 0; font-size: var(--fs-xl); }
  dialog.dialog::backdrop { background: var(--overlay); }
  .dialog-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-5) var(--sp-6) 0; }
  .dialog-body { padding: var(--sp-4) var(--sp-6) var(--sp-6); }

  /* ---------- Stepper ---------- */
  .stepper { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--sp-2); margin: 0 0 var(--sp-8); padding: 0; list-style: none; counter-reset: step; }
  .stepper li { position: relative; margin: 0; padding-top: var(--sp-3); color: var(--text-subtle); font-size: var(--fs-sm); font-weight: 500; counter-increment: step; }
  .stepper li::before { content: ""; position: absolute; inset: 0 0 auto; height: 3px; border-radius: 3px; background: var(--border); }
  .stepper li span::before { content: counter(step) " · "; }
  .stepper li.done::before, .stepper li.current::before { background: var(--primary); }
  .stepper li.current { color: var(--text); }
  .stepper li.done { color: var(--text-muted); }
  @media (max-width: 560px) {
    .stepper li { font-size: 0; }
    .stepper li.current { font-size: var(--fs-sm); }
    .stepper li.current span::before { content: "Schritt " counter(step) " von 4 · "; }
  }

  /* ---------- Sonstiges ---------- */
  .spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--border-strong); border-top-color: var(--primary); border-radius: 50%; animation: tp-spin .7s linear infinite; vertical-align: -3px; }
  .spinner-lg { width: 32px; height: 32px; border-width: 3px; margin-bottom: var(--sp-4); }
  .ob .actions { margin-top: var(--sp-5); }
  .ob form { display: grid; gap: var(--sp-1); }
  .ob hr { margin: var(--sp-6) 0; }
  .kbd, kbd { padding: 1px 5px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 4px; background: var(--surface); font-size: var(--fs-xs); }
  .copy-field { display: flex; align-items: center; gap: var(--sp-2); padding: 4px 4px 4px var(--sp-3); border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-2); }
  .copy-field code, .copy-field span { flex: 1; min-width: 0; padding: 0; border: 0; background: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-sm); }
  .progress { height: 6px; border-radius: var(--r-full); background: var(--surface-sunken); overflow: hidden; }
  .progress > span { display: block; width: var(--p, 0%); height: 100%; border-radius: inherit; background: var(--primary); }
  .divider { height: 1px; margin: var(--sp-5) 0; background: var(--border); }

  @keyframes tp-spin { to { transform: rotate(360deg); } }
  @keyframes tp-pulse { 0%, 100% { opacity: .3; } 50% { opacity: 1; } }
  @keyframes tp-pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
  @keyframes tp-toast { from { opacity: 0; transform: translateY(8px); } }
  @keyframes tp-in { from { opacity: 0; } }
}

@layer utilities {
  .stack > * + * { margin-top: var(--sp-4); }
  .row { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
  .between { justify-content: space-between; }
  .grow { flex: 1; min-width: 0; }
  .mt-0 { margin-top: 0 !important; } .mb-0 { margin-bottom: 0 !important; }
  .mt-2 { margin-top: var(--sp-2) !important; } .mt-4 { margin-top: var(--sp-4) !important; } .mt-6 { margin-top: var(--sp-6) !important; }
  .mb-2 { margin-bottom: var(--sp-2) !important; } .mb-4 { margin-bottom: var(--sp-4) !important; }
  .center { text-align: center; }
  .text-right { text-align: right !important; }
  .m-0 { margin: 0 !important; } .mb-1 { margin-bottom: var(--sp-1) !important; }
  .table-scroll { overflow-x: auto; }
  .text-lg { font-size: var(--fs-lg) !important; } .fw-600 { font-weight: 600; } .items-end { align-items: flex-end; }
  .my-2 { margin-block: var(--sp-2) !important; } .my-3 { margin-block: var(--sp-3) !important; } .mt-1 { margin-top: var(--sp-1) !important; }
  .w-num { width: 80px !important; } .is-disabled { opacity: .55; } .link-inherit { color: inherit; }
  .hp-field { position: absolute !important; left: -9999px !important; }
  .uppercase { text-transform: uppercase; }
  .form-msg { margin: var(--sp-2) 0; font-size: var(--fs-md); font-weight: 500; }
  .nowrap { white-space: nowrap; }
  .mono { font-family: var(--font-mono); font-size: var(--fs-sm); }
  .col-full { grid-column: 1 / -1; }
  .w-full { width: 100%; }
  /* Anteile für Balken, Ringe, Fortschritt ohne style-Attribut (CSP): Klasse p-0 … p-100 in 5er-Schritten, siehe ui/components.js pct(). */
  .p-0 { --p: 0%; } .p-5 { --p: 5%; } .p-10 { --p: 10%; } .p-15 { --p: 15%; } .p-20 { --p: 20%; } .p-25 { --p: 25%; } .p-30 { --p: 30%; } .p-35 { --p: 35%; } .p-40 { --p: 40%; } .p-45 { --p: 45%; } .p-50 { --p: 50%; } .p-55 { --p: 55%; } .p-60 { --p: 60%; } .p-65 { --p: 65%; } .p-70 { --p: 70%; } .p-75 { --p: 75%; } .p-80 { --p: 80%; } .p-85 { --p: 85%; } .p-90 { --p: 90%; } .p-95 { --p: 95%; } .p-100 { --p: 100%; }
}

/* Terminumfrage: Ergebnistabelle und Auswahllisten */
.row-best > th, .row-best > td { background: color-mix(in srgb, var(--mint, #2bb673) 14%, transparent); }
.scroll-box { max-height: 200px; overflow: auto; }

/* Terminumfrage (Berater-Formular, Teilnehmer-Seite, Ergebnismatrix) */
.poll-rows { display: grid; gap: .5rem; max-width: 30rem; margin-bottom: .75rem; }
.poll-row { display: grid; grid-template-columns: 1fr 8rem auto; gap: .5rem; align-items: center; }
.poll-row input { width: 100%; }
.poll-row .btn-icon { padding: .4rem .7rem; }
.poll-day { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; min-width: 3.6rem; padding: .35rem .5rem; border: 1px solid var(--border, #d9dee5); border-radius: .6rem; background: var(--surface, transparent); line-height: 1.15; text-align: center; }
.poll-day small { text-transform: uppercase; font-size: .68rem; letter-spacing: .04em; color: var(--muted, #667); }
.poll-day strong { font-size: 1.35rem; }
.poll-day em { font-style: normal; font-size: .72rem; }
.poll-time { font-weight: 600; }
.poll-opts { display: grid; gap: .6rem; margin: 1rem 0; }
.poll-opt { display: grid; grid-template-columns: auto 1fr auto; gap: .9rem; align-items: center; padding: .6rem .8rem; border: 1px solid var(--border, #d9dee5); border-radius: .75rem; }
.poll-opt .meta { display: grid; gap: .1rem; }
.poll-opt-ja { cursor: pointer; }
.poll-opt-ja:has(input:checked) { border-color: #2bb673; background: color-mix(in srgb, #2bb673 12%, transparent); }
.poll-yes { position: relative; display: inline-flex; align-items: center; gap: .5rem; font-weight: 600; }
.poll-yes input { width: 1.4rem; height: 1.4rem; margin: 0; accent-color: #2bb673; cursor: pointer; }
@media (max-width: 560px) { .dl, .review { grid-template-columns: 1fr; gap: 0; } .dl dd, .review dd { margin-bottom: var(--sp-3); } }

  .avatar { display: grid; width: 32px; height: 32px; flex: none; place-items: center; border-radius: 50%; background: var(--primary-soft); color: var(--primary-text);
    font-size: var(--fs-xs); font-weight: 600; letter-spacing: .02em; }
  .avatar.big, .avatar-lg { width: 48px; height: 48px; font-size: var(--fs-base); }

  /* ---------- Menü (details/summary) & Dialog ---------- */
  .menu { position: relative; }
  .menu > summary { list-style: none; }
  .menu-panel { position: absolute; z-index: 80; min-width: 220px; padding: var(--sp-1); border: 1px solid var(--border); border-radius: var(--r-lg);
    background: var(--surface); box-shadow: var(--shadow-lg); animation: tp-pop .12s var(--ease); }
  .menu-panel.up { bottom: calc(100% + 6px); left: 0; }
  .menu-panel.down { top: calc(100% + 6px); right: 0; }
  .menu-panel a, .menu-panel button { display: flex; width: 100%; align-items: center; gap: var(--sp-2); padding: 7px var(--sp-2); border: 0; border-radius: var(--r-sm);
    background: none; color: var(--text); font-size: var(--fs-md); text-align: left; text-decoration: none; }
  .menu-panel a:hover, .menu-panel button:hover { background: var(--surface-hover); text-decoration: none; }
  .menu-panel .i { color: var(--text-muted); }
  .menu-panel hr { margin: var(--sp-1) 0; }
  .menu-label { padding: 6px var(--sp-2) 2px; color: var(--text-subtle); font-size: var(--fs-xs); font-weight: 500; }
  .menu-panel .danger { color: var(--danger-text); }
  .menu-panel .danger .i { color: var(--danger-text); }
  .theme-switch { display: flex; gap: 2px; padding: 3px; margin: 2px var(--sp-1) var(--sp-1); border-radius: var(--r-md); background: var(--surface-2); }
  .theme-switch button { justify-content: center; padding: 5px; border-radius: var(--r-sm); color: var(--text-muted); }
  .theme-switch button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

  dialog.dialog { width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; border: 1px solid var(--border); border-radius: var(--r-xl);
    background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
  dialog.dialog.dialog-wide { width: min(680px, calc(100vw - 32px)); }
  .dialog-head h2 { margin: 0; font-size: var(--fs-xl); }
  dialog.dialog::backdrop { background: var(--overlay); }
  .dialog-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-5) var(--sp-6) 0; }
  .dialog-body { padding: var(--sp-4) var(--sp-6) var(--sp-6); }

  /* ---------- Stepper ---------- */
  .stepper { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--sp-2); margin: 0 0 var(--sp-8); padding: 0; list-style: none; counter-reset: step; }
  .stepper li { position: relative; margin: 0; padding-top: var(--sp-3); color: var(--text-subtle); font-size: var(--fs-sm); font-weight: 500; counter-increment: step; }
  .stepper li::before { content: ""; position: absolute; inset: 0 0 auto; height: 3px; border-radius: 3px; background: var(--border); }
  .stepper li span::before { content: counter(step) " · "; }
  .stepper li.done::before, .stepper li.current::before { background: var(--primary); }
  .stepper li.current { color: var(--text); }
  .stepper li.done { color: var(--text-muted); }
  @media (max-width: 560px) {
    .stepper li { font-size: 0; }
    .stepper li.current { font-size: var(--fs-sm); }
    .stepper li.current span::before { content: "Schritt " counter(step) " von 4 · "; }
  }

  /* ---------- Sonstiges ---------- */
  .spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--border-strong); border-top-color: var(--primary); border-radius: 50%; animation: tp-spin .7s linear infinite; vertical-align: -3px; }
  .spinner-lg { width: 32px; height: 32px; border-width: 3px; margin-bottom: var(--sp-4); }
  .ob .actions { margin-top: var(--sp-5); }
  .ob form { display: grid; gap: var(--sp-1); }
  .ob hr { margin: var(--sp-6) 0; }
  .kbd, kbd { padding: 1px 5px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 4px; background: var(--surface); font-size: var(--fs-xs); }
  .copy-field { display: flex; align-items: center; gap: var(--sp-2); padding: 4px 4px 4px var(--sp-3); border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-2); }
  .copy-field code, .copy-field span { flex: 1; min-width: 0; padding: 0; border: 0; background: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-sm); }
  .progress { height: 6px; border-radius: var(--r-full); background: var(--surface-sunken); overflow: hidden; }
  .progress > span { display: block; width: var(--p, 0%); height: 100%; border-radius: inherit; background: var(--primary); }
  .divider { height: 1px; margin: var(--sp-5) 0; background: var(--border); }

  @keyframes tp-spin { to { transform: rotate(360deg); } }
  @keyframes tp-pulse { 0%, 100% { opacity: .3; } 50% { opacity: 1; } }
  @keyframes tp-pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
  @keyframes tp-toast { from { opacity: 0; transform: translateY(8px); } }
  @keyframes tp-in { from { opacity: 0; } }
}

@layer utilities {
  .stack > * + * { margin-top: var(--sp-4); }
  .row { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
  .between { justify-content: space-between; }
  .grow { flex: 1; min-width: 0; }
  .mt-0 { margin-top: 0 !important; } .mb-0 { margin-bottom: 0 !important; }
  .mt-2 { margin-top: var(--sp-2) !important; } .mt-4 { margin-top: var(--sp-4) !important; } .mt-6 { margin-top: var(--sp-6) !important; }
  .mb-2 { margin-bottom: var(--sp-2) !important; } .mb-4 { margin-bottom: var(--sp-4) !important; }
  .center { text-align: center; }
  .text-right { text-align: right !important; }
  .m-0 { margin: 0 !important; } .mb-1 { margin-bottom: var(--sp-1) !important; }
  .table-scroll { overflow-x: auto; }
  .text-lg { font-size: var(--fs-lg) !important; } .fw-600 { font-weight: 600; } .items-end { align-items: flex-end; }
  .my-2 { margin-block: var(--sp-2) !important; } .my-3 { margin-block: var(--sp-3) !important; } .mt-1 { margin-top: var(--sp-1) !important; }
  .w-num { width: 80px !important; } .is-disabled { opacity: .55; } .link-inherit { color: inherit; }
  .hp-field { position: absolute !important; left: -9999px !important; }
  .uppercase { text-transform: uppercase; }
  .form-msg { margin: var(--sp-2) 0; font-size: var(--fs-md); font-weight: 500; }
  .nowrap { white-space: nowrap; }
  .mono { font-family: var(--font-mono); font-size: var(--fs-sm); }
  .col-full { grid-column: 1 / -1; }
  .w-full { width: 100%; }
  /* Anteile für Balken, Ringe, Fortschritt ohne style-Attribut (CSP): Klasse p-0 … p-100 in 5er-Schritten, siehe ui/components.js pct(). */
  .p-0 { --p: 0%; } .p-5 { --p: 5%; } .p-10 { --p: 10%; } .p-15 { --p: 15%; } .p-20 { --p: 20%; } .p-25 { --p: 25%; } .p-30 { --p: 30%; } .p-35 { --p: 35%; } .p-40 { --p: 40%; } .p-45 { --p: 45%; } .p-50 { --p: 50%; } .p-55 { --p: 55%; } .p-60 { --p: 60%; } .p-65 { --p: 65%; } .p-70 { --p: 70%; } .p-75 { --p: 75%; } .p-80 { --p: 80%; } .p-85 { --p: 85%; } .p-90 { --p: 90%; } .p-95 { --p: 95%; } .p-100 { --p: 100%; }
}

/* Terminumfrage: Ergebnistabelle und Auswahllisten */
.row-best > th, .row-best > td { background: color-mix(in srgb, var(--mint, #2bb673) 14%, transparent); }
.scroll-box { max-height: 200px; overflow: auto; }

/* Terminumfrage (Berater-Formular, Teilnehmer-Seite, Ergebnismatrix) */
.poll-rows { display: grid; gap: .5rem; max-width: 30rem; margin-bottom: .75rem; }
.poll-row { display: grid; grid-template-columns: 1fr 8rem auto; gap: .5rem; align-items: center; }
.poll-row input { width: 100%; }
.poll-row .btn-icon { padding: .4rem .7rem; }
.poll-day { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; min-width: 3.6rem; padding: .35rem .5rem; border: 1px solid var(--border, #d9dee5); border-radius: .6rem; background: var(--surface, transparent); line-height: 1.15; text-align: center; }
.poll-day small { text-transform: uppercase; font-size: .68rem; letter-spacing: .04em; color: var(--muted, #667); }
.poll-day strong { font-size: 1.35rem; }
.poll-day em { font-style: normal; font-size: .72rem; }
.poll-time { font-weight: 600; }
.poll-opts { display: grid; gap: .6rem; margin: 1rem 0; }
.poll-opt { display: grid; grid-template-columns: auto 1fr auto; gap: .9rem; align-items: center; padding: .6rem .8rem; border: 1px solid var(--border, #d9dee5); border-radius: .75rem; }
.poll-opt .meta { display: grid; gap: .1rem; }
@media (max-width: 560px) { .poll-opt { grid-template-columns: auto 1fr auto; } .poll-row { grid-template-columns: 1fr 6.5rem auto; } }
.poll-matrix { border-collapse: separate; border-spacing: 0; min-width: 100%; }
.poll-matrix th, .poll-matrix td { padding: .45rem .6rem; text-align: center; border-bottom: 1px solid var(--border, #e3e7ec); vertical-align: middle; }
.poll-matrix thead th { vertical-align: bottom; }
.poll-matrix tbody th { text-align: left; white-space: nowrap; font-weight: 600; }
.poll-matrix .cell-ja { background: color-mix(in srgb, #2bb673 28%, transparent); color: #1b7a4b; font-weight: 700; }
.poll-matrix .col-best { background: color-mix(in srgb, #2bb673 10%, transparent); }
.poll-matrix tfoot th, .poll-matrix tfoot td { font-weight: 700; border-top: 2px solid var(--border, #d9dee5); border-bottom: 0; }
