:root {
  color-scheme: light;
  --bg: #eef7f0;
  --surface: #ffffff;
  --surface-soft: #f7fbf8;
  --text: #102018;
  --muted: #65736b;
  --line: #d7e4db;
  --primary: #14532d;
  --primary-strong: #0f3d22;
  --primary-soft: #dcf5e5;
  --accent: #0f766e;
  --accent-soft: #d9f4ef;
  --warning: #a16207;
  --warning-soft: #fff2cc;
  --danger: #b42318;
  --danger-soft: #ffe2dd;
  --ok: #166534;
  --ok-soft: #dcfce7;
  --shadow: 0 14px 34px rgba(16, 32, 24, 0.1);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  background:
    linear-gradient(180deg, rgba(20, 83, 45, 0.14), transparent 270px),
    var(--bg);
}

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

button {
  min-height: 48px;
  border: 0;
  border-radius: var(--radius);
  font-weight: 800;
  cursor: pointer;
}

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

input,
select,
textarea {
  width: 100%;
  min-height: 48px;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  background: #ffffff;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

label {
  display: grid;
  gap: 7px;
  font-weight: 800;
}

label span {
  color: var(--muted);
  font-size: 0.84rem;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 1.62rem;
  line-height: 1.12;
}

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

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

.app-shell {
  width: min(100%, 620px);
  margin: 0 auto;
  padding: 12px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0 12px;
  background: rgba(238, 247, 240, 0.94);
  backdrop-filter: blur(10px);
}

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

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 50%;
  color: #ffffff;
  background: var(--primary);
  font-weight: 900;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong,
.brand small,
.status-panel strong,
.ride-title strong {
  overflow-wrap: anywhere;
}

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

.connection-badge,
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 4px 9px;
  border-radius: 999px;
  color: var(--primary);
  background: var(--primary-soft);
  font-size: 0.78rem;
  font-weight: 900;
  white-space: nowrap;
}

.connection-badge.offline,
.badge.danger {
  color: var(--danger);
  background: var(--danger-soft);
}

.badge.warning {
  color: var(--warning);
  background: var(--warning-soft);
}

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

.badge.neutral {
  color: #315348;
  background: #e6eee9;
}

.panel,
.stat-card {
  margin: 12px 0;
  padding: 16px;
  border: 1px solid rgba(215, 228, 219, 0.92);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.status-panel,
.user-main {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.api-health-result {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.api-health-result.ok {
  color: var(--ok);
}

.api-health-result.error {
  color: var(--danger);
}

.api-health-result.checking {
  color: var(--warning);
}

.eyebrow {
  color: var(--primary);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.section-heading {
  display: grid;
  gap: 7px;
  margin-bottom: 16px;
}

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

.hidden {
  display: none !important;
}

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

.wide,
.full-button {
  grid-column: 1 / -1;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 14px;
}

.primary-button {
  color: #ffffff;
  background: var(--primary);
}

.primary-button:active {
  background: var(--primary-strong);
}

.secondary-button {
  color: var(--primary);
  background: var(--primary-soft);
}

.ghost-button {
  min-height: 48px;
  padding: 10px 12px;
  color: var(--primary);
  background: #e9f5ee;
}

.danger-button {
  color: #ffffff;
  background: var(--danger);
}

.notice {
  margin: 12px 0;
  padding: 12px 14px;
  border-radius: var(--radius);
  color: var(--primary);
  background: var(--primary-soft);
  font-weight: 800;
}

.notice.error {
  color: var(--danger);
  background: var(--danger-soft);
}

.notice.warning {
  color: var(--warning);
  background: var(--warning-soft);
}

.app-content {
  display: block;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.stat-card {
  margin: 0;
  padding: 13px;
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.stat-card strong {
  display: block;
  margin-top: 3px;
  font-size: 1.55rem;
  line-height: 1;
}

.card-list {
  display: grid;
  gap: 12px;
}

.ride-card,
.resource-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

.ride-card.is-selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(20, 83, 45, 0.14);
}

.ride-card-header,
.resource-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.ride-title {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.ride-title span,
.resource-card span,
.detail-grid span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.detail-grid strong,
.resource-card strong {
  display: block;
  overflow-wrap: anywhere;
}

.ride-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.ride-actions button {
  min-height: 52px;
}

.assignment-hints {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.assignment-hints div,
.empty-state {
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  background: var(--surface-soft);
  font-weight: 800;
}

.assignment-hints .warning {
  color: var(--warning);
  background: var(--warning-soft);
  border-style: solid;
}

.assignment-hints .ok {
  color: var(--ok);
  background: var(--ok-soft);
  border-style: solid;
}

.referral-raw {
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--primary);
  background: var(--primary-soft);
  font-weight: 800;
  overflow-wrap: anywhere;
}

.compact-list {
  gap: 8px;
}

.resource-card {
  gap: 8px;
  padding: 12px;
}

@media (min-width: 560px) {
  .app-shell {
    padding: 16px;
  }

  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .button-row,
  .ride-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stats-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 900px) {
  .app-shell {
    width: min(100%, 1180px);
  }

  .app-content {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
    gap: 12px;
    align-items: start;
  }

  .user-panel,
  .stats-grid,
  .dispatch-panel {
    grid-column: 1 / -1;
  }
}
