/* Duncan Farming Simulator Dashboard
   One stylesheet for every page. Colours are tokens on :root (dark) and
   :root[data-theme="light"]; base.html picks the theme before the page paints. */

/* ======== tokens ======== */
:root {
    color-scheme: dark;
    --bg: #0b1016;
    --bg-glow-1: rgba(34, 197, 94, 0.14);
    --bg-glow-2: rgba(56, 189, 248, 0.10);
    --bg-2: #121a23;          /* cards */
    --bg-3: #19232e;          /* fields, nested surfaces */
    --hover: rgba(255, 255, 255, 0.045);
    --border: rgba(255, 255, 255, 0.07);
    --border-strong: rgba(255, 255, 255, 0.14);
    --text: #e7edf3;
    --text-2: #c3ccd6;
    --muted: #8d9aa8;
    --faint: #5f6c7a;
    --accent: #22c55e;
    --accent-2: #16a34a;
    --on-accent: #06240f;
    --info: #38bdf8;
    --warn: #f59e0b;
    --danger: #ef4444;
    --sel: #fbbf24;           /* the selected player or vehicle, on maps and in lists */
    --scroll: rgba(255, 255, 255, 0.16);
    --shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 12px 32px -20px rgba(0, 0, 0, 0.7);
    --shadow-lg: 0 24px 60px -24px rgba(0, 0, 0, 0.8);
    --radius: 14px;
    --radius-sm: 10px;
    --ring: 0 0 0 3px color-mix(in srgb, var(--accent) 28%, transparent);
}
:root[data-theme="light"] {
    color-scheme: light;
    --bg: #f3f5f8;
    --bg-glow-1: rgba(34, 197, 94, 0.12);
    --bg-glow-2: rgba(56, 189, 248, 0.10);
    --bg-2: #ffffff;
    --bg-3: #f1f4f8;
    --hover: rgba(15, 23, 42, 0.04);
    --border: rgba(15, 23, 42, 0.08);
    --border-strong: rgba(15, 23, 42, 0.16);
    --text: #0f172a;
    --text-2: #243041;
    --muted: #5b6b7c;
    --faint: #94a3b8;
    --accent: #16a34a;
    --accent-2: #15803d;
    --on-accent: #ffffff;
    --scroll: rgba(15, 23, 42, 0.18);
    --shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 10px 28px -18px rgba(15, 23, 42, 0.25);
    --shadow-lg: 0 24px 60px -24px rgba(15, 23, 42, 0.35);
}

/* ======== base ======== */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.45;
    color: var(--text);
    background: var(--bg);
    background-image:
        radial-gradient(900px 500px at 8% -10%, var(--bg-glow-1), transparent 60%),
        radial-gradient(800px 500px at 100% 0%, var(--bg-glow-2), transparent 60%);
    background-attachment: fixed;
    font-feature-settings: 'cv11', 'ss01';
}
h1 { margin: 0; font-size: 1.1rem; font-weight: 700; letter-spacing: -0.01em; }
h2 { margin: 0 0 10px; font-size: 1rem; font-weight: 700; letter-spacing: -0.01em; }
a { color: var(--accent); }
* { scrollbar-width: thin; scrollbar-color: var(--scroll) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--scroll); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: color-mix(in srgb, var(--accent) 35%, transparent); }

/* ======== layout modes ======== */
body.dash {
    height: 100vh;
    padding: 10px 16px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
body.page { padding: 10px 16px 32px; max-width: 1120px; margin: 0 auto; }
body.page.wide { max-width: 1500px; }
body.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }

/* ======== header ======== */
.header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 12px;
    min-height: 56px;
    padding: 8px 14px;
    margin-bottom: 10px;
    flex-shrink: 0;
    background: color-mix(in srgb, var(--bg-2) 82%, transparent);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
body.page .header { position: sticky; top: 8px; z-index: 30; }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; min-width: 0; flex-shrink: 0; }
.brand h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-logo { height: 34px; width: 34px; object-fit: cover; border-radius: 9px; box-shadow: 0 0 0 1px var(--border); }
.nav { display: flex; flex-wrap: wrap; gap: 2px; margin-left: 6px; padding: 3px; border-radius: 999px; background: var(--bg-3); border: 1px solid var(--border); }
.nav a {
    color: var(--muted); text-decoration: none; font-size: 0.8rem; font-weight: 600;
    padding: 5px 11px; border-radius: 999px; white-space: nowrap;
    transition: background 0.15s, color 0.15s;
}
.nav a:hover { background: var(--hover); color: var(--text); }
.nav a.on { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.user { margin-left: auto; display: flex; align-items: center; gap: 8px; font-size: 0.8rem; color: var(--muted); white-space: nowrap; }
.user a { color: var(--accent); text-decoration: none; font-weight: 600; }
.user form { margin: 0; }
.user .me { display: inline-flex; align-items: center; gap: 7px; color: var(--text-2); font-weight: 600; }
.user .me::before {
    content: attr(data-initial);
    display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--info)); color: var(--on-accent);
    font-size: 0.75rem; font-weight: 800;
}
.legend + .user { margin-left: 12px; }

/* ======== buttons and fields ======== */
button {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    background: var(--accent); color: var(--on-accent);
    border: 0; border-radius: var(--radius-sm); padding: 8px 14px; min-height: 36px;
    cursor: pointer; font: inherit; font-size: 0.85rem; font-weight: 700;
    transition: filter 0.15s, transform 0.08s, background 0.15s, color 0.15s;
}
button:hover { filter: brightness(1.08); }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.45; cursor: not-allowed; filter: none; transform: none; }
button.small { padding: 4px 10px; min-height: 28px; font-size: 0.75rem; }
button.danger { background: var(--danger); color: #fff; }
button.ghost, .modal-head button {
    background: var(--bg-3); color: var(--text-2); border: 1px solid var(--border-strong);
}
button.ghost:hover, .modal-head button:hover { filter: none; background: var(--hover); color: var(--text); border-color: var(--border-strong); }
.user button { padding: 4px 10px; min-height: 28px; font-size: 0.75rem; }

input:not([type=checkbox]):not([type=range]), select, textarea {
    padding: 8px 10px; min-height: 36px;
    background: var(--bg-3); color: var(--text);
    border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    font: inherit; font-size: 0.9rem;
    transition: border-color 0.15s, box-shadow 0.15s;
}
input:not([type=checkbox]):not([type=range]):focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
input::placeholder { color: var(--faint); }
select {
    -webkit-appearance: none; appearance: none; padding-right: 30px; cursor: pointer;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' fill='none' stroke='%238d9aa8' stroke-width='1.8' stroke-linecap='round'/></svg>");
    background-repeat: no-repeat; background-position: right 10px center;
}
select:disabled { opacity: 0.5; cursor: not-allowed; }
input[type=checkbox], input[type=range] { accent-color: var(--accent); }
input[type=checkbox] { width: 15px; height: 15px; margin: 0; cursor: pointer; }
input[type=range] { height: 22px; cursor: pointer; }

/* ======== cards, alerts, badges, tables, forms ======== */
.card {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.card-head h2 { margin: 0; }
.card h2 small { color: var(--faint); font-weight: 500; font-size: 0.75rem; margin-left: 6px; }
.card h3 { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 16px 0 8px; }
.alert { padding: 9px 12px; border-radius: var(--radius-sm); font-size: 0.85rem; margin: 0 0 12px; border: 1px solid transparent; }
.alert.error { background: color-mix(in srgb, var(--danger) 14%, transparent); border-color: color-mix(in srgb, var(--danger) 35%, transparent); color: var(--text); }
.alert.ok { background: color-mix(in srgb, var(--accent) 14%, transparent); border-color: color-mix(in srgb, var(--accent) 35%, transparent); color: var(--text); }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 0.72rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.on { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
.badge.off { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); }
.tag { font-size: 0.65rem; background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); padding: 1px 6px; border-radius: 5px; font-weight: 700; letter-spacing: 0.02em; }
.hint { color: var(--muted); font-size: 0.8rem; margin: 0 0 10px; }
.hint code { background: var(--bg-3); border: 1px solid var(--border); padding: 1px 5px; border-radius: 5px; font-size: 0.75rem; }
.mono { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.cards-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 560px), 1fr)); gap: 12px; align-items: start; }

table.data { width: 100%; border-collapse: collapse; font-size: 0.85rem; font-variant-numeric: tabular-nums; }
table.data th, table.data td { text-align: left; padding: 8px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data th { color: var(--muted); font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; }
table.data tbody tr { transition: background 0.12s; }
table.data tbody tr:hover td { background: var(--hover); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data.compact td, table.data.compact th { padding: 5px 8px; font-size: 0.8rem; }
table.data tr.is-online td { background: color-mix(in srgb, var(--accent) 8%, transparent); }
table.data tr.current td { background: color-mix(in srgb, var(--sel) 14%, transparent); }
table.data em { color: var(--faint); font-style: normal; }
table.data td:last-child, table.data th { white-space: nowrap; }
td.cap { text-transform: capitalize; }
.table-wrap { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; align-items: end; }
.form-grid label { display: flex; flex-direction: column; gap: 5px; font-size: 0.78rem; font-weight: 600; color: var(--muted); }
.form-grid .span2 { grid-column: 1 / -1; }
.form-grid .actions { display: flex; gap: 8px; }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 0; }
.inline-form input:not([type=checkbox]) { min-width: 0; }
.check { display: flex; align-items: center; gap: 6px; font-size: 0.85rem; cursor: pointer; }
.check.inline { display: inline-flex; margin-left: 10px; font-weight: 600; color: var(--text-2); }
.view-box { display: flex; align-items: center; gap: 6px; font-size: 0.78rem; font-weight: 600; color: var(--muted); flex-wrap: wrap; }
.view-box input { width: 74px; }
.view-box small { font-weight: 400; color: var(--faint); }
.srv-edit { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 14px; margin-bottom: 8px; background: var(--bg-3); }
.srv-edit summary { cursor: pointer; font-size: 0.9rem; list-style: none; display: flex; align-items: center; gap: 8px; }
.srv-edit summary::-webkit-details-marker { display: none; }
.srv-edit summary::before { content: "›"; color: var(--muted); font-size: 1.1rem; transition: transform 0.15s; }
.srv-edit[open] summary::before { transform: rotate(90deg); }
.srv-edit summary small { color: var(--faint); margin-left: auto; }
.srv-edit form { margin-top: 12px; }
.btn-link { font-size: 0.8rem; font-weight: 600; color: var(--accent); text-decoration: none; }
.btn-link:hover { text-decoration: underline; }

/* ======== login ======== */
.auth-card { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 14px; padding: 28px 26px 26px; }
.auth-head { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; margin-bottom: 4px; }
.auth-head .header-logo { width: 64px; height: 64px; border-radius: 18px; }
.auth-head h1 { font-size: 1.15rem; }
.auth-sub { margin: -4px 0 0; color: var(--muted); font-size: 0.85rem; }
.auth-card label { display: flex; flex-direction: column; gap: 5px; font-size: 0.78rem; font-weight: 600; color: var(--muted); }
.auth-card input { font-size: 1rem; min-height: 42px; }
.auth-card button[type=submit] { min-height: 42px; font-size: 0.95rem; margin-top: 4px; }

/* ======== dashboard grid ======== */
.dashboard-grid { display: flex; flex-direction: column; gap: 10px; flex: 1; min-height: 0; }
.group { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.row-title {
    display: flex; align-items: center; gap: 8px;
    font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em;
    color: var(--muted); margin: 0 0 6px 4px;
}
.row-title::before { content: ""; width: 3px; height: 12px; border-radius: 2px; background: var(--accent); }
.row { display: flex; gap: 10px; flex: 1; min-height: 0; }
.panel {
    flex: 1;
    display: flex;
    gap: 14px;
    min-height: 0;
    overflow: hidden;
    padding: 10px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.map-container {
    /* Square so marker percentages line up with the map image */
    height: 100%;
    aspect-ratio: 1 / 1;
    flex: none;
    background: #0f172a;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border-strong);
    position: relative;
    cursor: zoom-in;
}
/* Sized and offset by JS so only the chosen part of the map is visible */
.map-view { position: absolute; inset: 0; }
.map-view img { width: 100%; height: 100%; display: block; }
.markers { position: absolute; inset: 0; }

/* ======== markers ======== */
.marker {
    position: absolute;
    width: 12px;
    height: 12px;
    margin: -6px 0 0 -6px;
    border-radius: 50%;
    background: #ef4444;
    border: 2px solid white;
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.35), 0 0 6px rgba(0, 0, 0, 0.7);
}
.marker span {
    position: absolute;
    left: 14px;
    top: -3px;
    white-space: nowrap;
    font-size: 0.65rem;
    font-weight: 700;
    color: white;
    text-shadow: 0 0 3px #000, 0 0 3px #000, 0 1px 2px #000;
}
.vmarker { position: absolute; width: 7px; height: 7px; margin: -3px 0 0 -3px; }
/* Equipment kinds: shared by map markers and legend swatches */
.vmarker, .sw { border: 1px solid rgba(0,0,0,0.7); border-radius: 2px; }
.sw { display: inline-block; width: 9px; height: 9px; flex: none; }
.vmarker.vehicle, .sw.vehicle { background: #ffffff; border: 2px solid #0f172a; }
.vmarker.trailer, .sw.trailer { background: #f59e0b; }
.vmarker.weight, .sw.weight { background: #38bdf8; transform: rotate(45deg); }
.vmarker.seeder, .sw.seeder { background: #22c55e; border-radius: 50%; }
.vmarker.sprayer, .sw.sprayer { background: #a855f7; border-radius: 50%; }
.vmarker.harvest, .sw.harvest { background: #facc15; clip-path: polygon(50% 0, 100% 100%, 0 100%); border: none; border-radius: 0; }
.vmarker.tool, .sw.tool { background: #94a3b8; }
.sw.player { background: #ef4444; border-radius: 50%; }

.legend { margin-left: auto; display: flex; align-items: center; gap: 4px 10px; font-size: 0.74rem; color: var(--muted); white-space: nowrap; }
.legend label, .legend > span { cursor: pointer; display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px; border-radius: 999px; transition: background 0.12s, color 0.12s; }
.legend label:hover { background: var(--hover); color: var(--text); }
.legend > span { cursor: default; }
.legend #updated { color: var(--faint); font-variant-numeric: tabular-nums; }
.legend-bar {
    margin: 0 0 10px; padding: 5px 10px; flex-wrap: wrap; row-gap: 2px; flex-shrink: 0; white-space: normal;
    background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.legend-bar #updated { margin-left: auto; }

/* Field numbers, centred on each field like the in-game map */
.fnum {
    position: absolute;
    transform: translate(-50%, -50%);
    font-size: 0.55rem;
    font-weight: 700;
    color: rgba(255,255,255,0.85);
    text-shadow: 0 0 2px #000, 0 0 2px #000;
    pointer-events: none;
}
body.hide-fnum .fnum { display: none; }
/* Field-area outline, drawn between the map and the markers */
.map-view img.field-overlay { position: absolute; inset: 0; pointer-events: none; }
body.hide-fareas .field-overlay { display: none; }
.big .fnum { font-size: 0.95rem; }

/* ======== enlarged map ======== */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(4, 8, 14, 0.78);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal[hidden] { display: none; }
.modal-box { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.modal-head { display: flex; align-items: center; gap: 16px; color: #fff; font-size: 1.05rem; font-weight: 700; letter-spacing: -0.01em; }
.modal-head button { padding: 4px 12px; min-height: 30px; font-size: 0.8rem; background: rgba(255,255,255,0.08); color: #fff; border-color: rgba(255,255,255,0.18); }
.modal-head button:hover { background: rgba(255,255,255,0.16); color: #fff; }
.modal .map-container { cursor: default; flex: none; aspect-ratio: auto; border-radius: var(--radius); box-shadow: var(--shadow-lg); }
.big .vmarker { width: 12px; height: 12px; margin: -6px 0 0 -6px; }
.big .marker { width: 18px; height: 18px; margin: -9px 0 0 -9px; }
.big .marker span { font-size: 0.85rem; left: 22px; }

/* ======== server info ======== */
.info-container { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.server-title {
    margin: 2px 0 8px 0;
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
select.picker { width: 100%; margin: 0 0 8px; padding: 5px 30px 5px 9px; min-height: 32px; font-size: 0.78rem; flex: none; }
.status-area { flex: 1; min-height: 0; overflow-y: auto; }
.status-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.status-online, .status-offline {
    display: inline-flex; align-items: center; gap: 7px;
    font-weight: 700; font-size: 0.8rem; padding: 3px 9px 3px 7px; border-radius: 999px; margin: 0;
}
.status-online { color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }
.status-offline { color: var(--danger); background: color-mix(in srgb, var(--danger) 14%, transparent); }
.status-online::before, .status-offline::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-online::before { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 60%, transparent); animation: pulse 2.2s ease-out infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 55%, transparent); } 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
.status-count { color: var(--muted); font-size: 0.78rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.status-empty { color: var(--faint); margin: 4px 0; font-size: 0.8rem; font-style: italic; }
.player-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 5px; }
.player-card {
    background: var(--bg-3);
    border: 1px solid var(--border);
    border-left: 3px solid var(--info);
    padding: 7px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s;
}
.player-card:hover { background: var(--hover); border-color: var(--border-strong); border-left-color: var(--info); }
.player-card.selected { border-left-color: var(--sel); border-color: color-mix(in srgb, var(--sel) 45%, transparent); background: color-mix(in srgb, var(--sel) 12%, var(--bg-3)); }
.player-card .top { display: flex; justify-content: space-between; align-items: center; }
.player-card .top strong { color: var(--text); }
.player-card .top time { color: var(--muted); font-size: 0.75em; font-variant-numeric: tabular-nums; }
.player-card .where { color: var(--text-2); font-size: 0.75em; font-weight: 500; margin-top: 2px; }

/* ======== the selected player or vehicle ======== */
.markers .marker, .markers .vmarker { cursor: pointer; }
/* a bigger target than the dot itself, so small markers are easy to click */
.markers .vmarker::after, .markers .marker::after { content: ""; position: absolute; inset: -6px; }
.markers .vmarker.harvest { clip-path: none; background: none; width: 0; height: 0; margin: -4px 0 0 -4px;
    border: 4px solid transparent; border-top: 0; border-bottom: 8px solid #facc15; border-radius: 0; }
.markers .marker.selected, .markers .vmarker.selected {
    z-index: 5;
    filter: drop-shadow(0 0 2px #fff) drop-shadow(0 0 5px var(--sel)) drop-shadow(0 0 5px var(--sel));
    outline: 2px solid var(--sel); outline-offset: 3px;
}
.markers .vmarker.harvest.selected { outline: none; }
.big .markers .vmarker.harvest { border-width: 0 6px 12px; margin: -6px 0 0 -6px; }
.big .vmarker.selected { outline: 2px solid var(--sel); outline-offset: 2px; }
.big .marker.selected { box-shadow: 0 0 0 3px var(--sel); }
body:not(.dash) .markers .marker, body:not(.dash) .markers .vmarker { cursor: default; }
.detail {
    flex: none; margin-top: 8px; padding: 10px 12px; border-radius: var(--radius-sm);
    background: color-mix(in srgb, var(--sel) 9%, var(--bg-2));
    border: 1px solid color-mix(in srgb, var(--sel) 40%, transparent);
    font-size: 0.78rem; max-height: 55%; overflow-y: auto;
}
.detail[hidden] { display: none; }
.detail-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.detail-head strong { display: inline-flex; align-items: center; gap: 6px; font-size: 0.9rem; color: var(--text); overflow-wrap: anywhere; }
.detail-close { background: none; color: var(--muted); padding: 0 6px; min-height: 24px; font-size: 0.85rem; }
.detail-close:hover { background: var(--hover); color: var(--text); filter: none; }
.detail-rows { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 0; }
.detail-rows dt { color: var(--muted); white-space: nowrap; }
.detail-rows dd { margin: 0; color: var(--text); font-weight: 600; overflow-wrap: anywhere; }
.detail-actions { display: flex; align-items: center; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.detail-actions:empty { display: none; }
.detail-float {
    position: absolute; left: 10px; bottom: 10px; z-index: 20; width: min(320px, calc(100% - 20px));
    max-height: 60%; cursor: default; font-size: 0.85rem;
    background: color-mix(in srgb, var(--bg-2) 90%, transparent);
    -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
    box-shadow: var(--shadow-lg);
}

/* ======== history / playback ======== */
.hist-controls { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: end; }
.hist-controls label { display: flex; flex-direction: column; gap: 5px; font-size: 0.72rem; font-weight: 600; color: var(--muted); }
.hist-main { display: grid; grid-template-columns: minmax(0, 3fr) minmax(320px, 2fr); gap: 12px; align-items: start; }
@media (max-width: 1000px) { .hist-main { grid-template-columns: 1fr; } }
.hist-map-card .map-container { height: auto; aspect-ratio: auto; cursor: default; margin: 0 auto; }
.trail { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.trail polyline { fill: none; stroke: var(--sel); stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; opacity: 0.9; }
.playbar { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.playbar-track { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.playbar-track input[type=range] { width: 100%; margin: 0; }
.playbar #h-time { min-width: 150px; text-align: center; color: var(--text-2); }
.playbar #h-play { min-width: 84px; }
.hist-legend { margin: 10px 0 0; justify-content: center; flex-wrap: wrap; }
.hist-log { max-height: 80vh; overflow: auto; }
.vlabel {
    position: absolute; left: 9px; top: -6px; white-space: nowrap; font-size: 0.6rem; font-weight: 600;
    color: white; text-shadow: 0 0 3px #000, 0 0 3px #000; pointer-events: none;
}
/* The strip sits under the slider; its sides are pulled in to line up with the slider's travel */
.activity { position: relative; height: 8px; margin: 0 8px; background: var(--bg-3); border: 1px solid var(--border); border-radius: 5px; overflow: hidden; }
.activity i { position: absolute; top: 0; bottom: 0; min-width: 3px; background: var(--accent); cursor: pointer; transition: filter 0.12s; }
.activity i:hover { filter: brightness(1.2); }
/* periods laid end to end: a thin line where idle time was skipped */
.activity.joined i + i { box-shadow: inset 2px 0 0 var(--bg-2); }
.timeline-note { margin: 8px 0 0; text-align: center; min-height: 1.2em; }
button.time-jump {
    background: none; color: var(--accent); padding: 0; min-height: 0; border-radius: 3px;
    font: inherit; font-weight: 500; text-align: left; cursor: pointer; font-variant-numeric: tabular-nums;
}
button.time-jump:hover { background: none; filter: none; text-decoration: underline; }
.zoom-hint { color: var(--faint); cursor: default; }

/* ======== zoom and drag on maps (mapzoom.js) ======== */
.mapzoom { cursor: grab; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.mapzoom.mapzoom-moved, .modal .mapzoom { touch-action: none; }
.mapzoom.mapzoom-dragging { cursor: grabbing; }
.mapzoom .map-view img { -webkit-user-drag: none; user-select: none; pointer-events: none; }
.mapzoom-ctl {
    position: absolute; top: 8px; right: 8px; z-index: 20;
    display: flex; flex-direction: column; gap: 4px;
}
.mapzoom-ctl button {
    width: 28px; height: 28px; min-height: 0; padding: 0; border-radius: 8px;
    background: rgba(10, 14, 20, 0.72); color: #fff; border: 1px solid rgba(255,255,255,0.22);
    -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
    font-size: 1rem; line-height: 1; font-weight: 700; cursor: pointer;
}
.mapzoom-ctl button:hover { filter: none; background: var(--accent); color: var(--on-accent); border-color: transparent; }
.mapzoom-ctl button[hidden] { display: none; }
.big .mapzoom-ctl button, .big.mapzoom .mapzoom-ctl button { width: 36px; height: 36px; font-size: 1.2rem; }

/* ======== live movement: markers glide between updates ======== */
.markers .marker, .markers .vmarker { transition: left var(--glide, 5s) linear, top var(--glide, 5s) linear; }
.markers .fnum { z-index: 1; }
.markers .vmarker { z-index: 2; }
.markers .marker { z-index: 3; }
@media (prefers-reduced-motion: reduce) {
    .markers .marker, .markers .vmarker { transition: none; }
    .status-online::before { animation: none; }
    * { transition: none !important; }
}

/* ======== pages: vehicles filter ======== */
body.only-used table.data tbody tr:not(.is-online) { display: none; }

/* ======== small screens ======== */
@media (max-width: 900px) {
    body.dash { height: auto; min-height: 100vh; overflow: auto; }
    body.dash, body.page { padding: 8px; }
    body.page .header { position: static; }
    .header { padding: 8px 10px; }
    .brand { flex-shrink: 1; }
    .brand h1 { font-size: 0.95rem; }
    .nav { margin-left: 0; }
    .row { flex-direction: column; }
    .group, .row, .panel { flex: none; }
    .panel { flex-direction: column; overflow: visible; }
    .panel .map-container { width: 100%; height: auto; }
    .info-container { overflow: visible; }
    .status-area { overflow: visible; }
    .form-grid { grid-template-columns: 1fr; }
    .card-head { flex-wrap: wrap; }
    .playbar { flex-wrap: wrap; }
    .playbar-track { flex-basis: 100%; order: -1; }
    .auth-card { padding: 22px 18px; }
}

/* ======== filter toolbars (players, vehicles) ======== */
.filters { display: flex; flex-wrap: wrap; align-items: end; gap: 10px 14px; padding: 12px 16px; }
.filters label { display: flex; flex-direction: column; gap: 5px; font-size: 0.72rem; font-weight: 600; color: var(--muted); }
.filters label.check { flex-direction: row; align-items: center; min-height: 36px; font-size: 0.82rem; color: var(--text-2); }
.filters input[type=search] { min-width: 180px; }
.filters #f-count { margin: 0 0 9px auto; }
.filters #f-reset { margin-bottom: 1px; }
.filters #f-reset[hidden] { display: none; }
tr.no-match[hidden], tr.frow[hidden] { display: none; }

/* ======== account menu ======== */
.menu { position: relative; }
.menu > summary { list-style: none; display: inline-flex; align-items: center; gap: 7px; cursor: pointer; padding: 3px 10px 3px 3px; border-radius: 999px; border: 1px solid transparent; transition: background 0.12s, border-color 0.12s; }
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary::after { content: ""; width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg) translateY(-2px); opacity: 0.7; }
.menu > summary:hover, .menu[open] > summary { background: var(--bg-3); border-color: var(--border); color: var(--text); }
.menu-list {
    position: absolute; right: 0; top: calc(100% + 8px); min-width: 220px; z-index: 50;
    display: flex; flex-direction: column; padding: 6px;
    background: var(--bg-2); border: 1px solid var(--border-strong); border-radius: 12px; box-shadow: var(--shadow-lg);
}
.menu-head { padding: 8px 10px 9px; font-size: 0.72rem; color: var(--muted); border-bottom: 1px solid var(--border); margin-bottom: 4px; white-space: normal; }
.menu-head strong { color: var(--text); }
.menu-sep { height: 1px; background: var(--border); margin: 4px 0; }
.menu-list form { margin: 0; display: flex; }
.menu-item, .menu-list button.menu-item {
    display: flex; width: 100%; justify-content: flex-start; text-align: left;
    background: none; color: var(--text-2); border: 0; border-radius: 8px;
    padding: 8px 10px; min-height: 0; font-size: 0.85rem; font-weight: 500; text-decoration: none; cursor: pointer;
}
.menu-item:hover, .menu-list button.menu-item:hover { background: var(--hover); color: var(--text); filter: none; }
.menu-item.on { color: var(--accent); }
#theme-toggle::before { content: "☀  Light theme"; white-space: pre; }
:root[data-theme="light"] #theme-toggle::before { content: "☾  Dark theme"; }

/* ======== profile ======== */
.profile-card { display: flex; align-items: center; gap: 16px; }
.avatar { display: inline-grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; flex: none;
    background: linear-gradient(135deg, var(--accent), var(--info)); color: var(--on-accent); font-size: 1.4rem; font-weight: 800; }
.avatar::before { content: attr(data-initial); }
.profile-text h2 { margin: 0 0 4px; font-size: 1.15rem; }
.profile-text .hint { margin: 0; display: flex; align-items: center; }
