:root {
    --bg: #f6f8fb;
    --surface: #ffffff;
    --surface-soft: #eef7f5;
    --text: #17202a;
    --muted: #64748b;
    --line: #dbe4ee;
    --primary: #0f766e;
    --primary-dark: #115e59;
    --accent: #f97316;
    --danger: #b42318;
    --success: #15803d;
    --shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
    --radius: 8px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
    line-height: 1.5;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

img {
    display: block;
    max-width: 100%;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 0.4rem;
    font-size: 2rem;
    line-height: 1.15;
}

h2 {
    margin-bottom: 0.75rem;
    font-size: 1.25rem;
}

button,
input,
select,
textarea {
    font: inherit;
}

.container {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 32px 0 56px;
}

.topbar,
.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px max(16px, calc((100vw - 1180px) / 2));
    background: rgba(255, 255, 255, 0.94);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(14px);
}

.brand {
    color: var(--text);
    font-weight: 800;
    text-decoration: none;
}

.topnav {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 14px;
}

.topnav a {
    color: var(--text);
    font-size: 0.95rem;
}

.page-heading,
.hero {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 24px;
}

.hero {
    align-items: center;
    min-height: 280px;
    padding: 36px;
    background:
        linear-gradient(100deg, rgba(255, 255, 255, 0.94), rgba(255, 255, 255, 0.74)),
        linear-gradient(135deg, #dff7f0, #f8efe1 55%, #e9eefb);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.hero p {
    max-width: 700px;
    color: var(--muted);
}

.eyebrow {
    margin-bottom: 0.35rem;
    color: var(--primary-dark);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.muted,
.hint {
    color: var(--muted);
}

.hint {
    margin-top: 10px;
    font-size: 0.92rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 10px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 700;
    text-decoration: none;
    transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.btn:hover {
    text-decoration: none;
}

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

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

.btn-secondary {
    background: #ffffff;
    color: var(--text);
    border-color: var(--line);
}

.btn-secondary:hover {
    border-color: var(--primary);
    color: var(--primary-dark);
}

.panel,
.auth-card,
.area-card,
.stat-card,
.empty-state {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.panel {
    margin-bottom: 24px;
    padding: 22px;
}

.section-block {
    margin-top: 28px;
}

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

.section-heading h2 {
    margin-bottom: 0;
}

.auth-page {
    display: grid;
    place-items: center;
    padding: 32px 16px;
}

.auth-card {
    width: min(430px, 100%);
    padding: 28px;
}

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

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

.route-form {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    align-items: end;
}

.span-2 {
    grid-column: span 2;
}

label span,
fieldset legend {
    display: block;
    margin-bottom: 6px;
    color: #334155;
    font-size: 0.92rem;
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: var(--radius);
    background: #ffffff;
    color: var(--text);
    padding: 10px 12px;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.13);
    outline: none;
}

textarea {
    resize: vertical;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.checkbox-row input {
    width: auto;
}

.checkbox-row span {
    margin: 0;
    font-weight: 600;
}

.filter-set {
    display: flex;
    min-width: 0;
    flex-wrap: wrap;
    gap: 10px 16px;
    padding: 0;
    border: 0;
}

.filter-set legend {
    width: 100%;
}

.form-actions {
    display: flex;
    justify-content: flex-start;
}

.two-cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.alert {
    margin-bottom: 18px;
    padding: 12px 14px;
    border-radius: var(--radius);
    font-weight: 700;
}

.alert-success {
    background: #dcfce7;
    color: #14532d;
}

.alert-error {
    background: #fee2e2;
    color: var(--danger);
}

.stats-grid,
.area-grid,
.summary-grid {
    display: grid;
    gap: 16px;
}

.stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-bottom: 24px;
}

.stat-card {
    padding: 20px;
}

.stat-card span,
.summary-grid span {
    display: block;
    color: var(--muted);
    font-size: 0.9rem;
}

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

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

.area-card {
    overflow: hidden;
}

.area-card img {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    background: #e2e8f0;
}

.area-card > div {
    padding: 18px;
}

.empty-state {
    padding: 28px;
    text-align: center;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

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

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

th {
    color: #334155;
    font-size: 0.86rem;
}

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

.status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 800;
}

.status-open {
    background: #dcfce7;
    color: var(--success);
}

.status-closed {
    background: #fee2e2;
    color: var(--danger);
}

.editor-layout,
.route-layout,
.connection-editor-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 24px;
    align-items: start;
    margin-bottom: 24px;
}

.route-layout,
.connection-editor-layout {
    grid-template-columns: minmax(0, 1fr) 420px;
}

.map-shell {
    min-width: 0;
}

.map-board {
    position: relative;
    width: 100%;
    overflow: hidden;
    background: #dde8f0;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.map-board img {
    width: 100%;
    height: auto;
    user-select: none;
}

.map-editor {
    cursor: crosshair;
}

.connection-map {
    cursor: crosshair;
}

.map-marker,
.map-preview-marker {
    position: absolute;
    z-index: 4;
    transform: translate(
        calc(-50% + var(--marker-offset-x, 0px)),
        calc(-50% + var(--marker-offset-y, 0px))
    );
}

.map-marker {
    display: grid;
    width: 28px;
    height: 28px;
    place-items: center;
    border: 2px solid #ffffff;
    border-radius: 999px;
    background: var(--primary);
    color: #ffffff;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.28);
    font-size: 0.78rem;
    font-weight: 800;
}

button.map-marker {
    padding: 0;
    cursor: pointer;
}

.user-marker {
    width: 16px;
    height: 16px;
    background: #334155;
    opacity: 0.86;
}

.connection-point-marker {
    z-index: 7;
}

.connection-point-marker.is-in-path {
    border-color: var(--accent);
}

.connection-point-marker.is-start {
    background: var(--success);
}

.connection-point-marker.is-end {
    background: var(--accent);
}

.map-preview-marker {
    width: 14px;
    height: 14px;
    border: 2px solid var(--accent);
    border-radius: 999px;
    background: rgba(249, 115, 22, 0.34);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.86);
    pointer-events: none;
}

.route-overlay {
    position: absolute;
    inset: 0;
    z-index: 3;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.connection-overlay {
    position: absolute;
    inset: 0;
    z-index: 2;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.connection-line,
.connection-draft-line {
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
    vector-effect: non-scaling-stroke;
}

.connection-line {
    stroke: rgba(15, 23, 42, 0.52);
    stroke-width: 1;
}

.connection-piste.connection-blue {
    stroke: rgba(14, 165, 233, 0.76);
}

.connection-piste.connection-red {
    stroke: rgba(220, 38, 38, 0.76);
}

.connection-piste.connection-black {
    stroke: rgba(15, 23, 42, 0.78);
}

.connection-lift {
    stroke: rgba(17, 24, 39, 0.68);
    stroke-dasharray: 2 1.4;
}

.connection-closed {
    opacity: 0.28;
}

.connection-draft-line {
    stroke: var(--accent);
    stroke-width: 1.6;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.42));
}

.connection-end-handle {
    fill: var(--accent);
    stroke: #ffffff;
    stroke-width: 0.35;
    vector-effect: non-scaling-stroke;
}

.connection-mid-handle {
    fill: #ffffff;
    stroke: var(--accent);
    stroke-width: 0.32;
    vector-effect: non-scaling-stroke;
}

.route-line {
    fill: none;
    stroke: var(--accent);
    stroke-width: 1.25;
    stroke-linejoin: round;
    stroke-linecap: round;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.4));
    vector-effect: non-scaling-stroke;
}

.route-marker {
    z-index: 6;
    width: 30px;
    height: 30px;
    background: var(--accent);
}

.path-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
}

.side-panel {
    position: sticky;
    top: 86px;
}

.route-result {
    min-width: 0;
}

.summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-bottom: 18px;
}

.summary-grid div {
    padding: 12px;
    background: var(--surface-soft);
    border-radius: var(--radius);
}

.summary-grid strong {
    display: block;
    margin-top: 4px;
}

.step-list {
    display: grid;
    gap: 12px;
    margin: 0;
    padding-left: 22px;
}

.step-list li {
    padding-left: 4px;
}

.step-list span {
    display: block;
    color: var(--muted);
}

@media (max-width: 900px) {
    .page-heading,
    .hero,
    .topbar,
    .site-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .form-grid,
    .route-form,
    .stats-grid,
    .area-grid,
    .editor-layout,
    .route-layout,
    .connection-editor-layout {
        grid-template-columns: 1fr;
    }

    .span-2 {
        grid-column: span 1;
    }

    .side-panel {
        position: static;
    }
}

@media (max-width: 560px) {
    .container {
        width: min(100% - 20px, 1180px);
        padding-top: 20px;
    }

    .panel,
    .auth-card,
    .hero {
        padding: 18px;
    }

    h1 {
        font-size: 1.65rem;
    }

    .two-cols,
    .summary-grid {
        grid-template-columns: 1fr;
    }

    .topnav {
        gap: 10px;
    }
}
