:root {
    --bg: #f3f6f5;
    --panel: #ffffff;
    --text: #16211f;
    --muted: #6b7a76;
    --border: #dce5e2;
    --primary: #0d8f61;
    --primary-dark: #08764f;
    --soft: #e9f8f1;
    --danger: #c73636;
    --warning: #b56a00;
    --shadow: 0 18px 45px rgba(23, 39, 34, 0.12);
}

* {
    box-sizing: border-box;
}

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

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

button {
    border: 0;
    border-radius: 14px;
    padding: 12px 16px;
    background: var(--primary);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
    transition: 0.18s ease;
}

button:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
    transform: none;
}

.button-secondary {
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #f8fbfa;
    color: #263733;
    font-size: 13px;
    font-weight: 800;
}

.button-secondary:hover {
    background: #eef6f3;
    color: var(--primary-dark);
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 13px;
    padding: 11px 13px;
    background: #fff;
    color: var(--text);
    outline: none;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(13, 143, 97, 0.12);
}

label {
    display: block;
    font-size: 13px;
    font-weight: 700;
    color: #2b3734;
    margin-bottom: 6px;
}

.app-shell {
    display: grid;
    grid-template-columns: 430px minmax(0, 1fr);
    height: 100vh;
    min-height: 600px;
}

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 22px;
    background: linear-gradient(180deg, #ffffff 0%, #f7fbfa 100%);
    border-right: 1px solid var(--border);
    overflow: auto;
    z-index: 5;
}

.brand-block {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-icon {
    width: 54px;
    height: 54px;
    border-radius: 18px;
    display: grid;
    place-items: center;
    font-size: 28px;
    background: var(--soft);
    box-shadow: inset 0 0 0 1px rgba(13, 143, 97, 0.12);
}

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

.brand-block h1 {
    margin: 0 0 4px;
    font-size: 26px;
    line-height: 1.1;
}

.brand-block p,
.muted {
    margin: 0;
    color: var(--muted);
    line-height: 1.45;
}

.notice,
.search-card,
.fuel-preference-card,
.station-panel,
.admin-card,
.alert {
    border-radius: 22px;
    background: var(--panel);
    border: 1px solid var(--border);
    box-shadow: 0 8px 26px rgba(23, 39, 34, 0.07);
}

.notice {
    padding: 14px 16px;
    color: #315047;
    background: var(--soft);
    border-color: #ccece0;
    font-size: 14px;
    line-height: 1.45;
}

.search-card {
    padding: 16px;
}

.fuel-preference-card {
    padding: 16px;
}

.fuel-preference-card p {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.4;
}

.fuel-preference-title {
    margin-bottom: 10px;
    color: #2b3734;
    font-size: 13px;
    font-weight: 800;
}

.fuel-preference-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.fuel-preference-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    margin: 0;
    padding: 9px 10px;
    border: 1px solid var(--border);
    border-radius: 13px;
    background: #fbfdfc;
    color: #24332f;
    cursor: pointer;
    user-select: none;
    transition: 0.16s ease;
}

.fuel-preference-chip:hover {
    border-color: rgba(13, 143, 97, 0.45);
    background: #f1faf6;
}

.fuel-preference-chip input {
    width: auto;
    margin: 0;
    accent-color: var(--primary);
}

.fuel-preference-chip:has(input:checked) {
    border-color: rgba(13, 143, 97, 0.75);
    background: var(--soft);
    box-shadow: inset 0 0 0 1px rgba(13, 143, 97, 0.12);
}

.fuel-preference-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 10px;
}

.station-panel {
    padding: 18px;
}

.station-panel.empty {
    display: grid;
    place-items: center;
    text-align: center;
    min-height: 230px;
    color: var(--muted);
}

.station-panel.empty h2 {
    color: var(--text);
}

.station-title {
    margin-bottom: 4px;
    font-size: 23px;
}

.station-subtitle {
    color: var(--muted);
    line-height: 1.45;
    margin-bottom: 14px;
}

.map-wrap {
    position: relative;
    min-width: 0;
}

#map {
    width: 100%;
    height: 100%;
}

.map-floating-btn {
    position: absolute;
    top: 18px;
    right: 18px;
    z-index: 600;
    box-shadow: var(--shadow);
}

.fuel-list {
    display: grid;
    gap: 12px;
    margin: 16px 0;
}

.fuel-card {
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 14px;
    background: #fff;
}

.fuel-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}

.fuel-name {
    font-weight: 800;
    font-size: 16px;
}

.fuel-meta {
    margin-top: 4px;
    font-size: 13px;
    color: var(--muted);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    border-radius: 999px;
    padding: 7px 10px;
    font-size: 13px;
    font-weight: 800;
    background: #eef2f1;
    color: var(--muted);
}

.status-badge.available {
    background: #e1f8eb;
    color: #077245;
}

.status-badge.unavailable {
    background: #ffe8e8;
    color: #b51f1f;
}

.status-badge.unknown {
    background: #fff4df;
    color: var(--warning);
}

.report-form {
    display: grid;
    gap: 10px;
}

.status-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.status-buttons label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px;
    margin: 0;
    border: 1px solid var(--border);
    border-radius: 13px;
    cursor: pointer;
    background: #fafcfb;
}

.status-buttons input {
    width: auto;
}

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

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

.form-grid.three {
    grid-template-columns: 0.75fr 1fr 0.5fr;
}

.history-block {
    margin-top: 18px;
}

.history-block h3 {
    margin-bottom: 10px;
}

.history-list {
    display: grid;
    gap: 9px;
    max-height: 360px;
    overflow: auto;
    padding-right: 4px;
}

.history-item {
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 11px;
    background: #fbfdfc;
}

.history-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}

.history-fuel {
    font-weight: 800;
}

.history-date {
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap;
}

.history-text {
    color: #40514d;
    font-size: 14px;
    line-height: 1.4;
}

.marker-popup-title {
    font-weight: 900;
    margin-bottom: 8px;
    color: #111827;
}

.marker-popup-address {
    margin-top: 8px;
    color: #4b5563;
    font-size: 12px;
    line-height: 1.35;
}

.marker-popup-fuels {
    display: grid;
    gap: 5px;
    min-width: 220px;
    margin-top: 6px;
}

.marker-popup-fuels-title {
    margin-bottom: 2px;
    color: #374151;
    font-size: 12px;
    font-weight: 900;
}

.marker-popup-fuel-row {
    display: grid;
    grid-template-columns: minmax(72px, 1fr) auto;
    align-items: center;
    gap: 8px;
    padding: 5px 7px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    background: #f9fafb;
}

.marker-popup-fuel-row--available {
    background: #ecfdf3;
    border-color: #bbf7d0;
}

.marker-popup-fuel-row--unavailable {
    background: #fff1f2;
    border-color: #fecdd3;
}

.marker-popup-fuel-row--unknown {
    background: #fffbeb;
    border-color: #fde68a;
}

.marker-popup-fuel-name {
    color: #111827;
    font-size: 12px;
    font-weight: 900;
}

.marker-popup-fuel-right {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 5px;
    min-width: 0;
}

.marker-popup-fuel-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 76px;
    border-radius: 999px;
    padding: 4px 7px;
    font-size: 11px;
    font-weight: 1000;
    line-height: 1;
    color: #374151;
    background: #e5e7eb;
}

.marker-popup-fuel-status.available {
    color: #ffffff;
    background: #087647;
}

.marker-popup-fuel-status.unavailable {
    color: #ffffff;
    background: #b51f1f;
}

.marker-popup-fuel-status.unknown {
    color: #ffffff;
    background: #8a5200;
}

.marker-popup-fuel-price,
.marker-popup-fuel-date {
    color: #6b7280;
    font-size: 11px;
    font-weight: 800;
    white-space: nowrap;
}

.marker-popup-fuel-empty {
    margin-top: 6px;
    color: #6b7280;
    font-size: 12px;
    font-weight: 800;
}

.marker-popup-status {
    margin-top: 8px;
    padding-top: 7px;
    border-top: 1px solid #e5e7eb;
    color: #374151;
    font-size: 12px;
    font-weight: 800;
}

.admin-body {
    min-height: 100%;
}

.admin-shell {
    width: min(1440px, calc(100% - 28px));
    margin: 0 auto;
    padding: 24px 0 50px;
}

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

.admin-header h1 {
    margin-bottom: 4px;
}

.admin-exit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    padding: 12px 16px;
    color: #fff;
    text-decoration: none;
    background: #21322d;
    font-weight: 800;
}

.alert {
    padding: 14px 16px;
    margin-bottom: 14px;
    font-weight: 700;
}

.alert.success {
    background: #e9f9ef;
    color: #087647;
    border-color: #bfe9d0;
}

.alert.error {
    background: #fff0f0;
    color: #a51f1f;
    border-color: #f0c7c7;
}

.admin-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(340px, 0.75fr);
    gap: 18px;
    align-items: start;
}

.admin-card {
    padding: 18px;
    margin-bottom: 18px;
}

.login-card {
    width: min(440px, 100%);
    margin: 40px auto 0;
}

.login-card form,
.stacked-form {
    display: grid;
    gap: 11px;
}

.compact-form {
    margin-bottom: 16px;
}

#admin-map {
    height: 360px;
    border-radius: 20px;
    overflow: hidden;
    border: 1px solid var(--border);
    margin-bottom: 14px;
}

.fuel-admin-list {
    display: grid;
    gap: 8px;
}

.fuel-admin-row {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #fbfdfc;
}

.fuel-admin-row small {
    display: block;
    color: var(--muted);
}

.secondary-btn {
    background: #e9efed;
    color: #263632;
}

.secondary-btn:hover {
    background: #dce7e3;
}

.danger-btn {
    background: var(--danger);
}

.danger-btn:hover {
    background: #a92626;
}

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

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

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

th {
    color: var(--muted);
    font-size: 13px;
    white-space: nowrap;
}

td input[type="text"] {
    min-width: 135px;
}

td input[type="checkbox"] {
    width: auto;
    transform: scale(1.2);
}

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

.actions-cell form {
    margin: 0;
}

.actions-cell button {
    padding: 9px 12px;
    border-radius: 12px;
}

.leaflet-popup-content-wrapper {
    border-radius: 16px;
}

@media (max-width: 980px) {
    .app-shell {
        grid-template-columns: 1fr;
        height: auto;
        min-height: 100vh;
    }

    .sidebar {
        order: 2;
        border-right: 0;
        border-top: 1px solid var(--border);
        max-height: none;
    }

    .map-wrap {
        order: 1;
        height: 58vh;
        min-height: 420px;
    }

    .admin-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 620px) {
    .sidebar {
        padding: 14px;
    }

    .brand-block {
        align-items: flex-start;
    }

    .brand-block h1 {
        font-size: 22px;
    }

    .form-grid.two,
    .form-grid.three,
    .status-buttons,
    .fuel-preference-options,
    .fuel-preference-actions {
        grid-template-columns: 1fr;
    }

    .map-floating-btn {
        top: auto;
        right: 12px;
        bottom: 12px;
    }

    .admin-shell {
        width: min(100% - 18px, 1440px);
    }

    .admin-header {
        align-items: flex-start;
        flex-direction: column;
    }
}

/* Логотипы АЗС внутри круглых маркеров Leaflet */
.station-marker-icon {
    background: transparent !important;
    border: 0 !important;
    z-index: 800 !important;
}

.station-marker-icon.leaflet-interactive:hover,
.station-marker-icon.leaflet-marker-icon:hover {
    z-index: 1400 !important;
}

.station-marker {
    --marker-status-color: var(--warning);
    --marker-fill-color: #fff7e6;
    --marker-symbol: '?';
    --marker-symbol-bg: #7c4a03;
    position: relative;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    border: 4px solid rgba(255, 255, 255, 0.95);
    background-color: var(--marker-fill-color);
    box-shadow:
        0 0 0 3px var(--marker-status-color),
        0 10px 22px rgba(0, 0, 0, 0.24);
    overflow: visible;
    isolation: isolate;
    transition: transform 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease;
}

.station-marker::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 0;
    border-radius: inherit;
    pointer-events: none;
}

.station-marker::after {
    content: var(--marker-symbol);
    position: absolute;
    right: -7px;
    top: -7px;
    z-index: 999;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    border: 3px solid #fff;
    background: var(--marker-symbol-bg);
    color: #fff;
    font-size: 14px;
    font-weight: 1000;
    line-height: 1;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.28);
    pointer-events: none;
}

.station-marker-icon:hover .station-marker {
    transform: scale(1.08);
    box-shadow:
        0 0 0 4px var(--marker-status-color),
        0 14px 28px rgba(0, 0, 0, 0.28);
}

.station-marker--available {
    --marker-status-color: #087647;
    --marker-fill-color: #dff7e9;
    --marker-symbol: '✓';
    --marker-symbol-bg: #087647;
}

.station-marker--unavailable {
    --marker-status-color: #b51f1f;
    --marker-fill-color: #ffe3e3;
    --marker-symbol: '×';
    --marker-symbol-bg: #b51f1f;
}

.station-marker--unavailable::before {
    background: repeating-linear-gradient(
        135deg,
        rgba(181, 31, 31, 0.2) 0,
        rgba(181, 31, 31, 0.2) 4px,
        transparent 4px,
        transparent 8px
    );
}

.station-marker--unknown {
    --marker-status-color: #8a5200;
    --marker-fill-color: #fff1d6;
    --marker-symbol: '?';
    --marker-symbol-bg: #8a5200;
}

.station-marker--unknown::before {
    background-image: radial-gradient(rgba(138, 82, 0, 0.28) 1.2px, transparent 1.2px);
    background-size: 7px 7px;
}

.station-marker--preferred-fuel {
    box-shadow:
        0 0 0 3px var(--marker-status-color),
        0 0 0 7px rgba(255, 255, 255, 0.78),
        0 10px 22px rgba(0, 0, 0, 0.24);
}

.station-marker--preferred-fuel::after {
    width: 16px;
    height: 16px;
    font-size: 12px;
}

.station-marker-logo {
    position: relative;
    z-index: 2;
    width: 76%;
    height: 76%;
    object-fit: contain;
    display: block;
}

.station-marker-fallback {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #19302a;
    font-size: 17px;
    font-weight: 900;
    line-height: 1;
    background: transparent;
}
