/* ── Schlüsselübergabe Local Styles ───────────────────────── */

.app-container {
  max-width: 540px;
  margin: 0 auto;
  padding: 24px 16px 48px;
  flex: 1;
  width: 100%;
  box-sizing: border-box;
}

/* ── Header Brand Icon ───────────────────────────────────── */
.brand-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--r-sm);
  background: linear-gradient(135deg, var(--accent), var(--accent-d));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1rem;
  flex-shrink: 0;
}

.card-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 28px;
  box-shadow: 0 4px 20px rgba(0,0,0,.15);
}

[data-theme="light"] .card-box {
  box-shadow: 0 4px 20px rgba(0,0,0,.04);
}

.view-title {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -.02em;
  margin-bottom: 4px;
}

.view-sub {
  font-size: .88rem;
  color: var(--muted);
  margin-bottom: 24px;
  line-height: 1.45;
}

/* ── Action Selector Pills ─────────────────────────────── */
.action-selector {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 8px;
}

.action-pill {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: var(--surface-2);
  border: 1.5px solid var(--border-2);
  border-radius: var(--r-md);
  cursor: pointer;
  font-weight: 600;
  font-size: .9rem;
  color: var(--text);
  transition: all .15s ease;
  user-select: none;
}

.action-pill input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.action-pill:hover {
  border-color: var(--accent);
}

.action-pill:has(input:checked),
.action-pill.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Recipient Type Toggle ─────────────────────────────── */
.btn-recipient-type {
  flex: 1;
  padding: 10px 14px;
  background: var(--surface-2);
  border: 1.5px solid var(--border-2);
  color: var(--text);
  border-radius: var(--r-md);
  font-family: inherit;
  font-size: .85rem;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  transition: all .15s ease;
}

.btn-recipient-type:hover {
  border-color: var(--accent);
}

.btn-recipient-type.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ── Key Item Rows ─────────────────────────────────────── */
.key-items-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.key-item-row {
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: var(--r-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
}

.key-item-top {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.key-item-select {
  flex: 2;
  min-width: 180px;
}

.key-item-count {
  flex: 1;
  min-width: 90px;
}

.btn-remove-item {
  background: var(--err-bg);
  color: var(--err);
  border: 1px solid var(--err-border);
  border-radius: var(--r-sm);
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  flex-shrink: 0;
  transition: background .15s, color .15s;
}

.btn-remove-item:hover {
  background: var(--err);
  color: #fff;
}

.key-item-extra {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
}

/* ── Signature Canvas ──────────────────────────────────── */
.sig-container {
  position: relative;
  background: var(--surface-2);
  border: 1.5px dashed var(--border-2);
  border-radius: var(--r-md);
  overflow: hidden;
  touch-action: none;
}

#sig-canvas {
  width: 100%;
  height: 150px;
  display: block;
  cursor: crosshair;
}

.sig-hint {
  position: absolute;
  bottom: 8px;
  right: 12px;
  font-size: .75rem;
  color: var(--muted);
  pointer-events: none;
}

.append-hint {
  font-size: .78rem;
  color: var(--muted);
  margin-top: 12px;
  text-align: center;
  line-height: 1.4;
}

/* ── History & Cards ────────────────────────────────────── */
.history-controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.history-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 16px 20px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: border-color .15s, transform .15s;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.history-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.history-main {
  flex: 1;
}

.history-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.badge-action {
  font-size: .72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 99px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.badge-action.ausgabe {
  background: var(--ok-bg);
  color: var(--ok);
  border: 1px solid var(--ok-border);
}

.badge-action.rueckgabe {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid var(--accent-border);
}

.badge-action.schlosswechsel {
  background: var(--warn-bg);
  color: var(--warn);
  border: 1px solid var(--warn-border);
}

.history-recipient {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
}

.history-meta {
  font-size: .82rem;
  color: var(--muted);
  margin-bottom: 8px;
}

.history-items-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.item-chip {
  font-size: .78rem;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  padding: 2px 8px;
  border-radius: var(--r-sm);
  color: var(--text);
}

/* ── Stat Grid ─────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.stat-card {
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: var(--r-md);
  padding: 20px;
  text-align: center;
}

.stat-val {
  font-size: 2.2rem;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 6px;
}

.stat-lbl {
  font-size: .8rem;
  color: var(--muted);
  font-weight: 500;
}

/* ── Key Types Grid ────────────────────────────────────── */
.key-types-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.type-card {
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: var(--r-md);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.type-title {
  font-weight: 600;
  font-size: .92rem;
}

.type-badge {
  font-size: .7rem;
  color: var(--muted);
  background: var(--surface);
  padding: 2px 6px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
}

/* ── Modal Overrides ────────────────────────────────────── */
.modal-wide {
  max-width: 540px;
  width: 100%;
}

#detail-modal-body {
  padding: 16px 0;
}

@media (max-width: 600px) {
  .card-box { padding: 18px 16px; }
  .action-selector { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr !important; }
}
