:root {
  color-scheme: light;
  --bg: #edf3f0;
  --panel: #ffffff;
  --ink: #162523;
  --muted: #65736f;
  --line: #d7e0dc;
  --primary: #256f75;
  --primary-strong: #15575d;
  --accent: #b65b35;
  --danger: #a43636;
  --soft: #e4efec;
  --shadow: 0 18px 45px rgba(24, 54, 50, 0.12);
}

* {
  box-sizing: border-box;
}

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

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

.app-shell,
.login-shell {
  width: min(100%, 920px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px;
}

.login-shell {
  display: grid;
  align-items: center;
}

.login-form {
  display: grid;
  gap: 14px;
  width: min(100%, 440px);
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 18px;
}

.login-message {
  min-height: 1.25rem;
  margin: 0;
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 750;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 2px 18px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2rem, 10vw, 3.8rem);
  line-height: 0.95;
}

h2 {
  font-size: 1.35rem;
}

h3 {
  font-size: 1.05rem;
}

.status-pill {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.75);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  padding: 8px 12px;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  padding: 5px;
}

.tab-button {
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.tab-button.active {
  background: var(--panel);
  color: var(--primary-strong);
  box-shadow: 0 8px 20px rgba(31, 76, 72, 0.1);
}

.screen {
  display: none;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 16px;
}

.screen.active {
  display: block;
}

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

.button-row,
.row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.report-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

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

.admin-panel {
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
  padding: 14px;
}

.field {
  display: grid;
  gap: 7px;
}

.field span {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.field-hint {
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 750;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
  color: var(--ink);
  min-height: 48px;
  padding: 11px 12px;
  outline: none;
}

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

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 111, 117, 0.18);
}

.inline-row {
  display: flex;
  align-items: end;
  gap: 10px;
}

.grow {
  flex: 1;
}

.primary-button,
.secondary-button,
.ghost-button,
.text-button,
.icon-button {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 850;
}

.primary-button {
  min-height: 50px;
  background: var(--primary);
  color: #fff;
  padding: 0 18px;
}

.primary-button:active,
.secondary-button:active,
.ghost-button:active,
.icon-button:active {
  transform: translateY(1px);
}

.primary-button.compact {
  min-height: 42px;
  white-space: nowrap;
}

.secondary-button {
  width: 52px;
  height: 48px;
  background: var(--accent);
  color: #fff;
  font-size: 1.4rem;
}

.ghost-button {
  min-height: 38px;
  border: 1px solid var(--line);
  background: #fbfdfc;
  color: var(--primary-strong);
  padding: 0 13px;
}

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

.field-action {
  min-height: 48px;
  align-self: end;
}

.text-button {
  min-height: 36px;
  background: #e7f2ef;
  color: var(--primary-strong);
  padding: 0 10px;
}

.month-nav {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
  padding: 8px;
}

.month-nav strong {
  min-width: 0;
  color: var(--primary-strong);
  font-size: 1.1rem;
  text-align: center;
}

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

.summary-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
  padding: 12px;
}

.summary-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.summary-grid strong {
  display: block;
  margin-top: 6px;
  font-size: 1.45rem;
}

.table-wrap {
  position: relative;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 1120px;
  border-collapse: collapse;
  background: #fff;
}

.admin-table-wrap table {
  min-width: 560px;
}

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

th {
  position: sticky;
  top: 0;
  background: #eef6f4;
  color: #35504b;
  font-size: 0.76rem;
  text-transform: uppercase;
}

td[data-cell="startLocation"],
td[data-cell="destination"],
td[data-cell="notes"] {
  max-width: 220px;
  white-space: normal;
}

tr.invalid-distance td {
  background: #fff2f2;
}

.icon-button {
  width: 36px;
  height: 36px;
  background: #f5dddd;
  color: var(--danger);
  font-size: 1.2rem;
}

.empty-state {
  display: none;
  margin: 0;
  padding: 24px;
  color: var(--muted);
  font-weight: 750;
}

.empty-state.visible {
  display: block;
}

.export-dialog {
  width: min(92vw, 520px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--shadow);
  padding: 0;
}

.export-dialog::backdrop {
  background: rgba(22, 37, 35, 0.38);
}

.export-form {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.dialog-heading,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.period-fieldset {
  border: 0;
  margin: 0;
  padding: 0;
}

.period-fieldset legend {
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  padding: 5px;
}

.segmented-control label {
  min-width: 0;
}

.segmented-control input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented-control span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border-radius: 6px;
  color: var(--muted);
  font-weight: 850;
  text-align: center;
}

.segmented-control input:checked + span {
  background: var(--panel);
  color: var(--primary-strong);
  box-shadow: 0 8px 20px rgba(31, 76, 72, 0.1);
}

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

@media (max-width: 620px) {
  .app-shell {
    padding: 12px;
  }

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

  .status-pill {
    flex: 1;
    text-align: center;
  }

  .topbar-actions {
    width: 100%;
  }

  .screen {
    padding: 14px;
  }

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

  .button-row,
  .section-heading .primary-button {
    width: 100%;
  }

  .button-row > button {
    flex: 1;
  }

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

  .month-nav {
    grid-template-columns: 1fr;
  }

  .dialog-heading,
  .dialog-actions,
  .range-grid {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }
}

@media print {
  body {
    background: #fff;
  }

  .topbar,
  .tabs,
  #entryScreen,
  .section-heading button,
  .icon-button {
    display: none !important;
  }

  .app-shell,
  .screen {
    width: 100%;
    min-height: auto;
    padding: 0;
    border: 0;
    box-shadow: none;
  }

  #reportScreen {
    display: block;
  }

  .table-wrap {
    overflow: visible;
    border: 0;
  }
}
