/* Abfrage-Plattform – modernes, ruhiges Offline-Design */

*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --bg: #eef2f7;
  --surface: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-selected: #1e40af;
  --primary-soft: #eff6ff;
  --primary-ring: rgba(37, 99, 235, 0.22);
  --danger: #b91c1c;
  --danger-hover: #991b1b;
  --danger-soft: #fef2f2;
  --success-bg: #ecfdf5;
  --success-border: #a7f3d0;
  --success-text: #065f46;
  --error: #b91c1c;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.06);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --btn-h: 2.75rem;
  --focus-ring: 0 0 0 3px var(--primary-ring);
  --header-max: 960px;
  --content-max: 860px;
  --entry-max: 28rem;
  --space: 1rem;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ========== Header ========== */

.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 1.65rem 1.35rem 1.45rem;
}

.header-inner {
  width: 100%;
  max-width: var(--header-max);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  grid-template-areas:
    ". title chip"
    "nav nav nav"
    "sync sync sync";
  align-items: center;
  column-gap: 1rem;
  row-gap: 1.5rem;
}

.app-header h1 {
  margin: 0;
  grid-area: title;
  justify-self: center;
  text-align: center;
  font-size: clamp(1.35rem, 2.4vw, 1.65rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.25;
}

.btn-chipids {
  grid-area: chip;
  justify-self: end;
  background: var(--surface);
  border: 1.5px solid var(--border-strong);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.9rem;
  min-height: 2.4rem;
  padding: 0.45rem 0.95rem;
  white-space: nowrap;
}

.btn-chipids:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}

.btn-chipids.active {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
}

.main-nav {
  grid-area: nav;
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  justify-content: center;
}

.sync-status {
  grid-area: sync;
  justify-self: center;
  margin: 0;
  padding: 0.2rem 0.65rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--text-muted);
  border-radius: 999px;
  border: 1px solid transparent;
  line-height: 1.3;
  max-width: 100%;
  text-align: center;
}

.sync-status-synced {
  color: #166534;
  background: #f0fdf4;
  border-color: #bbf7d0;
}

.sync-status-synced::before {
  content: "";
  display: inline-block;
  width: 0.55rem;
  height: 0.55rem;
  margin-right: 0.4rem;
  border-radius: 50%;
  background: #22c55e;
  vertical-align: 0.05em;
}

.sync-status-syncing {
  color: #9a3412;
  background: #fff7ed;
  border-color: #fed7aa;
}

.sync-status-syncing::before {
  content: "";
  display: inline-block;
  width: 0.55rem;
  height: 0.55rem;
  margin-right: 0.4rem;
  border-radius: 50%;
  background: #f97316;
  vertical-align: 0.05em;
}

.sync-status-offline,
.sync-status-error {
  color: #991b1b;
  background: #fef2f2;
  border-color: #fecaca;
}

.sync-status-offline::before,
.sync-status-error::before {
  content: "";
  display: inline-block;
  width: 0.55rem;
  height: 0.55rem;
  margin-right: 0.4rem;
  border-radius: 50%;
  background: #ef4444;
  vertical-align: 0.05em;
}

.nav-btn {
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  min-height: var(--btn-h);
  padding: 0.65rem 1.35rem;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  min-width: 11rem;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.nav-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}

.nav-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}

.nav-btn:focus-visible,
.btn:focus-visible,
.choice-btn:focus-visible,
.abfragen-menu-btn:focus-visible,
.sort-btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* ========== Main layout ========== */

main {
  flex: 1 1 auto;
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 1.75rem 1.15rem 2rem;
  display: flex;
  flex-direction: column;
}

main.main-wide {
  max-width: min(1240px, 100%);
}

.view {
  width: 100%;
}

.view[hidden] {
  display: none !important;
}

#view-neu:not([hidden]) {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  width: 100%;
}

#view-neu:not([hidden]):has(#chip-step:not([hidden])),
#view-neu:not([hidden]):has(#erfolg-panel:not([hidden])) {
  justify-content: center;
  padding-block: clamp(1.25rem, 7vh, 4rem);
}

#view-gespeichert:not([hidden]),
#view-chipids:not([hidden]) {
  flex: 1 1 auto;
}

/* ========== Panels / Cards ========== */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.65rem 1.75rem;
  margin-bottom: 1.25rem;
}

.panel-entry {
  width: 100%;
  max-width: var(--entry-max);
  margin-left: auto;
  margin-right: auto;
  padding: 2rem 1.85rem 2.1rem;
}

.panel-entry h2 {
  margin: 0 0 0.55rem;
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.3;
}

.panel-entry .hint {
  margin: 0 0 1.45rem;
  font-size: 0.95rem;
  line-height: 1.5;
}

.panel-entry .field-row {
  margin-bottom: 1.15rem;
}

.panel-entry .error {
  margin-top: 0;
}

.panel-entry .btn-cta {
  width: 100%;
  margin-top: 0.35rem;
}

.panel h2 {
  margin: 0 0 1rem;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.3;
}

.hint {
  color: var(--text-muted);
  margin: 0 0 1rem;
  font-size: 0.95rem;
}

.chip-info {
  margin: 0 0 1.5rem;
  padding: 0.8rem 1rem;
  background: var(--primary-soft);
  border: 1px solid #bfdbfe;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
}

/* ========== Formular ========== */

.frage {
  border: none;
  margin: 0 0 1.6rem;
  padding: 0;
}

.frage legend,
.sub-legend {
  font-weight: 650;
  font-size: 1.02rem;
  margin-bottom: 0.7rem;
  padding: 0;
  color: var(--text);
}

.sub-legend {
  margin: 0 0 0.55rem;
}

.sub-fragen {
  margin-top: 0.95rem;
  padding: 1rem;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.sub-fragen > .frage {
  margin-bottom: 1.15rem;
}

.sub-fragen > .frage:last-child {
  margin-bottom: 0;
}

.sub-fragen .field-row {
  margin-bottom: 0;
  max-width: none;
}

.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.choice-btn {
  font: inherit;
  font-weight: 500;
  padding: 0.65rem 1.05rem;
  min-height: var(--btn-h);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.choice-btn:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.choice-btn.selected {
  background: var(--primary-selected);
  border-color: var(--primary-selected);
  color: #fff;
  font-weight: 600;
}

.field-row {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1rem;
  max-width: 280px;
}

.field-row-wide {
  max-width: none;
}

.field-row label {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text);
}

input[type="text"],
input[type="number"],
input[type="search"],
select {
  font: inherit;
  min-height: var(--btn-h);
  padding: 0.7rem 0.95rem;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  width: 100%;
  background: #fff;
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input::placeholder {
  color: #94a3b8;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--focus-ring);
}

/* ========== Buttons ========== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  min-height: var(--btn-h);
  padding: 0.65rem 1.25rem;
  border: 1.5px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  line-height: 1.2;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;
}

.btn:active {
  filter: brightness(0.97);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.2);
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-cta {
  min-height: 3rem;
  font-size: 1rem;
  padding: 0.75rem 1.35rem;
}

.btn-secondary {
  background: #fff;
  border-color: var(--border-strong);
  color: var(--text);
}

.btn-secondary:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

.btn-danger {
  background: #fff;
  border-color: var(--danger);
  color: var(--danger);
}

.btn-danger:hover {
  background: var(--danger);
  color: #fff;
}

.btn-large {
  width: 100%;
  min-height: 3rem;
  padding: 0.85rem 1.25rem;
  font-size: 1.05rem;
  margin-top: 0.35rem;
}

.error {
  color: var(--error);
  background: var(--danger-soft);
  border: 1px solid #fecaca;
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  margin: 0.75rem 0 1rem;
  font-size: 0.92rem;
}

.erfolg {
  background: var(--success-bg);
  border-color: var(--success-border);
  text-align: center;
}

.erfolg h2 {
  color: var(--success-text);
  margin-bottom: 0.5rem;
}

.erfolg p {
  color: var(--text-muted);
  margin: 0 0 1.35rem;
}

.auto-antwort {
  margin: 0;
  padding: 0.85rem 1rem;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.kombi-zeile {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  margin-bottom: 0.75rem;
}

.kombi-zeile select {
  flex: 1 1 180px;
  max-width: 260px;
}

.kombi-zeile .prozent-wrap {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.kombi-zeile input[type="number"] {
  width: 5.5rem;
}

.kombi-status {
  margin: 0.5rem 0 0;
  font-weight: 600;
}

.kombi-status .offen {
  color: var(--text-muted);
  font-weight: 500;
}

/* ========== Gespeicherte Abfragen ========== */

.toolbar {
  margin-bottom: 1.15rem;
}

.search-row {
  max-width: 22rem;
  margin-bottom: 0;
}

.panel-abfragen {
  position: relative;
}

.panel-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.15rem;
}

.panel-header-row h2 {
  margin: 0;
  flex: 1 1 auto;
  padding-top: 0.2rem;
}

.abfragen-menu-wrap {
  position: relative;
  flex: 0 0 auto;
}

.abfragen-menu-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text-muted);
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.abfragen-menu-btn:hover,
.abfragen-menu-btn[aria-expanded="true"] {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

.abfragen-menu {
  position: absolute;
  top: calc(100% + 0.4rem);
  right: 0;
  min-width: 13.5rem;
  max-width: calc(100vw - 2rem);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  z-index: 50;
  overflow: hidden;
}

.abfragen-menu[hidden] {
  display: none;
}

.abfragen-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  font-weight: 600;
  font-size: 0.92rem;
  padding: 0.8rem 1rem;
  border: none;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}

.abfragen-menu-item:hover {
  background: #f1f5f9;
}

.abfragen-menu-item-danger {
  color: var(--danger);
  border-top: 1px solid var(--border);
}

.abfragen-menu-item-danger:hover {
  background: var(--danger-soft);
}

.actions-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 1.25rem;
}

.abfragen-count {
  margin: 0 0 0.85rem;
  font-size: 0.92rem;
  color: var(--text-muted);
}

.abfragen-count strong {
  color: var(--text);
}

.abfragen-select-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.15rem;
  margin-bottom: 1rem;
  padding: 0.8rem 1rem;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.select-all-label {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}

.abfragen-select-info {
  flex: 1 1 auto;
  color: var(--text-muted);
  font-size: 0.9rem;
}

#abfragen-delete-selected:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.col-check {
  width: 2.5rem;
  text-align: center;
}

.col-action {
  width: 3rem;
  text-align: center;
}

.abfrage-row-check {
  width: 1.1rem;
  height: 1.1rem;
  cursor: pointer;
}

.abfrage-delete-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.15rem;
  height: 2.15rem;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
  font-size: 1.05rem;
  line-height: 1;
  padding: 0;
  color: var(--text-muted);
}

.abfrage-delete-btn:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

th,
td {
  text-align: left;
  padding: 0.8rem 0.7rem;
  border-bottom: 1px solid var(--border);
}

tbody tr:last-child td {
  border-bottom: none;
}

th {
  background: #f8fafc;
  font-weight: 650;
  white-space: nowrap;
  color: var(--text-muted);
  font-size: 0.85rem;
  text-transform: none;
  letter-spacing: 0.01em;
}

th.sortable {
  padding: 0;
}

.sort-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  width: 100%;
  margin: 0;
  padding: 0.8rem 0.7rem;
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 650;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
}

.sort-btn:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

th.sortable.sort-active .sort-btn {
  color: var(--primary);
}

.sort-indicator {
  font-size: 0.7rem;
  line-height: 1;
  min-width: 0.7rem;
}

tbody tr {
  cursor: pointer;
  transition: background 0.1s ease;
}

tbody tr:hover {
  background: var(--primary-soft);
}

tbody tr.selected-row {
  background: #dbeafe;
}

.detail-liste {
  margin: 0 0 1.25rem;
  display: grid;
  grid-template-columns: minmax(140px, 220px) 1fr;
  gap: 0.55rem 1rem;
}

.detail-liste dt {
  font-weight: 650;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.detail-liste dd {
  margin: 0;
}

/* ========== Footer ========== */

.app-footer {
  text-align: center;
  padding: 0.85rem 1rem;
  color: var(--text-muted);
  font-size: 0.82rem;
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.72);
  flex-shrink: 0;
}

.app-footer p {
  margin: 0;
}

/* ========== Analyse ========== */

.panel-analyse .panel-header-row {
  align-items: center;
  margin-bottom: 1.35rem;
}

.analyse-content {
  display: flex;
  flex-direction: column;
  gap: 1.35rem;
}

.analyse-empty {
  text-align: center;
  padding: 2rem 1rem;
}

.analyse-empty p {
  margin: 0 0 0.5rem;
  font-weight: 600;
}

.analyse-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.85rem;
}

.analyse-kpi {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem 1.05rem;
}

.analyse-kpi-value {
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--primary);
  line-height: 1.2;
}

.analyse-kpi-label {
  margin-top: 0.35rem;
  font-size: 0.88rem;
  color: var(--text-muted);
  font-weight: 600;
}

.analyse-section {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1.1rem 1.15rem 1.2rem;
}

.analyse-section h3 {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
  font-weight: 700;
}

.analyse-section-meta {
  margin: 0 0 0.95rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.analyse-bars {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.analyse-bar-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.35rem 0.85rem;
  margin-bottom: 0.35rem;
}

.analyse-bar-label {
  font-weight: 650;
  font-size: 0.95rem;
}

.analyse-bar-meta {
  font-size: 0.88rem;
  color: var(--text-muted);
  font-weight: 600;
}

.analyse-bar-track {
  width: 100%;
  height: 0.55rem;
  background: #eef2f7;
  border-radius: 999px;
  overflow: hidden;
}

.analyse-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 999px;
  min-width: 0;
}

.analyse-numeric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.65rem;
}

.analyse-numeric-item {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.analyse-numeric-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
}

.analyse-numeric-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

@media (max-width: 900px) {
  .analyse-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .analyse-numeric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .analyse-kpis {
    grid-template-columns: 1fr;
  }

  .analyse-numeric-grid {
    grid-template-columns: 1fr;
  }

  .panel-analyse .panel-header-row {
    flex-direction: column;
    align-items: stretch;
  }

  .panel-analyse .panel-header-row .btn {
    width: 100%;
  }
}

/* ========== Chip-ID Verwaltung ========== */

.chipids-panel h2 {
  margin-bottom: 1.15rem;
}

.chipids-toolbar {
  margin-bottom: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
}

.chip-import-msg {
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 0.92rem;
}

.chip-import-msg.success {
  background: var(--success-bg);
  border: 1px solid var(--success-border);
  color: var(--success-text);
}

.chip-import-msg.error {
  background: var(--danger-soft);
  border: 1px solid #fecaca;
  color: var(--error);
}

.chip-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.5rem;
  margin-bottom: 0.85rem;
  padding: 0.85rem 1.05rem;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  color: var(--text-muted);
}

.chip-stats strong {
  font-size: 1.05rem;
  color: var(--text);
}

.chip-grid-viewport {
  position: relative;
  overflow-x: hidden;
  overflow-y: auto;
  min-height: 120px;
  max-height: min(70vh, 640px);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #f8fafc;
  margin-top: 0.5rem;
  width: 100%;
  box-sizing: border-box;
}

.chip-grid-spacer {
  width: 100%;
  pointer-events: none;
}

.chip-grid {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  box-sizing: border-box;
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 0.5rem;
  padding: 0.75rem;
}

.chip-cell {
  appearance: none;
  -webkit-appearance: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.25rem;
  min-width: 0;
  width: 100%;
  min-height: var(--chip-cell-height, 3rem);
  height: var(--chip-cell-height, 3rem);
  padding: 0.35rem 0.4rem 0.35rem 0.45rem;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  font-family: ui-monospace, Consolas, "Courier New", monospace;
  font-size: var(--chip-font-size, 0.82rem);
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  user-select: none;
  transition: box-shadow 0.12s ease;
  box-sizing: border-box;
}

.chip-cell-id {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-all;
  line-height: 1.25;
  white-space: normal;
}

.chip-cell-x {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35rem;
  height: 1.35rem;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  opacity: 0.75;
  padding: 0;
}

.chip-cell-x:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.08);
}

.chip-cell:hover {
  box-shadow: var(--shadow-sm);
}

.chip-cell.chip-offen {
  background: #fef2f2;
  border-color: #ef4444;
  color: #991b1b;
}

.chip-cell.chip-fertig {
  background: #ecfdf5;
  border-color: #22c55e;
  color: #065f46;
}

/* ========== Modals ========== */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.42);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 1000;
}

.modal-overlay[hidden] {
  display: none;
}

.modal-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.18);
  padding: 1.5rem 1.6rem;
  width: min(480px, 100%);
  max-height: 90vh;
  overflow: auto;
}

.modal-panel-sm {
  width: min(400px, 100%);
}

.modal-panel h3 {
  margin: 0 0 0.65rem;
  font-size: 1.15rem;
  font-weight: 700;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  justify-content: flex-end;
  margin-top: 1.25rem;
}

/* ========== Responsive ========== */

@media (max-width: 720px) {
  .app-header {
    padding: 1.15rem 1rem 1.1rem;
  }

  .header-inner {
    grid-template-columns: 1fr;
    grid-template-areas:
      "title"
      "nav"
      "chip"
      "sync";
    row-gap: 0.95rem;
  }

  .app-header h1 {
    font-size: 1.3rem;
  }

  .btn-chipids {
    width: 100%;
    justify-self: stretch;
  }

  .main-nav {
    gap: 0.5rem;
  }

  .nav-btn {
    flex: 1 1 140px;
    min-width: 0;
  }

  main {
    padding: 1.25rem 0.9rem 1.5rem;
  }

  .panel {
    padding: 1.35rem 1.2rem;
  }

  .panel-entry {
    padding: 1.5rem 1.25rem 1.65rem;
  }

  #view-neu:not([hidden]):has(#chip-step:not([hidden])),
  #view-neu:not([hidden]):has(#erfolg-panel:not([hidden])) {
    justify-content: flex-start;
    padding-block: 0.75rem 1rem;
  }

  .choice-btn {
    flex: 1 1 calc(50% - 0.55rem);
  }

  .detail-liste {
    grid-template-columns: 1fr;
    gap: 0.15rem 0;
  }

  .detail-liste dt {
    margin-top: 0.5rem;
  }

  .actions-bar .btn {
    flex: 1 1 100%;
  }

  .chip-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .abfragen-select-bar {
    gap: 0.65rem;
  }

  #abfragen-delete-selected {
    width: 100%;
  }
}

@media (min-width: 601px) and (max-width: 900px) {
  .chip-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

@media (min-width: 1100px) {
  .app-header {
    padding: 1.75rem 1.5rem 1.5rem;
  }

  .header-inner {
    row-gap: 1.65rem;
  }
}
