:root {
  color-scheme: light;
  --navy-950: #071629;
  --navy-900: #0c2038;
  --navy-800: #123454;
  --blue-600: #1d6ed8;
  --blue-500: #2d86ee;
  --teal-500: #27c4a7;
  --green-600: #17945f;
  --gray-100: #f5f8fb;
  --gray-200: #dbe5ee;
  --gray-500: #64748b;
  --white: #ffffff;
  --danger: #c24135;
  --shadow: 0 22px 60px rgba(5, 18, 36, 0.26);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--navy-950);
  background:
    linear-gradient(135deg, rgba(7, 22, 41, 0.95), rgba(18, 52, 84, 0.92)),
    linear-gradient(90deg, #071629, #123454 55%, #0d3b55);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  place-items: center;
  padding: 32px 0;
}

.calculator-panel {
  width: 100%;
  background: var(--white);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.topbar,
.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--teal-500);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.08;
  color: var(--navy-950);
}

h1 {
  font-size: clamp(1.65rem, 4vw, 2.8rem);
}

h2 {
  font-size: 1.35rem;
}

.form-grid,
.admin-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 26px;
}

.field {
  position: relative;
  display: grid;
  gap: 8px;
}

.field.full,
.actions {
  grid-column: 1 / -1;
}

label {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--navy-800);
}

input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 0 14px;
  color: var(--navy-950);
  background: #fbfdff;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

input:focus {
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px rgba(45, 134, 238, 0.18);
  background: var(--white);
}

.inline-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.route-map {
  width: 100%;
  height: 300px;
  margin-top: 8px;
  border: 1px solid #d7e3ee;
  border-radius: 8px;
  overflow: hidden;
  background: #edf4fa;
}

.primary-button,
.ghost-button,
.icon-button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  font-weight: 700;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

.primary-button {
  padding: 0 18px;
  color: var(--white);
  background: var(--blue-600);
}

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

.ghost-button {
  padding: 0 16px;
  color: var(--navy-800);
  background: #eef5fb;
  border: 1px solid #cbd9e6;
}

.ghost-button:hover {
  background: #e4eef8;
}

.icon-button {
  width: 42px;
  color: var(--navy-800);
  background: #eef5fb;
}

button:active {
  transform: translateY(1px);
}

.unit {
  position: absolute;
  right: 12px;
  bottom: 13px;
  color: var(--gray-500);
  font-size: 0.82rem;
  pointer-events: none;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-top: 26px;
}

.metric {
  min-height: 104px;
  display: grid;
  align-content: space-between;
  gap: 14px;
  padding: 18px;
  border-radius: 8px;
  background: var(--gray-100);
  border: 1px solid #e2eaf2;
}

.metric span {
  color: var(--gray-500);
  font-size: 0.84rem;
  font-weight: 700;
}

.metric strong {
  color: var(--navy-950);
  font-size: 1.34rem;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.metric.total {
  background: var(--navy-900);
  border-color: var(--navy-900);
  grid-column: span 2;
}

.metric.total span,
.metric.total strong {
  color: var(--white);
}

.metric.total strong {
  font-size: 1.7rem;
}

.status-line,
.hint {
  color: var(--gray-500);
  font-size: 0.9rem;
}

.status-line {
  margin-top: 18px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #eef5fb;
}

.status-line.success {
  color: #0b6842;
  background: rgba(39, 196, 167, 0.14);
}

.status-line.error,
.hint.error {
  color: var(--danger);
}

.hint {
  margin: 0;
}

.admin-modal {
  width: min(620px, calc(100% - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

.admin-modal::backdrop {
  background: rgba(7, 22, 41, 0.62);
}

.modal-body {
  padding: 24px;
}

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

.hidden {
  display: none !important;
}

@media (max-width: 860px) {
  .results-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding: 10px 0;
    place-items: start center;
  }

  .calculator-panel {
    padding: 18px;
  }

  .topbar,
  .modal-header {
    align-items: stretch;
    flex-direction: column;
  }

  .form-grid,
  .admin-form,
  .inline-field,
  .results-grid {
    grid-template-columns: 1fr;
  }

  .route-map {
    height: 240px;
  }

  .metric.total {
    grid-column: auto;
  }

  .primary-button,
  .ghost-button {
    width: 100%;
  }
}
