:root {
  --bg: #f6f8f5;
  --panel: #ffffff;
  --ink: #111315;
  --muted: #65706c;
  --line: #dbe2dc;
  --brand: #008b49;
  --brand-dark: #006f3c;
  --accent: #e5a800;
  --blue: #0b59a3;
  --danger: #d90f16;
  --ok: #008b49;
  --shadow: 0 10px 25px rgba(17, 19, 21, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.45;
}

a {
  color: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 12px 20px;
  background: #0f1112;
  color: #fff;
  box-shadow: var(--shadow);
}

.brand {
  flex: 0 0 auto;
  font-weight: 800;
  text-decoration: none;
  font-size: 20px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.brand img {
  width: 36px;
  height: 36px;
  object-fit: contain;
  border-radius: 6px;
  background: #fff;
}

.topbar nav {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.group-switcher {
  flex: 0 0 220px;
  display: block;
}

.group-switcher select {
  min-height: 36px;
  padding: 6px 8px;
  border-color: rgba(255, 255, 255, 0.25);
  background: #fff;
  font-size: 14px;
}

.topbar nav a {
  flex: 0 0 auto;
  padding: 8px 10px;
  border-radius: 6px;
  text-decoration: none;
  color: rgba(255, 255, 255, 0.88);
  font-size: 14px;
}

.topbar nav a:hover {
  background: rgba(255, 255, 255, 0.12);
}

.shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 22px 0 44px;
}

.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    linear-gradient(135deg, rgba(0, 139, 73, 0.10), rgba(229, 168, 0, 0.08)),
    var(--bg);
}

.auth-panel {
  width: min(430px, 100%);
  border-top: 5px solid var(--brand);
}

.auth-logo {
  display: block;
  width: min(260px, 88%);
  height: auto;
  margin: 0 auto 12px;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

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

h1 {
  font-size: 30px;
}

h2 {
  font-size: 20px;
}

.muted {
  color: var(--muted);
  margin: 0 0 14px;
}

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

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

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

.trip-grid {
  grid-template-columns: minmax(320px, 430px) minmax(0, 1fr);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metrics div {
  background: #fff;
  border: 1px solid var(--line);
  border-left: 5px solid var(--brand);
  border-radius: 8px;
  padding: 16px;
}

.metrics span {
  display: block;
  font-size: 24px;
  font-weight: 800;
}

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

form {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  font-weight: 700;
  font-size: 14px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid #c6d0d7;
  border-radius: 6px;
  padding: 9px 10px;
  font: inherit;
  background: #fff;
  color: var(--ink);
}

textarea {
  resize: vertical;
}

button,
.button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  padding: 10px 14px;
  background: var(--brand);
  color: #fff;
  font-weight: 800;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

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

button:disabled {
  background: #aab5bc;
  cursor: not-allowed;
}

.secondary {
  background: #e8eef0;
  color: var(--ink);
}

.secondary:hover {
  background: #d9e3e7;
}

.danger {
  background: var(--danger);
}

.danger:hover {
  background: #a90d12;
}

.small-button {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 13px;
}

.inline {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 10px;
}

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

.compact-filter {
  align-self: start;
}

.compact-filter h2 {
  margin-bottom: 4px;
}

.distance-button {
  white-space: nowrap;
}

.address-field {
  position: relative;
}

.address-results {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  z-index: 20;
  display: none;
  max-height: 240px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: var(--shadow);
}

.address-results.is-open {
  display: block;
}

.address-option {
  width: 100%;
  min-height: 0;
  justify-content: flex-start;
  padding: 10px;
  border-radius: 0;
  background: #fff;
  color: var(--ink);
  text-align: left;
  font-weight: 600;
}

.address-option:hover {
  background: #edf7f2;
  color: var(--brand-dark);
}

.route-map {
  height: 280px;
  min-height: 280px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef3f1;
  overflow: hidden;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

.check input {
  width: 18px;
  min-height: 18px;
}

fieldset {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

legend {
  font-weight: 800;
  padding: 0 6px;
}

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

.cost-preview {
  background: #f7fbfa;
  border: 1px solid #abd8c2;
  border-radius: 8px;
  color: var(--brand-dark);
  padding: 12px;
  font-weight: 800;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 620px;
}

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

.route-cell {
  max-width: 360px;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.3;
}

th {
  color: #33414f;
  background: #f6f8f9;
  font-size: 13px;
}

tfoot th {
  background: #edf5f3;
}

.filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: end;
  margin-bottom: 18px;
}

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

.admin-section {
  margin-bottom: 18px;
  scroll-margin-top: 92px;
}

.rights-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(110px, 1fr));
  gap: 8px;
  min-width: 430px;
}

.password-form {
  display: grid;
  gap: 8px;
  min-width: 220px;
}

.tabs {
  position: sticky;
  top: 72px;
  z-index: 8;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin-bottom: 14px;
  padding: 8px;
  background: rgba(246, 248, 245, 0.94);
  border: 1px solid var(--line);
  border-radius: 8px;
  backdrop-filter: blur(8px);
}

.tabs a {
  flex: 0 0 auto;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border-radius: 6px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
}

.tabs a:hover {
  border-color: var(--brand);
  color: var(--brand-dark);
}

.admin-scroll {
  max-height: 420px;
  overflow: auto;
}

.admin-scroll.tall {
  max-height: 560px;
}

.admin-scroll thead th {
  position: sticky;
  top: 0;
  z-index: 2;
}

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

.messages {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.message {
  border-radius: 8px;
  padding: 10px 12px;
  background: #eef5ff;
  border: 1px solid #cfe0f7;
}

.message.error {
  color: var(--danger);
  background: #fff2f0;
  border-color: #ffd0cb;
}

.message.success {
  color: var(--ok);
  background: #eef9f1;
  border-color: #cdebd5;
}

.empty {
  color: var(--muted);
  margin: 0;
}

.table-wrap form {
  display: inline-grid;
}

@media (max-width: 820px) {
  .topbar {
    display: block;
    padding: 10px 14px;
  }

  .brand {
    display: block;
    margin-bottom: 8px;
  }

  .group-switcher {
    margin-bottom: 8px;
    width: 100%;
  }

  .shell {
    width: min(100% - 18px, 1180px);
    padding-top: 16px;
  }

  .page-head {
    display: grid;
  }

  .metrics,
  .two,
  .trip-grid,
  .filters,
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 14px;
  }

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

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

  .rights-form {
    grid-template-columns: 1fr;
    min-width: 280px;
  }

  .tabs {
    top: 96px;
  }
}
