:root {
  color-scheme: light;
  --bg: #f6f3ee;
  --panel: #ffffff;
  --text: #1f2421;
  --muted: #6b6f6d;
  --primary: #1f5f54;
  --primary-dark: #16453d;
  --accent: #c47c2a;
  --danger: #b3261e;
  --ok: #2f7d32;
  --border: #e4e0d8;
  --shadow: 0 12px 30px rgba(20, 26, 25, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top, #fbfaf8 0%, #f3efe9 45%, #efe9e0 100%);
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  color: var(--primary-dark);
}

header {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 10;
}

.nav {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  gap: 18px;
}

.nav .brand {
  font-weight: 700;
  letter-spacing: 0.5px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 18px;
}

.nav-actions {
  display: flex;
  align-items: center;
}

.nav .spacer {
  flex: 1;
}

.nav a {
  font-weight: 600;
}

.container {
  max-width: 1200px;
  margin: 24px auto 64px;
  padding: 0 24px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.grid {
  display: grid;
  gap: 20px;
}

.grid-2 {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.section-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 12px;
}

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

.btn {
  border: none;
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  min-height: 44px;
  touch-action: manipulation;
}

.btn[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 8px 18px rgba(31, 95, 84, 0.2);
}

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

.btn-secondary {
  background: #f1ece3;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
}

.badge {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.badge-muted {
  background: #ece7df;
  color: var(--muted);
}

.badge-ok {
  background: #dff3e1;
  color: var(--ok);
}

.badge-warn {
  background: #fff2d9;
  color: var(--accent);
}

.badge-danger {
  background: #f8d7d5;
  color: var(--danger);
}

.badge-info {
  background: #dbe9ff;
  color: #1c4f8a;
}

form .field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

label {
  font-weight: 600;
}

fieldset {
  border: none;
  padding: 0;
  margin: 0;
}

input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 14px;
  background: #fff;
  min-height: 44px;
}

input:not([type="checkbox"]):not([type="radio"]):focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(31, 95, 84, 0.2);
  border-color: var(--primary);
}

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

th,
td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.tab-list {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}

.tab {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #f9f6f1;
}

.flash {
  margin-bottom: 16px;
  padding: 12px 16px;
  border-radius: 12px;
  font-weight: 600;
}

.flash ul {
  margin: 8px 0 0 18px;
}

.flash-success {
  background: #e2f5e5;
  color: #245f2b;
}

.flash-error {
  background: #f8d7d5;
  color: #8e1f19;
}

.flash-warning {
  background: #fff3dc;
  color: #8a5a1a;
}

.login-card {
  max-width: 420px;
  margin: 80px auto;
}

.guest-block {
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  background: #fdfbf7;
}

.typeahead-wrapper {
  position: relative;
}

.typeahead-results {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  max-height: 220px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  z-index: 20;
}

.typeahead-item {
  padding: 12px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  touch-action: manipulation;
}

.typeahead-item:last-child {
  border-bottom: none;
}

.typeahead-item:hover {
  background: #f5f0e8;
}

.typeahead-item:active {
  background: #efe6d8;
}

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

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

.pill {
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #f2ede4;
}

.required {
  color: var(--danger);
}

.mobile-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: none;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 10px 14px calc(16px + env(safe-area-inset-bottom));
  background: var(--panel);
  border-top: 1px solid var(--border);
  box-shadow: 0 -10px 30px rgba(20, 26, 25, 0.08);
  z-index: 20;
}

.mobile-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  padding: 8px 6px;
  border-radius: 12px;
  min-height: 48px;
}

.mobile-nav a.is-active {
  color: var(--primary);
  background: #f2ede4;
}

.mobile-nav-icon {
  font-size: 18px;
  line-height: 1;
}

.form-steps {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.form-step-indicator {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #f9f6f1;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.form-step-indicator.is-active {
  background: #e4f0ee;
  color: var(--primary);
  border-color: rgba(31, 95, 84, 0.35);
}

.form-flow.is-js .form-step {
  display: none;
}

.form-flow.is-js .form-step.is-active {
  display: block;
}

.step-actions {
  display: none;
}

.form-flow.is-js[data-active-step="1"] .step-actions[data-step="1"],
.form-flow.is-js[data-active-step="2"] .step-actions[data-step="2"],
.form-flow.is-js[data-active-step="3"] .step-actions[data-step="3"] {
  display: flex;
}

.guest-section {
  margin-top: 12px;
}

.form-flow.is-js[data-active-step="2"] .guest-section[data-step="2"],
.form-flow.is-js[data-active-step="3"] .guest-section[data-step="3"] {
  display: block;
}

.form-flow.is-js[data-active-step="2"] .guest-section[data-step="3"],
.form-flow.is-js[data-active-step="3"] .guest-section[data-step="2"] {
  display: none;
}

.form-flow.is-js[data-active-step="1"] .guest-section,
.form-flow.is-js[data-active-step="4"] .guest-section {
  display: none;
}

.btn-wide {
  padding-left: 22px;
  padding-right: 22px;
}

.btn.is-loading {
  position: relative;
  pointer-events: none;
  opacity: 0.75;
}

.btn.is-loading::after {
  content: "";
  position: absolute;
  right: 12px;
  top: 50%;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.6);
  border-top-color: #fff;
  transform: translateY(-50%);
  animation: spin 0.8s linear infinite;
}

.btn-secondary.is-loading::after,
.btn-outline.is-loading::after {
  border-color: rgba(31, 36, 33, 0.4);
  border-top-color: var(--text);
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 40;
}

.modal.is-open {
  display: flex;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 18, 17, 0.4);
}

.modal-card {
  position: relative;
  background: var(--panel);
  padding: 20px;
  border-radius: 16px;
  box-shadow: var(--shadow);
  max-width: 420px;
  width: 100%;
}

.modal-title {
  font-weight: 700;
  margin-bottom: 8px;
}

.modal-text {
  margin: 0 0 16px;
  color: var(--muted);
}

.session-warning {
  position: fixed;
  left: 14px;
  right: 14px;
  bottom: calc(90px + env(safe-area-inset-bottom));
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: var(--shadow);
  z-index: 30;
}

.session-warning.is-visible {
  display: flex;
}

@keyframes spin {
  to {
    transform: translateY(-50%) rotate(360deg);
  }
}

@media (max-width: 768px) {
  body {
    background: #f5f1ea;
  }

  .nav {
    padding: 14px 16px;
  }

  .nav .spacer {
    display: none;
  }

  .nav-links {
    display: none;
  }

  .container {
    margin: 16px auto 96px;
    padding: 0 14px;
  }

  .panel {
    padding: 16px;
  }

  input,
  select,
  textarea {
    font-size: 16px;
  }

  .btn {
    width: 100%;
  }

  .actions {
    flex-direction: column;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .typeahead-results {
    max-height: 45vh;
  }

  .mobile-nav {
    display: grid;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0f1412;
    --panel: #141a17;
    --text: #eef1ee;
    --muted: #aab3ae;
    --primary: #5bb49f;
    --primary-dark: #3f7f71;
    --accent: #e1a35b;
    --danger: #ff6b5a;
    --ok: #6fd17a;
    --border: #2a312d;
    --shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  }

  body {
    background: radial-gradient(circle at top, #171f1b 0%, #111614 50%, #0b0f0d 100%);
  }

  .panel {
    background: #121715;
  }

  .tab,
  .btn-secondary {
    background: #1b221f;
    color: var(--text);
  }
}
