/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: 40px; padding: 0 var(--sp-4); border-radius: var(--r-md);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font-weight: 600; font-size: var(--fs-sm); cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .1s;
}
.btn svg { width: 18px; height: 18px; flex: none; }
.btn:hover { background: var(--surface-2); border-color: var(--ink-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--signal); border-color: var(--signal); color: var(--signal-ink); }
.btn-primary:hover { background: #FFD45E; border-color: #FFD45E; }
.btn-ink { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.btn-ink:hover { background: var(--ink-2); border-color: var(--ink-2); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); border-color: transparent; }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn-sm { min-height: 32px; padding: 0 var(--sp-3); font-size: var(--fs-xs); border-radius: var(--r-sm); }
.btn-icon { width: 40px; padding: 0; }
.btn-icon.btn-sm { width: 32px; }
.btn.is-busy { pointer-events: none; opacity: .7; }
.btn.is-busy::after { content: ""; width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn-row { display: flex; flex-wrap: wrap; gap: var(--sp-2); }

/* ---------- Formulare ---------- */
.field { display: grid; gap: 6px; }
.field > label, .field-label { font-size: var(--fs-sm); font-weight: 600; color: var(--ink-2); }
.field .hint { font-size: var(--fs-xs); color: var(--muted); }
.field .error { font-size: var(--fs-xs); color: var(--danger); }
.input, .select, .textarea {
  width: 100%; min-height: 42px; padding: 9px 12px;
  border: 1px solid var(--line-strong); border-radius: var(--r-md);
  background: var(--surface); color: var(--ink);
}
.textarea { min-height: 96px; resize: vertical; line-height: 1.45; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px color-mix(in srgb, var(--signal) 70%, transparent); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.form-grid { display: grid; gap: var(--sp-4); grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
.form-grid .span-2 { grid-column: 1 / -1; }
@media (max-width: 600px) { .form-grid { grid-template-columns: 1fr; } }
.check { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-sm); cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--ink); }

/* ---------- Segment-Schalter und Filterchips ---------- */
.segmented { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md); }
.segmented button { border: 0; background: transparent; padding: 7px 12px; border-radius: 9px; font-weight: 600; font-size: var(--fs-sm); color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.segmented button svg { width: 16px; height: 16px; }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1), 0 0 0 1px var(--line); }
.chips { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px;
  border-radius: var(--r-pill); border: 1px solid var(--line-strong); background: var(--surface);
  font-size: var(--fs-sm); font-weight: 500; color: var(--ink-2); cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.chip .n { font-size: var(--fs-xs); opacity: .7; }

/* ---------- Status-Plaketten ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 700; white-space: nowrap; }
.badge svg { width: 13px; height: 13px; }
.badge-upcoming { background: var(--other-soft); color: var(--ink-2); }
.badge-today { background: var(--signal); color: var(--signal-ink); }
.badge-lifted { background: var(--signal-soft); color: var(--warn); }
.badge-lifted.is-urgent { background: var(--warn); color: #fff; }
.badge-past, .badge-used, .badge-archived { background: var(--surface-2); color: var(--muted); }
.badge-expired { background: var(--danger-soft); color: var(--danger); }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-err { background: var(--danger-soft); color: var(--danger); }
.type-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.type-rail { --type: var(--rail); --type-soft: var(--rail-soft); }
.type-event { --type: var(--event); --type-soft: var(--event-soft); }
.type-other { --type: var(--other); --type-soft: var(--other-soft); }
.type-dot { background: var(--type); }

/* ---------- Flächen ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--sp-5); }
.panel-tight { padding: var(--sp-4); }
.panel h2 + *, .panel h3 + * { margin-top: var(--sp-3); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px var(--sp-5); margin: 0; font-size: var(--fs-sm); }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.divider { height: 1px; background: var(--line); border: 0; margin: 0; }
.empty { display: grid; justify-items: center; gap: var(--sp-3); padding: var(--sp-7) var(--sp-5); text-align: center; color: var(--muted); border: 1.5px dashed var(--line-strong); border-radius: var(--r-lg); }
.empty svg { width: 40px; height: 40px; color: var(--line-strong); }
.empty h3 { color: var(--ink); }
.callout { display: flex; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md); background: var(--surface-2); font-size: var(--fs-sm); }
.callout svg { width: 18px; height: 18px; flex: none; margin-top: 2px; }
.callout-warn { background: var(--warn-soft); color: var(--warn); }
.callout-err { background: var(--danger-soft); color: var(--danger); }
.callout-ok { background: var(--ok-soft); color: var(--ok); }
.callout a { font-weight: 600; }

/* ---------- Tabelle ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th { text-align: left; font-weight: 600; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table .clip { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Dialog ---------- */
dialog.dlg {
  width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px);
  padding: 0; border: 1px solid var(--line); border-radius: var(--r-lg);
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-2);
}
dialog.dlg[open] { animation: dlg-in .18s var(--ease); }
dialog.dlg::backdrop { background: rgba(10, 16, 22, .55); backdrop-filter: blur(2px); }
@keyframes dlg-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.dlg form { display: flex; flex-direction: column; max-height: calc(100dvh - 26px); }
.dlg-head { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--line); }
.dlg-head h2 { flex: 1; font-size: var(--fs-lg); }
.dlg-body { padding: var(--sp-5); overflow: auto; display: grid; gap: var(--sp-4); }
.dlg-foot { display: flex; justify-content: flex-end; gap: var(--sp-2); padding: var(--sp-4) var(--sp-5); border-top: 1px solid var(--line); }
@media (max-width: 600px) {
  dialog.dlg { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: var(--r-lg) var(--r-lg) 0 0; }
  dialog.dlg[open] { animation: sheet-in .22s var(--ease); }
  @keyframes sheet-in { from { transform: translateY(30px); opacity: 0; } }
}

/* ---------- Toasts ---------- */
.toasts { position: fixed; z-index: 100; left: 50%; bottom: 24px; transform: translateX(-50%); display: grid; gap: 8px; width: min(420px, calc(100vw - 24px)); pointer-events: none; }
.toast { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: var(--r-md); background: var(--ink); color: var(--surface); font-size: var(--fs-sm); box-shadow: var(--shadow-2); animation: toast-in .2s var(--ease); pointer-events: auto; }
.toast svg { width: 18px; height: 18px; flex: none; color: var(--signal); }
.toast-err svg { color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@media (max-width: 860px) { .toasts { bottom: calc(84px + env(safe-area-inset-bottom)); } }

/* ---------- Ladezustand ---------- */
.skeleton { border-radius: var(--r-lg); background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: shimmer 1.2s infinite; min-height: 96px; border: 1px solid var(--line); }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- Domain-Chips-Eingabe ---------- */
.tag-input { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-height: 44px; padding: 6px; border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--surface); }
.tag-input:focus-within { border-color: var(--ink); box-shadow: 0 0 0 3px color-mix(in srgb, var(--signal) 70%, transparent); }
.tag { display: inline-flex; align-items: center; gap: 4px; height: 28px; padding: 0 4px 0 10px; border-radius: var(--r-pill); background: var(--surface-2); border: 1px solid var(--line); font-size: var(--fs-sm); }
.tag button { border: 0; background: transparent; width: 22px; height: 22px; border-radius: 50%; cursor: pointer; color: var(--muted); display: grid; place-items: center; }
.tag button:hover { background: var(--line); color: var(--ink); }
.tag button svg { width: 12px; height: 12px; }
.tag-input input { flex: 1; min-width: 140px; border: 0; outline: 0; background: transparent; padding: 4px 6px; }
.suggest { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: var(--fs-xs); color: var(--muted); }
.suggest button { display: inline-flex; align-items: center; gap: 3px; border: 1px dashed var(--line-strong); background: transparent; border-radius: var(--r-pill); padding: 3px 9px; font-size: var(--fs-xs); cursor: pointer; color: var(--ink-2); }
.suggest button svg { width: 12px; height: 12px; }
