:root {
  color-scheme: light;
  --navy-950: #091b27;
  --navy-900: #102a3a;
  --navy-800: #183b50;
  --green-600: #159947;
  --green-500: #1daf57;
  --green-100: #e7f7ed;
  --blue-500: #1675e0;
  --slate-900: #17212b;
  --slate-700: #43515e;
  --slate-500: #73808b;
  --slate-300: #cfd7de;
  --slate-200: #e4e9ed;
  --slate-100: #f1f4f6;
  --white: #fff;
  --danger: #bb2d3b;
  --shadow: 0 16px 40px rgba(17, 38, 52, 0.09);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; color: var(--slate-900); background: #edf2f4; }
body { min-height: 100vh; }
a { color: inherit; }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.app-shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 26px 18px 20px;
  color: #eef7fa;
  background: linear-gradient(180deg, #0e2939, #091b27 82%);
  box-shadow: 5px 0 30px rgba(8, 27, 39, 0.12);
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; color: white; text-decoration: none; font-size: 15px; font-weight: 800; letter-spacing: .04em; }
.brand img { width: 54px; height: 42px; color: white; }
.sidebar nav { margin-top: 38px; }
.nav-link { display: flex; align-items: center; gap: 11px; min-height: 46px; padding: 0 14px; border-radius: 8px; color: #dce8ed; text-decoration: none; font-size: 14px; }
.nav-link.active { background: #1b455d; color: white; }
.sidebar-user { margin-top: auto; display: grid; grid-template-columns: 34px 1fr; gap: 2px 10px; align-items: center; color: #d6e4e9; font-size: 14px; }
.sidebar-user form { grid-column: 2; }
.avatar { grid-row: 1 / span 2; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; color: white; background: #234b62; }
.link-button { padding: 0; border: 0; color: #a9bec9; background: transparent; cursor: pointer; font-size: 12px; }

.main-content { min-width: 0; }
.page-wrap { width: min(1160px, calc(100% - 48px)); margin: 0 auto; padding: 48px 0 64px; }
.page-header { margin-bottom: 24px; }
.page-header.compact { margin-bottom: 20px; }
.page-header h1 { margin: 3px 0 7px; color: var(--navy-950); font-size: clamp(28px, 4vw, 40px); letter-spacing: -.035em; }
.page-header p:not(.eyebrow) { margin: 0; color: var(--slate-700); }
.eyebrow { margin: 0; color: var(--green-600); font-size: 12px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.muted { color: var(--slate-500); }
.card { background: var(--white); border: 1px solid rgba(15, 46, 63, .08); border-radius: 13px; box-shadow: var(--shadow); }

.generator-card { padding: 30px; }
.field-group { margin: 0 0 28px; padding: 0; border: 0; }
.field-group > label, .field-group legend { display: block; margin-bottom: 10px; color: var(--navy-950); font-size: 14px; font-weight: 750; }
.input-with-icon { position: relative; }
.input-with-icon span { position: absolute; left: 14px; top: 50%; color: var(--slate-500); transform: translateY(-50%); }
.input-with-icon input { padding-left: 42px; }
input[type="text"], input[type="number"] { width: 100%; min-height: 46px; padding: 10px 13px; border: 1px solid var(--slate-300); border-radius: 7px; color: var(--slate-900); background: white; outline: none; }
input:focus { border-color: var(--green-500); box-shadow: 0 0 0 3px rgba(29, 175, 87, .13); }
.field-error, .validation-summary { display: block; margin-top: 7px; color: var(--danger); font-size: 13px; }
.validation-summary:empty { display: none; }

.distance-row { display: grid; grid-template-columns: minmax(0, 1fr) 150px; gap: 24px; align-items: center; }
input[type="range"] { width: 100%; accent-color: var(--green-600); }
.distance-value { position: relative; }
.distance-value input { padding-right: 42px; font-weight: 750; text-align: right; }
.distance-value span { position: absolute; right: 13px; top: 50%; color: var(--slate-500); transform: translateY(-50%); }

.profile-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.profile-option { position: relative; display: grid; gap: 5px; min-height: 124px; padding: 16px; border: 1px solid var(--slate-300); border-radius: 9px; cursor: pointer; transition: border .15s, background .15s, transform .15s; }
.profile-option:hover { transform: translateY(-1px); border-color: #9eb1bd; }
.profile-option:has(input:checked) { border: 2px solid var(--green-500); padding: 15px; background: #f1fbf5; }
.profile-option input { position: absolute; opacity: 0; pointer-events: none; }
.profile-icon { color: var(--navy-800); font-size: 25px; font-weight: 800; }
.profile-option strong { color: var(--navy-950); font-size: 14px; }
.profile-option small { color: var(--slate-500); font-size: 12px; line-height: 1.35; }

.button { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 20px; border: 1px solid transparent; border-radius: 7px; font-weight: 750; text-decoration: none; cursor: pointer; }
.button-primary { color: white; background: linear-gradient(180deg, #20b75d, #139447); box-shadow: 0 7px 18px rgba(19, 148, 71, .18); }
.button-primary:hover { background: #11893f; }
.button-primary:disabled { color: #d8e4dd; background: #8aa89a; box-shadow: none; cursor: not-allowed; }
.button-secondary { border-color: var(--slate-300); color: var(--navy-900); background: white; }
.button-ghost { color: var(--navy-800); background: #eaf0f3; }
.button-wide, .generate-button { width: 100%; }
.generate-button { margin-top: 4px; }

.alert { margin-bottom: 22px; padding: 13px 15px; border-radius: 8px; font-size: 14px; }
.alert-error { color: #7c202a; border: 1px solid #f0bdc3; background: #fff0f2; }
.alert-info { color: #1a536c; border: 1px solid #b9ddeb; background: #eff9fd; }

.candidate-card { margin-top: 20px; padding: 26px; }
.candidate-card h2 { margin: 0 0 14px; color: var(--navy-950); font-size: 20px; }
.candidate-list { display: grid; gap: 9px; }
.candidate-option { width: 100%; min-height: 60px; display: flex; gap: 12px; align-items: center; padding: 10px 14px; border: 1px solid var(--slate-200); border-radius: 8px; color: inherit; text-align: left; background: white; cursor: pointer; }
.candidate-option:hover { border-color: var(--green-500); background: var(--green-100); }
.candidate-option span:last-child { display: grid; gap: 3px; }
.candidate-option small { color: var(--slate-500); }

.generation-overlay { position: fixed; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(8, 25, 36, .72); z-index: 100; }
.generation-overlay[hidden] { display: none; }
.generation-panel { width: min(560px, 100%); padding: 34px; }
.generation-panel h2 { margin: 5px 0 20px; color: var(--navy-950); }
.spinner { width: 36px; height: 36px; margin-bottom: 18px; border: 4px solid #dbe8df; border-top-color: var(--green-500); border-radius: 50%; animation: spin .9s linear infinite; }
.progress-list { display: grid; gap: 12px; margin: 0 0 20px; padding: 0; list-style: none; counter-reset: phase; }
.progress-list li { counter-increment: phase; display: flex; align-items: center; gap: 10px; color: var(--slate-500); }
.progress-list li::before { content: counter(phase); width: 25px; height: 25px; display: grid; place-items: center; border-radius: 50%; color: var(--slate-500); background: var(--slate-200); font-size: 12px; font-weight: 800; }
.progress-list li.active { color: var(--navy-900); font-weight: 700; }
.progress-list li.active::before { color: white; background: var(--green-500); }
@keyframes spin { to { transform: rotate(360deg); } }

.result-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(320px, .85fr); gap: 18px; }
.map-card { overflow: hidden; }
.route-map { width: 100%; min-height: 520px; background: #d9e3e5; }
.map-summary { margin: 0; padding: 13px 16px; color: var(--slate-700); font-size: 13px; }
.route-summary { padding: 22px; }
.route-status { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 16px; padding: 7px 10px; border-radius: 999px; color: #11703a; background: var(--green-100); font-size: 13px; font-weight: 750; }
.route-summary dl { margin: 0; }
.route-summary dl > div { display: grid; grid-template-columns: minmax(110px, .8fr) minmax(0, 1.2fr); gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--slate-200); }
.route-summary dt { color: var(--slate-500); font-size: 13px; }
.route-summary dd { margin: 0; color: var(--navy-950); font-size: 13px; font-weight: 700; overflow-wrap: anywhere; }
.route-warnings { margin-top: 16px; color: var(--slate-700); font-size: 12px; }
.result-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.evidence-strip { display: flex; flex-wrap: wrap; gap: 10px 22px; margin-top: 16px; color: var(--slate-500); font-size: 11px; }
.evidence-strip code { color: var(--slate-700); }

.login-shell { background: var(--navy-950); }
.login-shell .main-content { min-height: 100vh; }
.login-hero { position: relative; min-height: 100vh; display: grid; grid-template-rows: auto 1fr auto; place-items: center; overflow: hidden; padding: 38px 24px 28px; color: white; background:
  radial-gradient(circle at 14% 20%, rgba(255, 198, 101, .52), transparent 24%),
  linear-gradient(155deg, #6f95a4 0%, #375e70 30%, #16394b 58%, #081a26 100%); }
.login-hero::after { content: ""; position: absolute; inset: 43% -10% -25%; background: linear-gradient(145deg, transparent 0 23%, rgba(7, 24, 33, .92) 23.3% 34%, transparent 34.3%), linear-gradient(215deg, transparent 0 24%, rgba(15, 42, 53, .85) 24.3% 40%, transparent 40.3%); opacity: .82; }
.mountain-haze { position: absolute; inset: 0; background: linear-gradient(180deg, transparent 48%, rgba(5, 16, 23, .28)); }
.login-brand { position: relative; z-index: 2; display: flex; align-items: center; gap: 12px; font-size: 22px; font-weight: 900; line-height: .9; }
.login-brand img { width: 82px; color: white; }
.login-card { position: relative; z-index: 2; align-self: center; width: min(430px, 100%); padding: 34px; color: var(--slate-900); }
.login-card h1 { margin: 6px 0 8px; color: var(--navy-950); font-size: 28px; letter-spacing: -.03em; }
.security-note { margin: 14px 0 0; color: var(--slate-500); font-size: 12px; text-align: center; }
.google-g { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; color: #4285f4; background: white; font-weight: 900; }
.login-tagline { position: relative; z-index: 2; margin: 0; color: #eef5f7; font-size: 14px; }
.error-card { max-width: 640px; margin: 10vh auto 0; padding: 34px; }

@media (max-width: 900px) {
  .app-shell { display: block; }
  .sidebar { position: sticky; height: auto; min-height: 66px; flex-direction: row; align-items: center; padding: 10px 16px; }
  .brand img { width: 46px; height: 36px; }
  .sidebar nav { margin: 0 0 0 auto; }
  .nav-link { min-height: 44px; }
  .sidebar-user { margin: 0 0 0 10px; display: flex; }
  .sidebar-user > span:not(.avatar), .sidebar-user form { display: none; }
  .page-wrap { width: min(100% - 28px, 760px); padding-top: 28px; }
  .profile-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .result-grid { grid-template-columns: 1fr; }
  .route-map { min-height: 52vh; }
}

@media (max-width: 560px) {
  .brand span { display: none; }
  .nav-link { padding: 0 10px; font-size: 13px; }
  .generator-card, .candidate-card { padding: 20px; }
  .distance-row { grid-template-columns: 1fr; gap: 10px; }
  .distance-value { width: 140px; }
  .profile-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .profile-option { min-height: 122px; padding: 12px; }
  .profile-option:has(input:checked) { padding: 11px; }
  .result-actions .button { width: 100%; }
  .route-map { min-height: 48vh; }
  .login-card { padding: 26px 22px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
