:root {
  color-scheme: light;
  --bg: #f4f0e7;
  --surface: #ffffff;
  --surface-soft: #e9f3ef;
  --text: #18211f;
  --muted: #66706d;
  --primary: #22635d;
  --primary-dark: #184844;
  --accent: #c77c3f;
  --danger: #a33d3d;
  --line: #dbe3de;
  --shadow: 0 18px 42px rgba(24, 33, 31, 0.1);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(135deg, rgba(34, 99, 93, 0.11), transparent 34rem),
    var(--bg);
}

a {
  color: inherit;
  text-decoration: none;
}

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

button {
  cursor: pointer;
}

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

.app-shell {
  display: grid;
  min-height: 100vh;
}

.sidebar {
  display: none;
}

.main-content {
  width: min(100%, 1160px);
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px calc(94px + env(safe-area-inset-bottom));
}

.topbar,
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  margin-bottom: 18px;
}

.topbar h1,
.section-heading h2,
.summary-card strong,
.trip-main h3 {
  margin: 0;
  line-height: 1.1;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: clamp(2rem, 1.7rem + 1.4vw, 3.1rem);
}

.section-heading {
  margin: 26px 0 14px;
}

.section-heading h2 {
  font-size: clamp(1.35rem, 1.2rem + 0.7vw, 2rem);
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sync-pill {
  flex: 0 0 auto;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--primary-dark);
  background: rgba(255, 255, 255, 0.82);
  font-size: 0.85rem;
  font-weight: 800;
  box-shadow: 0 8px 20px rgba(24, 33, 31, 0.06);
}

.sync-pill.ok {
  border-color: rgba(34, 99, 93, 0.24);
  color: var(--primary-dark);
  background: rgba(233, 243, 239, 0.92);
}

.sync-pill.syncing {
  border-color: rgba(199, 124, 63, 0.28);
  color: #7a4a22;
  background: rgba(199, 124, 63, 0.12);
}

.sync-pill.error {
  border-color: rgba(163, 61, 61, 0.36);
  color: #ffffff;
  background: var(--danger);
}

.sync-pill.offline {
  border-color: rgba(102, 112, 109, 0.28);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.92);
}

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

.summary-card {
  display: grid;
  gap: 6px;
  min-height: 96px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 10px 26px rgba(24, 33, 31, 0.06);
}

.summary-card span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

.summary-card strong {
  align-self: end;
  font-size: clamp(1.25rem, 1rem + 1vw, 2rem);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.panel,
.trip-card,
.vehicle-item,
.empty-state {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.entry-form,
.edit-trip-form,
.vehicle-form,
.admin-form,
.legacy-import-form,
.sync-form {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.form-row {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--primary-dark);
  font-size: 0.88rem;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #ffffff;
  outline: none;
}

input,
select {
  min-height: 46px;
  padding: 0 12px;
}

textarea {
  resize: vertical;
  min-height: 88px;
  padding: 12px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(34, 99, 93, 0.15);
}

.toggle-card {
  display: grid;
  gap: 6px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
}

.checkbox-label input {
  width: 20px;
  min-height: 20px;
  accent-color: var(--primary);
}

.toggle-card small {
  color: var(--muted);
  line-height: 1.45;
}

.subsection-title {
  color: var(--primary-dark);
  font-size: 0.9rem;
  font-weight: 900;
}

.arrival-fields,
.return-fields {
  display: grid;
  gap: 14px;
}

.arrival-fields[hidden],
.return-fields[hidden] {
  display: none;
}

.calculated-distance {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.calculated-distance span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.calculated-distance strong {
  color: var(--primary-dark);
  font-size: 1.05rem;
}

.calculated-distance.total {
  background: var(--surface-soft);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.primary-button,
.secondary-button,
.danger-button {
  min-height: 44px;
  padding: 0 16px;
  border-radius: 8px;
  font-weight: 850;
}

.primary-button {
  border: 1px solid var(--primary);
  color: #ffffff;
  background: var(--primary);
}

.primary-button:hover {
  background: var(--primary-dark);
}

.secondary-button {
  border: 1px solid var(--line);
  color: var(--primary-dark);
  background: #ffffff;
}

.danger-button {
  border: 1px solid rgba(163, 61, 61, 0.22);
  color: var(--danger);
  background: rgba(163, 61, 61, 0.08);
}

.trip-list,
.vehicle-list,
.admin-list {
  display: grid;
  gap: 12px;
}

.combine-panel {
  display: grid;
  gap: 14px;
  margin-bottom: 14px;
  padding: 18px;
}

.day-filter {
  display: grid;
  gap: 14px;
  margin-bottom: 14px;
  padding: 18px;
}

.day-filter-controls {
  display: grid;
  grid-template-columns: auto minmax(160px, 1fr) auto auto;
  gap: 10px;
  align-items: end;
}

.icon-button {
  width: 46px;
  min-width: 46px;
  padding: 0;
}

.day-chip-list {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: thin;
}

.day-chip {
  display: grid;
  flex: 0 0 auto;
  gap: 2px;
  min-width: 118px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--primary-dark);
  background: #ffffff;
  text-align: left;
}

.day-chip.active {
  border-color: rgba(34, 99, 93, 0.46);
  color: #ffffff;
  background: var(--primary);
}

.day-chip strong,
.day-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.day-chip strong {
  font-size: 0.9rem;
}

.day-chip span {
  color: inherit;
  font-size: 0.75rem;
  opacity: 0.78;
}

.mini-calendar {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(233, 243, 239, 0.46);
}

.calendar-title {
  color: var(--primary-dark);
  font-weight: 900;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.calendar-weekday,
.calendar-day {
  display: grid;
  min-height: 36px;
  border-radius: 8px;
  place-items: center;
}

.calendar-weekday {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.calendar-day {
  border: 1px solid transparent;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.72);
  font-weight: 750;
}

.calendar-day.has-data {
  border-color: rgba(34, 99, 93, 0.36);
  color: var(--primary-dark);
  background: #ffffff;
  font-weight: 950;
  box-shadow: inset 0 -3px 0 var(--primary);
}

.calendar-day.has-open {
  border-color: rgba(199, 124, 63, 0.48);
  color: #6f3f17;
  background: rgba(199, 124, 63, 0.18);
  box-shadow: inset 0 -3px 0 var(--accent);
}

.calendar-day.active {
  border-color: var(--primary);
  color: #ffffff;
  background: var(--primary);
  box-shadow: none;
}

.calendar-day.empty {
  background: transparent;
}

.day-filter-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-weight: 800;
}

.edit-trip-form {
  margin-bottom: 14px;
}

.edit-trip-form[hidden] {
  display: none;
}

.compact-heading {
  margin: 0;
}

.compact-heading h2 {
  font-size: 1.2rem;
}

.trip-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 14px;
  padding: 16px;
}

.combined-card {
  grid-template-columns: minmax(0, 1fr);
}

.gap-card {
  border-color: rgba(199, 124, 63, 0.42);
  background: rgba(199, 124, 63, 0.12);
}

.gap-card h3 {
  color: #6f3f17;
}

.gap-detail {
  display: grid;
  gap: 8px;
}

.gap-detail div {
  display: grid;
  gap: 3px;
  padding: 10px;
  border: 1px solid rgba(199, 124, 63, 0.2);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.gap-detail span {
  color: #6f3f17;
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.gap-detail strong,
.gap-detail small {
  overflow-wrap: anywhere;
}

.gap-detail small {
  color: var(--muted);
  line-height: 1.4;
}

.gap-checks {
  display: grid;
  gap: 5px;
  padding: 10px;
  border: 1px solid rgba(199, 124, 63, 0.28);
  border-radius: 8px;
  color: #6f3f17;
  background: rgba(199, 124, 63, 0.1);
  font-weight: 800;
  line-height: 1.35;
}

.gap-checks.ok {
  border-color: rgba(34, 99, 93, 0.24);
  color: var(--primary-dark);
  background: rgba(233, 243, 239, 0.82);
}

.gap-checks.has-errors {
  border-color: rgba(163, 61, 61, 0.32);
  color: var(--danger);
  background: rgba(163, 61, 61, 0.08);
}

.compact-danger {
  justify-self: start;
  min-height: 34px;
  margin-top: 6px;
  padding: 7px 10px;
  font-size: 0.78rem;
}

.trip-select {
  display: grid;
  width: 28px;
  padding-top: 2px;
  place-items: start center;
}

.trip-select input {
  width: 20px;
  min-height: 20px;
  accent-color: var(--primary);
}

.trip-main {
  display: grid;
  gap: 7px;
}

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

.combined-trip-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  line-height: 1.45;
}

.combined-trip-row span {
  overflow-wrap: anywhere;
}

.trip-main h3 {
  font-size: 1.05rem;
}

.trip-meta,
.trip-note,
.empty-state {
  color: var(--muted);
  line-height: 1.5;
}

.trip-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.88rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  border-radius: 999px;
  color: var(--primary-dark);
  background: var(--surface-soft);
  font-size: 0.8rem;
  font-weight: 800;
}

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

.vehicle-form,
.admin-form {
  grid-template-columns: 1fr;
  margin-bottom: 14px;
}

.admin-grid {
  display: grid;
  gap: 18px;
}

.admin-panel {
  display: grid;
  gap: 12px;
}

.admin-panel h3 {
  margin: 0;
  color: var(--primary-dark);
  font-size: 1.05rem;
}

.sync-form {
  margin-bottom: 14px;
}

.sync-details {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.sync-details div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sync-details span {
  color: var(--muted);
  font-weight: 800;
}

.sync-details strong {
  text-align: right;
}

.vehicle-item,
.admin-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
}

.vehicle-item strong,
.admin-item strong {
  overflow-wrap: anywhere;
}

.empty-state {
  padding: 20px;
  text-align: center;
}

.compact-empty {
  flex: 1 0 100%;
  padding: 12px;
  box-shadow: none;
}

.bottom-nav {
  position: fixed;
  right: 16px;
  bottom: max(16px, env(safe-area-inset-bottom));
  left: 16px;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  max-width: 420px;
  margin: 0 auto;
  padding: 8px;
  border: 1px solid rgba(219, 227, 222, 0.88);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 18px 40px rgba(24, 33, 31, 0.18);
  backdrop-filter: blur(16px);
}

.bottom-nav a {
  display: grid;
  height: 48px;
  place-items: center;
  border-radius: 999px;
  color: var(--muted);
  font-size: 1.15rem;
  font-weight: 900;
}

.bottom-nav a.active {
  color: #ffffff;
  background: var(--primary);
}

.toast {
  position: fixed;
  right: 16px;
  bottom: calc(92px + env(safe-area-inset-bottom));
  left: 16px;
  z-index: 20;
  max-width: 460px;
  margin: 0 auto;
  padding: 14px 16px;
  border: 1px solid rgba(34, 99, 93, 0.24);
  border-radius: 8px;
  color: #ffffff;
  background: var(--primary-dark);
  box-shadow: 0 18px 42px rgba(24, 33, 31, 0.22);
  font-weight: 850;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  border-color: rgba(163, 61, 61, 0.36);
  background: var(--danger);
}

.toast.syncing {
  color: #7a4a22;
  background: #f7eadc;
}

@media (min-width: 760px) {
  .app-shell {
    grid-template-columns: 240px minmax(0, 1fr);
  }

  .sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    gap: 32px;
    height: 100vh;
    padding: 28px 18px;
    border-right: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(18px);
  }

  .brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 850;
  }

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

  .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 44px;
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--muted);
    font-weight: 750;
  }

  .nav-link.active,
  .nav-link:hover {
    color: var(--primary-dark);
    background: var(--surface-soft);
  }

  .nav-icon {
    display: grid;
    width: 26px;
    height: 26px;
    place-items: center;
  }

  .main-content {
    padding: 34px clamp(24px, 4vw, 56px) 56px;
  }

  .summary-grid {
    gap: 16px;
  }

  .entry-form,
  .edit-trip-form,
  .vehicle-form,
  .admin-form,
  .legacy-import-form,
  .sync-form {
    padding: 22px;
  }

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

  .vehicle-form,
  .admin-form {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
  }

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

  .admin-panel:first-child {
    grid-column: span 2;
  }

  .import-panel {
    grid-column: span 2;
  }

  .trip-card {
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: start;
  }

  .combined-card {
    grid-template-columns: minmax(0, 1fr);
  }

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

  .bottom-nav {
    display: none;
  }

  .toast {
    right: 28px;
    bottom: 28px;
    left: auto;
    margin: 0;
  }
}

@media (max-width: 759px) {
  .import-panel {
    display: none;
  }
}

@media (max-width: 460px) {
  .day-filter-controls {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  #todayFilter {
    grid-column: 1 / -1;
  }

  .day-filter-info {
    align-items: stretch;
    flex-direction: column;
  }

  .summary-card {
    padding: 13px;
  }

  .summary-card span {
    font-size: 0.74rem;
  }

  .form-actions .primary-button,
  .form-actions .secondary-button,
  .section-heading .secondary-button {
    width: 100%;
  }
}
