:root {
    --ink: #172825;
    --muted: #6f7d79;
    --green: #176c5a;
    --green-dark: #0b4d41;
    --cream: #f5f5ef;
    --line: #dfe5e1;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

/* Essential Leaflet layout styles are kept locally as a CDN fallback. */
.leaflet-pane,
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-tile-container,
.leaflet-pane > svg,
.leaflet-pane > canvas,
.leaflet-zoom-box {
    position: absolute;
    top: 0;
    left: 0;
}
.leaflet-container { overflow: hidden; background: #ddd; outline-offset: 1px; }
.leaflet-tile, .leaflet-marker-icon, .leaflet-marker-shadow { user-select: none; -webkit-user-drag: none; }
.leaflet-tile { width: 256px; height: 256px; filter: inherit; visibility: hidden; }
.leaflet-tile-loaded { visibility: inherit; }
.leaflet-zoom-animated { transform-origin: 0 0; }
.leaflet-zoom-anim .leaflet-zoom-animated {
    transition: transform .32s cubic-bezier(0, 0, .25, 1);
}
.leaflet-fade-anim .leaflet-popup {
    opacity: 0;
    transition: opacity .2s linear;
}
.leaflet-fade-anim .leaflet-map-pane .leaflet-popup {
    opacity: 1;
}
.leaflet-fade-anim .leaflet-tile {
    will-change: opacity;
}
.leaflet-tile-container { pointer-events: none; }
.leaflet-pane { z-index: 400; }
.leaflet-tile-pane { z-index: 200; }
.leaflet-overlay-pane { z-index: 400; }
.leaflet-shadow-pane { z-index: 500; }
.leaflet-marker-pane { z-index: 600; }
.leaflet-tooltip-pane { z-index: 650; }
.leaflet-popup-pane { z-index: 700; }
.leaflet-map-pane canvas { z-index: 100; }
.leaflet-map-pane svg { z-index: 200; }
.leaflet-control { position: relative; z-index: 800; pointer-events: auto; }
.leaflet-top, .leaflet-bottom { position: absolute; z-index: 1000; pointer-events: none; }
.leaflet-top { top: 0; }
.leaflet-right { right: 0; }
.leaflet-bottom { bottom: 0; }
.leaflet-left { left: 0; }
.leaflet-right .leaflet-control { float: right; clear: both; margin-right: 16px; }
.leaflet-bottom .leaflet-control { margin-bottom: 16px; }
.leaflet-control-zoom { border-radius: 8px; box-shadow: 0 2px 12px rgba(0,0,0,.2); }
.leaflet-control-zoom a { display: block; width: 34px; height: 34px; color: #172825; background: #fff; font: 22px/34px Arial, sans-serif; text-align: center; text-decoration: none; }
.leaflet-control-zoom a:first-child { border-radius: 8px 8px 0 0; border-bottom: 1px solid #ddd; }
.leaflet-control-zoom a:last-child { border-radius: 0 0 8px 8px; }
.leaflet-control-attribution { padding: 3px 7px; color: #555; background: rgba(255,255,255,.85); font-size: 10px; }
.leaflet-control-attribution a { color: #176c5a; }
.leaflet-interactive { cursor: pointer; }
.marker-cluster div {
    display: grid;
    width: 34px;
    height: 34px;
    margin: 3px;
    place-items: center;
    border-radius: 50%;
    color: white;
    background: var(--green);
    box-shadow: 0 2px 10px rgba(11, 77, 65, .3);
    font: 700 12px/1 "Manrope", sans-serif;
}
.marker-cluster { border-radius: 50%; background: rgba(23, 108, 90, .22); }
.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large { background: rgba(23, 108, 90, .22); }
.aggregate-marker div { font-size: 10px; }
.leaflet-pane > svg path.leaflet-interactive,
.leaflet-pane > canvas.leaflet-interactive { pointer-events: auto; }
.leaflet-popup { position: absolute; margin-bottom: 6px; text-align: center; }
.leaflet-popup-content-wrapper { padding: 1px; border-radius: 10px; background: white; box-shadow: 0 3px 14px rgba(0,0,0,.25); }
.leaflet-popup-content { margin: 13px 18px; line-height: 1.45; }
.station-popup-heading { margin: 0 0 7px; font-weight: 700; }
.station-popup-address { margin: 3px 0 8px; color: var(--muted); font-size: 11px; }
.station-popup-list { max-height: 280px; overflow-y: auto; padding-right: 4px; text-align: left; }
.station-popup-row { display: flex; align-items: center; gap: 10px; padding: 9px 2px; border-top: 1px solid var(--line); }
.station-popup-details { display: grid; flex: 1; min-width: 0; gap: 2px; font-size: 11px; }
.station-popup-details span { display: flex; align-items: center; gap: 5px; }
.operator-dot { display: inline-block; flex: 0 0 auto; width: 8px; height: 8px; border-radius: 50%; }
.station-popup-details strong { overflow-wrap: anywhere; font-size: 12px; }
.station-popup-row .sector-toggle { flex: 0 0 auto; margin-top: 0; padding: 6px; }
.leaflet-popup-tip-container { width: 40px; height: 20px; margin: 0 auto; overflow: hidden; }
.leaflet-popup-tip { width: 17px; height: 17px; margin: -10px auto 0; background: white; transform: rotate(45deg); box-shadow: 3px 3px 8px rgba(0,0,0,.18); }
.leaflet-popup-close-button { position: absolute; z-index: 1; top: 3px; right: 5px; border: 0; color: #777; background: transparent; font-size: 18px; text-decoration: none; }
.sector-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    border: 1px solid #cbd8d3;
    border-radius: 7px;
    padding: 6px 9px;
    color: var(--green);
    background: #f5faf8;
    font-family: inherit;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
}
.sector-toggle:hover { background: #e7f2ee; }
.sector-toggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sector-toggle .eye-slash { stroke: #b84c40; stroke-width: 2.2; }

body {
    color: var(--ink);
    background: var(--cream);
    font-family: "Manrope", system-ui, sans-serif;
}

.login-shell { display: grid; min-height: 100vh; grid-template-columns: minmax(340px, 44%) 1fr; }

.brand-panel {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
    padding: clamp(40px, 8vw, 110px);
    color: white;
    background: linear-gradient(145deg, #0b3f37, #14705d);
}

.brand-panel::before, .brand-panel::after {
    position: absolute;
    border: 1px solid rgba(255,255,255,.09);
    border-radius: 50%;
    content: "";
}
.brand-panel::before { width: 440px; height: 440px; top: -190px; left: -160px; }
.brand-panel::after { width: 520px; height: 520px; right: -350px; bottom: -200px; }

.brand-mark { display: block; width: 104px; height: 102px; margin-bottom: 32px; border-radius: 16px; background: white; object-fit: contain; }

.eyebrow { margin: 0 0 12px; color: #95d1c4; font-size: 12px; font-weight: 700; letter-spacing: .2em; }
.eyebrow.dark { color: var(--green); }
.brand-panel h1 { margin: 0; font-size: clamp(42px, 5vw, 68px); letter-spacing: -.05em; }
.brand-copy { max-width: 390px; margin: 18px 0 0; color: #c5ddd7; font-size: 17px; line-height: 1.7; }
.brand-footer { position: absolute; bottom: 34px; margin: 0; color: #8cb7ad; font-size: 12px; }

.login-panel { display: grid; place-items: center; padding: 40px; }
.login-card { width: min(100%, 430px); }
.login-card h2 { margin: 0; font-size: clamp(30px, 4vw, 42px); letter-spacing: -.04em; }
.muted { margin: 12px 0 32px; color: var(--muted); }
.form-error { margin-bottom: 20px; padding: 13px 15px; border: 1px solid #e5b6af; border-radius: 10px; color: #983d31; background: #fff1ef; font-size: 13px; }
.login-form { display: grid; gap: 20px; }
.field { display: grid; gap: 8px; }
.field label { font-size: 13px; font-weight: 700; }
.field input { width: 100%; border: 1px solid var(--line); border-radius: 10px; outline: 0; padding: 14px 15px; color: var(--ink); background: #fff; font: inherit; }
.field input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(23,108,90,.12); }
.primary-button { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; border: 0; border-radius: 10px; padding: 15px 18px; color: white; background: var(--green); font-family: inherit; font-size: 14px; font-weight: 700; cursor: pointer; transition: .2s; }
.primary-button:hover { background: var(--green-dark); transform: translateY(-1px); }

.map-page { height: 100vh; overflow: hidden; background: #eef1ed; }
.topbar { height: 72px; display: flex; align-items: center; justify-content: space-between; padding: 0 clamp(20px, 4vw, 58px); border-bottom: 1px solid var(--line); background: #fff; }
.logo { display: flex; align-items: center; gap: 11px; color: var(--ink); font-size: 19px; font-weight: 700; text-decoration: none; }
.logo > img { width: 42px; height: 42px; object-fit: contain; }
.account { display: flex; align-items: center; gap: 12px; }
.user-meta { display: grid; text-align: right; font-size: 12px; }
.user-meta span { color: var(--muted); font-size: 10px; }
.avatar { display: grid; width: 36px; height: 36px; place-items: center; border-radius: 50%; color: white; background: var(--green); font-weight: 700; }
.logout-button { border: 1px solid var(--line); border-radius: 8px; padding: 8px 11px; color: var(--muted); background: #fff; cursor: pointer; }
.settings-button { display: grid; width: 36px; height: 36px; place-items: center; border: 1px solid var(--line); border-radius: 8px; color: var(--green); }
.settings-button svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.map-shell { height: calc(100vh - 72px); padding: 0; }
#map { width: 100%; height: 100%; overflow: hidden; }
.cell-panel {
    position: absolute;
    z-index: 1100;
    top: 92px;
    left: 20px;
    width: min(390px, calc(100vw - 40px));
    max-height: calc(100vh - 116px);
    overflow-y: auto;
    padding: 16px;
    border: 1px solid rgba(23, 40, 37, .1);
    border-radius: 14px;
    background: rgba(255, 255, 255, .95);
    box-shadow: 0 8px 28px rgba(23, 40, 37, .18);
    backdrop-filter: blur(8px);
}
.cell-panel:has(.operator-menu:not([hidden])) { overflow: visible; }
.operator-filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px solid #d7dfdb; }
.operator-filters button { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 8px; padding: 7px 8px; color: var(--muted); background: #f7f9f8; font: 600 11px "Manrope", sans-serif; text-align: left; cursor: pointer; }
.operator-filters button > i { width: 8px; height: 8px; border-radius: 50%; }
.operator-filters button svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.operator-filters button .eye-slash { stroke: #b84c40; stroke-width: 2.2; }
.operator-filters button.is-visible { border-color: color-mix(in srgb, var(--green) 45%, white); color: var(--green-dark); background: #eef7f4; }
.cell-rows { display: grid; gap: 12px; }
.cell-row {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
    gap: 10px;
    padding: 8px 0 16px;
    border-bottom: 1px solid #d7dfdb;
}
.cell-row:last-child { padding-bottom: 4px; border-bottom: 0; }
.remove-cell-row {
    position: absolute;
    z-index: 1;
    top: -4px;
    right: -4px;
    display: grid;
    width: 22px;
    height: 22px;
    place-items: center;
    border: 1px solid #e1b5ae;
    border-radius: 50%;
    padding: 0;
    color: #a54035;
    background: #fff5f3;
    font: 700 16px/1 Arial, sans-serif;
    cursor: pointer;
}
.remove-cell-row:hover { color: white; background: #b84c40; }
.retry-action { position: relative; align-self: end; }
.retry-station-search {
    display: grid;
    width: 40px;
    height: 40px;
    place-items: center;
    border: 1px solid #d3ddd9;
    border-radius: 8px;
    padding: 0;
    color: var(--green);
    background: #f3f8f6;
    cursor: pointer;
}
.retry-station-search[hidden] { display: none; }
.retry-station-search:hover { color: white; background: var(--green); }
.retry-station-search svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.operator-menu {
    position: absolute;
    z-index: 20;
    top: 0;
    right: auto;
    left: 46px;
    display: grid;
    width: 120px;
    overflow: hidden;
    border: 1px solid #d7dfdb;
    border-radius: 9px;
    background: white;
    box-shadow: 0 8px 24px rgba(23, 40, 37, .2);
}
.operator-menu[hidden] { display: none; }
.operator-menu button { border: 0; border-bottom: 1px solid #edf1ef; padding: 9px 12px; color: var(--ink); background: white; font-family: inherit; font-size: 12px; text-align: left; cursor: pointer; }
.operator-menu button:last-child { border-bottom: 0; }
.operator-menu button:hover { color: white; background: var(--green); }
.map-field { display: grid; gap: 6px; }
.map-field label { color: var(--ink); font-size: 12px; font-weight: 700; }
.map-field input {
    min-width: 0;
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    outline: none;
    padding: 10px 11px;
    color: var(--ink);
    background: white;
    font: 14px "Manrope", system-ui, sans-serif;
}
.map-field input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(23, 108, 90, .12); }
.cell-actions { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.add-cell-button {
    flex: 1;
    border: 0;
    border-radius: 8px;
    padding: 10px 14px;
    color: white;
    background: var(--green);
    font-family: inherit;
    font-weight: 700;
    cursor: pointer;
}
.add-cell-button:hover { background: var(--green-dark); }
.clear-cell-button {
    flex: 0 0 auto;
    border: 1px solid #dfb9b3;
    border-radius: 8px;
    padding: 8px 10px;
    color: #a54035;
    background: #fff;
    font-family: inherit;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
}
.clear-cell-button:hover { color: white; background: #b84c40; }
.station-status { min-height: 16px; margin: 9px 2px 0; color: var(--muted); font-size: 11px; }
.all-antennas-status {
    position: absolute;
    z-index: 1050;
    left: 16px;
    bottom: 18px;
    border-radius: 8px;
    padding: 7px 10px;
    color: #43524e;
    background: rgba(255,255,255,.9);
    box-shadow: 0 3px 12px rgba(23,40,37,.14);
    font-size: 11px;
    pointer-events: none;
}
.antenna-marker {
    position: relative;
    filter: drop-shadow(0 3px 4px rgba(0, 0, 0, .38));
}
.antenna-marker svg {
    display: block;
    width: 36px;
    height: 44px;
    overflow: visible;
    color: var(--antenna-color, #176c5a);
}
.antenna-marker path {
    fill: none;
    stroke: currentColor;
    stroke-width: 2.4;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.antenna-marker .antenna-pin { fill: currentColor; stroke: white; stroke-width: 1.5; }
.antenna-marker .antenna-glyph { fill: none; stroke: white; stroke-width: 2; }
.antenna-marker .antenna-core { fill: white; stroke: none; }
.antenna-operator-colors { position: absolute; right: -5px; bottom: -2px; display: flex; gap: 1px; padding: 1px; border-radius: 5px; background: white; }
.antenna-operator-colors i { display: block; width: 6px; height: 6px; border-radius: 50%; }
.settings-page { min-height: 100vh; background: #eef1ed; }
.back-map { color: var(--green); font-size: 13px; font-weight: 700; text-decoration: none; }
.settings-shell { width: min(1120px, calc(100% - 36px)); margin: 0 auto; padding: 44px 0 70px; }
.settings-heading h1 { margin: 0 0 28px; font-size: 38px; }
.settings-message { margin-bottom: 18px; padding: 12px 15px; border-radius: 9px; color: var(--green-dark); background: #dff0e9; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.settings-card { border: 1px solid var(--line); border-radius: 16px; padding: 26px; background: white; box-shadow: 0 8px 26px rgba(23,40,37,.07); }
.settings-card h2 { margin: 0 0 7px; font-size: 20px; }
.settings-card > p, .settings-card > div > p { margin: 0 0 22px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.settings-form { display: grid; gap: 15px; }
.field-error { color: #a54035; }
.antenna-setting { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; }
.toggle { position: relative; display: block; width: 52px; height: 29px; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; }
.toggle span { position: absolute; inset: 0; border-radius: 20px; background: #cbd3d0; transition: .2s; }
.toggle span::after { position: absolute; width: 23px; height: 23px; top: 3px; left: 3px; border-radius: 50%; background: white; box-shadow: 0 2px 5px rgba(0,0,0,.2); content: ''; transition: .2s; }
.toggle input:checked + span { background: var(--green); }
.toggle input:checked + span::after { transform: translateX(23px); }
@media (max-width: 760px) { .settings-grid { grid-template-columns: 1fr; } .antenna-setting { grid-column: auto; } }

@media (max-width: 720px) {
    .login-shell { grid-template-columns: 1fr; }
    .brand-panel { min-height: 280px; padding: 36px 28px; }
    .brand-mark { margin-bottom: 18px; }
    .brand-footer { display: none; }
    .login-panel { padding: 42px 24px; }
    .user-meta { display: none; }
    #map { height: 100%; }
    .cell-panel { top: 84px; left: 12px; width: calc(100vw - 24px); max-height: 45vh; padding: 12px; }
}
