:root {
    --bg: #07111d;
    --bg-2: #0c1d33;
    --panel: rgba(11, 24, 42, 0.92);
    --panel-2: rgba(8, 17, 31, 0.95);
    --panel-strong: #060f1b;
    --text: #edf4ff;
    --muted: #91a7c7;
    --line: #223754;
    --accent: #2f6df6;
    --accent-dark: #1f56cc;
    --success: #2da56c;
    --error: #db5b5b;
    --warning: #f2b544;
    --shadow: 0 26px 70px rgba(0, 0, 0, 0.45);
    --radius: 18px;
    --radius-sm: 12px;
    --panel-tint: rgba(47, 109, 246, 0.12);
    --font-display: "Bahnschrift", "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font-display);
    background:
        radial-gradient(circle at top left, rgba(47, 109, 246, 0.18), transparent 28%),
        radial-gradient(circle at bottom right, rgba(17, 41, 84, 0.32), transparent 36%),
        linear-gradient(180deg, var(--bg-2), var(--bg));
    color: var(--text);
}

body.theme-police {
    --accent: #2c7be5;
    --accent-dark: #1c5cae;
    --panel-tint: rgba(44, 123, 229, 0.14);
    background:
        linear-gradient(180deg, rgba(6, 12, 20, 0.92), rgba(5, 11, 18, 0.98)),
        repeating-linear-gradient(0deg, rgba(124, 155, 198, 0.05) 0 1px, transparent 1px 48px),
        repeating-linear-gradient(90deg, rgba(124, 155, 198, 0.05) 0 1px, transparent 1px 48px),
        linear-gradient(180deg, #09111b, #050b12);
}

body.theme-fireems {
    --accent: #d64f36;
    --accent-dark: #ab3d2a;
    --panel-tint: rgba(214, 79, 54, 0.15);
    background:
        radial-gradient(circle at top right, rgba(214, 79, 54, 0.14), transparent 24%),
        repeating-linear-gradient(0deg, rgba(255, 171, 142, 0.05) 0 1px, transparent 1px 48px),
        repeating-linear-gradient(90deg, rgba(255, 171, 142, 0.04) 0 1px, transparent 1px 48px),
        linear-gradient(180deg, #170c0a, #0b0f14);
}

body.theme-mdt .card,
body.theme-police .card,
body.theme-fireems .card {
    background:
        linear-gradient(180deg, rgba(10, 20, 34, 0.94), rgba(6, 13, 24, 0.98)),
        linear-gradient(90deg, transparent, transparent);
    position: relative;
}

body.theme-mdt .card::before,
body.theme-police .card::before,
body.theme-fireems .card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 3px;
    border-radius: var(--radius) var(--radius) 0 0;
    background: linear-gradient(90deg, var(--accent), transparent 72%);
    opacity: 0.8;
}

.shell {
    width: min(1240px, calc(100vw - 2rem));
    margin: 0 auto;
    padding: 2rem 0 3rem;
}

.landing-page .shell {
    padding-top: 4rem;
}

.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    backdrop-filter: blur(10px);
}

.app-shell {
    display: grid;
    grid-template-columns: 310px minmax(0, 1fr);
    gap: 1rem;
    align-items: start;
}

.sidebar,
.workspace {
    display: grid;
    gap: 1rem;
    align-content: start;
}

.sidebar-title {
    margin-bottom: 0.45rem;
}

.sidebar-subtitle {
    margin: 0;
    color: var(--muted);
}

.sidebar-nav {
    display: grid;
    gap: 0.6rem;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.9rem 1rem;
    border-radius: 12px;
    text-decoration: none;
    color: var(--text);
    background: rgba(8, 18, 31, 0.88);
    border: 1px solid var(--line);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-size: 0.78rem;
}

.sidebar-nav a.active {
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.08), transparent), var(--accent);
    border-color: rgba(255, 255, 255, 0.14);
}

.cad-meta {
    display: grid;
    gap: 0.7rem;
}

.dense-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stat-card {
    background:
        linear-gradient(180deg, rgba(8, 18, 31, 0.96), rgba(4, 10, 18, 0.98)),
        var(--panel);
}

.section-title,
.action-strip {
    display: flex;
    gap: 1rem;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
}

.hero,
.status-grid,
.grid,
.auth-grid {
    display: grid;
    gap: 1rem;
}

.hero {
    grid-template-columns: 1.45fr 1fr;
    align-items: center;
}

.status-grid {
    grid-template-columns: repeat(3, 1fr);
}

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

.three-column {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.dashboard-shell {
    display: grid;
    gap: 1rem;
}

.eyebrow {
    margin: 0 0 0.7rem;
    color: var(--accent);
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

h1,
h2 {
    margin-top: 0;
    letter-spacing: 0.01em;
}

.lede {
    color: var(--muted);
    max-width: 48rem;
}

.status-grid article,
.list-item {
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 1rem;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent),
        rgba(6, 16, 29, 0.82);
}

.status-grid span,
.list-item span,
label {
    display: block;
    color: var(--muted);
    font-size: 0.92rem;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.topbar-actions,
.button-row,
.inline-form,
.list-head,
.data-chip-row {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
}

.page-nav {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.page-nav a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.72rem 1rem;
    border-radius: 999px;
    text-decoration: none;
    color: #dce8ff;
    background: rgba(15, 30, 53, 0.92);
    border: 1px solid var(--line);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 0.81rem;
}

.page-nav a.active {
    background: var(--accent);
    color: white;
    border-color: rgba(255, 255, 255, 0.12);
}

.pill,
.badge,
.data-chip {
    border-radius: 999px;
    padding: 0.42rem 0.8rem;
    font-size: 0.84rem;
    background: rgba(15, 32, 58, 0.9);
    color: #dce8ff;
    border: 1px solid rgba(59, 92, 138, 0.55);
}

.badge.status-available {
    background: rgba(45, 165, 108, 0.14);
    color: #7ef0b8;
}

.badge.status-busy {
    background: rgba(242, 181, 68, 0.14);
    color: #ffd37c;
}

.badge.status-travel {
    background: rgba(44, 123, 229, 0.16);
    color: #9ac4ff;
}

.badge.status-offline {
    background: rgba(219, 91, 91, 0.14);
    color: #ff9a9a;
}

.badge.open {
    background: rgba(45, 165, 108, 0.12);
    color: #6be3aa;
}

.badge.assigned {
    background: rgba(242, 181, 68, 0.12);
    color: #ffd37c;
}

.badge.closed {
    background: rgba(219, 91, 91, 0.12);
    color: #ff9a9a;
}

.metric {
    font-size: 2.25rem;
    margin: 0.35rem 0 0;
    font-weight: 800;
    color: #ffffff;
}

.subtle-text {
    color: var(--muted);
}

.form-card,
form {
    display: grid;
    gap: 0.85rem;
}

input,
select,
textarea,
button,
.button-link {
    font: inherit;
}

input,
select,
textarea {
    width: 100%;
    margin-top: 0.4rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 0.85rem 0.95rem;
    background: rgba(6, 14, 25, 0.98);
    color: var(--text);
}

button,
.button-link {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 0.4rem;
    border: 0;
    border-radius: 999px;
    padding: 0.85rem 1.1rem;
    background: var(--accent);
    color: white;
    text-decoration: none;
    cursor: pointer;
    transition: transform 160ms ease, background 160ms ease, opacity 160ms ease;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.83rem;
    font-weight: 700;
}

button:hover,
.button-link:hover {
    transform: translateY(-1px);
    background: var(--accent-dark);
}

button.secondary,
.button-link.subtle {
    background: var(--panel-strong);
}

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

.stack {
    display: grid;
    gap: 0.8rem;
}

.notice.success {
    border-color: rgba(45, 165, 108, 0.35);
}

.notice.error {
    border-color: rgba(219, 91, 91, 0.35);
}

.compact-form {
    gap: 0.65rem;
}

.live-map {
    position: relative;
    min-height: 360px;
    aspect-ratio: 3 / 2;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    overflow: hidden;
    background:
        radial-gradient(circle at 20% 18%, rgba(47, 109, 246, 0.16), transparent 18%),
        radial-gradient(circle at 78% 62%, rgba(8, 17, 31, 0.3), transparent 24%),
        linear-gradient(180deg, #10203a 0%, #091322 100%);
    cursor: zoom-in;
}

.live-map:fullscreen {
    width: 100vw;
    height: 100vh;
    max-width: none;
    border-radius: 0;
    border: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at 20% 18%, rgba(47, 109, 246, 0.18), transparent 18%),
        radial-gradient(circle at 78% 62%, rgba(8, 17, 31, 0.34), transparent 24%),
        linear-gradient(180deg, #10203a 0%, #091322 100%);
    cursor: zoom-out;
}

.live-map:fullscreen .live-map-base {
    background-size: contain;
}

.live-map.hide-grid .live-map-grid {
    opacity: 0;
}

.live-map.hide-labels .live-map-label {
    display: none;
}

.live-map-grid {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(145, 167, 199, 0.08) 1px, transparent 1px),
        linear-gradient(90deg, rgba(145, 167, 199, 0.08) 1px, transparent 1px);
    background-size: 10% 10%;
    transition: opacity 160ms ease, transform 160ms ease;
}

.live-map-base {
    position: absolute;
    inset: 0;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    opacity: 0.98;
    transition: transform 160ms ease;
}

.live-map-markers {
    position: absolute;
    inset: 0;
    transition: transform 160ms ease;
}

.live-map-base,
.live-map-grid,
.live-map-markers {
    transform: translate(var(--map-translate-x, 0px), var(--map-translate-y, 0px)) scale(var(--map-scale, 1));
    transform-origin: center center;
}

.live-map.is-draggable {
    cursor: grab;
}

.live-map.is-dragging {
    cursor: grabbing;
}

.live-map-marker {
    position: absolute;
    transform: translate(-50%, -50%);
    min-width: 12px;
    min-height: 12px;
    border-radius: 999px;
    border: 2px solid #fff;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
}

.live-map-marker::after {
    content: "";
    position: absolute;
    inset: -8px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.16);
}

.live-map-marker.police {
    background: #1b4fd1;
}

.live-map-marker.fire {
    background: #c43d2d;
}

.live-map-marker.ems {
    background: #238b45;
}

.live-map-label {
    position: absolute;
    top: 12px;
    left: 14px;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    background: rgba(6, 15, 27, 0.95);
    border: 1px solid var(--line);
    color: #d8e6ff;
    font-size: 0.8rem;
    white-space: nowrap;
}

.map-controls {
    position: absolute;
    top: 18px;
    left: 18px;
    z-index: 3;
    display: grid;
    gap: 0.55rem;
}

.map-control-button {
    width: 46px;
    min-width: 46px;
    height: 46px;
    padding: 0;
    border-radius: 12px;
    background: rgba(17, 28, 44, 0.96);
    border: 1px solid rgba(88, 112, 145, 0.36);
    box-shadow: 0 14px 24px rgba(0, 0, 0, 0.28);
    font-size: 0.68rem;
    letter-spacing: 0.06em;
}

.map-control-button:hover {
    background: rgba(35, 54, 80, 0.98);
}

.map-control-button.is-active {
    box-shadow: inset 0 0 0 1px rgba(111, 175, 255, 0.22), 0 14px 24px rgba(0, 0, 0, 0.28);
}

.feed-hidden {
    display: none;
}

.map-legend {
    position: absolute;
    right: 16px;
    bottom: 16px;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    z-index: 2;
}

.map-legend-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.35rem 0.65rem;
    border-radius: 999px;
    background: rgba(5, 13, 24, 0.92);
    border: 1px solid var(--line);
    color: #dce8ff;
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.map-legend-chip::before {
    content: "";
    width: 9px;
    height: 9px;
    border-radius: 999px;
    background: currentColor;
}

.map-legend-chip.police {
    color: #6ea4ff;
}

.map-legend-chip.fire {
    color: #ff8e6e;
}

.map-legend-chip.ems {
    color: #74da9a;
}

.unit-status-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.unit-status-card {
    display: grid;
    gap: 0.75rem;
}

.status-button-grid {
    display: grid;
    gap: 0.55rem;
    grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
}

.status-button-grid .inline-form {
    display: block;
}

.status-button-grid button {
    width: 100%;
    padding-inline: 0.7rem;
}

.is-current-status {
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.07), transparent), var(--panel-strong);
}


@media (max-width: 840px) {
    .app-shell,
    .hero,
    .status-grid,
    .auth-grid,
    .two-column,
    .three-column,
    .topbar {
        grid-template-columns: 1fr;
        display: grid;
    }

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

    .topbar-actions {
        justify-content: flex-start;
    }
}
