/* Village Planning — dashboard control styling (blue/white theme) */
.vp-select {
    width: 100%;
    margin-top: 2px;
    border-radius: 0.5rem;
    border: 1px solid rgb(209 213 219);
    background-color: #fff;
    padding: 0.4rem 0.6rem;
    font-size: 0.875rem;
    line-height: 1.25rem;
    color: rgb(17 24 39);
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.03);
}
.vp-select:focus {
    outline: 2px solid transparent;
    outline-offset: 2px;
    border-color: #1E3A5F;
    box-shadow: 0 0 0 1px #1E3A5F;
}
.dark .vp-select {
    background-color: rgb(255 255 255 / 0.05);
    border-color: rgb(255 255 255 / 0.1);
    color: rgb(243 244 246);
}
.dark .vp-select option { color: #111827; }
.leaflet-container { font: inherit; }

/* ============================================================
   Dark-navy sidebar (aligned to the logo), light text + icons.
   Applies in both light and dark mode.
   ============================================================ */
.fi-sidebar,
.fi-sidebar-header,
.fi-sidebar-nav {
    background-color: #16304d !important;
    border-color: rgba(255, 255, 255, 0.08) !important;
}
.fi-sidebar-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.10) !important;
}

/* Group headings */
.fi-sidebar-group-label {
    color: #8fb0d4 !important;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.68rem;
}
.fi-sidebar-group-collapse-button,
.fi-sidebar-group-collapse-button .fi-icon {
    color: #8fb0d4 !important;
}

/* Nav items — light text + icons that stand out */
.fi-sidebar-item-button {
    color: #dbe7f4 !important;
}
.fi-sidebar-item-icon,
.fi-sidebar-item-button .fi-icon {
    color: #a9c6e4 !important;
}
.fi-sidebar-item-button:hover {
    background-color: rgba(255, 255, 255, 0.09) !important;
}
.fi-sidebar-item-button:hover,
.fi-sidebar-item-button:hover .fi-sidebar-item-icon,
.fi-sidebar-item-button:hover .fi-icon {
    color: #ffffff !important;
}

/* Active item — highlighted */
.fi-sidebar-item.fi-active > .fi-sidebar-item-button,
.fi-sidebar-item-active > .fi-sidebar-item-button {
    background-color: rgba(96, 165, 250, 0.22) !important;
}
.fi-sidebar-item.fi-active > .fi-sidebar-item-button,
.fi-sidebar-item.fi-active > .fi-sidebar-item-button .fi-sidebar-item-icon,
.fi-sidebar-item.fi-active > .fi-sidebar-item-button .fi-icon,
.fi-sidebar-item-active > .fi-sidebar-item-button,
.fi-sidebar-item-active > .fi-sidebar-item-button .fi-icon {
    color: #ffffff !important;
}

/* Sidebar badges (e.g. Roles count) */
.fi-sidebar-item .fi-badge {
    background-color: rgba(255, 255, 255, 0.16) !important;
    color: #eaf2fb !important;
}

/* Collapse-sidebar toggle button */
.fi-sidebar-close-overlay-button,
.fi-topbar .fi-icon-btn { color: inherit; }

/* Hide brand text when the desktop sidebar is collapsed (keeps just the logo). */
.fi-sidebar-collapsed .vp-brand-text { display: none !important; }

/* Label spans are coloured separately by Filament — brighten them explicitly. */
.fi-sidebar-item-label {
    color: #e6eefb !important;
    font-weight: 500;
}
.fi-sidebar-item-button:hover .fi-sidebar-item-label {
    color: #ffffff !important;
}
.fi-sidebar-item.fi-active > .fi-sidebar-item-button .fi-sidebar-item-label,
.fi-sidebar-item-active > .fi-sidebar-item-button .fi-sidebar-item-label {
    color: #ffffff !important;
    font-weight: 600;
}

/* ============================================================
   Brand (logo + Village Planner + v1.1.0).
   Layout + colour adapt to context:
     • base / sidebar → compact row, small text
     • login (.fi-simple-header) → logo ABOVE name, centred, larger
   ============================================================ */
/* Filament wraps the brand in a fixed-height (1.5rem) .fi-logo box; let it grow
   to our two-line brand so the login heading below never overlaps it. */
.fi-logo { height: auto !important; }

.vp-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
.vp-brand-logo {
    width: 2.1rem;
    height: 2.1rem;
    flex: none;                 /* never let the text squeeze the logo */
    border-radius: 0.5rem;
    background: #fff;
    padding: 0.18rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.10);
    object-fit: contain;
}
.vp-brand-name {
    font-weight: 700;
    font-size: 0.82rem;
    line-height: 1.15;
    letter-spacing: -0.01em;
    white-space: nowrap;
    color: #1e3a5f;
}
.vp-brand-version {
    font-size: 0.66rem;
    font-weight: 500;
    margin-top: 1px;
    color: #64748b;
}

/* Dark mode (login screen in dark) */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .vp-brand-name { color: #e8eef7; }
    :root:not([data-theme="light"]) .vp-brand-version { color: #94a3b8; }
}
:root[data-theme="dark"] .vp-brand-name { color: #e8eef7; }
:root[data-theme="dark"] .vp-brand-version { color: #94a3b8; }

/* Sidebar — compact row, smaller text, light colour on the navy background. */
.fi-sidebar .vp-brand-name { color: #ffffff !important; font-size: 0.8rem; }
.fi-sidebar .vp-brand-version { color: #93c5fd !important; }
.fi-sidebar-header { padding-top: 0.85rem !important; padding-bottom: 0.85rem !important; }

/* Login screen — logo ABOVE the app name, centred, larger logo.
   Order top→bottom: logo · Village Planner · v1.1.0 · Sign in · form. */
.fi-simple-header .vp-brand {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.3rem;
}
/* On the white login card the navy emblem needs no chip — plain image, no
   background / border / shadow, minimal margin. */
.fi-simple-header .vp-brand-logo {
    width: 9.5rem;
    height: 9.5rem;
    padding: 0;
    margin: 0;
    border: none;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}
.fi-simple-header .vp-brand-name { font-size: 1.3rem; white-space: normal; margin-top: 0.1rem; }
.fi-simple-header .vp-brand-version { font-size: 0.78rem; letter-spacing: 0.04em; }

/* Space Filament's native "Sign in" heading from the brand above it. */
.fi-simple-header .fi-simple-header-heading { margin-top: 0.5rem; }

/* ============================================================
   Login screen fit — keep it a single, un-scrolled simple page.
   The bigger logo made the card tall; shift it up + tighten spacing
   so it fits the viewport on desktop and mobile without scrolling.
   ============================================================ */
.fi-simple-layout { min-height: 100dvh; }
.fi-simple-main {
    margin-top: 1.75rem !important;
    margin-bottom: 1.75rem !important;
    padding-top: 1.75rem !important;
    padding-bottom: 1.75rem !important;
}
.fi-simple-header { margin-bottom: 0.25rem; }
.fi-simple-page { row-gap: 1rem !important; }

/* Shorter viewports / mobile: shrink the logo + spacing so no scroll is needed. */
@media (max-height: 760px), (max-width: 480px) {
    .fi-simple-header .vp-brand-logo { width: 6.5rem; height: 6.5rem; }
    .fi-simple-header .vp-brand-name { font-size: 1.15rem; }
    .fi-simple-main {
        margin-top: 1rem !important;
        margin-bottom: 1rem !important;
        padding-top: 1.25rem !important;
        padding-bottom: 1.25rem !important;
    }
    .fi-simple-header .fi-simple-header-heading { margin-top: 0.35rem; }
    .fi-simple-page { row-gap: 0.75rem !important; }
}

/* ============================================================
   Mobile data-entry: force Filament form grids to ONE column
   below the lg breakpoint so fields aren't cramped. (The base
   grid-cols-[--cols-default] class doesn't resolve on some
   builds, leaving a broken multi-column layout on phones.)
   ============================================================ */
@media (max-width: 1023px) {
    .fi-fo-component-ctn {
        grid-template-columns: repeat(1, minmax(0, 1fr)) !important;
    }
    /* Any field asked to span >1 column just spans the single column. */
    .fi-fo-component-ctn > * {
        grid-column: span 1 / span 1 !important;
    }
}

/* ---- Projected LPV count table ---- */
.vp-num { font-variant-numeric: tabular-nums; }
.vp-lpv-sticky { position: sticky; left: 0; background: #fff; }
.dark .vp-lpv-sticky { background: rgb(17 24 39); }
.vp-lpv-winner { background: rgb(240 253 244); border: 1px solid rgb(187 247 208); }
.dark .vp-lpv-winner { background: rgba(74, 222, 128, .1); border-color: rgba(74, 222, 128, .25); }
.vp-lpv-elected { font-weight: 700; color: rgb(21 128 61); }
.dark .vp-lpv-elected { color: rgb(74 222 128); }
.vp-lpv-excluded .vp-lpv-votes { text-decoration: line-through; color: rgb(220 38 38); }
.dark .vp-lpv-excluded .vp-lpv-votes { color: rgb(248 113 113); }
.vp-lpv-notes { list-style: none; padding: 0; }

/* ---- Dashboards: chips, hero, KPIs, heatmaps, progress ---- */
.vp-chips { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.vp-chips-label { font-size: .75rem; color: rgb(100 116 139); margin-right: .25rem; }
.vp-chip { display: inline-flex; align-items: center; gap: .35rem; font-size: .75rem; font-weight: 500;
    padding: .25rem .6rem; border-radius: 9999px; background: rgb(30 58 95 / .08); color: rgb(30 58 95);
    border: 1px solid rgb(30 58 95 / .15); cursor: pointer; transition: background .15s; }
.vp-chip:hover { background: rgb(30 58 95 / .16); }
.dark .vp-chip { background: rgb(147 197 253 / .12); color: rgb(191 219 254); border-color: rgb(147 197 253 / .25); }
.vp-chip-clear { background: transparent; border-style: dashed; }
.vp-chip-count { margin-left: .5rem; font-size: .7rem; font-weight: 600; padding: .1rem .5rem; border-radius: 9999px;
    background: rgb(30 58 95); color: #fff; vertical-align: middle; }

.vp-hero { position: relative; overflow: hidden; border-radius: 1rem; padding: 1.5rem 1.75rem; color: #fff;
    background: linear-gradient(120deg, #0f2440 0%, #1E3A5F 45%, #2c5a8c 100%); }
.vp-hero::after { content: ''; position: absolute; right: -60px; top: -60px; width: 260px; height: 260px;
    border-radius: 9999px; background: radial-gradient(circle, rgb(255 255 255 / .12), transparent 70%); }
.vp-hero-eyebrow { font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; color: rgb(191 219 254); font-weight: 600; }
.vp-hero-title { font-size: 1.6rem; font-weight: 800; line-height: 1.2; margin-top: .25rem; }
.vp-hero-sub { font-size: .9rem; color: rgb(219 234 254); margin-top: .35rem; max-width: 60rem; }
.vp-hero-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .75rem; margin-top: 1.25rem; position: relative; z-index: 1; }
.vp-hero-stat { background: rgb(255 255 255 / .09); border: 1px solid rgb(255 255 255 / .14); border-radius: .75rem; padding: .7rem .9rem; }
.vp-hero-stat-label { font-size: .7rem; color: rgb(191 219 254); text-transform: uppercase; letter-spacing: .06em; }
.vp-hero-stat-value { font-size: 1.45rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.vp-hero-stat-sub { font-size: .72rem; color: rgb(219 234 254); }

.vp-controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .75rem; align-items: end; }
.vp-label { display: block; font-size: .75rem; font-weight: 500; color: rgb(100 116 139); margin-bottom: .2rem; }
.vp-seg { display: inline-flex; border: 1px solid rgb(203 213 225); border-radius: .6rem; overflow: hidden; }
.dark .vp-seg { border-color: rgb(255 255 255 / .15); }
.vp-seg button { font-size: .8rem; padding: .4rem .8rem; color: rgb(71 85 105); background: transparent; }
.dark .vp-seg button { color: rgb(203 213 225); }
.vp-seg button + button { border-left: 1px solid rgb(203 213 225); }
.dark .vp-seg button + button { border-left-color: rgb(255 255 255 / .15); }
.vp-seg button.is-on { background: rgb(30 58 95); color: #fff; }

.vp-cand-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .75rem; }
.vp-cand-card { border-radius: .8rem; border: 1px solid rgb(226 232 240); padding: .8rem .9rem; background: #fff; position: relative; overflow: hidden; }
.dark .vp-cand-card { border-color: rgb(255 255 255 / .1); background: rgb(255 255 255 / .03); }
.vp-cand-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--c, #94a3b8); }
.vp-cand-name { font-weight: 600; font-size: .88rem; display: flex; align-items: center; gap: .45rem; }
.vp-dot { width: 10px; height: 10px; border-radius: 9999px; display: inline-block; flex: none; background: var(--c, #94a3b8); border: 1px solid rgb(0 0 0 / .12); }
.vp-cand-big { font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums; margin-top: .2rem; }
.vp-cand-meta { font-size: .72rem; color: rgb(100 116 139); }
.vp-bar { height: 6px; border-radius: 9999px; background: rgb(226 232 240); overflow: hidden; margin-top: .45rem; }
.dark .vp-bar { background: rgb(255 255 255 / .1); }
.vp-bar > span { display: block; height: 100%; border-radius: 9999px; background: var(--c, rgb(30 58 95)); }

.vp-table { width: 100%; font-size: .82rem; border-collapse: separate; border-spacing: 0; }
.vp-table th { font-size: .68rem; text-transform: uppercase; letter-spacing: .05em; color: rgb(100 116 139); font-weight: 600;
    text-align: left; padding: .5rem .55rem; border-bottom: 1px solid rgb(226 232 240); white-space: nowrap; position: sticky; top: 0; background: #fff; z-index: 1; }
.dark .vp-table th { background: rgb(24 24 27); border-bottom-color: rgb(255 255 255 / .1); }
.vp-table td { padding: .45rem .55rem; border-bottom: 1px solid rgb(241 245 249); white-space: nowrap; }
.dark .vp-table td { border-bottom-color: rgb(255 255 255 / .05); }
.vp-table tr.is-click { cursor: pointer; }
.vp-table tr.is-click:hover td { background: rgb(30 58 95 / .04); }
.dark .vp-table tr.is-click:hover td { background: rgb(255 255 255 / .04); }
.vp-table .r { text-align: right; font-variant-numeric: tabular-nums; }
.vp-table .muted { color: rgb(148 163 184); }
.vp-scroll { max-height: 640px; overflow: auto; }
.vp-heat { text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; border-radius: .3rem; }
.vp-heat-lead { outline: 2px solid var(--c); outline-offset: -2px; font-weight: 700; }
.vp-pill { display: inline-flex; align-items: center; gap: .35rem; font-size: .75rem; font-weight: 600; padding: .15rem .55rem;
    border-radius: 9999px; background: rgb(241 245 249); }
.dark .vp-pill { background: rgb(255 255 255 / .08); }
.vp-gap { color: rgb(220 38 38); font-weight: 600; }
.vp-progress { display: flex; align-items: center; gap: .5rem; min-width: 140px; }
.vp-progress .vp-bar { flex: 1; margin-top: 0; }
.vp-progress-val { font-size: .75rem; font-variant-numeric: tabular-nums; width: 3.2rem; text-align: right; }
.vp-insight { display: flex; gap: .6rem; align-items: flex-start; font-size: .85rem; padding: .6rem .75rem; border-radius: .6rem;
    background: rgb(30 58 95 / .05); border: 1px solid rgb(30 58 95 / .1); }
.dark .vp-insight { background: rgb(147 197 253 / .06); border-color: rgb(147 197 253 / .15); }
.vp-grid-2 { display: grid; grid-template-columns: 1fr; gap: 1.5rem; }
@media (min-width: 1024px) { .vp-grid-2 { grid-template-columns: 1fr 1fr; } .vp-grid-3-1 { grid-template-columns: 2fr 1fr; } }

/* ---- Voter change-history timeline ---- */
.vp-timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.vp-timeline::before { content: ''; position: absolute; left: 13px; top: 6px; bottom: 6px; width: 2px; background: rgb(226 232 240); }
.dark .vp-timeline::before { background: rgb(255 255 255 / .1); }
.vp-timeline-item { position: relative; padding-left: 2.5rem; padding-bottom: 1.1rem; }
.vp-timeline-item:last-child { padding-bottom: 0; }
.vp-timeline-dot { position: absolute; left: 0; top: 0; width: 28px; height: 28px; border-radius: 9999px; display: grid; place-items: center;
    color: #fff; background: var(--c); box-shadow: 0 0 0 4px #fff; }
.dark .vp-timeline-dot { box-shadow: 0 0 0 4px rgb(24 24 27); }
.vp-timeline-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: .25rem .6rem; font-size: .88rem; }
.vp-timeline-when { font-size: .75rem; color: rgb(148 163 184); margin-left: auto; }
.vp-diff { max-width: 720px; }
.vp-diff td { white-space: normal; }
.vp-diff-old { color: rgb(185 28 28); text-decoration: line-through; text-decoration-color: rgb(185 28 28 / .4); }
.dark .vp-diff-old { color: rgb(252 165 165); }
.vp-diff-new { color: rgb(21 128 61); font-weight: 600; }
.dark .vp-diff-new { color: rgb(134 239 172); }

/* ---- Voter photo / camera field ---- */
.vp-cam { display: flex; flex-direction: column; gap: .75rem; max-width: 420px; }
.vp-cam-frame { position: relative; width: 100%; aspect-ratio: 3 / 4; max-height: 60vh; border-radius: .9rem; overflow: hidden;
    background: rgb(241 245 249); border: 1px dashed rgb(203 213 225); }
.dark .vp-cam-frame { background: rgb(255 255 255 / .04); border-color: rgb(255 255 255 / .15); }
.vp-cam-media { width: 100%; height: 100%; object-fit: cover; display: block; }
.vp-cam-mirror { transform: scaleX(-1); }
.vp-cam-empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .4rem;
    color: rgb(148 163 184); font-size: .85rem; }
.vp-cam-busy { position: absolute; inset: 0; display: grid; place-items: center; background: rgb(15 23 42 / .45); color: #fff; font-weight: 600; }
.vp-cam-row { display: flex; flex-wrap: wrap; gap: .5rem; }
.vp-cam-btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 44px; padding: .5rem .9rem;
    border-radius: .6rem; font-size: .88rem; font-weight: 600; cursor: pointer; border: 1px solid rgb(203 213 225);
    background: #fff; color: rgb(30 41 59); flex: 1 1 auto; }
.dark .vp-cam-btn { background: rgb(255 255 255 / .05); border-color: rgb(255 255 255 / .15); color: rgb(226 232 240); }
.vp-cam-btn-primary { background: rgb(30 58 95); border-color: rgb(30 58 95); color: #fff; }
.dark .vp-cam-btn-primary { background: rgb(59 130 246); border-color: rgb(59 130 246); color: #fff; }
.vp-cam-btn-danger { color: rgb(185 28 28); }
.dark .vp-cam-btn-danger { color: rgb(252 165 165); }
.vp-cam-error { font-size: .82rem; color: rgb(185 28 28); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.vp-photo-thumb { width: 36px; height: 36px; border-radius: 9999px; object-fit: cover; }
/* On phones, show the photo + record origin above the voter details. */
@media (max-width: 1023px) { :has(> .vp-mobile-first) { order: -1; } }

/* ---- Record origin: last edit, old → new ---- */
.vp-lastchg { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .45rem; }
.vp-lastchg li { font-size: .85rem; border-left: 3px solid rgb(217 119 6); padding-left: .55rem; }
.vp-lastchg-label { display: block; font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: rgb(100 116 139); }
.vp-lastchg-vals { display: flex; flex-wrap: wrap; align-items: baseline; gap: .1rem .4rem; overflow-wrap: anywhere; }
.vp-lastchg-arrow { color: rgb(148 163 184); }
.vp-lastchg-meta { margin-top: .5rem; font-size: .72rem; color: rgb(148 163 184); }

/* ---- Voter card QR scanner ---- */
.vp-scan { display: flex; flex-direction: column; gap: 1.5rem; max-width: 560px; }
.vp-scan-frame { position: relative; width: 100%; aspect-ratio: 1 / 1; max-height: 70vh; border-radius: .9rem; overflow: hidden; background: #0f172a; }
#vp-qr-reader { width: 100%; height: 100%; }
#vp-qr-reader video { width: 100% !important; height: 100% !important; object-fit: cover; }
.vp-scan-idle { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .6rem; color: #94a3b8; font-size: .9rem; }
