/* ═══════════════════════════════════════════════════════════════
   SatCompare — Design System
   Dark, professional aesthetic (extracted from Ecofeat v4)
   ═══════════════════════════════════════════════════════════════ */

:root {
    /* Surfaces */
    --bg:         #0a0e0d;
    --surface-1:  #0f1413;
    --surface-2:  #161c1a;
    --surface-3:  #1f2725;
    --surface-4:  #2a3431;

    /* Borders */
    --border:        rgba(255, 255, 255, 0.06);
    --border-strong: rgba(255, 255, 255, 0.10);
    --border-accent: rgba(74, 222, 128, 0.25);

    /* Text */
    --fg:        #e8efe9;
    --fg-muted:  #8fa39b;
    --fg-dim:    #5a6b64;

    /* Accent (eco green) */
    --accent:        #4ade80;
    --accent-strong: #22c55e;
    --accent-soft:   rgba(74, 222, 128, 0.12);
    --accent-glow:   rgba(74, 222, 128, 0.35);

    /* Error */
    --red:       #ef4444;
    --red-soft:  rgba(239, 68, 68, 0.12);

    /* Typography */
    --font-ui:   'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', Consolas, monospace;

    /* Layout */
    --header-h:   52px;
    --sidebar-w:  400px;

    /* Radii */
    --radius-sm: 6px;
    --radius:    10px;
    --radius-lg: 14px;

    /* Shadows */
    --shadow-1: 0 1px 2px rgba(0,0,0,.4);
    --shadow-2: 0 8px 24px rgba(0,0,0,.5);
    --shadow-3: 0 20px 60px rgba(0,0,0,.6);

    /* Transitions */
    --t-fast: 0.15s ease;
    --t:      0.22s ease;
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    background: var(--bg);
    color: var(--fg);
    font-family: var(--font-ui);
    font-size: 14px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}
body { display: flex; flex-direction: column; overflow: hidden; }

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input  { font-family: inherit; color: inherit; }
a      { color: inherit; text-decoration: none; }
.ico   { display: inline-block; vertical-align: middle; }

/* ── Scrollbars ─────────────────────────────────────────────── */
*::-webkit-scrollbar        { width: 6px; height: 6px; }
*::-webkit-scrollbar-track  { background: transparent; }
*::-webkit-scrollbar-thumb  { background: var(--surface-3); border-radius: 3px; }
*::-webkit-scrollbar-thumb:hover { background: var(--surface-4); }

/* ═══════════════════════════════════════════════════════════════
   TOPBAR
   ═══════════════════════════════════════════════════════════════ */
.topbar {
    height: var(--header-h);
    flex: 0 0 var(--header-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    background: var(--surface-1);
    border-bottom: 1px solid var(--border);
    z-index: 50;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
    width: 30px; height: 30px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: #0a1a10;
    display: grid; place-items: center;
    box-shadow: 0 0 0 1px var(--border-accent), 0 4px 12px rgba(74,222,128,.15);
}
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }
.brand-tag {
    font-size: 11px;
    color: var(--fg-dim);
    padding-left: 10px;
    margin-left: 4px;
    border-left: 1px solid var(--border);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
@media (max-width: 600px) { .brand-tag { display: none; } }

/* Header stats chips */
.header-meta { display: flex; gap: 8px; align-items: center; }
.stat-chip {
    font-family: var(--font-mono);
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 99px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--fg-muted);
    white-space: nowrap;
}
.stat-chip.accent { background: var(--accent-soft); border-color: var(--border-accent); color: var(--accent); }

/* ═══════════════════════════════════════════════════════════════
   WORKSPACE
   ═══════════════════════════════════════════════════════════════ */
.workspace {
    flex: 1 1 auto;
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    min-height: 0;
    overflow: hidden;
    transition: grid-template-columns 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

body.has-map {
    --sidebar-w: 560px;
}

@media (max-width: 900px) {
    .workspace { grid-template-columns: 1fr; }
    .sidebar { display: none; }
}

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
    background: var(--surface-1);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    min-height: 0;
    padding: 16px 0 24px;
}

.sidebar-section {
    padding: 0 16px;
    margin-bottom: 24px;
}
.sidebar-section + .sidebar-section {
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.section-label {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--fg-dim);
    margin-bottom: 14px;
}
.section-label .ico { color: var(--accent); }

.field-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    font-weight: 500;
    color: var(--fg-muted);
    margin: 0 0 8px;
}

/* Segmented control */
.seg-control {
    display: flex;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 3px;
    gap: 2px;
    margin-bottom: 18px;
}
.seg-btn {
    flex: 1;
    padding: 6px 4px;
    font-size: 11px;
    font-weight: 500;
    color: var(--fg-muted);
    border-radius: 6px;
    transition: var(--t-fast);
    text-align: center;
}
.seg-btn:hover { color: var(--fg); background: var(--surface-3); }
.seg-btn.is-active {
    background: var(--accent-soft);
    color: var(--accent);
    border: 1px solid var(--border-accent);
}

/* Range slider */
.range-input {
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    background: var(--surface-3);
    border-radius: 2px;
    outline: none;
    margin-bottom: 4px;
    cursor: pointer;
}
.range-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px; height: 16px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
    transition: var(--t-fast);
}
.range-input::-webkit-slider-thumb:hover { box-shadow: 0 0 0 5px var(--accent-soft); }
.range-hints {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: var(--fg-dim);
    margin-bottom: 16px;
}

/* Text input */
.text-input {
    width: 100%;
    padding: 8px 10px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    outline: none;
    transition: var(--t-fast);
    margin-bottom: 6px;
    -moz-appearance: textfield;
}
.text-input::-webkit-outer-spin-button,
.text-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.text-input:focus { border-color: var(--border-accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.text-input::placeholder { color: var(--fg-dim); }

/* Help button & box */
.help-btn {
    display: inline-flex;
    align-items: center;
    color: var(--fg-dim);
    transition: var(--t-fast);
    flex-shrink: 0;
}
.help-btn:hover { color: var(--fg); }

.help-box {
    padding: 10px 12px;
    background: var(--surface-2);
    border: 1px solid var(--border-accent);
    border-radius: 8px;
    font-size: 11.5px;
    color: var(--fg-muted);
    line-height: 1.55;
    margin-bottom: 8px;
}

/* About text */
.about-text {
    font-size: 11.5px;
    color: var(--fg-dim);
    line-height: 1.6;
    margin: 0;
}
.about-text b { color: var(--fg-muted); font-weight: 600; }

/* ═══════════════════════════════════════════════════════════════
   COMPARE AREA
   ═══════════════════════════════════════════════════════════════ */
.compare-area {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

/* Snaps column — vertical stack */
.snaps-row {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 20px;
    overflow-y: auto;
    min-height: 0;
    align-items: center;
}

/* Snap card */
.snap-card {
    width: 100%;
    max-width: 860px;
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: var(--t-fast);
}
.snap-card:has(.drop-zone.is-loaded) { border-color: var(--border-strong); }
.snap-card--result { border-color: var(--border-accent); }

.snap-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px 8px;
}
.snap-card__label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--fg-dim);
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Drop zone */
.drop-zone {
    position: relative;
    aspect-ratio: 2 / 1;
    height: auto;
    margin: 0 10px;
    background: var(--surface-2);
    border: 1.5px dashed var(--border-strong);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    transition: var(--t-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}
.drop-zone:hover, .drop-zone:focus {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 4%, var(--surface-2));
    outline: none;
}
.drop-zone.is-dragover {
    border-color: var(--accent);
    background: var(--accent-soft);
}
.drop-zone.is-loaded {
    border-style: solid;
    border-color: var(--border);
    cursor: default;
}
.drop-zone--result {
    cursor: default;
}
.drop-zone--result:hover, .drop-zone--result:focus {
    border-color: var(--border-strong);
    background: var(--surface-2);
}

.drop-zone canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: none;
}
.drop-zone.is-loaded canvas,
.drop-zone.has-result canvas { display: block; }

.drop-hint {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    color: var(--fg-dim);
    text-align: center;
    padding: 16px;
    pointer-events: none;
    transition: var(--t-fast);
}
.drop-hint .ico { color: var(--fg-dim); }
.drop-hint span { font-size: 12.5px; font-weight: 500; }
.drop-hint-sub { font-size: 10.5px; color: var(--fg-dim); font-weight: 400; }
.drop-zone.is-loaded .drop-hint,
.drop-zone.has-result .drop-hint { display: none; }

/* Clear and download buttons */
.snap-clear, .btn-icon-sm {
    width: 26px; height: 26px;
    display: grid; place-items: center;
    border-radius: 6px;
    color: var(--fg-dim);
    transition: var(--t-fast);
    flex-shrink: 0;
}
.snap-clear:hover { background: var(--red-soft); color: var(--red); }
.btn-icon-sm:hover { background: var(--surface-2); color: var(--fg); }

/* Filename */
.snap-filename {
    padding: 8px 14px 12px;
    font-size: 11px;
    color: var(--fg-dim);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-height: 32px;
}

/* Result info bar */
.result-info-bar {
    margin: 0 10px 14px;
    padding: 10px 14px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 16px;
}
.result-info-bar:empty { display: none; }
.stat-item { display: flex; flex-direction: column; gap: 2px; }
.stat-item-label { font-size: 10px; color: var(--fg-dim); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; white-space: nowrap; }
.stat-item-value { font-family: var(--font-mono); font-size: 13px; color: var(--fg); font-weight: 600; white-space: nowrap; }
.stat-item-value.accent { color: var(--accent); }
.stat-sep { display: none; }
.stat-scale-note {
    grid-column: 1 / -1;
    font-size: 10px;
    color: var(--fg-dim);
    padding-top: 4px;
    border-top: 1px solid var(--border);
}

/* ═══════════════════════════════════════════════════════════════
   ACTION BAR
   ═══════════════════════════════════════════════════════════════ */
.action-bar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    background: var(--surface-1);
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 22px;
    border-radius: 8px;
    background: var(--accent);
    color: #0a1a10;
    font-weight: 600;
    font-size: 13px;
    transition: var(--t-fast);
    white-space: nowrap;
}
.btn-primary:hover:not(:disabled) {
    background: var(--accent-strong);
    transform: translateY(-1px);
    box-shadow: 0 6px 18px var(--accent-glow);
}
.btn-primary:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.error-msg {
    font-size: 12.5px;
    color: var(--red);
    padding: 7px 12px;
    background: var(--red-soft);
    border: 1px solid rgba(239,68,68,.25);
    border-radius: 6px;
}

/* ═══════════════════════════════════════════════════════════════
   NEW COMPONENTS — ЛесАналитик v2.0
   ═══════════════════════════════════════════════════════════════ */

/* ── Select input ───────────────────────────────────────────── */
.select-input {
    width: 100%;
    padding: 8px 28px 8px 10px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 12.5px;
    color: var(--fg);
    outline: none;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235a6b64' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    margin-bottom: 10px;
    transition: var(--t-fast);
}
.select-input:focus { border-color: var(--border-accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.select-input:disabled { opacity: 0.45; cursor: not-allowed; }
.select-input option { background: var(--surface-3); color: var(--fg); }

/* ── Divider ────────────────────────────────────────────────── */
.divider {
    height: 1px;
    background: var(--border);
    margin: 14px 0;
}

/* ── Coordinates grid ───────────────────────────────────────── */
.coord-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-bottom: 8px;
}
.coord-grid .text-input { margin-bottom: 0; font-size: 11.5px; padding: 7px 8px; }

/* ── Secondary button ───────────────────────────────────────── */
.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 8px 14px;
    border-radius: 8px;
    background: var(--surface-2);
    border: 1px solid var(--border-strong);
    color: var(--fg-muted);
    font-size: 12.5px;
    font-weight: 500;
    transition: var(--t-fast);
    white-space: nowrap;
}
.btn-secondary:hover:not(:disabled) {
    background: var(--surface-3);
    color: var(--fg);
    border-color: var(--border-accent);
}
.btn-secondary:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-secondary.full { width: 100%; margin-bottom: 6px; }

/* ── Mini Leaflet map ───────────────────────────────────────── */
.mini-map {
    height: 0;
    opacity: 0;
    overflow: hidden;
    border-radius: var(--radius);
    border: 0px solid var(--border);
    margin-top: 0;
    transition:
        height    0.4s cubic-bezier(0.4, 0, 0.2, 1),
        opacity   0.35s ease 0.1s,
        border    0.3s ease,
        margin    0.4s ease;
}
body.has-map .mini-map {
    height: 420px;
    opacity: 1;
    border: 1px solid var(--border);
    margin-top: 10px;
}
.mini-map .leaflet-container { background: var(--surface-2); }
.mini-map .leaflet-control-zoom a {
    background: var(--surface-3) !important;
    border-color: var(--border) !important;
    color: var(--fg-muted) !important;
}

/* ── Image metadata row ─────────────────────────────────────── */
.meta-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}
.meta-date, .meta-source { margin-bottom: 0; font-size: 11.5px; padding: 7px 8px; }
.meta-source { padding-right: 24px; }

/* ── Sidebar hint text ──────────────────────────────────────── */
.sidebar-hint {
    margin: 6px 0 0;
    font-size: 11px;
    color: var(--fg-dim);
    line-height: 1.55;
}

/* ── Date input ─────────────────────────────────────────────── */
input[type="date"].text-input {
    color-scheme: dark;
}

/* ═══════════════════════════════════════════════════════════════
   REPORT OVERLAY
   ═══════════════════════════════════════════════════════════════ */
.report-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: stretch;
    justify-content: flex-end;
}
.report-overlay[hidden] { display: none; }

.report-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.report-modal {
    position: relative;
    z-index: 1;
    width: min(720px, 100vw);
    background: var(--surface-1);
    border-left: 1px solid var(--border-strong);
    box-shadow: var(--shadow-3);
    display: flex;
    flex-direction: column;
    max-height: 100vh;
}

.report-modal__header {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
}
.report-modal__title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 14px;
}
.report-modal__title .ico { color: var(--accent); }

.report-modal__body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 24px;
}

.report-modal__footer {
    flex: 0 0 auto;
    display: flex;
    gap: 10px;
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    background: var(--surface-1);
}

/* ── Report content (inside modal body) ────────────────────── */
.rpt-header {
    margin-bottom: 24px;
    padding-bottom: 18px;
    border-bottom: 2px solid var(--border-accent);
}
.rpt-logo {
    font-size: 22px;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: -0.02em;
    margin-bottom: 4px;
}
.rpt-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--fg);
    margin-bottom: 4px;
}
.rpt-date { font-size: 12px; color: var(--fg-dim); }

.rpt-section {
    margin-bottom: 22px;
}
.rpt-section-title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}

.rpt-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.rpt-table tr { border-bottom: 1px solid var(--border); }
.rpt-table th {
    text-align: left;
    padding: 7px 10px 7px 0;
    color: var(--fg-dim);
    font-weight: 500;
    width: 45%;
    vertical-align: top;
}
.rpt-table td {
    padding: 7px 0;
    color: var(--fg);
    font-weight: 500;
}

.rpt-stats {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}
.rpt-stat {
    flex: 1;
    min-width: 100px;
    padding: 14px 16px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-align: center;
}
.rpt-stat-value {
    font-family: var(--font-mono);
    font-size: 24px;
    font-weight: 700;
    color: var(--accent);
    line-height: 1;
    margin-bottom: 4px;
}
.rpt-stat-label {
    font-size: 10px;
    color: var(--fg-dim);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.rpt-images {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}
@media (max-width: 600px) { .rpt-images { grid-template-columns: 1fr; } }

.rpt-img-wrap {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.rpt-img-wrap img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: contain;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: block;
}
.rpt-img-label {
    font-size: 10.5px;
    color: var(--fg-dim);
    text-align: center;
}

.rpt-note {
    font-size: 12px;
    color: var(--fg-dim);
    margin: 0 0 10px;
    font-style: italic;
}

.appeal-textarea {
    width: 100%;
    min-height: 340px;
    padding: 14px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 12px;
    font-family: var(--font-mono);
    color: var(--fg);
    line-height: 1.7;
    resize: vertical;
    outline: none;
    transition: var(--t-fast);
}
.appeal-textarea:focus { border-color: var(--border-accent); }

/* ═══════════════════════════════════════════════════════════════
   PRINT / PDF
   ═══════════════════════════════════════════════════════════════ */
@media print {
    * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }

    /* Hide everything except report */
    body > *:not(#report-overlay) { display: none !important; }
    .report-backdrop, .report-modal__header, .report-modal__footer { display: none !important; }

    .report-overlay {
        position: static !important;
        display: block !important;
    }
    .report-modal {
        position: static !important;
        width: 100% !important;
        max-height: none !important;
        border: none !important;
        box-shadow: none !important;
        background: white !important;
        color: black !important;
    }
    .report-modal__body {
        overflow: visible !important;
        padding: 0 !important;
        color: black !important;
    }

    /* Light theme for print */
    .rpt-logo { color: #16a34a !important; }
    .rpt-section-title { color: #16a34a !important; border-color: #d1fae5 !important; }
    .rpt-stat { background: #f0fdf4 !important; border-color: #bbf7d0 !important; }
    .rpt-stat-value { color: #16a34a !important; }
    .rpt-table th { color: #6b7280 !important; }
    .rpt-table td { color: #111827 !important; }
    .rpt-table tr { border-color: #e5e7eb !important; }
    .rpt-img-wrap img { background: #f9fafb !important; border-color: #e5e7eb !important; }
    .appeal-textarea {
        background: #f9fafb !important;
        border-color: #e5e7eb !important;
        color: #111827 !important;
        height: auto !important;
        min-height: 0 !important;
        font-size: 11px !important;
    }
    .rpt-header { border-color: #bbf7d0 !important; }
    .rpt-date, .rpt-note, .rpt-img-label { color: #6b7280 !important; }
    .rpt-title { color: #111827 !important; }
}
