:root {
  --bg: #f6f7f8;
  --text: #161719;
  --muted: #68707a;
  --line: #dde1e6;
  --surface: #ffffff;
  --surface-strong: #f0f2f4;
  --red: #d91f2a;
  --red-dark: #a9151f;
  --green: #138a4b;
  --amber: #b26a00;
  --radius: 8px;
  --shadow: 0 18px 50px rgba(22, 23, 25, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.56;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0;
}

body.is-logged-out .app-shell {
  min-height: 100dvh;
  display: grid;
  place-items: center;
}

.login-screen {
  width: min(420px, 100%);
  display: grid;
  gap: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.login-copy {
  color: var(--muted);
  line-height: 1.45;
}

.app-main {
  display: grid;
  gap: 14px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-logo {
  width: 132px;
  height: auto;
  border-radius: var(--radius);
  display: block;
  flex: 0 0 auto;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.55rem, 2.6vw, 2.25rem);
  line-height: 1.05;
}

h2 {
  font-size: 1.15rem;
  line-height: 1.2;
}

.eyebrow {
  color: var(--red);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.login-form,
.account-list {
  display: grid;
  gap: 10px;
}

.current-user,
.demo-pins {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--surface-strong);
}

.current-user {
  display: grid;
  gap: 8px;
}

.demo-pins {
  color: var(--muted);
  font-size: 0.9rem;
}

.demo-pins p + p {
  margin-top: 4px;
}

.is-hidden {
  display: none;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.account-button {
  display: grid;
  gap: 4px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 12px;
  text-align: left;
}

.account-button.is-active {
  border-color: var(--red);
  background: #fff5f5;
}

.account-button span {
  color: var(--muted);
  font-size: 0.88rem;
}

.content-panel {
  min-width: 0;
  overflow: hidden;
}

.app-footer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: stretch;
}

.tabs {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-strong);
  position: sticky;
  top: 0;
  z-index: 5;
}

.tab,
.ghost-button,
.primary-button {
  border-radius: var(--radius);
  border: 1px solid transparent;
  min-height: 46px;
  padding: 0 14px;
  font-weight: 750;
}

.tab {
  background: transparent;
  color: var(--muted);
  flex: 1;
}

.tab.is-active {
  background: var(--surface);
  color: var(--text);
  border-color: var(--line);
}

.ghost-button {
  background: var(--surface);
  border-color: var(--line);
  color: var(--text);
}

.primary-button {
  width: 100%;
  background: var(--red);
  color: #ffffff;
}

.primary-button:hover,
.primary-button:focus-visible {
  background: var(--red-dark);
}

.view {
  display: none;
  padding: 18px;
}

.view.is-visible {
  display: block;
}

.section-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.section-heading.compact {
  margin-bottom: 12px;
}

.section-heading select {
  max-width: 310px;
}

.event-details {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.event-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.event-card {
  display: grid;
  gap: 4px;
  min-height: 96px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 12px;
  text-align: left;
  touch-action: manipulation;
}

.event-card span,
.event-card small {
  color: var(--muted);
  font-size: 0.86rem;
}

.event-card.is-active {
  border-color: var(--red);
  background: #fff5f5;
  box-shadow: inset 0 0 0 1px rgba(217, 31, 42, 0.18);
}

.detail-tile,
.stat,
.response-row {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.detail-tile {
  padding: 12px;
}

.detail-tile b,
.stat b {
  display: block;
  margin-top: 4px;
}

.detail-tile span,
.stat span,
.status-text,
.comment-meta {
  color: var(--muted);
  font-size: 0.88rem;
}

.driver-actions {
  display: grid;
  gap: 12px;
}

.driver-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: var(--surface);
}

.driver-card-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.status-pill {
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.82rem;
  font-weight: 800;
  white-space: nowrap;
}

.status-coming {
  background: #e8f7ee;
  color: var(--green);
}

.status-not {
  background: #fff0f0;
  color: var(--red-dark);
}

.status-open {
  background: #fff4de;
  color: var(--amber);
}

.action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.action-button {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-weight: 800;
  touch-action: manipulation;
}

.action-button:hover,
.action-button:focus-visible {
  border-color: var(--red);
}

.action-coming.is-selected {
  border-color: var(--green);
  background: #e8f7ee;
  color: var(--green);
}

.action-not.is-selected {
  border-color: var(--red);
  background: #fff0f0;
  color: var(--red-dark);
}

.driver-card textarea {
  width: 100%;
  margin-top: 10px;
  resize: vertical;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(260px, 390px) minmax(0, 1fr);
  gap: 18px;
}

.event-form {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 750;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  min-height: 46px;
  padding: 10px 11px;
}

textarea {
  min-height: 94px;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.form-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.repeat-box {
  display: grid;
  grid-template-columns: 1fr 130px;
  gap: 10px;
  align-items: end;
}

.check-label {
  min-height: 46px;
  grid-template-columns: auto 1fr;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  padding: 0 12px;
}

.check-label input {
  width: auto;
  min-height: auto;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}

.stat {
  padding: 12px;
}

.stat-button {
  appearance: none;
  color: var(--text);
  min-height: 98px;
  text-align: left;
  touch-action: manipulation;
  transition:
    border-color 150ms ease,
    box-shadow 150ms ease,
    transform 150ms ease;
}

.stat-button:hover,
.stat-button:focus-visible {
  border-color: var(--red);
  box-shadow: 0 10px 26px rgba(217, 31, 42, 0.12);
  transform: translateY(-1px);
}

.stat-button.is-active {
  border-color: var(--red);
  background: #fff5f5;
  box-shadow: inset 0 0 0 1px rgba(217, 31, 42, 0.18);
}

.response-list {
  display: grid;
  gap: 8px;
}

.response-row {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.compact-button {
  min-height: 36px;
  padding: 0 10px;
  font-size: 0.88rem;
}

.danger-button {
  border-color: #ffd0d0;
  color: var(--red-dark);
}

.comment-meta {
  margin-top: 4px;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 18px;
  color: var(--muted);
  text-align: center;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(360px, calc(100vw - 36px));
  transform: translateY(120px);
  opacity: 0;
  border-radius: var(--radius);
  background: #161719;
  color: #ffffff;
  padding: 12px 14px;
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 860px) {
  .app-shell {
    width: min(100% - 20px, 680px);
    padding: 14px 0;
  }

  .topbar {
    align-items: start;
    flex-direction: column;
  }

  .brand {
    align-items: start;
  }

  .layout,
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .admin-summary {
    order: -1;
  }

  .event-list,
  .event-details {
    grid-template-columns: 1fr 1fr;
  }

  .stats {
    grid-template-columns: 1fr 1fr;
  }

  .section-heading {
    display: grid;
  }

  .section-heading select {
    max-width: none;
  }
}

@media (max-width: 520px) {
  .brand-logo {
    width: 104px;
  }

  .view {
    padding: 12px;
  }

  .section-heading {
    gap: 10px;
  }

  .event-list,
  .event-details {
    grid-template-columns: 1fr;
  }

  .field-row,
  .action-row,
  .form-actions,
  .repeat-box {
    grid-template-columns: 1fr;
  }

  .response-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    padding: 10px;
  }

  .row-actions {
    justify-content: flex-start;
  }

  #adminEventList .response-row {
    grid-template-columns: 1fr;
  }

  #adminEventList .row-actions {
    width: 100%;
  }

  #adminEventList .compact-button {
    flex: 1 1 96px;
  }

  #peopleList .response-row {
    grid-template-columns: 1fr;
  }

  #peopleList .row-actions {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  #peopleList .status-text {
    display: block;
    width: 100%;
    overflow-wrap: anywhere;
  }

  .tabs {
    gap: 6px;
    padding: 8px;
  }

  .tab {
    min-height: 44px;
    padding: 0 8px;
    font-size: 0.9rem;
  }

  .stat-button {
    min-height: 86px;
    padding: 10px;
  }

  .app-footer {
    grid-template-columns: 1fr;
  }
}
