/* Тёмная тема с синим неоном. Палитра задаётся здесь, цвета меток на карте — в app.js (STATE_COLORS). */
:root {
    --bg: #050813;
    --bg-2: #0a1022;
    --panel: rgba(14, 22, 44, 0.88);
    --line: rgba(25, 211, 255, 0.22);
    --neon: #19d3ff;
    --neon-2: #4d7cff;
    --text: #e8f1ff;
    --hint: #7e92b8;
    --pink: #ff2d6f;
    --amber: #ffb020;
    --green: #2bff88;
    --slate: #5b6b8c;
    --glow: 0 0 14px rgba(25, 211, 255, 0.45);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
    margin: 0;
    height: 100%;
    background:
        radial-gradient(1100px 560px at 8% -12%, rgba(77, 124, 255, 0.20), transparent 60%),
        radial-gradient(900px 480px at 100% 0%, rgba(25, 211, 255, 0.12), transparent 55%),
        var(--bg);
    color: var(--text);
    font: 15px/1.38 -apple-system, "Segoe UI", Roboto, sans-serif;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 960px;
    margin: 0 auto;
    padding-bottom: env(safe-area-inset-bottom);
}

/* ---------- заголовки ---------- */

.neon-title {
    margin: 0;
    font-size: 19px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #eaf8ff;
    text-shadow: 0 0 8px rgba(25, 211, 255, 0.9), 0 0 24px rgba(77, 124, 255, 0.7);
}

header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px 6px;
}
header .neon-title { flex: 1; }

h2 {
    margin: 22px 0 8px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--neon);
    text-shadow: 0 0 8px rgba(25, 211, 255, 0.5);
}

.status { font-size: 13px; }
.status.live { color: var(--green); text-shadow: 0 0 8px var(--green); }
.status.offline { color: var(--slate); }
.counter { color: var(--hint); font-size: 13px; }
.meta { color: var(--hint); font-size: 13px; }

/* ---------- вкладки ---------- */

.tabs { display: flex; gap: 8px; padding: 6px 16px 10px; }

.tab {
    position: relative;
    flex: 1;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 9px 6px;
    background: var(--panel);
    color: var(--hint);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: box-shadow 0.2s, color 0.2s, border-color 0.2s;
}
.tab:hover { color: var(--text); }
.tab.active {
    color: #fff;
    border-color: var(--neon);
    box-shadow: 0 0 16px rgba(25, 211, 255, 0.5), inset 0 0 14px rgba(25, 211, 255, 0.16);
    text-shadow: 0 0 8px rgba(25, 211, 255, 0.9);
}

.tab-count { color: var(--neon); font-size: 12px; font-weight: 700; }
.tab.active .tab-count { color: #fff; }

.sortbar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px 0;
}
.sort-label { color: var(--hint); font-size: 12px; margin-right: 2px; }

/* ---------- прогресс: уровень, статистика, достижения ---------- */

.progress { margin-top: 14px; }
.h2-note { color: var(--hint); font-weight: 400; letter-spacing: 0; text-transform: none; font-size: 12px; }

.level-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: linear-gradient(135deg, rgba(77, 124, 255, 0.22), rgba(10, 16, 34, 0.92));
    box-shadow: var(--glow);
}
.level-ring {
    flex: none;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid var(--neon);
    box-shadow: 0 0 18px rgba(25, 211, 255, 0.7), inset 0 0 14px rgba(25, 211, 255, 0.35);
    font-size: 28px;
    font-weight: 800;
    color: #fff;
    text-shadow: 0 0 10px var(--neon);
}
.level-info { flex: 1; min-width: 0; }
.level-title { font-size: 18px; font-weight: 800; color: #fff; text-shadow: 0 0 10px rgba(25, 211, 255, 0.6); }
.bar { height: 9px; margin: 7px 0 5px; border-radius: 6px; background: rgba(126, 146, 184, 0.25); overflow: hidden; }
.bar-fill {
    height: 100%;
    width: 0;
    border-radius: 6px;
    background: linear-gradient(90deg, var(--neon-2), var(--neon));
    box-shadow: 0 0 10px var(--neon);
    transition: width 0.6s ease;
}

.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.stat {
    padding: 9px 6px;
    text-align: center;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: var(--panel);
}
.stat .num { font-size: 20px; font-weight: 800; color: #fff; text-shadow: 0 0 8px rgba(25, 211, 255, 0.55); }
.stat .cap { font-size: 11px; color: var(--hint); }

.ach-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.ach {
    padding: 10px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: var(--panel);
}
.ach .icon { font-size: 26px; filter: grayscale(1) opacity(0.45); }
.ach .atitle { margin-top: 2px; font-weight: 700; color: var(--hint); }
.ach .adesc { font-size: 11px; color: var(--hint); margin-top: 1px; }
.ach .bar { height: 5px; margin: 7px 0 2px; }
.ach .abar-note { font-size: 11px; color: var(--hint); }
.ach.unlocked {
    border-color: rgba(255, 176, 32, 0.6);
    background: linear-gradient(160deg, rgba(255, 176, 32, 0.16), var(--panel));
    box-shadow: 0 0 14px rgba(255, 176, 32, 0.28);
}
.ach.unlocked .icon { filter: drop-shadow(0 0 8px rgba(255, 176, 32, 0.8)); }
.ach.unlocked .atitle { color: #ffe3a3; text-shadow: 0 0 8px rgba(255, 176, 32, 0.5); }

/* ---------- рейтинг ---------- */

.rating-periods { margin-left: auto; display: inline-flex; gap: 6px; }
.rank {
    flex: none;
    width: 28px;
    text-align: center;
    font-size: 18px;
    font-weight: 800;
    color: var(--hint);
}
.person.top1 { border-color: rgba(255, 215, 0, 0.7); box-shadow: 0 0 16px rgba(255, 215, 0, 0.3); }
.person.top2 { border-color: rgba(200, 214, 235, 0.6); }
.person.top3 { border-color: rgba(214, 140, 80, 0.6); }
.person .score { text-align: right; font-weight: 800; color: #fff; font-size: 18px; line-height: 1.1; }
.person .score small { display: block; font-weight: 400; font-size: 11px; color: var(--hint); }
.lvl {
    display: inline-block;
    margin-left: 6px;
    padding: 0 6px;
    border-radius: 8px;
    border: 1px solid var(--line);
    color: var(--neon);
    font-size: 11px;
    font-weight: 700;
    vertical-align: 1px;
}

/* ---------- люди ---------- */

.people-list { display: grid; gap: 8px; }
.people-head {
    margin: 12px 2px 2px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--neon);
}
.person {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: linear-gradient(180deg, rgba(20, 31, 62, 0.92), rgba(10, 16, 34, 0.92));
}
.person.offline { opacity: 0.55; }
.person.working {
    border-color: rgba(43, 255, 136, 0.55);
    box-shadow: 0 0 14px rgba(43, 255, 136, 0.25);
}
.person.break { border-color: rgba(255, 176, 32, 0.45); }
.person .avatar { width: 42px; height: 42px; font-size: 17px; border-width: 1px; box-shadow: none; position: relative; }
.person .dot {
    position: absolute;
    right: -2px;
    bottom: -2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid var(--bg-2);
    background: var(--slate);
}
.person .dot.on { background: var(--green); box-shadow: 0 0 8px var(--green); }
.person .info { flex: 1; min-width: 0; }
.person .pname { font-weight: 600; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person .badge { font-size: 12px; font-weight: 600; white-space: nowrap; }
.person .badge.working { color: var(--green); }
.person .badge.break { color: var(--amber); }
.person .badge.inactive { color: var(--hint); }

.tab-badge {
    display: inline-block;
    min-width: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--pink);
    color: #fff;
    font-size: 11px;
    line-height: 18px;
    box-shadow: 0 0 10px var(--pink);
}

.tab-content { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* ---------- карта ---------- */

#map {
    flex: 0 0 40%;
    min-height: 200px;
    margin: 0 16px;
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: var(--glow), inset 0 0 24px rgba(25, 211, 255, 0.08);
    overflow: hidden;
}

/* светлые тайлы OpenStreetMap перекрашиваются в тёмно-синюю гамму */
.leaflet-tile-pane {
    filter: invert(1) hue-rotate(200deg) saturate(0.65) brightness(0.8) contrast(1.08);
}
.leaflet-container { background: var(--bg-2); font: inherit; }
.leaflet-control-attribution {
    background: rgba(5, 8, 19, 0.7) !important;
    color: var(--hint) !important;
}
.leaflet-popup-content-wrapper, .leaflet-popup-tip {
    background: var(--bg-2);
    color: var(--text);
    border: 1px solid var(--line);
    box-shadow: var(--glow);
}

.neon-marker {
    filter: drop-shadow(0 0 7px var(--glow-color, #19d3ff));
}
.neon-marker.pulse { animation: markerPulse 1.6s ease-in-out infinite; }

.leaflet-tooltip.neon-tip {
    background: rgba(5, 8, 19, 0.88);
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--neon);
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    box-shadow: 0 0 8px rgba(25, 211, 255, 0.35);
    text-shadow: 0 0 6px rgba(25, 211, 255, 0.7);
    white-space: nowrap;
}
.leaflet-tooltip.neon-tip::before { display: none; }
.hide-tips .leaflet-tooltip.neon-tip { display: none; }

/* ---------- список событий ---------- */

main { flex: 1; overflow-y: auto; padding: 12px 16px 24px; }

.empty { color: var(--hint); text-align: center; margin-top: 24px; }

ul { list-style: none; margin: 0; padding: 0; }
#list { display: grid; gap: 10px; }

.card {
    --state: var(--slate);
    padding: 11px 13px;
    border-radius: 14px;
    border: 1px solid var(--line);
    border-left: 3px solid var(--state);
    background: linear-gradient(180deg, rgba(20, 31, 62, 0.92), rgba(10, 16, 34, 0.92));
    cursor: pointer;
}
.card.active { --state: var(--pink); }
.card.st-taken { --state: var(--amber); }
.card.st-on_site { --state: var(--neon); }
.card.st-done { --state: var(--green); }
.card.active, .card.st-taken, .card.st-on_site, .card.st-done {
    box-shadow: 0 0 16px color-mix(in srgb, var(--state) 32%, transparent);
}
.card.fresh { animation: cardFlash 2.4s ease-out; }

.card .top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.card .title { font-weight: 700; color: #fff; }
.card .age { font-size: 12px; font-weight: 600; color: var(--hint); white-space: nowrap; }
.card.active .age { color: var(--state); text-shadow: 0 0 8px var(--state); }
.card .addr { margin-top: 3px; font-weight: 500; }
.card .meta { margin-top: 2px; }

.claim {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 9px;
}
.claim .who { font-size: 13px; font-weight: 600; margin-right: auto; }
.claim .who.free { color: var(--hint); }
.claim .who.mine { color: var(--green); text-shadow: 0 0 8px rgba(43, 255, 136, 0.6); }
.claim .who.busy { color: var(--amber); }

.actions { margin-top: 8px; }
.actions a { color: var(--neon); text-decoration: none; font-size: 13px; }

/* ---------- кнопки ---------- */

button { font: inherit; cursor: pointer; }
button:disabled { opacity: 0.55; cursor: default; }

.mini {
    border: 1px solid var(--line);
    border-radius: 9px;
    padding: 5px 10px;
    background: rgba(10, 16, 34, 0.9);
    color: var(--text);
    font-size: 12px;
    font-weight: 600;
    transition: box-shadow 0.15s, border-color 0.15s;
}
.mini:hover:not(:disabled) { border-color: var(--neon); box-shadow: 0 0 10px rgba(25, 211, 255, 0.5); }
.mini.selected { border-color: var(--neon); color: #fff; box-shadow: 0 0 12px rgba(25, 211, 255, 0.6); }
.mini.danger { color: var(--pink); }

.btn-primary {
    border: 0;
    border-radius: 11px;
    padding: 9px 16px;
    background: linear-gradient(90deg, var(--neon-2), var(--neon));
    color: #02101a;
    font-weight: 700;
    box-shadow: 0 0 16px rgba(25, 211, 255, 0.55);
}
.btn-primary.small { padding: 5px 12px; font-size: 12px; border-radius: 9px; }

/* ---------- чат ---------- */

.chat-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 4px 16px 12px;
}

.msg {
    align-self: flex-start;
    max-width: 85%;
    padding: 7px 11px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: var(--panel);
}
.msg.mine {
    align-self: flex-end;
    border-color: var(--neon);
    box-shadow: 0 0 12px rgba(25, 211, 255, 0.35);
}
.msg .who { font-size: 12px; color: var(--neon); font-weight: 600; }
.msg .who .time { color: var(--hint); font-weight: 400; margin-left: 6px; }
.msg .text { margin-top: 1px; overflow-wrap: anywhere; white-space: pre-wrap; }

.chat-form { display: flex; gap: 8px; padding: 8px 16px 12px; }
.chat-form input {
    flex: 1;
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 10px 12px;
    background: var(--panel);
    color: var(--text);
    font: inherit;
    outline: none;
}
.chat-form input:focus { border-color: var(--neon); box-shadow: var(--glow); }

/* ---------- профиль ---------- */

.profile { padding: 8px 16px 32px; overflow-y: auto; }

.who-row, .who { display: flex; align-items: center; gap: 14px; }
.who { margin-top: 8px; }

.avatar {
    width: 66px;
    height: 66px;
    border-radius: 50%;
    border: 2px solid var(--neon);
    background: linear-gradient(135deg, var(--neon-2), var(--neon)) center / cover no-repeat;
    box-shadow: var(--glow);
    color: #02101a;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    font-weight: 700;
    flex: none;
}

.name { font-size: 19px; font-weight: 700; color: #fff; }

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

.statuses button, button.wide {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px 6px;
    background: var(--panel);
    color: var(--text);
    transition: box-shadow 0.15s, border-color 0.15s;
}
.statuses button:hover:not(:disabled), button.wide:hover:not(:disabled) { border-color: var(--neon); }
.statuses button.selected {
    border-color: var(--neon);
    color: #fff;
    font-weight: 700;
    box-shadow: 0 0 16px rgba(25, 211, 255, 0.5), inset 0 0 12px rgba(25, 211, 255, 0.14);
}

button.wide { width: 100%; margin-top: 4px; }
button.wide.on {
    border-color: var(--neon);
    background: linear-gradient(90deg, rgba(77, 124, 255, 0.35), rgba(25, 211, 255, 0.25));
    color: #fff;
    box-shadow: var(--glow);
}
button.wide.ghost { margin-top: 28px; color: var(--pink); }

#status-since, #subscription-hint { margin: 8px 0; }
#subscription-hint a { color: var(--neon); }

/* ---------- вход ---------- */

.login { max-width: 420px; margin: 0 auto; padding: 72px 24px; text-align: center; }
.login .neon-title { font-size: 26px; margin-bottom: 10px; }
.login p { color: var(--hint); }
#login-widget { display: flex; justify-content: center; margin: 24px 0; min-height: 40px; }
.error { color: var(--pink); }

/* ---------- всплывающее сообщение ---------- */

.toast {
    position: fixed;
    left: 50%;
    bottom: calc(24px + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    max-width: 88%;
    padding: 10px 16px;
    border-radius: 12px;
    border: 1px solid var(--pink);
    background: rgba(5, 8, 19, 0.95);
    color: #fff;
    box-shadow: 0 0 18px rgba(255, 45, 111, 0.55);
    z-index: 1000;
}

.toast.reward {
    border-color: #ffb020;
    box-shadow: 0 0 22px rgba(255, 176, 32, 0.7);
    font-weight: 700;
    animation: rewardPop 0.5s ease-out;
}

/* ---------- анимации ---------- */

@keyframes rewardPop {
    0% { transform: translateX(-50%) scale(0.7); opacity: 0; }
    70% { transform: translateX(-50%) scale(1.06); opacity: 1; }
    100% { transform: translateX(-50%) scale(1); }
}

@keyframes markerPulse {
    0%, 100% { filter: drop-shadow(0 0 4px var(--glow-color, #19d3ff)); }
    50% { filter: drop-shadow(0 0 13px var(--glow-color, #19d3ff)); }
}

@keyframes cardFlash {
    0% { box-shadow: 0 0 30px var(--state); background: color-mix(in srgb, var(--state) 22%, #0a1022); }
    100% { box-shadow: 0 0 16px color-mix(in srgb, var(--state) 32%, transparent); }
}

/* ---------- узкие экраны ---------- */

@media (max-width: 420px) {
    .card .top { flex-direction: column; gap: 0; }
    .statuses button { font-size: 13px; padding: 11px 2px; }
}
