html, body {
    margin: 0;
    padding: 0;
    height: 100%;
}

#app { height: 100%; }

.report-map {
    width: 100%;
    height: 420px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--mud-palette-lines-default, #ebebea);
}

/* ----- Device pane (Home.razor) ---------------------------------------------
   Visual pattern lifted from TrackServerNewFE's tag-list: status dot with
   pulsing halo on online, name + monospace IMEI subline, right-side "meta"
   column with a last-update pill. Uses MudBlazor's --mud-palette-primary
   so it respects per-tenant branding instead of hardcoding an accent.
------------------------------------------------------------------------------ */
.cl-tag-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

.cl-tag-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--mud-palette-lines-default, #ebebea);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    position: relative;
    overflow: hidden;
    min-width: 0;
}
.cl-tag-item:hover {
    background: var(--mud-palette-action-default-hover, #f4f4f2);
}
.cl-tag-item.cl-tag-selected {
    background: var(--mud-palette-primary-hover, rgba(31, 111, 235, 0.08));
    border-left: 3px solid var(--mud-palette-primary, #1f6feb);
    padding-left: 13px;
}

.cl-tag-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    position: relative;
}
.cl-tag-dot.online {
    background: #4caf82;
    box-shadow: 0 0 0 3px rgba(76, 175, 130, 0.2);
}
.cl-tag-dot.online::after {
    content: "";
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    border: 1px solid rgba(76, 175, 130, 0.4);
    animation: cl-tag-pulse 2s infinite;
}
.cl-tag-dot.offline {
    background: #e05a5a;
    box-shadow: 0 0 0 3px rgba(224, 90, 90, 0.2);
}
.cl-tag-dot.unknown {
    background: #a09a94;
    box-shadow: 0 0 0 3px rgba(160, 154, 148, 0.2);
}
@keyframes cl-tag-pulse {
    0%   { transform: scale(1);   opacity: 0.9; }
    100% { transform: scale(1.8); opacity: 0;   }
}

.cl-tag-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}
.cl-tag-name {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--mud-palette-text-primary);
}
.cl-tag-sub {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 10px;
    color: var(--mud-palette-text-disabled);
    font-family: ui-monospace, "Space Mono", Menlo, Consolas, monospace;
    margin-top: 2px;
    overflow: hidden;
}
.cl-tag-sub-id {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cl-tag-badge {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    font-size: 8px;
    font-weight: 700;
    letter-spacing: 0.5px;
    padding: 1px 4px;
    border-radius: 3px;
    line-height: 14px;
    background: rgba(76, 175, 130, 0.12);
    color: #4caf82;
    border: 1px solid rgba(76, 175, 130, 0.22);
    text-transform: uppercase;
}
.cl-tag-badge.offline {
    background: rgba(224, 90, 90, 0.12);
    color: #b04545;
    border-color: rgba(224, 90, 90, 0.22);
}

.cl-tag-meta {
    text-align: right;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}
.cl-tag-speed {
    font-size: 11px;
    font-weight: 600;
    color: var(--mud-palette-text-secondary);
}
.cl-tag-time {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 6px;
    font-size: 10px;
    font-weight: 600;
    font-family: ui-monospace, "Space Mono", Menlo, Consolas, monospace;
    color: var(--mud-palette-text-secondary);
    background: var(--mud-palette-action-default-hover, #f4f4f2);
    border: 1px solid var(--mud-palette-lines-default, #ebebea);
    border-radius: 5px;
    white-space: nowrap;
}

/* Live-map device markers. Colour reflects time since the last server
   update: green <5m, yellow <15m, blue <1h, red older. The pulse ring is
   added briefly when a marker upserts so the eye catches the change.
   A permanent label pill sits below the dot showing the device name. */
.chicane-marker {
    position: relative;
    /* iconSize is matched to the dot; the label overflows below. */
    width: 22px;
    height: 22px;
}
.chicane-marker-label {
    position: absolute;
    top: 26px;
    left: 50%;
    transform: translateX(-50%);
    padding: 2px 8px;
    background: #fff;
    color: #1a1714;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.3;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,.25);
    white-space: nowrap;
    pointer-events: none;
}
.chicane-dot {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 3px solid #fff;
    box-shadow: 0 0 3px rgba(0,0,0,.45);
    box-sizing: border-box;
    position: relative;
}

/* Hover tooltip card. We override Leaflet's default tooltip chrome so the
   card has its own padding, shadow, and rounded corners and a tail-less
   look. Width is fixed so the two stat tiles align cleanly. */
.leaflet-tooltip.chicane-tip {
    background: #fff;
    border: 1px solid #e6e6e4;
    border-radius: 12px;
    box-shadow: 0 6px 18px rgba(0,0,0,.18);
    padding: 0;
    color: #1a1714;
    font: 500 12px/1.3 var(--mud-typography-default-family, "Outfit", system-ui, sans-serif);
    white-space: normal;
}
.leaflet-tooltip.chicane-tip::before { display: none; }
.chicane-tip-card { padding: 10px 12px; min-width: 220px; }
.chicane-tip-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}
.chicane-tip-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px rgba(0,0,0,.15);
    flex-shrink: 0;
}
.chicane-tip-dot.green  { background: #2ecc40; }
.chicane-tip-dot.yellow { background: #ffdc00; }
.chicane-tip-dot.blue   { background: #1f6feb; }
.chicane-tip-dot.red    { background: #ff4136; }
.chicane-tip-name {
    flex: 1;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chicane-tip-time {
    font-size: 11px;
    color: #6b6560;
    font-family: ui-monospace, "Space Mono", Menlo, Consolas, monospace;
    white-space: nowrap;
}
.chicane-tip-sub {
    font-size: 11px;
    color: #6b6560;
    margin-bottom: 8px;
}
.chicane-tip-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}
.chicane-tip-stat {
    background: #f4f4f2;
    border: 1px solid #ebebea;
    border-radius: 8px;
    padding: 8px 10px;
    text-align: center;
}
.chicane-tip-stat-num {
    font-size: 18px;
    font-weight: 700;
    line-height: 1.1;
    color: #1a1714;
}
.chicane-tip-stat-lbl {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.6px;
    color: #a09a94;
    text-transform: uppercase;
    margin-top: 2px;
}
.chicane-dot-green  { background: #2ecc40; }
.chicane-dot-yellow { background: #ffdc00; }
.chicane-dot-blue   { background: #1f6feb; }
.chicane-dot-red    { background: #ff4136; }

.chicane-dot.pulse::after {
    content: "";
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid currentColor;
    color: inherit;
    animation: chicane-pulse 1s ease-out 2;
    pointer-events: none;
}
.chicane-dot-green.pulse::after  { color: #2ecc40; }
.chicane-dot-yellow.pulse::after { color: #ffdc00; }
.chicane-dot-blue.pulse::after   { color: #1f6feb; }
.chicane-dot-red.pulse::after    { color: #ff4136; }

@keyframes chicane-pulse {
    0%   { transform: scale(1);   opacity: 0.9; }
    100% { transform: scale(2.4); opacity: 0;   }
}

/* Pages that want to claim the rest of the viewport (live map, fence editor,
   etc.). Dense MudAppBar is 48px high; subtract that off the viewport. */
.full-height-page {
    height: calc(100vh - 48px);
    display: flex;
    min-height: 0;
}

#blazor-error-ui {
    color-scheme: light only;
    background: #ffe1e1;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

.loading-progress {
    position: relative;
    display: block;
    width: 8rem;
    height: 8rem;
    margin: 20vh auto 1rem auto;
}

.loading-progress circle {
    fill: none;
    stroke: #e0e0e0;
    stroke-width: 0.6rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: #1f6feb;
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: 600;
    inset: calc(20vh + 3.25rem) 0 auto 0;
    color: #1f6feb;
}

.loading-progress-text:after {
    content: var(--blazor-load-percentage-text, "Loading");
}
