:root {
  color-scheme: light;
  --bg: #f2f1ef;
  --surface: #ffffff;
  --surface-soft: #f8f8f8;
  --text: #151820;
  --muted: #747985;
  --line: #e5e1df;
  --red: #e02f32;
  --red-dark: #c82127;
  --red-soft: #fff0f0;
  --green: #4a8f31;
  --green-soft: #eaf6df;
  --amber: #a46c17;
  --shadow: 0 20px 50px rgba(29, 31, 36, 0.12);
  --small-shadow: 0 10px 26px rgba(29, 31, 36, 0.08);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-width: 320px;
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(242, 241, 239, 0.98)),
    url("/assets/gazel-next-bg.png") center bottom / min(460px, 100vw) auto no-repeat,
    var(--bg);
  color: var(--text);
}

button,
input,
textarea {
  font: inherit;
}

.app {
  width: min(1040px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0;
}

.driver-app {
  width: 100%;
  max-width: 430px;
  min-height: 100dvh;
  padding: 18px 12px 72px;
}

.driver-app *,
.query,
.field,
.metric,
.total-card,
.result {
  min-width: 0;
}

.driver-app::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72) 0%, rgba(242, 241, 239, 0.84) 48%, rgba(242, 241, 239, 0.2) 100%),
    linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.82), rgba(255, 255, 255, 0)),
    repeating-linear-gradient(90deg, rgba(21, 24, 32, 0.03) 0 1px, transparent 1px 42px);
}

.driver-app::after {
  content: "";
  position: fixed;
  left: 50%;
  bottom: 2px;
  z-index: 2;
  width: min(430px, 100vw);
  height: 370px;
  pointer-events: none;
  background: url("/assets/gazel-next-bg.png") center bottom / cover no-repeat;
  filter: grayscale(1);
  opacity: 0.11;
  transform: translateX(-50%);
  mix-blend-mode: multiply;
}

.driver-app > * {
  position: relative;
  z-index: 1;
}

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

.mobile-topbar {
  margin-bottom: 16px;
}

.brand {
  display: inline-flex;
  align-items: baseline;
  color: var(--text);
  text-decoration: none;
  font-size: 28px;
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1;
}

.brand span {
  color: var(--red);
}

.eyebrow {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.hero-copy {
  margin-bottom: 16px;
}

h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 850;
  letter-spacing: 0;
}

.hero-copy p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.status-pill {
  min-width: 74px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
  background: rgba(255, 255, 255, 0.76);
  color: var(--muted);
  text-align: center;
  font-size: 12px;
  font-weight: 800;
  box-shadow: var(--small-shadow);
}

.status-pill[data-tone="busy"] {
  color: var(--red-dark);
}

.status-pill[data-tone="ok"] {
  color: var(--green);
}

.status-pill[data-tone="warn"] {
  color: var(--amber);
}

.status-pill[data-tone="error"] {
  color: var(--red-dark);
}

.layout {
  display: grid;
  grid-template-columns: 390px 1fr;
  gap: 18px;
  align-items: start;
}

.driver-app .layout {
  display: block;
}

.panel,
.query,
.result {
  border: 1px solid rgba(21, 24, 32, 0.08);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--small-shadow);
}

.query {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 14px;
}

.driver-app .query {
  margin-bottom: 12px;
}

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

.driver-app .field:first-child {
  grid-column: 1 / -1;
}

.field-wide,
.advanced {
  grid-column: 1 / -1;
}

.field span,
.advanced summary {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.advanced summary {
  cursor: pointer;
  margin-bottom: 12px;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 10px 12px;
  background: #fff;
  color: var(--text);
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

input {
  min-height: 44px;
}

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

input:focus,
textarea:focus {
  border-color: rgba(224, 47, 50, 0.72);
  box-shadow: 0 0 0 4px rgba(224, 47, 50, 0.1);
}

.primary {
  grid-column: 1 / -1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  border: 0;
  border-radius: 13px;
  background: var(--red);
  color: #fff;
  cursor: pointer;
  font-weight: 850;
  box-shadow: 0 12px 24px rgba(224, 47, 50, 0.22);
}

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

.button-icon {
  font-size: 20px;
  line-height: 1;
}

.result {
  padding: 0;
  overflow: hidden;
}

.total-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: 12px;
  border-radius: 17px;
  padding: 18px;
  background: linear-gradient(145deg, var(--red), var(--red-dark));
  color: #fff;
  box-shadow: 0 16px 32px rgba(224, 47, 50, 0.24);
}

.total-card span {
  display: block;
  margin: 0;
  color: rgba(255, 255, 255, 0.86);
  font-size: 13px;
  font-weight: 700;
}

.total-card strong {
  display: block;
  margin-top: 6px;
  font-size: 38px;
  font-weight: 900;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.total-icon {
  flex: 0 0 auto;
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.44);
  border-radius: 15px;
}

.total-icon svg {
  width: 30px;
  height: 30px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

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

.metric {
  min-height: 102px;
  border: 1px solid rgba(21, 24, 32, 0.08);
  border-radius: 14px;
  padding: 13px;
  background: var(--surface);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.metric span {
  display: block;
  min-height: 32px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.metric strong {
  display: block;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 28px;
  font-weight: 900;
  letter-spacing: 0;
}

.details {
  min-height: 120px;
  border-top: 1px solid rgba(21, 24, 32, 0.08);
  padding: 12px;
  background: rgba(248, 248, 248, 0.76);
  backdrop-filter: blur(10px);
}

.details-top {
  margin-top: 0;
  border-top: 0;
  padding-top: 0;
}

.empty {
  margin: 0;
  border-radius: 14px;
  padding: 16px;
  background: var(--surface);
  color: var(--muted);
  font-weight: 700;
}

.detail-list {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
  border-radius: 16px;
  padding: 14px;
  background: var(--surface);
}

.detail-list p {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin: 0;
  border-bottom: 1px solid #efedeb;
  padding-bottom: 8px;
}

.detail-list p:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.detail-list span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.detail-list b {
  overflow-wrap: anywhere;
  text-align: right;
}

.warning {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  border: 1px solid #f0d29a;
  border-radius: 14px;
  padding: 12px;
  background: #fff8ec;
  color: #68460d;
}

.warning p {
  margin: 0;
  line-height: 1.45;
}

.diagnostic-note {
  color: #765115;
  font-size: 13px;
  font-weight: 800;
}

.key-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.key-list span,
code {
  border: 1px solid rgba(104, 70, 13, 0.16);
  border-radius: 8px;
  padding: 4px 7px;
  background: rgba(255, 255, 255, 0.72);
  color: #352509;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.success {
  margin-bottom: 14px;
  border: 1px solid rgba(74, 143, 49, 0.25);
  border-radius: 14px;
  padding: 12px;
  background: var(--green-soft);
  color: var(--green);
  font-weight: 850;
}

.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  background: var(--surface);
  color: var(--red-dark);
  text-decoration: none;
  font-size: 14px;
  font-weight: 850;
  box-shadow: var(--small-shadow);
}

button.link-button {
  cursor: pointer;
}

.detail-list a {
  color: var(--red-dark);
  text-decoration: none;
}

.secondary-action {
  grid-column: 1 / -1;
  min-height: 46px;
  box-shadow: none;
}

.admin-layout {
  grid-template-columns: 460px 1fr;
}

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

pre {
  overflow: auto;
  max-height: 240px;
  margin: 0;
  white-space: pre-wrap;
}

.vehicles {
  margin: 14px 0 0;
  padding-left: 20px;
  color: var(--muted);
}

.pvz-summary {
  margin-top: 12px;
}

.pvz-summary h2 {
  margin: 0 0 10px;
  font-size: 17px;
  font-weight: 900;
  letter-spacing: 0;
}

.table-wrap {
  overflow: visible;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 10px;
}

thead {
  display: none;
}

tr {
  display: grid;
  gap: 8px;
  border: 1px solid rgba(21, 24, 32, 0.08);
  border-radius: 16px;
  padding: 12px;
  background: var(--surface);
}

td {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid #efedeb;
  padding: 0 0 8px;
  color: var(--text);
  font-weight: 850;
  text-align: right;
}

td::before {
  content: attr(data-label);
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-align: left;
}

td:first-child {
  display: block;
  text-align: left;
}

td:first-child::before {
  display: block;
  margin-bottom: 4px;
}

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

@media (min-width: 860px) {
  .driver-app {
    padding-top: 28px;
  }

  .driver-app .layout {
    display: block;
  }

  .driver-app .result {
    box-shadow: var(--shadow);
  }
}

@media (min-width: 700px) {
  .app:not(.driver-app) .layout {
    display: grid;
  }

  .app:not(.driver-app) .result-grid {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  }
}

@media (max-width: 420px) {
  .driver-app {
    padding-right: 10px;
    padding-left: 10px;
  }

  .total-card strong {
    font-size: 34px;
  }

  .metric strong {
    font-size: 25px;
  }
}

@media (max-width: 980px) {
  .app:not(.driver-app) .layout,
  .app:not(.driver-app) .result-grid {
    grid-template-columns: 1fr;
  }

  .app:not(.driver-app) .query {
    grid-template-columns: 1fr;
  }

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

  .driver-app .topbar {
    align-items: center;
    flex-direction: row;
  }
}
