*,
*::before,
*::after {
    box-sizing: border-box;
}

:root {
    --primary: #cc8016;
    --primary-soft: rgba(204, 128, 22, 0.12);
    --primary-strong: #a76610;
    --bg: #f5f5f8;
    --bg-elevated: #ffffff;
    --text: #1f2933;
    --muted: #6b7280;
    --border-subtle: #e5e7eb;
    --shadow-soft: 0 18px 45px rgba(15, 23, 42, 0.08);
    --radius-lg: 18px;
    --radius-xl: 24px;
    --radius-pill: 999px;
    --sidebar-width: 290px;
    --step-active-bg: rgba(204, 128, 22, 0.1);
    --danger: #e11d48;
    --success: #16a34a;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background-color: var(--bg);
}

body {
    min-height: 100vh;
}

/* Login */

.login-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top left, #fef3c7 0, #f5f5f8 40%, #e5e7eb 80%);
    padding: 20px;
}

.login-card {
    width: min(420px, 100%);
    background: #ffffff;
    border-radius: 24px;
    box-shadow: 0 24px 80px rgba(15, 23, 42, 0.18);
    padding: 22px 22px 20px;
    border: 1px solid rgba(15, 23, 42, 0.06);
}

.login-brand {
    padding-bottom: 8px;
    margin-bottom: 10px;
    border-bottom: 1px solid #e5e7eb;
}

.login-title {
    margin: 0 0 6px;
    font-size: 22px;
}

.login-subtitle {
    margin: 0 0 12px;
    font-size: 13px;
    color: var(--muted);
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 8px;
}

.login-form label {
    font-size: 13px;
    font-weight: 500;
}

.login-form input {
    border-radius: 12px;
    border: 1px solid var(--border-subtle);
    padding: 9px 11px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
    background: #f9fafb;
}

.login-form input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 1px rgba(204, 128, 22, 0.22);
    background: #ffffff;
}

.btn-login {
    margin-top: 4px;
    width: 100%;
}

.login-help {
    font-size: 11px;
    color: var(--muted);
    margin: 0;
}

.login-help code {
    font-size: 11px;
    background: #f3f4f6;
    padding: 1px 4px;
    border-radius: 4px;
}

.login-error {
    background: rgba(248, 113, 113, 0.08);
    border-radius: 12px;
    padding: 7px 9px;
    font-size: 12px;
    color: #b91c1c;
    margin-bottom: 8px;
    border: 1px solid rgba(239, 68, 68, 0.45);
}

/* Layout */

.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #111827 0%, #020617 100%);
    color: #f9fafb;
    padding: 20px 18px 18px;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px 18px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.25);
    margin-bottom: 16px;
}

.brand-logo {
    width: 38px;
    height: 38px;
    border-radius: 14px;
    background: radial-gradient(circle at 30% 20%, #fde68a 0, #f59e0b 45%, #b45309 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #111827;
    font-weight: 800;
    font-size: 20px;
}

.brand-text {
    display: flex;
    flex-direction: column;
}

.brand-name {
    font-weight: 600;
    letter-spacing: 0.04em;
    font-size: 16px;
}

.brand-subtitle {
    font-size: 12px;
    color: #9ca3af;
}

.steps-nav {
    list-style: none;
    padding: 0;
    margin: 12px 0 0;
    flex: 1;
    overflow-y: auto;
}

.step-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 10px;
    border-radius: 14px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease;
    position: relative;
}

.step-nav-item::before {
    content: "";
    position: absolute;
    left: 4px;
    top: 16px;
    bottom: 16px;
    width: 3px;
    border-radius: 999px;
    background: transparent;
}

.step-nav-item:hover {
    background: rgba(31, 41, 55, 0.95);
    transform: translateX(1px);
}

.step-nav-item.active {
    background: rgba(15, 23, 42, 0.9);
}

.step-nav-item.active::before {
    background: linear-gradient(180deg, #fed7aa 0%, #f97316 40%, #b45309 100%);
}

.step-index {
    width: 24px;
    height: 24px;
    border-radius: 999px;
    border: 1px solid rgba(156, 163, 175, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    color: #d1d5db;
}

.step-nav-item.active .step-index {
    border-color: #fbbf24;
    background: radial-gradient(circle, #fbbf24 0, #f97316 50%, #b45309 100%);
    color: #111827;
}

.step-labels {
    display: flex;
    flex-direction: column;
}

.step-title {
    font-size: 14px;
    font-weight: 500;
}

.step-sub {
    font-size: 11px;
    color: #9ca3af;
}

.sidebar-footer {
    margin-top: 10px;
    padding: 10px 10px 6px;
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.15), rgba(248, 250, 252, 0.04));
    border-radius: 18px;
    border: 1px solid rgba(148, 163, 184, 0.3);
}

.hint-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #facc15;
    margin-bottom: 4px;
}

.hint-text {
    font-size: 12px;
    color: #e5e7eb;
}

.main {
    flex: 1;
    padding: 24px 26px;
    max-width: 1180px;
    margin: 0 auto;
}

.main-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
    gap: 12px;
}

.main-header h1 {
    margin: 0;
    font-size: 24px;
}

.subtitle {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 14px;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 11px;
    border-radius: 999px;
    background: #e5f9ed;
    color: #14532d;
    font-size: 12px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: #22c55e;
    position: relative;
    overflow: visible;
}

.status-dot::after {
    content: "";
    position: absolute;
    inset: -4px;
    border-radius: inherit;
    border: 2px solid rgba(34, 197, 94, 0.4);
    animation: status-pulse 1.6s infinite;
}

@keyframes status-pulse {
    0% { transform: scale(0.6); opacity: 1; }
    100% { transform: scale(1.4); opacity: 0; }
}

.status-text {
    font-weight: 500;
}

/* Step panels */

.step-panel {
    display: none;
}

.step-panel.active {
    display: block;
}

.panel-header {
    margin-bottom: 12px;
}

.panel-header h2 {
    margin: 0 0 4px;
    font-size: 18px;
}

.panel-header p {
    margin: 0;
    font-size: 14px;
    color: var(--muted);
}

/* Cards */

.card {
    background: var(--bg-elevated);
    border-radius: var(--radius-xl);
    padding: 18px 18px 16px;
    box-shadow: var(--shadow-soft);
    border: 1px solid rgba(15, 23, 42, 0.03);
    margin-bottom: 16px;
}

/* Form layout */

.form-grid {
    display: grid;
    gap: 16px;
}

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

.form-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.form-field label {
    font-size: 13px;
    font-weight: 500;
}

.form-field input,
.form-field textarea {
    border-radius: 12px;
    border: 1px solid var(--border-subtle);
    padding: 9px 11px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
    background: #f9fafb;
}

.form-field input:focus,
.form-field textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 1px rgba(204, 128, 22, 0.22);
    background: #ffffff;
}

.form-field small.help-text,
.help-text {
    font-size: 12px;
    color: var(--muted);
}

/* Buttons */

.btn {
    border-radius: 999px;
    border: none;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease;
}

.btn.primary {
    background: var(--primary);
    color: #ffffff;
    box-shadow: 0 15px 30px rgba(180, 83, 9, 0.35);
}

.btn.primary:hover {
    background: var(--primary-strong);
    transform: translateY(-0.5px);
}

.btn.secondary {
    background: #e5e7eb;
    color: #111827;
}

.btn.secondary:hover {
    background: #d1d5db;
}

.btn.ghost {
    background: transparent;
    border: 1px solid var(--border-subtle);
    color: #374151;
}

.btn.ghost:hover {
    border-color: var(--primary);
    color: var(--primary-strong);
}

.btn:disabled {
    cursor: default;
    opacity: 0.7;
    box-shadow: none;
}

/* Form footer */

.form-footer {
    margin-top: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: flex-end;
}

.inline-status {
    font-size: 12px;
    color: var(--muted);
}

/* Pills */

.pill-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border-subtle);
    padding: 5px 10px;
    font-size: 13px;
    cursor: pointer;
    background: #f9fafb;
    transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease, transform 0.08s ease;
}

.pill input {
    display: none;
}

.pill span {
    pointer-events: none;
}

/* Use :has where supported for checked state */
.pill:has(input:checked) {
    background: var(--primary-soft);
    border-color: rgba(204, 128, 22, 0.7);
    color: #111827;
    transform: translateY(-0.5px);
}

/* Badges */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary-strong);
    font-size: 12px;
    font-weight: 500;
}

.badge.subtle {
    background: #e5e7eb;
    color: #374151;
}

/* Step 1 animation */

.animation-shell {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--muted);
    font-size: 13px;
}

.anim-caption {
    margin-top: 6px;
}

.anim-orbit {
    position: relative;
    width: 110px;
    height: 110px;
}

.orbit-center {
    position: absolute;
    inset: 38px;
    border-radius: 999px;
    background: radial-gradient(circle, #fed7aa 0, #f97316 45%, #b45309 85%);
    box-shadow: 0 0 0 6px rgba(248, 250, 252, 0.9);
}

.orbit-dot {
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 999px;
    border: 2px solid rgba(148, 163, 184, 0.5);
    background: #ffffff;
}

.dot-1 {
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    animation: orbit1 4s linear infinite;
}

.dot-2 {
    bottom: 2px;
    left: 0;
    animation: orbit2 4.8s linear infinite;
}

.dot-3 {
    bottom: 2px;
    right: 0;
    animation: orbit3 5.2s linear infinite;
}

@keyframes orbit1 {
    0% { transform: translate(-50%, 0) rotate(0deg); }
    100% { transform: translate(-50%, 0) rotate(360deg); }
}
@keyframes orbit2 {
    0% { transform: translate(0, 0) rotate(0deg); }
    100% { transform: translate(0, 0) rotate(-360deg); }
}
@keyframes orbit3 {
    0% { transform: translate(0, 0) rotate(0deg); }
    100% { transform: translate(0, 0) rotate(360deg); }
}

/* Step 2 animation */

.anim-cards {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

.card-placeholder {
    width: 54px;
    height: 74px;
    border-radius: 12px;
    background: linear-gradient(180deg, #e5e7eb 0%, #f3f4f6 100%);
    position: relative;
    overflow: hidden;
}

.card-placeholder::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(156, 163, 175, 0.3), transparent);
    transform: translateX(-100%);
    animation: card-shimmer 1.6s infinite;
}

@keyframes card-shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.cp1 { transform: rotate(-4deg); }
.cp2 { transform: translateY(-2px); }
.cp3 { transform: rotate(3deg); }

/* Step 3 animation */

.anim-building {
    margin-top: 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.building-body {
    width: 60px;
    height: 70px;
    border-radius: 12px;
    background: linear-gradient(180deg, #e5e7eb 0%, #f9fafb 100%);
    position: relative;
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.2);
}

.building-base {
    width: 72px;
    height: 8px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.18);
    margin-top: 5px;
    filter: blur(1px);
}

.window {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 4px;
    background: #e5e7eb;
    animation: window-glow 2s infinite alternate;
}

.w1 { top: 10px; left: 12px; animation-delay: 0s; }
.w2 { top: 10px; right: 12px; animation-delay: 0.3s; }
.w3 { top: 30px; left: 12px; animation-delay: 0.6s; }
.w4 { top: 30px; right: 12px; animation-delay: 0.9s; }

@keyframes window-glow {
    0% { background: #e5e7eb; box-shadow: none; }
    100% { background: #fde68a; box-shadow: 0 0 10px rgba(250, 204, 21, 0.7); }
}

/* Step 4 typewriter animation */

.generation-progress {
    text-align: center;
    padding: 20px 10px 16px;
    border-radius: 18px;
    border: 1px dashed var(--border-subtle);
}

.anim-typewriter {
    width: 180px;
    height: 34px;
    border-radius: 999px;
    border: 1px solid var(--border-subtle);
    margin: 0 auto;
    position: relative;
    overflow: hidden;
    background: #f9fafb;
}

.type-line {
    position: absolute;
    left: 10px;
    top: 10px;
    height: 14px;
    border-right: 2px solid var(--primary);
    width: 60%;
    animation: typing 2.2s steps(20, end) infinite, blink-caret 0.8s step-end infinite;
}

@keyframes typing {
    0% { width: 0; }
    60% { width: 60%; }
    100% { width: 0; }
}

@keyframes blink-caret {
    0%, 100% { border-color: transparent; }
    50% { border-color: var(--primary); }
}

/* Step 2 locations list */

.step2-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.locations-list {
    max-height: 360px;
    overflow-y: auto;
    border-radius: 14px;
    border: 1px solid #e5e7eb;
    padding: 6px;
    background: #f9fafb;
}

.location-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 8px;
    border-radius: 12px;
    background: #ffffff;
    margin-bottom: 6px;
    border: 1px solid transparent;
    transition: border-color 0.16s ease, background 0.16s ease, transform 0.08s ease;
}

.location-item:hover {
    border-color: var(--border-subtle);
    transform: translateY(-0.5px);
}

.location-main {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-width: 60%;
}

.location-name {
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    color: #111827;
    text-decoration: underline dotted rgba(148, 163, 184, 0.6);
    text-underline-offset: 2px;
}

.location-meta {
    font-size: 12px;
    color: var(--muted);
}

.location-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.location-type-pill {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 999px;
    text-transform: capitalize;
}

.location-type-pill.employer {
    background: rgba(56, 189, 248, 0.15);
    color: #0369a1;
}
.location-type-pill.school_university {
    background: rgba(59, 130, 246, 0.18);
    color: #1d4ed8;
}
.location-type-pill.hospital_medical {
    background: rgba(248, 113, 113, 0.2);
    color: #b91c1c;
}
.location-type-pill.shopping {
    background: rgba(249, 115, 22, 0.18);
    color: #c2410c;
}
.location-type-pill.park_entertainment {
    background: rgba(52, 211, 153, 0.18);
    color: #047857;
}
.location-type-pill.transit {
    background: rgba(129, 140, 248, 0.18);
    color: #4c1d95;
}
.location-type-pill.other {
    background: rgba(148, 163, 184, 0.18);
    color: #374151;
}

.toggle-include {
    width: 32px;
    height: 18px;
    border-radius: 999px;
    background: #e5e7eb;
    position: relative;
    cursor: pointer;
    transition: background 0.16s ease;
}

.toggle-include::before {
    content: "";
    position: absolute;
    top: 2px;
    left: 3px;
    width: 14px;
    height: 14px;
    border-radius: 999px;
    background: #ffffff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.3);
    transition: transform 0.16s ease;
}

.toggle-include.active {
    background: var(--primary);
}

.toggle-include.active::before {
    transform: translateX(12px);
}

.loc-drive {
    font-size: 11px;
    color: var(--muted);
}

/* Results table */

.results-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.results-table-wrap {
    max-height: 420px;
    overflow-y: auto;
    border-radius: 16px;
    border: 1px solid var(--border-subtle);
    background: #f9fafb;
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.results-table thead {
    background: #f3f4f6;
    position: sticky;
    top: 0;
    z-index: 1;
}

.results-table th,
.results-table td {
    padding: 7px 8px;
    text-align: left;
}

.results-table tbody tr:nth-child(odd) {
    background: #ffffff;
}

.results-table tbody tr:nth-child(even) {
    background: #f9fafb;
}

/* Modal */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.42);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 50;
}

.modal-backdrop.active {
    display: flex;
}

.modal {
    width: min(720px, 94vw);
    max-height: 80vh;
    background: #ffffff;
    border-radius: 18px;
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.4);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-header {
    padding: 10px 14px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.modal-header h3 {
    margin: 0;
    font-size: 15px;
}

.modal-close {
    border: none;
    background: transparent;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}

.modal-body {
    padding: 10px;
}

#map-container {
    width: 100%;
    height: 380px;
    border-radius: 12px;
    overflow: hidden;
}

/* Misc */

.hidden {
    display: none !important;
}

@media (max-width: 960px) {
    .sidebar {
        display: none;
    }
    .main {
        padding: 16px 16px 22px;
    }
    .main-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .form-grid.two-columns {
        grid-template-columns: 1fr;
    }
}
