:root {
  --ink: #12161c;
  --panel: #1a2029;
  --panel-alt: #212936;
  --line: #2e3948;
  --gold: #c9a227;
  --gold-bright: #e0b93a;
  --paper: #efe9d8;
  --paper-line: #d8cfb2;
  --text: #e7e9ec;
  --text-dim: #8d96a3;
  --danger: #b5462f;
  --danger-bright: #d0573b;

  --font-display: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--ink);
  background-image: 
    radial-gradient(circle at 10% 0%, rgba(201, 162, 39, 0.03), transparent 50%),
    radial-gradient(circle at 90% 100%, rgba(201, 162, 39, 0.03), transparent 50%);
  color: var(--text);
  font-family: var(--font-display);
  min-height: 100vh;
}

/* ===================== TOPBAR ===================== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: rgba(26, 32, 41, 0.7);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.badge-mark {
  width: 38px;
  height: 38px;
  border: 2px solid var(--gold);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gold-bright);
  font-size: 18px;
  background: radial-gradient(circle, rgba(201, 162, 39, 0.12), transparent 70%);
}

.topbar-title {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.topbar-title-main {
  font-weight: 700;
  letter-spacing: 2px;
  font-size: 17px;
  color: var(--text);
}

.topbar-title-sub {
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--gold);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ===================== BUTTONS ===================== */
.btn-primary,
.btn-ghost,
.btn-danger {
  font-family: var(--font-display);
  letter-spacing: 0.5px;
  font-size: 13px;
  font-weight: 600;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--gold-bright), var(--gold));
  color: var(--ink);
  box-shadow: 0 4px 12px rgba(201, 162, 39, 0.2);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(201, 162, 39, 0.3);
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--line);
}

.btn-ghost:hover {
  border-color: var(--gold);
  color: var(--gold-bright);
}

.btn-danger {
  background: rgba(33, 41, 54, 0.5);
  color: var(--text-dim);
  border-color: var(--line);
}

.btn-danger:hover {
  background: rgba(181, 70, 47, 0.1);
  border-color: var(--danger);
  color: var(--danger-bright);
}

/* ===================== DROPDOWN ===================== */
.dropdown {
  position: relative;
}

.dropdown-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chevron {
  font-size: 11px;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  list-style: none;
  margin: 0;
  padding: 6px;
  width: 220px;
  display: none;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
  z-index: 60;
}

.dropdown-menu.open {
  display: block;
}

.dropdown-menu li {
  padding: 10px 14px;
  font-size: 13px;
  letter-spacing: 0.4px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-dim);
  transition: all 0.2s;
}

.dropdown-menu li:hover {
  background: var(--panel-alt);
  color: var(--gold-bright);
}

.dropdown-menu li.active {
  color: var(--gold-bright);
  background: rgba(201, 162, 39, 0.05);
}

/* ===================== LAYOUT ===================== */
.app-main {
  padding: 24px;
  max-width: 1600px;
  margin: 0 auto;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.creator-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}

@media (max-width: 1024px) {
  .creator-layout {
    grid-template-columns: 1fr;
  }
}

.panel {
  background: var(--panel);
  border: 1px solid rgba(46, 57, 72, 0.5);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  overflow: hidden;
  position: relative;
}

.form-panel::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 150%;
  height: 150%;
  background: radial-gradient(circle, rgba(201, 162, 39, 0.02) 0%, transparent 60%);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.panel-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(33, 41, 54, 0.3);
}

.panel-header-label {
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  font-size: 12px;
  color: var(--gold);
}

.placeholder-notice {
  margin: 20px 24px 0;
  padding: 14px 18px;
  background: rgba(201, 162, 39, 0.08);
  border: 1px dashed rgba(201, 162, 39, 0.4);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-dim);
}

/* ===================== FORM ===================== */
.akten-form {
  padding: 24px;
}

.field-row {
  display: flex;
  gap: 20px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1 1 220px;
}

.field-small {
  flex: 0 1 160px;
}

label {
  font-size: 11px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-dim);
  font-weight: 600;
}

.optional-tag {
  font-size: 10px;
  color: var(--gold);
  border: 1px solid var(--gold);
  padding: 2px 6px;
  border-radius: 20px;
  text-transform: none;
  letter-spacing: 0;
  margin-left: 8px;
}

input[type="text"],
input[type="date"],
textarea {
  background: rgba(33, 41, 54, 0.5);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-family: var(--font-display);
  font-size: 14px;
  outline: none;
  transition: all 0.2s ease;
  width: 100%;
}

input[type="text"]:focus,
input[type="date"]:focus,
textarea:focus {
  background: var(--panel-alt);
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.15);
}

textarea {
  resize: vertical;
  font-family: var(--font-mono);
  font-size: 13px;
  min-height: 100px;
}

.field-hint {
  font-size: 11px;
  color: var(--text-dim);
  margin: 0;
  font-family: var(--font-display);
}

.section-divider {
  margin: 32px 0 20px;
  padding-top: 0;
  border-top: none;
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-dim);
  font-weight: 700;
}

.radio-group {
  display: flex;
  gap: 4px;
  background: rgba(33, 41, 54, 0.5);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  width: fit-content;
}

.radio-pill {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 24px;
  border-radius: calc(var(--radius-md) - 2px);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
  transition: all 0.2s ease;
  margin: 0;
}

.radio-pill:has(input:checked) {
  background: var(--gold);
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(201, 162, 39, 0.25);
}

.radio-pill input {
  display: none;
}

.checkbox-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

@media (max-width: 1400px) {
  .checkbox-row {
    grid-template-columns: 1fr;
  }
}

.checkbox-pill {
  background: rgba(33, 41, 54, 0.5);
  border: 1px solid var(--line);
  padding: 16px;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 0.2s ease;
}

.checkbox-pill:hover {
  background: var(--panel-alt);
  border-color: rgba(201, 162, 39, 0.4);
}

.checkbox-pill input {
  display: none;
}

.pill-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.pill-content {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.pill-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
  line-height: 1.3;
  transition: all 0.2s ease;
}

.pill-check {
  margin-left: auto;
  color: transparent;
  display: flex;
  align-items: center;
  transition: all 0.2s ease;
}

#pill-rechtsbeistand:has(input:checked) {
  border-color: var(--gold);
  background: rgba(201, 162, 39, 0.05);
}
#pill-rechtsbeistand:has(input:checked) .pill-check {
  color: var(--gold-bright);
}
#pill-rechtsbeistand:has(input:checked) .pill-icon {
  background: var(--gold);
  color: var(--ink);
}
#pill-rechtsbeistand:has(input:checked) .pill-title {
  color: var(--gold-bright);
}

#pill-richter:has(input:checked), #pill-medizin:has(input:checked) {
  border-color: var(--danger);
  background: rgba(181, 70, 47, 0.05);
}
#pill-richter:has(input:checked) .pill-icon, #pill-medizin:has(input:checked) .pill-icon {
  background: var(--danger);
  color: #fff;
}
#pill-richter:has(input:checked) .pill-title, #pill-medizin:has(input:checked) .pill-title {
  color: var(--danger-bright);
}
#pill-richter:has(input:checked) .pill-check, #pill-medizin:has(input:checked) .pill-check {
  color: var(--danger-bright);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 16px;
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.validation-errors {
  margin-top: 24px;
  padding: 14px 18px;
  background: rgba(181, 70, 47, 0.1);
  border: 1px solid var(--danger);
  border-radius: var(--radius-md);
  color: var(--danger-bright);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.5;
}

/* ===================== REPORT (Signature element: carbon-copy case file) ===================== */
.report-panel {
  position: sticky;
  top: 90px;
}

.report-paper {
  margin: 24px;
  background: var(--paper);
  color: #1c1a12;
  border-radius: 4px;
  padding: 28px 32px;
  min-height: 400px;
  box-shadow:
    inset 0 0 0 1px var(--paper-line),
    0 14px 30px rgba(0, 0, 0, 0.4);
  background-image: repeating-linear-gradient(to bottom,
      transparent, transparent 27px, rgba(0, 0, 0, 0.045) 28px);
}

#report-output {
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 28px;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}

.report-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px 24px;
}

.copy-confirm {
  font-size: 13px;
  font-weight: 500;
  color: var(--gold-bright);
  letter-spacing: 0.5px;
}

/* ===================== HISTORY VIEW ===================== */
.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.history-header h1 {
  font-size: 24px;
  letter-spacing: 1px;
  margin: 0;
}

.history-header span {
  color: var(--gold-bright);
}

.tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 24px;
}

.tab-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-family: var(--font-display);
  letter-spacing: 0.5px;
  font-weight: 600;
  font-size: 14px;
  padding: 14px 20px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.2s;
}

.tab-btn.active {
  color: var(--gold-bright);
  border-bottom-color: var(--gold);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 4px;
  margin-bottom: 24px;
  background: rgba(33, 41, 54, 0.3);
}

.segmented-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  padding: 8px 20px;
  border-radius: 16px;
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.5px;
  transition: all 0.2s;
}

.segmented-btn.active {
  background: var(--gold);
  color: var(--ink);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.stat-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.stat-card .stat-value {
  font-family: var(--font-mono);
  font-size: 32px;
  color: var(--gold-bright);
  font-weight: 700;
}

.stat-card .stat-label {
  font-size: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-dim);
  font-weight: 600;
  margin-top: 8px;
}

.verlauf-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 24px;
}

@media (max-width: 900px) {
  .verlauf-layout {
    grid-template-columns: 1fr;
  }
}

.verlauf-list {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  max-height: 620px;
  overflow-y: auto;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.verlauf-item {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: all 0.2s;
}

.verlauf-item:hover {
  background: rgba(33, 41, 54, 0.5);
}

.verlauf-item.active {
  background: rgba(201, 162, 39, 0.1);
  border-left: 4px solid var(--gold);
}

.verlauf-item .vi-typ {
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 700;
}

.verlauf-item .vi-name {
  font-family: var(--font-mono);
  font-size: 14px;
  margin-top: 6px;
  color: var(--text);
}

.verlauf-item .vi-date {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
}

.verlauf-detail {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px;
  min-height: 300px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.empty-hint {
  color: var(--text-dim);
  font-size: 14px;
  font-family: var(--font-mono);
}

/* ===================== MODAL ===================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 16, 0.85);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal {
  background: var(--panel);
  border: 1px solid rgba(201, 162, 39, 0.5);
  border-radius: var(--radius-lg);
  padding: 32px;
  max-width: 420px;
  width: 90%;
  box-shadow: 0 12px 48px rgba(0,0,0,0.4);
}

.modal h2 {
  margin: 0 0 12px;
  font-size: 20px;
  color: var(--text);
}

.modal p {
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.6;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
}