:root {
    --bg: #f4f6f8;
    --panel: #ffffff;
    --text: #17202a;
    --muted: #667085;
    --border: #d9dee6;
    --accent: #1769aa;
    --good: #1d8b4c;
    --warn: #a76800;
    --bad: #b42318;
    --operator: #5b4bb7;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--text); background: var(--bg); }
button, select, input { font: inherit; }

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
    min-height: 72px;
    padding: 12px 18px;
    border-bottom: 1px solid var(--border);
    background: var(--panel);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.topbar h1 { margin: 0; font-size: 22px; }
.topbar p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.status-strip { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.pill { border-radius: 999px; padding: 5px 10px; background: #edf2f7; font-size: 12px; font-weight: 700; }
.pill.good { background: #e7f6ed; color: #17683b; }
.pill.warn { background: #fff3d6; color: #815800; }
.pill.bad { background: #fdecea; color: #a8241b; }
.muted { color: var(--muted); }

.main-grid {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr) 340px;
}
.sidebar, .details { background: var(--panel); min-width: 0; overflow: auto; }
.sidebar { border-right: 1px solid var(--border); }
.details { border-left: 1px solid var(--border); }

.controls { padding: 14px; display: grid; gap: 10px; border-bottom: 1px solid var(--border); }
.controls label:not(.check) { display: grid; gap: 5px; color: var(--muted); font-size: 12px; }
.controls select, .controls button { min-height: 40px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel); color: var(--text); padding: 0 10px; }
.controls button { cursor: pointer; font-weight: 650; }
.controls button:hover { border-color: var(--accent); }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; }

.section-title { padding: 12px 14px; display: flex; justify-content: space-between; border-bottom: 1px solid var(--border); }
.drone-list { display: grid; }
.drone-row { width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--border); background: transparent; color: inherit; padding: 12px 14px; cursor: pointer; }
.drone-row:hover, .drone-row.selected { background: #eef5fb; }
.drone-row .line1 { display: flex; gap: 8px; justify-content: space-between; align-items: center; }
.drone-row .name { font-weight: 750; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drone-row .meta { margin-top: 5px; font-size: 12px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #98a2b3; flex: 0 0 auto; }
.dot.active { background: var(--good); }
.dot.sim { outline: 2px solid #d29b00; }

.map-wrap { position: relative; min-width: 0; min-height: 520px; }
#map { position: absolute; inset: 0; background: #dfe7ec; }
.map-empty { position: absolute; z-index: 600; left: 50%; top: 16px; transform: translateX(-50%); background: rgba(255,255,255,.92); color: #344054; border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px; display: none; gap: 4px; flex-direction: column; align-items: center; box-shadow: 0 3px 14px rgba(0,0,0,.08); }
.map-empty span { font-size: 12px; color: var(--muted); }

.drone-icon, .operator-icon { background: transparent; border: none; }
.drone-icon .marker-body {
    width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
    background: #fff; border: 3px solid #1f6fa8; box-shadow: 0 2px 8px rgba(0,0,0,.3); font-size: 15px;
}
.drone-icon.stale .marker-body { opacity: .55; filter: grayscale(.7); }
.drone-icon.sim .marker-body { border-style: dashed; }
.drone-icon .heading { display: inline-block; transform-origin: center; }
.operator-icon .marker-body {
    width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
    background: #fff; border: 3px solid var(--operator); box-shadow: 0 2px 8px rgba(0,0,0,.3); font-size: 14px;
}

.details { padding: 16px; }
.details h2 { margin: 0 0 4px; font-size: 20px; word-break: break-word; }
.details .sub { color: var(--muted); font-size: 12px; margin-bottom: 16px; word-break: break-all; }
.details-placeholder { min-height: 180px; display: grid; place-content: center; text-align: center; color: var(--muted); gap: 5px; }
.detail-section { margin: 16px 0 0; }
.detail-section h3 { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 0 0 8px; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px 10px; font-size: 13px; }
.detail-grid .value { text-align: right; font-variant-numeric: tabular-nums; word-break: break-word; }
.action-row { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.action-row button { min-height: 38px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel); color: var(--text); padding: 0 10px; cursor: pointer; }

@media (max-width: 1050px) {
    .main-grid { grid-template-columns: 280px minmax(0, 1fr); grid-template-rows: minmax(520px, 1fr) auto; }
    .details { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--border); max-height: 360px; }
}

@media (max-width: 720px) {
    .topbar { align-items: flex-start; flex-direction: column; }
    .status-strip { justify-content: flex-start; }
    .main-grid { display: flex; flex-direction: column; }
    .sidebar { border-right: 0; border-bottom: 1px solid var(--border); max-height: 320px; }
    .map-wrap { min-height: 480px; }
    .details { max-height: none; }
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #11151a;
        --panel: #171c22;
        --text: #e8edf2;
        --muted: #9aa4b2;
        --border: #303741;
        --accent: #6db4e8;
    }
    .drone-row:hover, .drone-row.selected { background: #1d2a35; }
    .map-empty { background: rgba(23,28,34,.94); color: var(--text); }
    .controls select { color-scheme: dark; }
}
