:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #eef2f7;
  --text: #111827;
  --muted: #667085;
  --line: #d9e0ea;
  --primary: #2563eb;
  --primary-strong: #1d4ed8;
  --danger: #dc2626;
  --success: #16803c;
  --shadow: 0 18px 50px rgba(15, 23, 42, 0.12);
}

.dark {
  color-scheme: dark;
  --bg: #0f172a;
  --surface: #182235;
  --surface-2: #223047;
  --text: #f8fafc;
  --muted: #a9b4c5;
  --line: #314158;
  --primary: #60a5fa;
  --primary-strong: #3b82f6;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

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

button,
input,
select {
  font: inherit;
}

a {
  color: inherit;
}

.app-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px 24px;
}

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

.topbar h1,
.install-card h1,
.admin-title h1 {
  margin: 0;
  font-size: 30px;
  letter-spacing: 0;
}

.eyebrow {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.theme-toggle {
  width: 46px;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  cursor: pointer;
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(360px, 0.9fr);
  gap: 16px;
  align-items: start;
}

.map-panel,
.calculator-card,
.result-card,
.all-prices,
.install-card,
.admin-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.map-panel {
  overflow: hidden;
  position: sticky;
  top: 16px;
}

.map {
  height: min(68vh, 720px);
  min-height: 420px;
  background: var(--surface-2);
}

.route-summary {
  padding: 14px 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-weight: 700;
}

.calculator-card {
  padding: 18px;
}

.calculator-card h2,
.all-prices h2,
.admin-card h2 {
  margin: 20px 0 12px;
  font-size: 18px;
}

.field-grid,
.form-stack {
  display: grid;
  gap: 12px;
}

label span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0 13px;
  outline: none;
  font-size: 16px;
}

input:focus,
select:focus {
  border-color: var(--primary);
}

.address-field {
  position: relative;
}

.suggestions {
  position: absolute;
  z-index: 30;
  right: 0;
  left: 0;
  top: 78px;
  overflow: hidden;
  max-height: 320px;
  overflow-y: auto;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.suggestions button,
.suggestion-state {
  display: block;
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  padding: 14px;
  text-align: left;
}

.suggestions button {
  cursor: pointer;
}

.suggestions strong,
.suggestions small {
  display: block;
}

.suggestions strong {
  font-size: 14px;
  line-height: 1.35;
}

.suggestions small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.tariff-list,
.services-list {
  display: grid;
  gap: 10px;
}

.tariff-option,
.service-option {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 10px 12px;
  cursor: pointer;
}

.tariff-option input,
.service-option input {
  width: 20px;
  min-height: 20px;
}

.tariff-option span {
  margin: 0;
  flex: 1;
}

.tariff-option small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.service-option span {
  margin: 0;
  flex: 1;
  color: var(--text);
}

.service-option b {
  white-space: nowrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  padding: 0 18px;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--primary-strong);
}

.btn-secondary {
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.btn-wide {
  width: 100%;
  margin-top: 18px;
}

.alert {
  margin-top: 14px;
  border-radius: 8px;
  padding: 12px;
  font-weight: 700;
}

.alert-error {
  background: rgba(220, 38, 38, 0.12);
  color: var(--danger);
}

.alert-success {
  background: rgba(22, 128, 60, 0.12);
  color: var(--success);
}

.result-card,
.all-prices {
  margin-top: 16px;
  padding: 16px;
  box-shadow: none;
}

.result-price {
  margin: 4px 0 8px;
  font-size: 42px;
  font-weight: 900;
}

.result-card p {
  margin: 0 0 14px;
  color: var(--muted);
  line-height: 1.45;
}

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

.price-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
}

.price-row:last-child {
  border-bottom: 0;
}

.hidden {
  display: none !important;
}

.install-page,
.offline-page,
.admin-login-page {
  display: grid;
  place-items: center;
  padding: 18px;
}

.install-card {
  width: min(520px, 100%);
  padding: 22px;
}

.install-card p {
  color: var(--muted);
  line-height: 1.5;
}

.admin-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 18px 16px 32px;
}

.admin-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0;
}

.admin-nav a {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 11px 13px;
  text-decoration: none;
  font-weight: 800;
}

.admin-card {
  padding: 18px;
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

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

.admin-table th {
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
}

.admin-table input {
  min-width: 100px;
}

.muted-text {
  color: var(--muted);
  line-height: 1.5;
}

.update-form {
  margin-top: 16px;
}

.inline-form {
  display: contents;
}

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

.stat {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 16px;
}

.stat strong {
  display: block;
  margin-top: 6px;
  font-size: 28px;
}

@media (max-width: 860px) {
  .main-grid {
    display: flex;
    flex-direction: column;
  }

  .map-panel {
    position: static;
    width: 100%;
    order: 2;
  }

  .map {
    height: 34vh;
    min-height: 240px;
  }

  .calculator-card {
    width: 100%;
    order: 1;
  }

  .action-row,
  .stats-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .app-shell,
  .admin-shell {
    padding-right: 10px;
    padding-left: 10px;
  }

  .topbar h1,
  .install-card h1,
  .admin-title h1 {
    font-size: 25px;
  }

  .calculator-card,
  .install-card,
  .admin-card {
    padding: 12px;
  }

  .tariff-option,
  .service-option {
    min-height: 54px;
  }

  .btn {
    min-height: 52px;
  }

  .result-price {
    font-size: 34px;
  }
}
