@import url("https://fonts.googleapis.com/css2?family=Mukta:wght@300;400;700&display=swap");

:root {
  /* Color tokens */
  --bg: #f7f7f7;
  --panel: #ffffff;
  --ink: #000000;
  --muted: #4a4a4a;
  --line: #d9d9d9;
  --line-strong: #bdbdbd;
  --primary: #e4032e;
  --primary-dark: #98021f;
  --danger: #b0152f;
  --warn: #a15b00;
  --white: #ffffff;
  --black: #000000;
  --ink-soft: #2c2c2c;
  --ink-subtle: #272727;
  --ink-dim: #222222;
  --ink-strong: #333333;
  --ink-cool: #27343f;
  --muted-soft: #666666;
  --surface-soft: #fcfcfc;
  --surface-muted: #fafafa;
  --surface-alt: #f6f8fa;
  --surface-alt-2: #f5f6f8;
  --surface-alt-3: #f2f5f8;
  --surface-gray: #f4f4f4;
  --surface-gray-2: #eceff2;
  --surface-success: #e9f6ec;
  --surface-danger: #fcecef;
  --surface-danger-soft: #fff6f8;
  --surface-danger-strong: #fff3f5;
  --surface-danger-hover: #fff1f3;
  --surface-success-soft: #f4fbf6;
  --surface-info-soft: #f7f9fb;
  --line-soft: #e6e6e6;
  --line-mid: #a6a6a6;
  --line-muted: #9b9b9b;
  --line-cool: #bcc7d2;
  --line-danger-soft: #f3b9c5;
  --danger-dark: #8f1127;
  --danger-ink: #9f1239;
  --success: #1f7a3f;
  --success-dark: #18733f;
  --success-ink: #166534;
  --info: #4a5d6f;
  --warning: #d9a400;
  --warning-deep: #d97706;
  --neutral-indicator: #9ca3af;
  --progress-track: #ebebeb;
  --primary-tint-02: rgba(228, 3, 46, 0.02);
  --primary-tint-06: rgba(228, 3, 46, 0.06);
  --primary-tint-08: rgba(228, 3, 46, 0.08);
  --primary-tint-20: rgba(228, 3, 46, 0.2);
  --transparent: rgba(228, 3, 46, 0);
  --border-alpha-18: rgba(0, 0, 0, 0.18);

  /* Spacing scale */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;

  /* Radius scale */
  --radius-xs: 2px;
  --radius-sm: 4px;
  --radius-pill: 999px;

  /* Shadow scale */
  --shadow-1: 0 4px 14px rgba(0, 0, 0, 0.05);
  --shadow-2: 0 8px 22px rgba(0, 0, 0, 0.05);

  /* Focus token */
  --focus-ring: 2px solid rgba(228, 3, 46, 0.3);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Mukta", "Segoe UI", Arial, sans-serif;
  font-weight: 300;
  color: var(--ink);
  background:
    linear-gradient(to bottom, var(--white) 0, var(--white) 120px, var(--bg) 120px),
    repeating-linear-gradient(
      -45deg,
      var(--primary-tint-02) 0,
      var(--primary-tint-02) 10px,
      var(--transparent) 10px,
      var(--transparent) 20px
    );
}

body.is-busy,
body.is-busy * {
  cursor: wait !important;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: var(--space-4);
  align-items: center;
  padding: 22px 20px var(--space-4);
  background: var(--white);
  color: var(--ink);
  border-top: 6px solid var(--primary);
  border-bottom: 1px solid var(--line);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo {
  width: 170px;
  max-width: 42vw;
  height: auto;
  display: block;
  flex: 0 0 auto;
}

.topbar h1 {
  margin: 0;
  font-size: 1.52rem;
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
}

.layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
  padding: var(--space-4);
  max-width: 1240px;
  margin: 0 auto 32px;
}

.panel {
  background: var(--panel);
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  padding: var(--space-4);
  box-shadow: var(--shadow-2);
}

.panel h2 {
  margin: 0 0 10px;
  font-size: 1.35rem;
  line-height: 1.2;
  font-weight: 700;
}

.panel h3 {
  margin: 16px 0 10px;
  font-size: 1.05rem;
  font-weight: 700;
}

.hidden {
  display: none !important;
}

.form {
  display: grid;
  gap: var(--space-3);
}

.inline-form {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  align-items: end;
}

.inline-form > .panel-title {
  grid-column: 1 / -1;
}

.user-row-form {
  margin-top: 6px;
}

.form-section {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  background: var(--surface-soft);
}

.section-title {
  margin: 0 0 10px;
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--ink-soft);
}

.form-grid {
  display: grid;
  gap: var(--space-3);
}

.form-grid-two {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.form-grid-four {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.form-actions {
  display: flex;
  justify-content: flex-start;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.action-feedback {
  margin-top: 4px;
  font-size: 0.9rem;
  font-weight: 600;
}

.action-feedback.pending {
  color: var(--muted);
}

.action-feedback.success {
  color: var(--success-dark);
}

.action-feedback.error {
  color: var(--danger);
}

.campaign-form,
.booking-form {
  gap: 12px;
}

.campaign-sortiment-controls {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.campaign-sortiment-controls button {
  min-width: 120px;
}

.campaign-form button[type="submit"],
.booking-form button[type="submit"] {
  width: auto;
  min-width: 220px;
}

.optional-field {
  color: var(--muted-soft);
}

label {
  display: grid;
  gap: var(--space-1);
  color: var(--muted);
  font-size: 0.94rem;
  font-weight: 400;
  min-width: 0;
}

input,
select,
button {
  font: inherit;
  padding: 10px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--line-strong);
}

input,
select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

input[type='checkbox'],
input[type='radio'] {
  width: auto;
  max-width: none;
  min-width: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  accent-color: var(--primary);
}

.campaign-editor .table-wrap {
  overflow-x: auto;
}

.campaign-list-wrap {
  margin-bottom: var(--space-4);
  min-height: 420px;
  padding-bottom: 150px;
}

.campaign-list-table {
  min-width: 1360px;
}

.panel-form-title h3 {
  margin: 0;
}

.panel-toolbar {
  margin-bottom: var(--space-3);
}

.booking-list-wrap {
  margin-bottom: var(--space-4);
}

.booking-list-table {
  min-width: 980px;
}

.th-filter-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
}

.th-filter-btn {
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--line-strong);
  background: var(--white);
  font-size: 0.78rem;
  line-height: 1;
  cursor: pointer;
}

.th-filter-btn.active {
  border-color: var(--primary-dark);
  color: var(--primary-dark);
  background: var(--surface-danger-strong);
}

.th-filter-popover {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 15;
  min-width: 210px;
  max-width: 280px;
  padding: var(--space-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--white);
  box-shadow: var(--shadow-1);
}

.th-filter-popover label {
  gap: 6px;
  font-size: 0.85rem;
  text-transform: none;
  letter-spacing: normal;
}

.sortimentsbereich-list-wrap {
  margin-bottom: var(--space-4);
}

.sortimentsbereich-list-table {
  min-width: 980px;
}

select[multiple] {
  min-height: 108px;
  padding: 6px;
}

#sortimentsbereichPanel .table-wrap table {
  min-width: 0;
  table-layout: auto;
}

#sortimentsbereichPanel .table-wrap th,
#sortimentsbereichPanel .table-wrap td {
  vertical-align: top;
}

#sortimentsbereichPanel .table-wrap th {
  word-break: normal;
  white-space: normal;
}

#sortimentsbereichPanel .table-wrap td {
  word-break: normal;
  overflow-wrap: anywhere;
}

#sortimentsbereichTable th:nth-child(1),
#sortimentsbereichTable td:nth-child(1),
#responsiblePersonTable th:nth-child(1),
#responsiblePersonTable td:nth-child(1) {
  width: 140px;
}

#sortimentsbereichTable th:nth-child(4),
#sortimentsbereichTable td:nth-child(4) {
  width: 320px;
}

#sortimentsbereichTable th:nth-child(5),
#sortimentsbereichTable td:nth-child(5),
#responsiblePersonTable th:nth-child(7),
#responsiblePersonTable td:nth-child(7) {
  width: 240px;
}

input:focus,
select:focus,
button:focus-visible {
  outline: var(--focus-ring);
  outline-offset: 1px;
}

.btn,
button {
  border: 1px solid var(--primary);
  background: var(--primary);
  color: var(--white);
  font-weight: 700;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease;
}

.btn-primary {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--white);
}

.btn:hover,
button:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.btn:disabled,
button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn.is-loading,
button.is-loading {
  opacity: 0.7;
  cursor: wait;
}

.btn.is-loading::after,
button.is-loading::after {
  content: " ...";
}

.btn-secondary,
button.ghost {
  background: var(--white);
  color: var(--primary);
  border-color: var(--primary);
}

.btn-secondary:hover,
button.ghost:hover {
  background: var(--primary-tint-06);
}

.admin-create-btn,
.btn-create {
  min-height: 40px;
  min-width: 165px;
  padding: 10px 14px;
}

.admin-close-btn,
.btn-close {
  min-height: 40px;
  min-width: 125px;
  padding: 10px 14px;
}

#appPanel .form .admin-submit-btn,
#appPanel .form .btn-save {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  justify-self: stretch;
}

#appPanel .inline-form .admin-submit-btn,
#appPanel .inline-form .btn-save {
  grid-column: 1 / -1;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  margin-top: 8px;
}

.stat {
  border: 1px solid var(--line);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-xs);
  padding: 10px 12px;
  background: var(--white);
}

.stat .value {
  font-size: 1.4rem;
  font-weight: 700;
}

.panel-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.panel-title input[type="search"] {
  width: min(440px, 100%);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--white);
  min-height: 300px;
  padding-bottom: 150px;
}

.config-table-wrap {
  min-height: 0;
  padding-bottom: 0;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  font-size: 0.95rem;
}

th {
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.8rem;
  letter-spacing: 0.03em;
  color: var(--ink-subtle);
  background: var(--surface-muted);
  position: sticky;
  top: 0;
  z-index: 1;
}

.table-wrap tbody tr:nth-child(even) {
  background: var(--surface-soft);
}

.table-wrap tbody tr:hover {
  background: var(--surface-alt);
}

.booking-capacity-cell {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.traffic-light {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-alpha-18);
  background: var(--neutral-indicator);
}

.traffic-light.is-green {
  background: var(--success);
}

.traffic-light.is-yellow {
  background: var(--warning);
}

.traffic-light.is-orange {
  background: var(--warning-deep);
}

.traffic-light.is-red {
  background: var(--danger);
}

.badge {
  display: inline-block;
  border-radius: var(--radius-pill);
  padding: 3px 10px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}

.badge.geplant {
  background: var(--surface-gray);
  color: var(--ink-strong);
}

.badge.bestätigt {
  background: var(--surface-gray-2);
  color: var(--ink-cool);
}

.badge.abgerechnet {
  background: var(--surface-success);
  color: var(--success-ink);
}

.badge.storniert {
  background: var(--surface-danger);
  color: var(--danger-ink);
}

.budget-item {
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  padding: 10px;
  margin-bottom: var(--space-2);
}

.status-overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.status-overview-item {
  border: 1px solid var(--line);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-xs);
  background: var(--white);
  padding: 10px 12px;
}

.status-overview-item .label {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  font-weight: 700;
}

.status-overview-item .value {
  font-size: 1.45rem;
  font-weight: 700;
}

.status-count-link {
  background: transparent;
  border: 0;
  color: var(--primary);
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}

.status-count-link:hover {
  color: var(--primary-dark);
  background: transparent;
  border: 0;
}

.capacity-overview h3 {
  margin: 0 0 var(--space-2);
}

.progress {
  height: 8px;
  width: 100%;
  background: var(--progress-track);
  border-radius: var(--radius-pill);
  overflow: hidden;
  margin-top: 6px;
}

.progress > span {
  display: block;
  height: 100%;
  background: var(--primary);
}

.progress.over > span {
  background: var(--danger);
}

.actions {
  display: flex;
  gap: 6px;
}

.actions button {
  padding: 6px 8px;
  font-size: 0.8rem;
}

.row-context-menu {
  position: relative;
  display: inline-flex;
}

.row-context-menu__trigger {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--line-strong);
  background: var(--white);
  color: var(--muted);
  border-radius: var(--radius-xs);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  line-height: 1;
}

.row-context-menu__trigger:hover {
  background: var(--surface-alt-2);
  border-color: var(--line-muted);
  color: var(--ink-dim);
}

.row-context-menu.is-open .row-context-menu__trigger {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-tint-08);
}

.row-context-menu__panel {
  position: fixed;
  top: 0;
  left: 0;
  min-width: 150px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-1);
  padding: 6px;
  display: none;
  z-index: 1200;
  max-height: 70vh;
  overflow-y: auto;
}

.row-context-menu.is-open .row-context-menu__panel {
  display: grid;
  gap: 4px;
}

.row-context-menu__panel button {
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-xs);
  background: var(--white);
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 600;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}

.row-context-menu__panel button:hover,
.row-context-menu__panel button:focus-visible {
  background: var(--surface-alt-3);
  border-color: var(--line-cool);
  border-left: 3px solid var(--info);
  padding-left: 8px;
  outline: none;
}

.row-context-menu__panel button.danger {
  background: transparent;
  border-color: transparent;
  color: var(--danger);
}

.row-context-menu__panel button.danger:hover,
.row-context-menu__panel button.danger:focus-visible {
  background: var(--surface-danger-hover);
  border-color: var(--line-danger-soft);
  border-left: 3px solid var(--danger);
  padding-left: 8px;
  color: var(--danger-dark);
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
}

.btn-danger,
button.danger,
.danger {
  background: var(--danger);
  border-color: var(--danger);
}

.btn-danger:hover,
button.danger:hover,
.danger:hover {
  background: var(--danger-dark);
  border-color: var(--danger-dark);
}

.warn {
  color: var(--warn);
  font-weight: 700;
}

.session-box {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.help-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
}

.help-link:hover {
  border-color: var(--primary-dark);
  background: var(--surface-danger-strong);
  color: var(--primary-dark);
}

.help-link__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: var(--radius-pill);
  background: var(--primary);
  color: var(--white);
  font-size: 0.84rem;
  font-weight: 700;
  line-height: 1;
}

#sessionBox {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.pill {
  background: var(--primary-tint-08);
  color: var(--danger-dark);
  border: 1px solid var(--primary-tint-20);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.82rem;
}

.hint {
  margin-top: 10px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-xs);
  padding: 10px;
  color: var(--muted);
  background: var(--surface-soft);
}

.login-divider {
  margin: 10px 0;
  font-size: 0.95rem;
}

.muted {
  color: var(--muted);
}

.inline-feedback {
  margin-top: var(--space-2);
  border: 1px solid var(--line);
  border-left: 4px solid var(--line-strong);
  border-radius: var(--radius-xs);
  padding: 8px 10px;
  background: var(--white);
  color: var(--ink);
  font-size: 0.88rem;
}

.inline-feedback.error {
  border-left-color: var(--danger);
  background: var(--surface-danger-soft);
}

.feedback-area {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.28);
  pointer-events: none;
}

.feedback-area:empty {
  display: none;
}

.alert {
  width: min(520px, calc(100vw - 40px));
  border: 1px solid var(--line);
  border-left: 4px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  background: var(--white);
  color: var(--ink);
  box-shadow: var(--shadow-1);
  pointer-events: auto;
}

.alert.error {
  border-left-color: var(--danger);
  background: var(--surface-danger-soft);
}

.alert.success {
  border-left-color: var(--success);
  background: var(--surface-success-soft);
}

.alert.info {
  border-left-color: var(--info);
  background: var(--surface-info-soft);
}

.alert-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.action-row {
  display: grid;
  gap: 8px;
}

.row-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.view-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 2px 0 8px;
}

.tab-btn {
  background: var(--white);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  min-width: 120px;
}

.tab-btn:hover {
  background: var(--surface-muted);
  border-color: var(--line-mid);
}

.tab-btn.active,
.tab-btn[aria-selected="true"] {
  background: var(--primary);
  color: var(--white);
  border-color: var(--primary);
}

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .brand-block {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .brand-logo {
    width: 190px;
    max-width: 70vw;
  }

  .topbar h1 {
    font-size: 1.32rem;
  }

  .campaign-form button[type="submit"],
  .booking-form button[type="submit"] {
    width: 100%;
    min-width: 0;
  }

  .table-wrap {
    min-height: 240px;
    padding-bottom: 120px;
  }
}
