/* ============================================
   MétéoR Océan Indien - Synthèse Dashboard
   Modern compact theme
   ============================================ */

/* --- Design Tokens --- */
:root {
    --bg-body: #f1f5f9;
    --bg-card: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #374151;
    --text-muted: #4b5563;
    --border: #e2e8f0;
    --border-light: #f1f5f9;

    --accent: #1d4ed8;
    --accent-light: #dbeafe;
    --accent-dark: #1e40af;

    --header-bg: #0f172a;
    --header-text: #f1f5f9;
    --header-border: #334155;

    --offline-bg: #fef2f2;
    --offline-text: #991b1b;
    --offline-hover: #b91c1c;
    --late-bg: #fffbeb;
    --late-text: #92400e;
    --late-hover: #b45309;

    --green: #15803d;
    --orange: #c2410c;
    --purple: #6d28d9;
    --red: #b91c1c;

    --radius: 6px;
    --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
    --shadow-lg: 0 4px 12px rgba(0,0,0,.1);

    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'Fira Mono', ui-monospace, 'SF Mono', Consolas, monospace;
    --font-display: 'Audiowide', cursive;
    --font-station: 'Kanit', sans-serif;

    /* Extended tokens for dark mode */
    --table-zebra: #eef2f7;
    --table-header-2nd: #1e293b;
    --detail-bg: #f8fafc;
    --child-row-bg: #f8fafc;
    --favorite-odd: #bfdbfe;
    --favorite-even: #a5c8f5;
    --offline-even: #fde8e8;
    --late-even: #fef3c7;
    --dp-d1: #2563eb;
    --dp-d2: #9333ea;
    --dp-d3: #0d9488;
    --dp-d1-bg: #eff6ff;
    --dp-d2-bg: #faf5ff;
    --dp-d3-bg: #f0fdfa;
    --dp-row-hover: rgba(255,255,255,.7);
    --dp-radio-border: #cbd5e1;
    --legend-bg: rgba(255,255,255,.92);
}

/* --- Dark mode --- */
[data-theme="dark"] {
    --bg-body: #0c1220;
    --bg-card: #1e293b;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #8494a7;
    --border: #334155;
    --border-light: #1e293b;
    --accent: #60a5fa;
    --accent-light: #1e3a5f;
    --accent-dark: #60a5fa;
    --header-bg: #0a0f1a;
    --header-text: #e2e8f0;
    --header-border: #1e293b;
    --offline-bg: #450a0a;
    --offline-text: #fca5a5;
    --late-bg: #451a03;
    --late-text: #fcd34d;
    --green: #22c55e;
    --orange: #f97316;
    --purple: #a78bfa;
    --red: #ef4444;
    --shadow: 0 1px 3px rgba(0,0,0,.3), 0 1px 2px rgba(0,0,0,.2);
    --shadow-lg: 0 4px 12px rgba(0,0,0,.4);
    --table-zebra: #162032;
    --table-header-2nd: #0f1a2e;
    --detail-bg: #162032;
    --child-row-bg: #162032;
    --favorite-odd: #1e3a5f;
    --favorite-even: #172e4a;
    --offline-even: #3b1010;
    --late-even: #3b2506;
    --dp-d1: #60a5fa;
    --dp-d2: #a78bfa;
    --dp-d1-bg: #1e2d4a;
    --dp-d2-bg: #2d1b4e;
    --dp-d3-bg: #1a3332;
    --dp-row-hover: rgba(255,255,255,.08);
    --dp-radio-border: #475569;
    --legend-bg: rgba(30,41,59,.92);
}

/* Dark mode: hover rows need darker blue bg for white text contrast (desktop only) */
@media (min-width: 641px) {
    [data-theme="dark"] table.dataTable tbody tr:not(.child):hover td,
    [data-theme="dark"] table.dataTable tbody tr:not(.child):hover th {
        background-color: #2563eb !important;
    }
}

/* Dark mode: nav link contrast */
[data-theme="dark"] h1 .nav-link {
    color: #93c5fd;
    border-color: rgba(255,255,255,.25);
}
[data-theme="dark"] h1 .header-logo {
    filter: drop-shadow(0 0 8px rgba(0,0,0,.7)) drop-shadow(0 2px 4px rgba(0,0,0,.5)) brightness(1.15);
}

/* Dark mode: form inputs */
[data-theme="dark"] .dataTables_filter input,
[data-theme="dark"] .dp-search,
[data-theme="dark"] .dm-select,
[data-theme="dark"] select {
    color-scheme: dark;
}

/* --- Accessibility helpers --- */
.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;
}

.skip-link {
    position: absolute;
    top: -100%;
    left: 0;
    z-index: 10000;
    padding: 8px 16px;
    background: var(--accent);
    color: #fff;
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    border-radius: 0 0 var(--radius) 0;
}

.skip-link:focus {
    top: 0;
}

/* --- Reset / Base --- */
*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    padding: 0 0 2rem;
    background: var(--bg-body);
    color: var(--text-primary);
    font-family: var(--font-sans);
    -webkit-font-smoothing: auto;
    -moz-osx-font-smoothing: auto;
    font-size: 14px;
    line-height: 1.4;
}

/* --- Header --- */
h1 {
    font-family: var(--font-display);
    font-variant: small-caps;
    margin: 0;
    padding: 0.5rem 1rem;
    background: var(--header-bg);
    color: var(--header-text);
    font-size: 1.25rem;
    letter-spacing: 1.5px;
    border-bottom: 3px solid var(--accent);
    position: sticky;
    top: 0;
    z-index: 100;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 1rem;
}

h1 .nav-link {
    justify-self: start;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--accent-light);
    text-decoration: none;
    font-family: var(--font-sans);
    font-variant: normal;
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.02em;
    padding: 3px 10px;
    border: 1px solid rgba(255,255,255,.15);
    border-radius: 4px;
    transition: background .2s;
}

h1 .nav-link:hover {
    background: rgba(255,255,255,.1);
}

h1 .header-center {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

h1 .header-logo {
    height: 26px;
    vertical-align: middle;
}

.title-short { display: none; }

/* --- Theme toggle --- */
#theme-toggle {
    background: none;
    border: 1px solid rgba(255,255,255,.15);
    border-radius: 4px;
    color: #cbd5e1;
    cursor: pointer;
    padding: 3px 6px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    transition: background .2s, color .2s;
}
#theme-toggle:hover {
    background: rgba(255,255,255,.1);
    color: #f1f5f9;
}
#theme-toggle .icon-auto,
#theme-toggle .icon-sun,
#theme-toggle .icon-moon { display: none; }
[data-theme-mode="auto"] #theme-toggle .icon-auto { display: inline; }
[data-theme-mode="light"] #theme-toggle .icon-sun { display: inline; }
[data-theme-mode="dark"] #theme-toggle .icon-moon { display: inline; }

/* --- Auto-reload widget --- */
#auto-reload {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-sans);
    font-variant: normal;
    font-size: 11px;
    letter-spacing: 0;
    color: #cbd5e1;
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 4px;
    padding: 3px 8px;
    white-space: nowrap;
}

#auto-reload label {
    cursor: default;
}

#reload-select {
    background: var(--header-bg);
    color: var(--header-text);
    border: 1px solid var(--header-border);
    border-radius: 3px;
    padding: 2px 4px;
    font-size: 11px;
    font-family: var(--font-sans);
    cursor: pointer;
    outline: none;
}

#reload-select:focus {
    border-color: var(--accent);
}

#reload-select option {
    background: var(--header-bg);
    color: var(--header-text);
}

#reload-countdown {
    font-family: var(--font-mono);
    font-size: 10px;
    color: #93c5fd;
    min-width: 48px;
}

#reload-now {
    background: none;
    border: none;
    color: #93c5fd;
    cursor: pointer;
    padding: 2px;
    line-height: 1;
    vertical-align: middle;
    opacity: .7;
    transition: opacity .15s;
}

#reload-now:hover {
    opacity: 1;
}

#refresh-status {
    justify-self: end;
    font-size: 11px;
    font-family: var(--font-sans);
    font-variant: normal;
    letter-spacing: 0;
    color: #94a3b8;
    white-space: nowrap;
}

#refresh-status.loading::before {
    content: '';
    display: inline-block;
    width: 10px;
    height: 10px;
    border: 2px solid #94a3b8;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin .8s linear infinite;
    margin-right: 5px;
    vertical-align: middle;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* --- Loading overlay --- */
.loading-overlay {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 32px;
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: 14px;
}
.loading-overlay::before {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .6s linear infinite;
}

h2 {
    font-family: var(--font-display);
    font-variant: small-caps;
    margin: 1rem 0.75rem 0.5rem;
    padding: 0.5rem 0.75rem;
    font-size: 1.1rem;
    color: var(--text-secondary);
    background: var(--bg-card);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

/* h2 with embedded search filter */
#h2-online {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

#h2-online .dataTables_filter {
    margin: 0;
    font-variant: normal;
    font-family: var(--font-sans);
}

#h2-online .dataTables_filter label {
    font-size: 11px;
}

#h2-online .dataTables_filter input {
    font-size: 11px;
    padding: 3px 6px;
}

/* --- Section offline (collapsible) --- */
#section_offline {
    margin: 0.5rem 0.75rem 0;
}

#section_offline summary {
    cursor: pointer;
    list-style: none;
}

#section_offline summary::-webkit-details-marker {
    display: none;
}

#section_offline summary h2 {
    margin: 0;
    position: relative;
    padding-left: 1.5rem;
    background: var(--offline-bg);
    border-left-color: var(--red);
    color: var(--offline-text);
}

#section_offline summary h2::before {
    content: '\25B6';
    position: absolute;
    left: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.65rem;
    transition: transform .2s;
}

#section_offline summary h2::after {
    content: ' 🔌';
}

#section_offline[open] summary h2::before {
    transform: translateY(-50%) rotate(90deg);
}

/* ==============================
   DataTables Overrides
   ============================== */
.dataTables_wrapper {
    padding: 0.25rem 0;
    font-family: var(--font-sans);
}

/* Filter is moved into h2 via JS, hide from wrapper */
#table-data_wrapper > .dataTables_filter {
    margin-bottom: 0.5rem;
}

.dataTables_wrapper .dataTables_filter label {
    font-size: 12px;
    color: var(--text-secondary);
}

.dataTables_filter input {
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 13px;
    outline: none;
    transition: border-color .2s, box-shadow .2s;
    margin-left: 4px;
}

.dataTables_filter input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.dataTables_wrapper .dataTables_info {
    font-size: 11px;
    color: var(--text-muted);
    padding-top: 0.5rem !important;
}

/* Hide length selector (paging is off anyway) */
.dataTables_length { display: none; }

/* ==============================
   Tables
   ============================== */
#table-data,
#table-offline {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--bg-card);
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius);
    overflow: hidden;
}

/* --- Table headers --- */
#table-data thead tr th,
#table-offline thead tr th {
    font-family: var(--font-sans);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--header-text);
    background: var(--header-bg) !important;
    padding: 3px 2px;
    white-space: nowrap;
    border-bottom: none;
    vertical-align: middle;
}

/* Top header row (group labels) */
#table-data thead tr:first-child th,
#table-offline thead tr:first-child th {
    padding: 4px 3px 1px;
    font-size: 9px;
    letter-spacing: 0.8px;
    color: #93c5fd;
    background: var(--table-header-2nd) !important;
}

/* Override inline border-right style */
#table-data thead tr th[style],
#table-offline thead tr th[style] {
    border-right-color: var(--header-border) !important;
}

#table-data thead tr th.small,
#table-offline thead tr th.small {
    font-size: 8px;
}

/* DataTables sorting icons on dark headers */
table.dataTable thead .sorting,
table.dataTable thead .sorting_asc,
table.dataTable thead .sorting_desc,
table.dataTable thead .sorting_asc_disabled,
table.dataTable thead .sorting_desc_disabled {
    background-color: var(--header-bg) !important;
}

table.dataTable thead .sorting {
    background-image: url('https://cdn.datatables.net/1.10.20/images/sort_both.png') !important;
    opacity: 0.5;
}
table.dataTable thead .sorting_asc {
    background-image: url('https://cdn.datatables.net/1.10.20/images/sort_asc.png') !important;
}
table.dataTable thead .sorting_desc {
    background-image: url('https://cdn.datatables.net/1.10.20/images/sort_desc.png') !important;
}

/* --- Table body base --- */
tbody {
    border: none;
}

td {
    text-align: center;
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 500;
    padding: 1px 2px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}

/* Force color on DataTables-enhanced tables (beats table.dataTable selectors) */
table.dataTable tbody td {
    color: var(--text-primary);
}

/* Neutralize DataTables sorting column backgrounds */
table.dataTable tbody td.sorting_1,
table.dataTable tbody td.sorting_2,
table.dataTable tbody td.sorting_3 {
    background-color: inherit !important;
}

/* Neutralize DataTables .display hover background */
table.dataTable.display tbody tr:hover,
table.dataTable.hover tbody tr:hover {
    background-color: transparent !important;
}

/* Station code (th in tbody) */
#table-data tbody tr th,
#table-offline tbody tr th {
    font-family: var(--font-station);
    font-weight: 600;
    font-size: 12px;
    letter-spacing: 0.3px;
    color: var(--accent);
    padding: 1px 2px;
    border-bottom: 1px solid var(--border);
    background: transparent;
    white-space: nowrap;
}

/* Timestamps nowrap */
td.dateloss,
td.refresh-time {
    white-space: nowrap;
}

/* Zebra striping */
table.dataTable tbody tr.odd {
    background-color: var(--bg-card) !important;
}
table.dataTable tbody tr.even {
    background-color: var(--table-zebra) !important;
}
table.dataTable tbody tr.even th {
    background-color: var(--table-zebra);
}

/* Remove DataTables default border */
table.dataTable.no-footer {
    border-bottom: none;
}
table.dataTable {
    border-collapse: separate !important;
    border-spacing: 0;
}

/* Links in cells */
tbody tr td a,
table.dataTable tbody tr td a {
    color: var(--accent);
    font-size: 12px;
    text-decoration: none;
    font-family: var(--font-sans);
    font-weight: 600;
}

/* --- Favorite stations --- */
#table-data tbody tr th,
#table-offline tbody tr th {
    cursor: pointer;
}

table.dataTable tbody tr.favorite th::before {
    content: '\2605\00a0';
    color: #d97706;
}

table.dataTable tbody tr.favorite td,
table.dataTable tbody tr.favorite th {
    font-weight: 700;
    border-bottom-color: #93c5fd;
}

table.dataTable tbody tr.favorite.odd td,
table.dataTable tbody tr.favorite.odd th {
    background-color: var(--favorite-odd) !important;
}

table.dataTable tbody tr.favorite.even td,
table.dataTable tbody tr.favorite.even th {
    background-color: var(--favorite-even) !important;
}

/* --- Location cell --- */
tbody#station-data tr td.location,
tbody#station-offline tr td.location {
    text-align: left;
    white-space: nowrap;
}

tbody#station-data tr td.location a,
tbody#station-offline tr td.location a {
    font-size: 12px;
}

tbody#station-data tr td.location a:before,
tbody#station-offline tr td.location a:before {
    content: '🔗 ';
}

/* ==============================
   Status rows (base, non-hover)
   ============================== */

/* Offline - base */
table.dataTable tbody tr.offline td,
table.dataTable tbody tr.offline th {
    background-color: var(--offline-bg) !important;
}
table.dataTable tbody tr.offline.even td,
table.dataTable tbody tr.offline.even th {
    background-color: var(--offline-even) !important;
}
table.dataTable tbody tr.offline:not(:hover) th {
    color: var(--offline-text);
}

/* Late - base */
table.dataTable tbody tr.late td,
table.dataTable tbody tr.late th {
    background-color: var(--late-bg) !important;
}
table.dataTable tbody tr.late.even td,
table.dataTable tbody tr.late.even th {
    background-color: var(--late-even) !important;
}
table.dataTable tbody tr.late:not(:hover) th {
    color: var(--late-text);
}

/* ==============================
   HOVER — must come LAST to win cascade
   All rules use table.dataTable tbody prefix
   for specificity >= base rules (0,3,4)
   ============================== */

/* General hover (online rows) — exclude child (detail) rows */
table.dataTable tbody tr:not(.child):hover td,
table.dataTable tbody tr:not(.child):hover th {
    background-color: var(--accent) !important;
    color: #fff !important;
}
table.dataTable tbody tr:not(.child):hover td a {
    color: #fff !important;
}

/* Offline hover */
table.dataTable tbody tr.offline:not(.child):hover td,
table.dataTable tbody tr.offline:not(.child):hover th {
    background-color: var(--offline-hover) !important;
    color: #fff !important;
}
table.dataTable tbody tr.offline:not(.child):hover td a {
    color: #fff !important;
}

/* Late hover */
table.dataTable tbody tr.late:not(.child):hover td,
table.dataTable tbody tr.late:not(.child):hover th {
    background-color: var(--late-hover) !important;
    color: #fff !important;
}
table.dataTable tbody tr.late:not(.child):hover td a {
    color: #fff !important;
}

/* ==============================
   Timestamps
   ============================== */
td.dateloss,
td.refresh-time,
table.dataTable tbody td.dateloss,
table.dataTable tbody td.refresh-time {
    text-decoration: none;
    white-space: nowrap;
    font-size: 12px;
    font-family: var(--font-sans);
    color: var(--text-secondary);
    font-weight: 500;
}

tr.reaching_dataloss td.dateloss:before {
    content: "🚨\00a0";
}

/* ==============================
   Records & Indicators
   ============================== */
td.broken-record:before {
    animation: blinker 2s linear infinite;
}

@keyframes blinker {
    50% { opacity: 0; }
}

td.broken-record-month:before { content: "Ⓜ️\00a0"; }
td.broken-record-year:before { content: "🅰️\00a0"; }
td.broken-record-total:before { content: "🌟\00a0"; }

td.missing-data:before { content: "❗"; }

/* Rain rate errors */
tbody#station-data tr.rr_error td.daily-rain-rate-max,
tbody#station-data tr.rr_error td.daily-rain,
tbody#station-data tr.rr_error td.monthly-rain {
    font-weight: bold;
    color: var(--orange);
}

tbody#station-data tr.rr_error td.daily-rain-rate-max:before,
tbody#station-data tr.rr_error td.daily-rain:before,
tbody#station-data tr.rr_error td.monthly-rain:before {
    content: "❗";
}

/* ==============================
   Details control (expand/collapse)
   ============================== */
td.details-control {
    background: url('../details_open.png') no-repeat center center;
    cursor: pointer;
    width: 18px;
}

tr.shown td.details-control {
    background: url('../details_close.png') no-repeat center center;
}

tr.no-submenu td.details-control {
    background: none;
    cursor: not-allowed;
    opacity: 0.4;
}

tr.no-submenu td.details-control:before {
    content: "🚧";
}

/* ==============================
   Detail tables (expanded rows)
   ============================== */
table.detail_table {
    background: var(--detail-bg);
    border-radius: 4px;
    margin: 4px 0;
}

table.detail_table td,
table.detail_table th {
    border-left: 1px solid var(--border);
    font-size: 11px;
    padding: 3px 6px;
    font-family: var(--font-sans);
}

table.detail_table th {
    background: var(--border-light);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

table.detail_table td {
    font-family: var(--font-mono);
    color: var(--text-primary);
}

/* Child rows (expanded detail) — desktop background */
table.dataTable tbody tr.child {
    background: var(--child-row-bg);
}

/* --- Animation row details --- */
table.dataTable tbody tr.child td {
    overflow: hidden;
    max-height: 800px;
    transition: max-height .3s ease, opacity .3s ease, padding .3s ease;
}
table.dataTable tbody tr.child.collapsing td {
    max-height: 0 !important;
    opacity: 0;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}

/* ==============================
   Battery & Signal
   ============================== */
td.battery_LOW {
    color: var(--red);
    font-weight: bold;
}

td.battery_OK {
    color: var(--green);
    font-weight: bold;
}

td.sig-qual {
    white-space: nowrap;
}

td.signal_alert {
    font-weight: bold;
    color: var(--red);
}
td.signal_alert:before { content: '⚠️'; }

td.signal_bof {
    font-weight: bold;
    color: var(--purple);
}

td.signal_ok {
    font-weight: bold;
    color: var(--green);
}

span.datetime_hilow {
    font-size: 80%;
    color: var(--text-muted);
}

/* ==============================
   Fit tables to viewport width
   ============================== */

/* Wrapper scrolls as last resort */
.dataTables_wrapper {
    overflow-x: auto;
    margin: 0 0.25rem;
}

/* Virtual sort cell — always hidden */
td.virtual-sort,
th.virtual-sort-hdr,
td.d2-display:not(.d2-active),
th.d2-display-hdr,
td.d3-display:not(.d3-active),
th.d3-display-hdr {
    display: none !important;
}

/* ==============================
   DataPicker (overlay + panel + radios)
   ============================== */

/* Overlay */
.dp-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    backdrop-filter: blur(2px);
    z-index: 1998;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s ease;
}

.dp-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

/* Panel */
.dp-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    width: 520px;
    max-width: calc(100vw - 32px);
    max-height: 75vh;
    background: var(--bg-card);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,.2), 0 0 0 1px rgba(0,0,0,.05);
    z-index: 1999;
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s cubic-bezier(0.16, 1, 0.3, 1),
                transform .25s cubic-bezier(0.16, 1, 0.3, 1);
}

.dp-panel.open {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, -50%) scale(1);
}

/* Panel header */
.dp-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px 10px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.dp-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.2px;
}

/* Search input wrapper */
.dp-search-wrap {
    flex: 1;
    min-width: 0;
    margin: 0 12px;
    position: relative;
    display: flex;
    align-items: center;
}

.dp-search-icon {
    position: absolute;
    left: 10px;
    color: #94a3b8;
    pointer-events: none;
    transition: color .15s;
}

.dp-search-wrap:focus-within .dp-search-icon {
    color: var(--accent);
}

.dp-search {
    width: 100%;
    padding: 6px 32px 6px 30px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-body);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 13px;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}

.dp-search::placeholder {
    color: #94a3b8;
}

.dp-search:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-light);
}

.dp-search-clear {
    position: absolute;
    right: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border: none;
    border-radius: 50%;
    background: var(--border);
    color: var(--text-muted);
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity .15s, background .15s, color .15s;
}

.dp-search-wrap.has-query .dp-search-clear {
    opacity: 1;
    pointer-events: auto;
}

.dp-search-clear:hover {
    background: #cbd5e1;
    color: var(--text-primary);
}

.dp-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 6px;
    background: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    transition: background .15s, color .15s;
    line-height: 1;
}

.dp-close:hover {
    background: var(--bg-body);
    color: var(--text-primary);
}

/* Column headers */
.dp-cols-header {
    display: grid;
    grid-template-columns: 1fr 52px 52px 52px;
    align-items: center;
    padding: 8px 18px 6px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--bg-card);
    z-index: 1;
    flex-shrink: 0;
}

.dp-col-label {
    text-align: center;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 3px 10px;
    border-radius: 10px;
    display: inline-block;
}

.dp-col-d1 { color: var(--dp-d1); background: var(--dp-d1-bg); }
.dp-col-d2 { color: var(--dp-d2); background: var(--dp-d2-bg); }
.dp-col-d3 { color: var(--dp-d3); background: var(--dp-d3-bg); }

/* Body / scroll area */
.dp-body {
    overflow-y: auto;
    flex: 1;
    padding: 4px 0 8px;
}

/* Group block */
.dp-group {
    margin: 0 10px 6px;
    border-radius: 8px;
    background: var(--bg-body);
    border: 1px solid var(--border);
    overflow: hidden;
}

/* Group title */
.dp-group-title {
    padding: 8px 14px;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #fff;
    background: var(--header-bg);
    border-bottom: 1px solid rgba(255,255,255,.08);
    display: flex;
    align-items: center;
    gap: 8px;
    text-shadow: 0 1px 2px rgba(0,0,0,.3);
}

.dp-group-title::before {
    content: '';
    display: inline-block;
    width: 3px;
    height: 14px;
    border-radius: 2px;
    flex-shrink: 0;
}

/* Group color accents */
.dp-group[data-group="Températures"] .dp-group-title { background: #b91c1c; }
.dp-group[data-group="Températures"] .dp-group-title::before { background: #fca5a5; }
.dp-group[data-group="Vent"] .dp-group-title { background: #047857; }
.dp-group[data-group="Vent"] .dp-group-title::before { background: #6ee7b7; }
.dp-group[data-group="Pluie"] .dp-group-title { background: #1d4ed8; }
.dp-group[data-group="Pluie"] .dp-group-title::before { background: #93c5fd; }
.dp-group[data-group="Atmosphère"] .dp-group-title { background: #b45309; }
.dp-group[data-group="Atmosphère"] .dp-group-title::before { background: #fcd34d; }
.dp-group[data-group="Station"] .dp-group-title { background: #475569; }
.dp-group[data-group="Station"] .dp-group-title::before { background: #94a3b8; }

/* "Aucune" row */
.dp-row-none {
    margin: 6px 10px 2px;
    border-radius: 8px;
    border: 1px dashed var(--border);
    background: var(--bg-card);
}

.dp-row-none .dp-row-label {
    color: var(--text-muted);
    font-style: italic;
}

/* Row */
.dp-row {
    display: grid;
    grid-template-columns: 1fr 52px 52px 52px;
    align-items: center;
    padding: 6px 14px;
    transition: background .12s;
}

.dp-row:not(.dp-row-none):hover {
    background: var(--dp-row-hover);
}

.dp-row:not(.dp-row-none):not(:last-child) {
    border-bottom: 1px solid rgba(0,0,0,.04);
}

.dp-row-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    line-height: 1.3;
}

/* Custom radio */
.dp-radio {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 32px;
    cursor: pointer;
    outline: none;
}

.dp-radio-dot {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid var(--dp-radio-border);
    position: relative;
    transition: border-color .2s cubic-bezier(0.16, 1, 0.3, 1),
                background .2s cubic-bezier(0.16, 1, 0.3, 1),
                box-shadow .2s cubic-bezier(0.16, 1, 0.3, 1);
}

.dp-radio-dot::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: transparent;
    transform: translate(-50%, -50%) scale(0);
    transition: transform .2s cubic-bezier(0.16, 1, 0.3, 1),
                background .2s cubic-bezier(0.16, 1, 0.3, 1);
}

.dp-radio[data-col="d1"]:hover .dp-radio-dot { border-color: var(--dp-d1); }
.dp-radio[data-col="d2"]:hover .dp-radio-dot { border-color: var(--dp-d2); }
.dp-radio[data-col="d3"]:hover .dp-radio-dot { border-color: var(--dp-d3); }

.dp-radio.dp-disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}

.dp-radio:focus-visible .dp-radio-dot {
    box-shadow: 0 0 0 2px var(--accent-light);
}

/* Selected D1 */
.dp-radio[data-col="d1"].selected .dp-radio-dot {
    border-color: var(--dp-d1);
    background: var(--dp-d1-bg);
    box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
.dp-radio[data-col="d1"].selected .dp-radio-dot::after {
    background: var(--dp-d1);
    transform: translate(-50%, -50%) scale(1);
}

/* Selected D2 */
.dp-radio[data-col="d2"].selected .dp-radio-dot {
    border-color: var(--dp-d2);
    background: var(--dp-d2-bg);
    box-shadow: 0 0 0 3px rgba(147,51,234,.15);
}
.dp-radio[data-col="d2"].selected .dp-radio-dot::after {
    background: var(--dp-d2);
    transform: translate(-50%, -50%) scale(1);
}

/* Selected D3 */
.dp-radio[data-col="d3"].selected .dp-radio-dot {
    border-color: var(--dp-d3);
    background: var(--dp-d3-bg);
    box-shadow: 0 0 0 3px rgba(13,148,136,.15);
}
.dp-radio[data-col="d3"].selected .dp-radio-dot::after {
    background: var(--dp-d3);
    transform: translate(-50%, -50%) scale(1);
}

/* DataPicker button labels */
.dp-label-d1 {
    color: var(--dp-d1);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dp-label-d2 {
    color: var(--dp-d2);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dp-label-d3 {
    color: var(--dp-d3);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dp-sep {
    color: #94a3b8;
    font-weight: 700;
    flex-shrink: 0;
}

.dp-chevron {
    margin-left: auto;
    flex-shrink: 0;
    color: var(--text-muted);
    transition: transform .25s cubic-bezier(0.16, 1, 0.3, 1);
}

.data-picker-btn.open .dp-chevron {
    transform: rotate(180deg);
}

/* --- Mobile sort control (hidden on desktop) --- */
#mobile-sort {
    display: none;
}

/* ==============================
   Mobile
   ============================== */
@media (max-width: 640px) {
    /* --- Page layout --- */
    body {
        padding-bottom: 1rem;
    }

    h1 {
        grid-template-columns: auto 1fr auto;
        grid-template-rows: auto auto;
        padding: 0.3rem 0.5rem;
        gap: 2px 8px;
        font-size: 0.75rem;
    }

    h1 .header-center { display: contents; }

    h1 .header-logo { display: none; }

    .title-full { display: none; }
    .title-short { display: inline; }

    /* Ligne 1 : nav | titre | thème */
    h1 nav { grid-column: 1; grid-row: 1; justify-self: start; }

    h1 .header-center > span {
        grid-column: 2; grid-row: 1;
        text-align: center;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    h1 #theme-toggle { grid-column: 3; grid-row: 1; justify-self: end; }

    /* Ligne 2 : auto-reload | status (absolu) */
    h1 #auto-reload {
        grid-column: 1 / -1; grid-row: 2;
        justify-self: start;
        font-size: 10px;
        padding: 2px 5px;
    }

    h1 #auto-reload label { display: none; }

    #refresh-status {
        position: absolute;
        right: 0.5rem;
        bottom: 0.3rem;
        font-size: 10px;
    }

    h1 .nav-link {
        font-size: 12px;
        padding: 4px 10px;
        background: rgba(255,255,255,.08);
        border-color: rgba(255,255,255,.25);
    }

    h2 {
        font-size: 0.8rem;
        margin: 0.3rem 0.4rem 0.2rem;
        padding: 0.3rem 0.5rem;
    }

    #h2-online {
        flex-wrap: wrap;
        gap: 0.2rem;
    }

    #h2-online .dataTables_filter {
        width: 100%;
    }

    #h2-online .dataTables_filter input {
        width: calc(100% - 70px);
    }

    #section_offline {
        margin: 0.3rem 0.4rem 0;
    }

    .dataTables_wrapper {
        margin: 0 0.4rem;
        overflow-x: visible;
    }

    /* --- Mobile sort control --- */
    #mobile-sort {
        display: flex;
        align-items: center;
        gap: 6px;
        margin: 0 0.4rem 4px;
        padding: 5px 8px;
        background: var(--bg-card);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        box-shadow: var(--shadow);
    }

    /* DataPicker button */
    #data-picker-btn {
        flex: 1;
        display: flex;
        align-items: center;
        gap: 4px;
        font-family: var(--font-sans);
        font-size: 11px;
        padding: 4px 8px;
        border: 1px solid var(--border);
        border-radius: 4px;
        background: var(--bg-card);
        color: var(--text-primary);
        cursor: pointer;
        outline: none;
        transition: border-color .15s, box-shadow .15s;
        text-align: left;
        line-height: 1.3;
    }

    #data-picker-btn:hover {
        border-color: #94a3b8;
    }

    #mobile-sort button {
        line-height: 1;
        padding: 4px 6px;
        border: 1px solid var(--border);
        border-radius: 4px;
        background: var(--bg-card);
        cursor: pointer;
        transition: background .15s, color .15s, border-color .15s;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    #mobile-sort-reset {
        color: var(--orange);
    }
    #mobile-sort-reset:hover {
        background: var(--offline-bg);
        color: var(--red);
        border-color: var(--red);
    }

    /* DataPicker panel mobile (bottom sheet) */
    .dp-panel {
        top: auto;
        bottom: 0;
        left: 0;
        width: 100%;
        max-width: 100%;
        max-height: 85vh;
        border-radius: 16px 16px 0 0;
        transform: translate(0, 100%);
        transition: opacity .3s cubic-bezier(0.16, 1, 0.3, 1),
                    transform .3s cubic-bezier(0.16, 1, 0.3, 1);
    }

    .dp-panel.open {
        transform: translate(0, 0);
    }

    .dp-header {
        padding: 10px 14px 8px;
    }

    .dp-title {
        font-size: 13px;
    }

    .dp-search {
        padding: 4px 28px 4px 28px;
        font-size: 12px;
    }

    .dp-search-icon {
        left: 8px;
        width: 12px;
        height: 12px;
    }

    .dp-close {
        width: 24px;
        height: 24px;
        font-size: 18px;
    }

    .dp-cols-header {
        grid-template-columns: 1fr 36px 36px 36px;
        padding: 5px 14px 4px;
    }

    .dp-col-label {
        font-size: 9px;
        padding: 2px 6px;
    }

    .dp-body {
        padding: 2px 0 6px;
    }

    .dp-group {
        margin: 0 8px 4px;
        border-radius: 6px;
    }

    .dp-group-title {
        padding: 5px 10px;
        font-size: 9px;
    }

    .dp-row-none {
        margin: 4px 8px 2px;
        border-radius: 6px;
    }

    .dp-row {
        grid-template-columns: 1fr 36px 36px 36px;
        padding: 4px 10px;
    }

    .dp-radio {
        width: 36px;
        height: 28px;
    }

    .dp-radio-dot {
        width: 15px;
        height: 15px;
    }

    .dp-radio-dot::after {
        width: 7px;
        height: 7px;
    }

    .dp-row-label {
        font-size: 12px;
    }

    /* Condensed header */
    #condensed-header {
        align-items: center;
        margin: 0 0.4rem;
        padding: 4px 10px;
        background: var(--header-bg);
        color: var(--header-text);
        font-size: 10px;
        font-weight: 600;
        font-family: var(--font-sans);
        border-radius: var(--radius) var(--radius) 0 0;
    }

    .ch-code {
        flex-shrink: 0;
        min-width: 70px;
    }

    .ch-col {
        flex: 1;
        text-align: right;
        cursor: pointer;
        padding: 2px 4px;
        border-radius: 3px;
        transition: background .15s;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .ch-col:hover {
        background: rgba(255,255,255,.15);
    }

    .ch-col.sort-active-hdr {
        background: rgba(255,255,255,.1);
        color: #93c5fd;
    }

    /* --- Card layout: table → block --- */
    #table-data,
    #table-offline {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        box-shadow: none;
        background: transparent;
        overflow: visible;
        border-radius: 0;
    }

    #table-data thead,
    #table-offline thead {
        display: none;
    }

    #table-data tbody,
    #table-offline tbody {
        display: block;
    }

    #table-data tbody tr,
    #table-offline tbody tr {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 0 10px;
        background: var(--bg-card);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        box-shadow: var(--shadow);
        margin-bottom: 6px;
        padding: 8px 12px 10px;
        position: relative;
    }

    /* --- Hide row-number --- */
    #table-data tbody tr > td:first-child,
    #table-offline tbody tr > td:first-child {
        display: none;
    }

    /* --- Details-control: expand/collapse button --- */
    #table-data tbody tr > td.details-control,
    #table-offline tbody tr > td.details-control {
        display: flex !important;
        align-items: center;
        justify-content: center;
        position: absolute;
        top: 11px;
        right: 15px;
        box-sizing: border-box !important;
        width: 22px !important;
        height: 22px !important;
        padding: 0;
        background: none !important;
        border: 1.5px solid var(--border) !important;
        border-radius: 50%;
        overflow: visible;
        cursor: pointer;
        z-index: 2;
        font-size: 0;
    }

    #table-data tbody tr > td.details-control::before,
    #table-offline tbody tr > td.details-control::before {
        display: none;
    }

    #table-data tbody tr > td.details-control::after,
    #table-offline tbody tr > td.details-control::after {
        content: '';
        display: block;
        width: 9px;
        height: 9px;
        background-color: var(--text-muted);
        -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M5 1v8M1 5h8' stroke='%23000' stroke-width='1.8' stroke-linecap='round' fill='none'/%3E%3C/svg%3E") center/contain no-repeat;
        mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M5 1v8M1 5h8' stroke='%23000' stroke-width='1.8' stroke-linecap='round' fill='none'/%3E%3C/svg%3E") center/contain no-repeat;
    }

    #table-data tbody tr.shown > td.details-control::after,
    #table-offline tbody tr.shown > td.details-control::after {
        background-color: var(--accent);
        -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M1 5h8' stroke='%23000' stroke-width='1.8' stroke-linecap='round' fill='none'/%3E%3C/svg%3E");
        mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M1 5h8' stroke='%23000' stroke-width='1.8' stroke-linecap='round' fill='none'/%3E%3C/svg%3E");
    }

    #table-data tbody tr.shown > td.details-control,
    #table-offline tbody tr.shown > td.details-control {
        border-color: var(--accent) !important;
        background: var(--accent-light) !important;
    }

    /* Disabled state for no-submenu */
    #table-data tbody tr.no-submenu > td.details-control,
    #table-offline tbody tr.no-submenu > td.details-control {
        display: none !important;
    }

    /* --- Child rows (expanded details) --- */
    #table-data tbody tr.child,
    #table-offline tbody tr.child {
        display: block !important;
        padding: 6px 10px;
        margin-top: -6px;
        margin-bottom: 6px;
        background: var(--child-row-bg);
        border: 1px solid var(--border);
        border-top: none;
        border-radius: 0 0 var(--radius) var(--radius);
        box-shadow: var(--shadow);
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    #table-data tbody tr.child td,
    #table-offline tbody tr.child td {
        display: block !important;
        font-size: 12px;
        padding: 0;
    }

    #table-data tbody tr.child td::before,
    #table-offline tbody tr.child td::before {
        display: none;
    }

    /* Parent card above child: merge with child */
    #table-data tbody tr.shown,
    #table-offline tbody tr.shown {
        margin-bottom: 0;
        border-radius: var(--radius) var(--radius) 0 0;
        padding-bottom: 6px;
    }

    /* --- Station code = card header --- */
    #table-data tbody tr th,
    #table-offline tbody tr th {
        grid-column: 1 / -1;
        font-family: var(--font-station);
        font-size: 12px;
        font-weight: 700;
        line-height: 1.3;
        color: var(--accent);
        padding: 4px 28px 8px 4px;
        margin-bottom: 1px;
        border-top: none;
        border-bottom: 1.5px solid var(--accent);
        background: transparent !important;
        text-align: left;
        white-space: normal;
    }

    /* --- Location full width --- */
    td.location {
        grid-column: 1 / -1;
        padding-bottom: 4px !important;
        margin-bottom: 2px;
        border-bottom: 1px solid var(--border-light) !important;
    }

    /* --- Each cell: label + value inline --- */
    #table-data tbody tr td,
    #table-offline tbody tr td {
        display: flex;
        flex-direction: row;
        align-items: baseline;
        gap: 4px;
        text-align: left;
        font-family: var(--font-mono);
        font-size: 12px;
        font-weight: 600;
        padding: 2px 0;
        border-top: none !important;
        border-bottom: 1px solid var(--border-light) !important;
        color: var(--text-primary);
        line-height: 1.3;
        min-height: 18px;
    }

    #table-data tbody tr td::before,
    #table-offline tbody tr td::before {
        font-family: var(--font-sans);
        font-size: 10px;
        font-weight: 600;
        color: var(--text-muted);
        text-transform: uppercase;
        letter-spacing: 0.2px;
        line-height: 1.3;
        flex-shrink: 0;
        min-width: 85px;
    }

    /* --- Labels --- */
    td.country::before { content: "Pays"; }
    td.location::before { content: "Lieu"; }
    td.altitude::before { content: "Altitude"; }
    td.refresh-time::before { content: "Dernière MAJ"; }
    td.dateloss::before { content: "Perte données"; }
    td.direct-pa::before { content: "PA (hPa)"; }
    td.direct-rh::before { content: "Humidité (%)"; }
    td.direct-temp::before { content: "T (°C)"; }
    td.daily-t-max::before { content: "Tx (°C)"; }
    td.daily-t-min::before { content: "Tn (°C)"; }
    td.current-wind10min::before { content: "Vent (km/h)"; }
    td.daily-windmax::before { content: "Raf. (km/h)"; }
    td.daily-rain-rate-max::before { content: "IP max (mm/h)"; }
    td.daily-rain::before { content: "Pluie jour"; }
    td.direct-1h-rain::before { content: "Pluie 1h"; }
    td.direct-3h-rain::before { content: "Pluie 3h"; }
    td.direct-6h-rain::before { content: "Pluie 6h"; }
    td.direct-12h-rain::before { content: "Pluie 12h"; }
    td.direct-24h-rain::before { content: "Pluie 24h"; }
    td.daily-rain-yesterday::before { content: "Pluie J-1"; }
    td.monthly-rain::before { content: "Pluie mois"; }
    td.monthly-etp::before { content: "ETP mois"; }
    td.yearly-rain::before { content: "Pluie année"; }
    td.daily-in-t-max::before { content: "Tx console"; }
    td.sig-qual::before { content: "Signal"; }

    /* --- Record icons on mobile (::after car ::before = label) --- */
    td.broken-record-month::after { content: "\00a0Ⓜ️"; }
    td.broken-record-year::after { content: "\00a0🅰️"; }
    td.broken-record-total::after { content: "\00a0🌟"; }
    td.broken-record::after {
        animation: blinker 2s linear infinite;
    }

    /* --- Location link --- */
    tbody#station-data tr td.location a,
    tbody#station-offline tr td.location a {
        font-size: 12px;
    }

    td.location {
        white-space: normal !important;
    }

    /* --- Timestamp --- */
    td.dateloss,
    td.refresh-time,
    table.dataTable tbody td.dateloss,
    table.dataTable tbody td.refresh-time {
        font-size: 12px;
        font-family: var(--font-sans);
        white-space: normal;
    }

    /* --- Favorite cards (blue, before status so status overrides) --- */
    table.dataTable tbody tr.favorite {
        border-left: 4px solid var(--accent);
        background: var(--accent-light) !important;
        box-shadow: 0 2px 8px rgba(29, 78, 216, .12);
    }
    table.dataTable tbody tr.favorite td {
        background-color: transparent !important;
    }
    #table-data tbody tr.favorite th {
        color: var(--accent-dark);
        border-bottom-color: var(--accent);
        background: var(--favorite-even) !important;
    }
    table.dataTable tbody tr.favorite.odd td,
    table.dataTable tbody tr.favorite.odd th,
    table.dataTable tbody tr.favorite.even td,
    table.dataTable tbody tr.favorite.even th {
        background-color: transparent !important;
        background: transparent !important;
    }

    /* --- Status cards (override favorites when combined) --- */
    table.dataTable tbody tr.offline td,
    table.dataTable tbody tr.offline.odd td,
    table.dataTable tbody tr.offline.even td {
        background-color: transparent !important;
        background: transparent !important;
    }
    table.dataTable tbody tr.offline {
        border-left: 4px solid var(--red);
        background: var(--offline-bg) !important;
        box-shadow: none;
    }
    #table-data tbody tr.offline th {
        color: var(--offline-text);
        border-bottom-color: var(--red);
        background: var(--offline-even) !important;
    }

    table.dataTable tbody tr.late td,
    table.dataTable tbody tr.late.odd td,
    table.dataTable tbody tr.late.even td {
        background-color: transparent !important;
        background: transparent !important;
    }
    table.dataTable tbody tr.late {
        border-left: 4px solid var(--orange);
        background: var(--late-bg) !important;
        box-shadow: none;
    }
    #table-data tbody tr.late th {
        color: var(--late-text);
        border-bottom-color: var(--orange);
        background: var(--late-even) !important;
    }

    /* --- Status icons on card header --- */
    #table-data tbody tr.offline th::after,
    #table-offline tbody tr.offline th::after {
        content: "\00a0\26A0\FE0F";
    }
    #table-data tbody tr.late th::after {
        content: "\00a0\23F3";
    }

    /* --- Zebra, hover & column highlight: neutralize on cards --- */
    table.dataTable tbody tr.odd:not(.offline):not(.late),
    table.dataTable tbody tr.even:not(.offline):not(.late) {
        background-color: var(--bg-card) !important;
    }
    table.dataTable tbody tr.odd th,
    table.dataTable tbody tr.even th {
        background-color: transparent !important;
    }
    table.dataTable tbody tr:hover td,
    table.dataTable tbody tr:hover th {
        background-color: transparent !important;
        color: inherit !important;
    }
    table.dataTable tbody tr:hover td a {
        color: var(--accent) !important;
    }
    table.dataTable tbody tr.offline:hover td,
    table.dataTable tbody tr.offline:hover th,
    table.dataTable tbody tr.late:hover td,
    table.dataTable tbody tr.late:hover th {
        background-color: transparent !important;
        color: inherit !important;
    }

    /* Hide country column on mobile */
    td.country {
        display: none !important;
    }

    /* --- Condensed mode (sort active) --- */
    #table-data.mobile-condensed tbody tr {
        display: flex !important;
        align-items: center;
        padding: 4px 10px;
        margin-bottom: 0;
        gap: 0;
        border: none;
        border-bottom: 1px solid var(--border-light);
        border-radius: 0;
        box-shadow: none;
    }

    #table-data.mobile-condensed tbody tr th {
        font-size: 12px;
        font-family: var(--font-mono);
        padding: 0;
        margin: 0;
        border: none;
        flex-shrink: 0;
        min-width: 80px;
    }

    #table-data.mobile-condensed tbody tr td {
        display: none !important;
    }

    #table-data.mobile-condensed tbody tr td.sort-active,
    #table-data.mobile-condensed tbody tr td.d2-active,
    #table-data.mobile-condensed tbody tr td.d3-active {
        display: block !important;
        text-align: right;
        flex: 1;
        font-size: 13px;
        font-weight: 700;
        background: transparent !important;
        background-color: transparent !important;
        border: none;
        padding: 0;
    }

    #table-data.mobile-condensed tbody tr td.sort-active::before,
    #table-data.mobile-condensed tbody tr td.d2-active::before,
    #table-data.mobile-condensed tbody tr td.d3-active::before {
        display: none;
    }

    /* Hide record/status icons in condensed mode */
    #table-data.mobile-condensed tbody tr td.sort-active::after,
    #table-data.mobile-condensed tbody tr td.d2-active::after,
    #table-data.mobile-condensed tbody tr td.d3-active::after {
        display: none;
    }
    #table-data.mobile-condensed tbody tr.offline th::after,
    #table-data.mobile-condensed tbody tr.late th::after {
        display: none;
    }

    /* 3-column mode: smaller font to fit on 375px */
    #table-data.mobile-condensed.cols-3 tbody tr th {
        min-width: 60px;
    }
    #table-data.mobile-condensed.cols-3 tbody tr td.sort-active,
    #table-data.mobile-condensed.cols-3 tbody tr td.d2-active,
    #table-data.mobile-condensed.cols-3 tbody tr td.d3-active {
        font-size: 12px;
    }
    #table-data.mobile-condensed.cols-3 #condensed-header .ch-code {
        min-width: 60px;
    }

    /* Favorites in condensed mode (before status so status overrides) */
    #table-data.mobile-condensed tbody tr.favorite {
        background: var(--accent-light) !important;
        border-left: 3px solid var(--accent);
        box-shadow: none;
    }
    #table-data.mobile-condensed tbody tr.favorite th {
        color: var(--accent-dark);
        font-weight: 700;
        background: transparent !important;
    }
    #table-data.mobile-condensed tbody tr.favorite td.sort-active,
    #table-data.mobile-condensed tbody tr.favorite td.d2-active,
    #table-data.mobile-condensed tbody tr.favorite td.d3-active {
        color: var(--accent-dark);
        font-weight: 700;
    }

    /* Status in condensed mode (override favorites when combined) */
    #table-data.mobile-condensed tbody tr.offline {
        border-left: 3px solid var(--red);
        background: var(--offline-bg) !important;
    }
    #table-data.mobile-condensed tbody tr.offline th {
        border: none;
        color: var(--offline-text);
        background: transparent !important;
    }
    #table-data.mobile-condensed tbody tr.offline td.sort-active,
    #table-data.mobile-condensed tbody tr.offline td.d2-active,
    #table-data.mobile-condensed tbody tr.offline td.d3-active {
        color: var(--offline-text);
    }
    #table-data.mobile-condensed tbody tr.late {
        border-left: 3px solid var(--orange);
        background: var(--late-bg) !important;
    }
    #table-data.mobile-condensed tbody tr.late th {
        border: none;
        color: var(--late-text);
        background: transparent !important;
    }
    #table-data.mobile-condensed tbody tr.late td.sort-active,
    #table-data.mobile-condensed tbody tr.late td.d2-active,
    #table-data.mobile-condensed tbody tr.late td.d3-active {
        color: var(--late-text);
    }

    /* Hover in condensed mode */
    #table-data.mobile-condensed tbody tr:hover {
        background-color: var(--accent-light) !important;
    }
    #table-data.mobile-condensed tbody tr:hover th {
        color: var(--accent-dark) !important;
    }
    #table-data.mobile-condensed tbody tr:hover td.sort-active,
    #table-data.mobile-condensed tbody tr:hover td.d2-active,
    #table-data.mobile-condensed tbody tr:hover td.d3-active {
        color: var(--accent-dark) !important;
    }
    #table-data.mobile-condensed tbody tr.favorite:hover {
        background-color: var(--favorite-odd) !important;
    }
    #table-data.mobile-condensed tbody tr.favorite:hover th,
    #table-data.mobile-condensed tbody tr.favorite:hover td.sort-active,
    #table-data.mobile-condensed tbody tr.favorite:hover td.d2-active,
    #table-data.mobile-condensed tbody tr.favorite:hover td.d3-active {
        color: var(--accent-dark) !important;
    }
    #table-data.mobile-condensed tbody tr.offline:hover {
        background-color: var(--offline-even) !important;
    }
    #table-data.mobile-condensed tbody tr.offline:hover th,
    #table-data.mobile-condensed tbody tr.offline:hover td.sort-active,
    #table-data.mobile-condensed tbody tr.offline:hover td.d2-active,
    #table-data.mobile-condensed tbody tr.offline:hover td.d3-active {
        color: var(--offline-text) !important;
    }
    #table-data.mobile-condensed tbody tr.late:hover {
        background-color: var(--late-even) !important;
    }
    #table-data.mobile-condensed tbody tr.late:hover th,
    #table-data.mobile-condensed tbody tr.late:hover td.sort-active,
    #table-data.mobile-condensed tbody tr.late:hover td.d2-active,
    #table-data.mobile-condensed tbody tr.late:hover td.d3-active {
        color: var(--late-text) !important;
    }

    /* --- Mobile detail panels (expanded rows) --- */
    .detail-mobile {
        padding: 2px 0;
    }

    .dm-select {
        width: 100%;
        font-family: var(--font-sans);
        font-size: 12px;
        font-weight: 600;
        padding: 5px 8px;
        border: 1px solid var(--border);
        border-radius: 4px;
        background: var(--bg-card);
        color: var(--text-primary);
        cursor: pointer;
        outline: none;
        margin-bottom: 6px;
    }

    .dm-select:focus {
        border-color: var(--accent);
        box-shadow: 0 0 0 3px var(--accent-light);
    }

    .dm-select optgroup {
        font-style: normal;
        font-weight: 700;
        color: var(--text-muted);
        font-size: 11px;
    }

    .dm-select option {
        font-weight: 500;
        color: var(--text-primary);
        padding: 2px 4px;
    }

    .dm-section {
        margin-bottom: 0;
    }

    .dm-grid {
        display: grid;
        grid-template-columns: auto 1fr 1fr;
        gap: 1px 8px;
        font-size: 12px;
        font-family: var(--font-mono);
    }

    .dm-grid-2 {
        grid-template-columns: auto 1fr;
    }

    .dm-hdr {
        font-size: 10px;
        font-weight: 600;
        text-transform: uppercase;
        color: var(--text-muted);
    }

    .dm-label {
        font-size: 10px;
        font-weight: 600;
        color: var(--text-secondary);
        font-family: var(--font-sans);
    }

    .dm-grid small {
        font-size: 9px;
        color: var(--text-muted);
        display: block;
    }

    .dm-monitoring .battery_OK {
        color: var(--green);
        font-weight: 700;
    }

    .dm-monitoring .battery_LOW {
        color: var(--red);
        font-weight: 700;
    }

    /* --- Hide expand button on offline stations --- */
    #table-offline tbody tr > td.details-control {
        display: none !important;
    }

    #table-data.mobile-condensed tbody tr.offline > td.details-control {
        display: none !important;
    }

    /* --- Offline table: always condensed on mobile --- */
    #table-offline tbody tr {
        display: flex !important;
        align-items: center;
        padding: 4px 10px;
        margin-bottom: 0;
        gap: 0;
        border: none;
        border-bottom: 1px solid var(--border-light);
        border-left: 3px solid var(--red);
        border-radius: 0;
        box-shadow: none;
        background: var(--offline-bg) !important;
    }

    #table-offline tbody tr th {
        font-size: 12px;
        font-family: var(--font-mono);
        padding: 0;
        margin: 0;
        border: none;
        flex-shrink: 0;
        min-width: 80px;
        color: var(--offline-text);
    }

    #table-offline tbody tr td {
        display: none !important;
    }

    #table-offline tbody tr td.dateloss {
        display: block !important;
        text-align: right;
        flex: 1;
        font-size: 12px;
        font-weight: 600;
        font-family: var(--font-sans);
        background: transparent !important;
        background-color: transparent !important;
        border: none;
        padding: 0;
        color: var(--offline-text);
    }

    #table-offline tbody tr td.dateloss::before {
        display: none;
    }

    #table-offline tbody tr.reaching_dataloss td.dateloss {
        color: var(--red);
        font-weight: 700;
    }

    /* DataTables overrides */
    table.dataTable {
        border-collapse: separate !important;
        border-spacing: 0;
    }
    table.dataTable tbody td.sorting_1,
    table.dataTable tbody td.sorting_2,
    table.dataTable tbody td.sorting_3 {
        background-color: transparent !important;
        background: transparent !important;
    }
    #table-data.mobile-condensed tbody tr td.sorting_1,
    #table-data.mobile-condensed tbody tr td.sorting_2,
    #table-data.mobile-condensed tbody tr td.sorting_3,
    #table-data.mobile-condensed tbody tr.favorite td.sorting_1,
    #table-data.mobile-condensed tbody tr.favorite td.sorting_2,
    #table-data.mobile-condensed tbody tr.favorite td.sorting_3 {
        background: transparent !important;
        background-color: transparent !important;
    }

    #table-data.mobile-condensed tbody tr td.d2-active.sorting_1,
    #table-data.mobile-condensed tbody tr td.d2-active.sorting_2,
    #table-data.mobile-condensed tbody tr td.d2-active.sorting_3,
    #table-data.mobile-condensed tbody tr td.d3-active.sorting_1,
    #table-data.mobile-condensed tbody tr td.d3-active.sorting_2,
    #table-data.mobile-condensed tbody tr td.d3-active.sorting_3 {
        background: transparent !important;
        background-color: transparent !important;
    }
}

/* --- Focus styles --- */
#data-picker-btn:focus-visible,
#mobile-sort-reset:focus-visible {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-light);
}

td.details-control:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

.dp-close:focus-visible,
.dp-search-clear:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

