:root {
  --ink: #111b18;
  --muted: #61716a;
  --line: #d6e0dc;
  --panel: #ffffff;
  --soft: #eef6f3;
  --blue: #176b8f;
  --blue-dark: #0e4b63;
  --green: #73c991;
  --green-strong: #07a957;
  --yellow: #f4c542;
  --red: #d83434;
  --cream: #fffaf0;
  --shadow: 0 16px 48px rgba(13, 37, 31, 0.08);
  --shadow-soft: 0 8px 24px rgba(13, 37, 31, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(140deg, rgba(23, 107, 143, 0.08), transparent 38%),
    linear-gradient(180deg, #f7faf9, #eef4f1);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

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

button {
  border: 1px solid var(--blue-dark);
  background: var(--blue);
  color: #fff;
  border-radius: 7px;
  padding: 9px 12px;
  cursor: pointer;
  font-weight: 800;
  font-size: 14px;
  box-shadow: 0 8px 18px rgba(23, 107, 143, 0.16);
  transition: transform 0.14s ease, box-shadow 0.14s ease, background 0.14s ease, border-color 0.14s ease;
}

button.secondary {
  background: #fff;
  color: var(--blue-dark);
  box-shadow: none;
}

button.ghost {
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
  box-shadow: none;
}

button.danger {
  border-color: #9f1f1f;
  background: #c92a2a;
  color: #fff;
}

button.compact {
  padding: 6px 8px;
  font-size: 12px;
  white-space: nowrap;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(23, 107, 143, 0.2);
}

button.secondary:hover,
button.ghost:hover {
  border-color: #aebfba;
  background: #f8fbfa;
  box-shadow: 0 8px 18px rgba(13, 37, 31, 0.08);
}

button:active {
  transform: translateY(0);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  transform: none;
  box-shadow: none;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(23, 107, 143, 0.22);
  outline-offset: 2px;
}

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(680px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 32px;
  box-shadow: var(--shadow);
}

.signed-in-email {
  display: grid;
  gap: 4px;
  border: 1px solid #c5d8d1;
  background: #f6fbf8;
  border-radius: 8px;
  padding: 14px 16px;
}

.signed-in-email span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.signed-in-email strong {
  color: var(--ink);
  overflow-wrap: anywhere;
}

.google-login {
  min-height: 44px;
  display: flex;
  align-items: center;
}

.shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: linear-gradient(180deg, #102923, #17382f);
  color: #eef7f3;
  padding: 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  margin: 0 0 20px;
  font-size: 22px;
  letter-spacing: 0;
}

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

.nav button {
  width: 100%;
  text-align: left;
  border-color: transparent;
  background: transparent;
  color: #eaf5f0;
  box-shadow: none;
  padding: 10px 11px;
}

.nav button.active,
.nav button:hover {
  background: rgba(255, 255, 255, 0.12);
  box-shadow: inset 3px 0 0 #80d7a6;
  transform: none;
}

.workspace {
  min-width: 0;
}

.topbar {
  min-height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  padding: 0 22px;
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(10px);
}

.topbar-title strong {
  display: block;
  font-size: 18px;
}

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

.content {
  padding: 22px;
}

.view {
  display: grid;
  gap: 16px;
}

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

.panel h2,
.panel h3 {
  margin: 0 0 12px;
  line-height: 1.15;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

.stat {
  background: linear-gradient(180deg, #fff, #f8fbfa);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  box-shadow: var(--shadow-soft);
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.stat strong {
  display: block;
  margin-top: 8px;
  font-size: 26px;
  line-height: 1;
}

.grid-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.grid-form .wide {
  grid-column: span 2;
}

.grid-form .full {
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 700;
  font-size: 14px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px 11px;
  background: #fff;
  color: var(--ink);
  transition: border-color 0.14s ease, box-shadow 0.14s ease, background 0.14s ease;
}

input:hover,
select:hover,
textarea:hover {
  border-color: #adc0ba;
}

input[type="checkbox"] {
  width: auto;
}

input[readonly] {
  background: #f4f7f5;
  color: var(--muted);
}

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

.hidden,
.city-other.hidden {
  display: none;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

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

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

th {
  background: #e8f2ee;
  color: #1c3f36;
  position: sticky;
  top: 0;
  z-index: 1;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0;
}

tbody tr:hover td {
  background: #f6faf8;
}

tr:last-child td {
  border-bottom: 0;
}

.alert-panel {
  border-color: #efba57;
  background: linear-gradient(180deg, #fff9ea, #fff);
}

.alert-row td {
  background: #fff8e7;
}

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 9px;
  font-weight: 800;
  font-size: 12px;
  white-space: nowrap;
}

.pill.assigned {
  background: #d9eafd;
  color: #134b78;
}

.pill.trip {
  background: #dff3d2;
  color: #22630f;
}

.pill.cancel {
  background: #fee4e2;
  color: #9a1c1c;
}

.pill.waiting {
  background: #fff0bf;
  color: #6b4b00;
}

.pill.done {
  background: #e7e7e7;
  color: #333;
}

.notice {
  padding: 10px 12px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--cream);
  color: var(--muted);
  margin: 0 0 12px;
}

.toast {
  position: fixed;
  right: 22px;
  top: 82px;
  z-index: 20;
  max-width: min(380px, calc(100vw - 32px));
  border-radius: 8px;
  padding: 12px 14px;
  background: #12372f;
  color: #fff;
  box-shadow: 0 18px 48px rgba(13, 37, 31, 0.24);
  font-weight: 800;
}

.toast.error {
  background: #b42318;
}

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

.row-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.quick-update {
  display: flex;
  gap: 6px;
  align-items: center;
}

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

.trip-card,
.return-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #fff, #fbfdfc);
  padding: 14px;
  box-shadow: 0 10px 28px rgba(13, 37, 31, 0.06);
}

.trip-card.status-assigned,
.return-card.status-assigned {
  border-left: 5px solid #6aa5d8;
}

.trip-card.status-trip,
.return-card.status-trip {
  border-left: 5px solid var(--green-strong);
}

.trip-card.status-waiting,
.return-card.status-waiting {
  border-left: 5px solid #e0aa14;
}

.trip-card.status-cancel,
.return-card.status-cancel {
  border-left: 5px solid var(--red);
}

.trip-card.status-done,
.return-card.status-done {
  border-left: 5px solid #8c9692;
}

.return-card {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 12px;
}

.priority-badge {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: var(--blue-dark);
  color: #fff;
  font-weight: 800;
}

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

.trip-card-header h3 {
  margin: 0 0 4px;
}

.trip-card-pills,
.summary-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 10px;
}

.compact-grid {
  grid-template-columns: repeat(4, minmax(120px, 1fr));
}

.detail-grid div {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfefd;
  padding: 9px;
  min-width: 0;
}

.detail-grid span,
.detail-grid small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.detail-grid strong {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.wide-detail {
  grid-column: span 2;
}

.trip-card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 12px;
}

.trip-card-actions .quick-update {
  flex: 1 1 260px;
  min-width: min(100%, 260px);
}

.history-panel {
  border-color: #9ebbd0;
  background: linear-gradient(180deg, #f7fbfd, #fff);
}

.removal-panel {
  border-color: #e49b9b;
  background: linear-gradient(180deg, #fff8f7, #fff);
}

.driver-names-panel {
  border-color: #9fcab4;
  background: linear-gradient(180deg, #f4fbf7, #fff);
}

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

.history-summary {
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
  margin-bottom: 12px;
}

.history-summary h3 {
  margin: 0 0 12px;
  font-size: 28px;
}

.summary-pills {
  justify-content: flex-start;
}

.summary-pills span {
  border-radius: 8px;
  background: #eef1f0;
  color: #4e5a56;
  padding: 7px 10px;
  font-weight: 800;
}

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

.average-target,
.average-swatch {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.average-target {
  background: #f7fbfd;
}

.average-target span,
.average-swatch span {
  display: block;
  font-size: 12px;
  font-weight: 800;
}

.average-target strong,
.average-swatch strong {
  display: block;
  margin-bottom: 5px;
  font-size: 18px;
}

.average-swatch.red {
  background: #db1717;
  border-color: #ad0f0f;
  color: #fff;
}

.average-swatch.yellow {
  background: #ffeb00;
  border-color: #cfbf00;
  color: #1f1c00;
}

.average-swatch.green {
  background: #00cf5d;
  border-color: #009c45;
  color: #041f0e;
}

.average-counts {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.mini-count,
.average-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.mini-count.red,
.average-pill.red {
  background: #db1717;
  color: #fff;
}

.mini-count.yellow,
.average-pill.yellow {
  background: #ffeb00;
  color: #1f1c00;
}

.mini-count.green,
.average-pill.green {
  background: #00cf5d;
  color: #041f0e;
}

.avg-row td {
  font-weight: 700;
}

.avg-row .tiny {
  color: inherit;
  opacity: 0.86;
}

.avg-row.avg-red td {
  background: #d91515;
  border-bottom-color: #ab0d0d;
  color: #fff;
}

.avg-row.avg-yellow td {
  background: #ffe900;
  border-bottom-color: #cab800;
  color: #1f1c00;
}

.avg-row.avg-green td {
  background: #00d967;
  border-bottom-color: #00a64e;
  color: #041f0e;
}

.avg-row.avg-red .average-pill.red {
  background: #fff;
  color: #b10000;
}

.avg-row.avg-yellow .average-pill.yellow {
  background: #1f1c00;
  color: #ffeb00;
}

.avg-row.avg-green .average-pill.green {
  background: #041f0e;
  color: #00f276;
}

.history-list {
  display: grid;
}

.history-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(170px, auto);
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.history-item:last-child {
  border-bottom: 0;
}

.history-item p {
  margin: 6px 0 0;
  color: var(--muted);
}

.history-meta {
  display: grid;
  gap: 4px;
  color: var(--muted);
  text-align: right;
}

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.vendor-sections {
  display: grid;
  gap: 14px;
}

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

.staff-card-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 12px;
}

.staff-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
  padding: 14px;
}

.staff-card.disabled {
  background: #fff8f7;
  border-color: #efb0aa;
}

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

.staff-card-head h3 {
  margin: 0 0 4px;
}

.staff-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
}

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

.driver-card.removed {
  background: #fffdfa;
}

.driver-refund-form {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.vendor-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfdfc;
}

.route-checks {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
}

.route-checks label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-weight: 700;
}

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

.section-title h3 {
  margin: 0;
}

.tiny {
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 980px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .stats,
  .average-summary,
  .grid-form,
  .split,
  .detail-grid,
  .compact-grid,
  .history-item {
    grid-template-columns: 1fr;
  }

  .grid-form .wide,
  .grid-form .full,
  .wide-detail {
    grid-column: auto;
  }

  .return-card {
    grid-template-columns: 1fr;
  }

  .trip-card-header,
  .history-meta {
    text-align: left;
    justify-content: flex-start;
  }
}
