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

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    background: #f0f2f5;
    color: #344767;
}

/* ── Layout ──────────────────────────────────────────────────────────────── */
:root {
    --sidebar-w: 250px;
    --header-h: 56px;
    --blue: #1a73e8;
    --blue-dark: #0d47a1;
    --card-shadow: 0 2px 12px rgba(0,0,0,.12);
}

.layout-sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-w);
    background: linear-gradient(195deg, #42424a 0%, #191919 100%);
    color: #fff;
    z-index: 100;
    display: flex;
    flex-direction: column;
    box-shadow: 3px 0 10px rgba(0,0,0,.3);
}

.sidebar-brand {
    padding: 20px 24px 16px;
    border-bottom: 1px solid rgba(255,255,255,.15);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-brand img { height: 36px; }
.sidebar-brand-text { font-size: 1rem; font-weight: 600; letter-spacing: .5px; }

.sidebar-nav { flex: 1; padding: 16px 12px; }

.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 8px;
    color: rgba(255,255,255,.75);
    cursor: pointer;
    font-size: .875rem;
    margin-bottom: 4px;
    transition: background .2s, color .2s;
    user-select: none;
}

.sidebar-nav-item:hover { background: rgba(255,255,255,.1); color: #fff; }
.sidebar-nav-item.active { background: var(--blue); color: #fff; box-shadow: 0 2px 8px rgba(26,115,232,.5); }
.sidebar-nav-item i { font-size: 1rem; width: 20px; text-align: center; }

.layout-main {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    height: var(--header-h);
    background: rgba(255,255,255,.9);
    backdrop-filter: blur(6px);
    border-bottom: 1px solid rgba(0,0,0,.07);
    display: flex;
    align-items: center;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
    gap: 12px;
}

.topbar-title { font-weight: 600; font-size: 1rem; flex: 1; }

.topbar-sse {
    font-size: .75rem;
    display: flex;
    align-items: center;
    gap: 5px;
}

.dot-live {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: #4caf50;
    animation: pulse 1.5s infinite;
}

.dot-dead { background: #f44336; animation: none; }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .3; }
}

.page-content { padding: 24px; flex: 1; }

/* ── Login ───────────────────────────────────────────────────────────────── */
.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #1a237e 0%, #1a73e8 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,.2);
    width: 100%;
    max-width: 420px;
    overflow: hidden;
}

.login-header {
    background: linear-gradient(135deg, #1a237e, #1a73e8);
    padding: 28px;
    text-align: center;
}

.login-header img { height: 56px; }
.login-header h2 { color: #fff; margin: 12px 0 0; font-size: 1.25rem; }

.login-body { padding: 28px; }
.login-body .form-label { font-size: .875rem; font-weight: 500; }
.login-body .form-control { border-radius: 8px; }

.login-error {
    background: #ffebee;
    color: #c62828;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: .875rem;
    margin-bottom: 16px;
}

.btn-login {
    width: 100%;
    padding: 11px;
    border-radius: 8px;
    background: var(--blue);
    color: #fff;
    border: none;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background .2s;
}

.btn-login:hover:not(:disabled) { background: var(--blue-dark); }
.btn-login:disabled { opacity: .65; cursor: not-allowed; }

.login-version {
    text-align: center;
    font-size: .75rem;
    color: #9e9e9e;
    margin-top: 16px;
}

/* ── Sensor cards ────────────────────────────────────────────────────────── */
.sensors-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: 24px;
}

.sensor-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    overflow: hidden;
}

.sensor-card-header {
    background: linear-gradient(195deg, #1a73e8 0%, #0d47a1 100%);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 56px;
}

.sensor-card-title { font-size: 1rem; font-weight: 600; flex: 1; text-align: center; }

.sensor-card-actions { display: flex; align-items: center; gap: 4px; }

.icon-btn {
    background: none;
    border: none;
    color: rgba(255,255,255,.85);
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 6px;
    font-size: 1rem;
    line-height: 1;
    transition: background .15s;
}

.icon-btn:hover { background: rgba(255,255,255,.2); color: #fff; }

.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: .7rem;
}

.status-dot { width: 9px; height: 9px; border-radius: 50%; }
.status-online { background: #66bb6a; box-shadow: 0 0 6px #66bb6a; }
.status-offline { background: #ef5350; }

.sensor-card-body { padding: 16px; }

.gauge-wrapper {
    width: 100%;
    aspect-ratio: 1 / 1;
    max-height: 320px;
    position: relative;
    display: block;
    overflow: hidden;
}

.sensor-info {
    text-align: center;
    padding: 8px 0 4px;
    font-size: .875rem;
    color: #555;
    line-height: 1.6;
}

.sensor-info .fill-notice { color: #e53935; font-weight: 500; }

.sensor-badges {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin: 6px 0;
}

.badge-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: .75rem;
    color: #666;
    background: #f5f5f5;
    border-radius: 20px;
    padding: 3px 10px;
}

/* ── Settings slide ──────────────────────────────────────────────────────── */
.settings-slide { padding: 16px; }
.settings-slide h4 { text-align: center; font-size: 1rem; margin-bottom: 16px; }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: .8rem; font-weight: 500; color: #555; margin-bottom: 4px; }
.form-group input, .form-group select {
    width: 100%;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: .875rem;
    outline: none;
    transition: border-color .2s;
}
.form-group input:focus, .form-group select:focus { border-color: var(--blue); }

.depth-radio { display: flex; align-items: center; gap: 6px; }
.depth-radio label { margin: 0; font-size: .875rem; cursor: pointer; }

.tank-use-group { display: flex; gap: 8px; }
.tank-use-btn {
    flex: 1;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #f5f5f5;
    cursor: pointer;
    font-size: .875rem;
    transition: all .2s;
}
.tank-use-btn.active { background: var(--blue); color: #fff; border-color: var(--blue); }

.settings-footer {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    padding: 12px 16px;
    border-top: 1px solid #f0f0f0;
}

.btn {
    padding: 8px 18px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: .875rem;
    font-weight: 500;
    transition: all .2s;
}

.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--blue-dark); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-secondary { background: #f0f0f0; color: #555; }
.btn-secondary:hover { background: #e0e0e0; }

.email-unverified {
    background: #fff3e0;
    color: #e65100;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: .8rem;
    margin-top: 8px;
}

.email-row { display: flex; align-items: flex-end; gap: 8px; }
.email-row .form-group { flex: 1; margin-bottom: 0; }

/* ── Dialog ──────────────────────────────────────────────────────────────── */
.dialog-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.dialog {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,.2);
    width: 100%;
    max-width: 460px;
    padding: 24px;
}

.dialog h3 { font-size: 1.1rem; margin: 0 0 8px; }
.dialog p { font-size: .875rem; color: #666; margin: 0 0 16px; }

.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

.shape-options { display: flex; gap: 16px; margin: 16px 0; }
.shape-option {
    flex: 1;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    padding: 16px;
    cursor: pointer;
    text-align: center;
    transition: all .2s;
}
.shape-option:hover { border-color: var(--blue); }
.shape-option.selected { border-color: var(--blue); background: #e8f0fe; }
.shape-option svg { display: block; margin: 0 auto 8px; width: 60px; height: 60px; }
.shape-option span { font-size: .875rem; font-weight: 500; }

/* ── History ─────────────────────────────────────────────────────────────── */
.map-card {
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--header-h) - 48px);
}

.corpo-map {
    flex: 1;
    min-height: 0;
    width: 100%;
    /* Leaflet's internal panes/controls use z-index up to ~700-1000; without
       its own stacking context those values compare directly against
       .layout-sidebar (z-index:100) in the root stacking context, so the
       map renders above the mobile slide-in sidebar. */
    isolation: isolate;
}

/* ── Szczegóły split layout ──────────────────────────────────────────────── */
.szczegoly-wrap {
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--header-h) - 48px);
    gap: 12px;
}

.szczegoly-selector-bar {
    flex-shrink: 0;
    background: linear-gradient(195deg, #1a73e8 0%, #0d47a1 100%);
    border-radius: 12px;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    box-shadow: var(--card-shadow);
}

.szczegoly-sensor-select {
    flex: 1;
    min-width: 160px;
    max-width: 360px;
    border: 1px solid rgba(255,255,255,.45);
    border-radius: 8px;
    padding: 5px 10px;
    font-size: .875rem;
    font-family: monospace;
    background: rgba(255,255,255,.15);
    color: #fff;
}
.szczegoly-sensor-select option { color: #344767; background: #fff; }

.szczegoly-top {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
}

.szczegoly-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.szczegoly-card-header {
    flex-shrink: 0;
    background: linear-gradient(195deg, #1a73e8 0%, #0d47a1 100%);
    color: #fff;
    padding: 10px 16px;
    font-weight: 600;
    font-size: .875rem;
}

.szczegoly-card-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 14px 16px;
}

.param-status {
    display: inline-block;
    margin-left: 8px;
    padding: 1px 7px;
    border-radius: 10px;
    font-size: .75rem;
    font-weight: 600;
    vertical-align: middle;
}

.param-status--ok {
    background: #e8f5e9;
    color: #2e7d32;
}

.param-status--pending {
    background: #fff3e0;
    color: #e65100;
}

.param-status--default {
    background: #f5f5f5;
    color: #9e9e9e;
}

.szczegoly-bottom {
    flex: 1;
    min-height: 0;
    background: #fff;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.szczegoly-chart-area {
    flex: 1;
    min-height: 0;
}

.detail-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 7px 20px;
    font-size: .85rem;
    margin: 0;
}
.detail-grid dt { color: #888; white-space: nowrap; }
.detail-grid dd { margin: 0; font-weight: 500; color: #344767; word-break: break-word; }

/* Sensor edit form inside Szczegóły card */
.sef-header-btn { float: right; background: none; border: none; color: #fff; cursor: pointer; font-size: 1rem; padding: 0; opacity: .85; }
.sef-header-btn:hover { opacity: 1; }
.sensor-edit-form { display: flex; flex-direction: column; gap: 10px; }
.sef-row { display: grid; grid-template-columns: 140px 1fr; align-items: start; gap: 8px; font-size: .85rem; }
.sef-row > label:first-child { color: #888; padding-top: 5px; white-space: nowrap; }
.sef-input { width: 100%; border: 1px solid #d0d7de; border-radius: 6px; padding: 5px 8px; font-size: .85rem; color: #344767; outline: none; background: #fff; }
.sef-input:focus { border-color: #1a73e8; box-shadow: 0 0 0 2px rgba(26,115,232,.15); }
.sef-input-sm { width: 80px; }
.sef-radio-group { display: flex; flex-direction: column; gap: 4px; }
.sef-radio { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.sef-addr-wrap { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.sef-addr-row { display: flex; gap: 4px; align-items: center; }
.sef-addr-row .sef-input { flex: 1; min-width: 0; }
.sef-gps-btn { flex-shrink: 0; width: 30px; height: 30px; border: 1px solid #d0d7de; border-radius: 6px; background: #f6f8fa; cursor: pointer; color: #1a73e8; font-size: .85rem; display: flex; align-items: center; justify-content: center; }
.sef-gps-btn:hover:not(:disabled) { background: #e8f0fe; border-color: #1a73e8; }
.sef-gps-btn:disabled { opacity: .5; cursor: not-allowed; }
.sef-gps-coords { font-size: .75rem; color: #888; font-family: monospace; padding-left: 1px; }
#map-picker { cursor: crosshair; }
.sef-error { color: #e53935; font-size: .8rem; }
.sef-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; }

.history-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    margin-bottom: 24px;
    overflow: hidden;
}

.history-card-header {
    background: linear-gradient(195deg, #1a73e8 0%, #0d47a1 100%);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.history-card-header h3 { margin: 0; font-size: 1rem; font-weight: 600; }

.history-controls { display: flex; align-items: center; gap: 8px; }

.period-btns { display: flex; gap: 4px; }
.period-btn {
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,.5);
    background: none;
    color: rgba(255,255,255,.8);
    cursor: pointer;
    font-size: .75rem;
    transition: all .15s;
}
.period-btn:hover { background: rgba(255,255,255,.15); color: #fff; }
.period-btn.active { background: rgba(255,255,255,.25); color: #fff; border-color: rgba(255,255,255,.8); }

.period-range { display: flex; align-items: center; gap: 4px; }
.period-range-sep { color: rgba(255,255,255,.7); font-size: .8rem; }
.period-date-input {
    padding: 3px 6px;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,.5);
    background: rgba(255,255,255,.12);
    color: #fff;
    font-size: .75rem;
    cursor: pointer;
    width: 120px;
    color-scheme: dark;
}
.period-date-input:focus { outline: none; border-color: rgba(255,255,255,.9); background: rgba(255,255,255,.2); }

.battery-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: .8rem;
    color: rgba(255,255,255,.85);
}

.toggle-switch {
    position: relative;
    width: 32px;
    height: 18px;
    background: rgba(255,255,255,.3);
    border-radius: 9px;
    transition: background .2s;
}

.toggle-switch.on { background: #4caf50; }

.toggle-knob {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    background: #fff;
    border-radius: 50%;
    transition: transform .2s;
    box-shadow: 0 1px 3px rgba(0,0,0,.3);
}

.toggle-switch.on .toggle-knob { transform: translateX(14px); }

.chart-container { padding: 16px; min-height: 520px; position: relative; }

/* ── D3 chart styles ─────────────────────────────────────────────────────── */
.chart-area { fill: rgba(8, 72, 146, 0.15); }
.chart-line { fill: none; stroke: #0d47a1; stroke-width: 1.5px; }
.chart-line-battery { fill: none; stroke: red; stroke-width: 1.5px; }
.chart-line-humidity { fill: none; stroke: green; stroke-width: 1.5px; }
.chart-line-temp { fill: none; stroke: orange; stroke-width: 1.5px; }
.dot { fill: #2e2461; }
.dot-bat { fill: #8d2c2c; }

.chart-grid line { stroke: #e8e8e8; }
.chart-grid path { stroke-width: 0; }

.chart-tooltip {
    position: absolute;
    background: rgba(0,0,0,.78);
    color: #fff;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: .78rem;
    pointer-events: none;
    z-index: 10;
    white-space: nowrap;
    transition: opacity .15s;
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 8px 0 0;
    font-size: .8rem;
    color: #555;
}

.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-color { display: inline-block; width: 28px; height: 14px; border-radius: 3px; }

/* ── Hamburger button ────────────────────────────────────────────────────── */
.hamburger-btn {
    display: none;
    background: none;
    border: none;
    font-size: 1.2rem;
    color: #344767;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 6px;
    margin-right: 4px;
    line-height: 1;
}
.hamburger-btn:hover { background: #f0f0f0; }

/* ── Mobile overlay ──────────────────────────────────────────────────────── */
.mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 99;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .hamburger-btn { display: block; }
    .mobile-overlay { display: block; }

    .layout-sidebar {
        width: var(--sidebar-w);
        transform: translateX(calc(-1 * var(--sidebar-w)));
        transition: transform .25s ease;
    }
    .layout-sidebar.sidebar-mobile-open {
        transform: translateX(0);
    }

    .layout-main { margin-left: 0; }
    .sensors-grid { grid-template-columns: 1fr; }

    .szczegoly-selector-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    .szczegoly-sensor-select {
        max-width: 100%;
    }
    .history-controls {
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 2px;
    }
    .period-btns { flex-wrap: nowrap; }
    .period-date-input { width: 110px; }

    .szczegoly-top { grid-template-columns: 1fr; }
    .szczegoly-wrap { height: auto; }
    .szczegoly-bottom { min-height: 300px; }
}

/* ── Sidebar org label ───────────────────────────────────────────────────── */
.sidebar-org-label {
    font-size: .72rem;
    color: rgba(255,255,255,.5);
    padding: 0 14px 10px;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Users view ──────────────────────────────────────────────────────────── */
.users-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    overflow: hidden;
}

.users-card-header {
    background: linear-gradient(195deg, #1a73e8 0%, #0d47a1 100%);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.users-card-header h3 { margin: 0; font-size: 1rem; font-weight: 600; }

.users-table-wrap { overflow-x: auto; }

.th-sort {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}
.th-sort:hover { background: #f0f4ff; }
.th-sort .fa { margin-left: 4px; opacity: .45; font-size: .7rem; }
.th-sort .fa-sort-up, .th-sort .fa-sort-down { opacity: 1; color: #1a73e8; }

.sensor-search-wrap {
    position: relative;
    display: flex;
    align-items: center;
}
.sensor-search-icon {
    position: absolute;
    left: 9px;
    color: #9e9e9e;
    font-size: .8rem;
    pointer-events: none;
}
.sensor-search-input {
    padding: 5px 10px 5px 28px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: .82rem;
    width: 200px;
    background: #fff;
    color: #344767;
    outline: none;
}
.sensor-search-input:focus { border-color: #1a73e8; box-shadow: 0 0 0 2px rgba(26,115,232,.15); }

.table-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 10px 16px;
    border-top: 1px solid #f0f0f0;
}
.page-btn {
    background: none;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 5px 10px;
    cursor: pointer;
    color: #344767;
    font-size: .8rem;
    transition: background .15s;
}
.page-btn:hover:not(:disabled) { background: #f0f4ff; border-color: #1a73e8; color: #1a73e8; }
.page-btn:disabled { opacity: .35; cursor: default; }
.page-info { font-size: .82rem; color: #555; }

.msg-sensor-filter {
    border: 1px solid rgba(255,255,255,.45);
    border-radius: 8px;
    padding: 4px 10px;
    font-size: .8rem;
    font-family: monospace;
    background: rgba(255,255,255,.15);
    color: #fff;
}
.msg-sensor-filter option { color: #344767; background: #fff; }

.users-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .875rem;
}

.users-table thead tr {
    background: #f5f7fa;
    border-bottom: 2px solid #e8eaed;
}

.users-table th {
    text-align: left;
    padding: 12px 16px;
    font-weight: 600;
    color: #555;
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    white-space: nowrap;
}

.users-table td {
    padding: 12px 16px;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
    color: #344767;
}

.users-table tbody tr:last-child td { border-bottom: none; }
.users-table tbody tr:hover td { background: #f9fafc; }
.sensor-row-clickable { cursor: pointer; }
.sensor-row-clickable:hover td { background: #e8f0fe !important; }

/* ── Expand toggle column ────────────────────────────────────────────────── */
.col-expand {
    width: 32px;
    padding: 0 4px !important;
    text-align: center;
}

.expand-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #9e9e9e;
    padding: 4px 6px;
    line-height: 1;
    border-radius: 4px;
    transition: color .15s;
}
.expand-btn:hover { color: #1a73e8; }
.expand-btn i { transition: transform .15s; display: inline-block; }
.expand-btn.expanded i { transform: rotate(90deg); }

/* ── Responsive: hide secondary columns on narrow screens ────────────────── */
@media (max-width: 768px) {
    .col-secondary { display: none; }
}

/* On wider screens hide the expand button — columns are visible */
@media (min-width: 769px) {
    .col-expand { display: none; }
    .date-short { display: none; }
}

@media (max-width: 768px) {
    .date-full { display: none; }
}

/* ── Expanded detail row ─────────────────────────────────────────────────── */
.sensor-detail-row td {
    background: #f0f4ff !important;
    padding: 8px 12px 10px 36px !important;
    border-top: none !important;
}
.sensor-detail-row:hover td { background: #f0f4ff !important; }

.sensor-detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 6px 16px;
}

.sdg-item {
    display: flex;
    flex-direction: column;
    font-size: .8rem;
}

.sdg-label {
    font-size: .7rem;
    font-weight: 600;
    color: #9e9e9e;
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-bottom: 1px;
}

.cell-login {
    font-family: monospace;
    font-size: .82rem;
    color: #555;
}

.cell-gps {
    font-size: .78rem;
    color: #555;
    max-width: 200px;
}

.role-badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 20px;
    font-size: .72rem;
    font-weight: 600;
    margin-right: 4px;
    background: #e8f0fe;
    color: #1a73e8;
    border: 1px solid #c5d8fd;
    text-transform: lowercase;
}

.role-badge.role-admin {
    background: #fce8e6;
    color: #c5221f;
    border-color: #f5c6c5;
}

.role-badge.role-hr {
    background: #e8f5e9;
    color: #2e7d32;
    border-color: #a5d6a7;
}

/* ── Roles checklist (hr user modal) ────────────────────────────────────── */
.roles-checklist {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px;
}

.roles-checklist-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 20px;
    border: 1px solid #ddd;
    cursor: pointer;
    font-size: .8rem;
    font-weight: 500;
    color: #555;
    user-select: none;
    transition: all .15s;
}

.roles-checklist-item:hover { border-color: #1a73e8; color: #1a73e8; }

.roles-checklist-item.checked {
    background: #e8f0fe;
    border-color: #1a73e8;
    color: #1a73e8;
}

.roles-checklist-item input[type="checkbox"] {
    width: auto;
    border: none;
    padding: 0;
    margin: 0;
    accent-color: #1a73e8;
    cursor: pointer;
}

/* ── Sensor detail dialog ────────────────────────────────────────────────── */
.sensor-detail-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 8px 16px;
    font-size: .875rem;
    margin: 16px 0;
}

.sd-label {
    color: #777;
    font-weight: 500;
    white-space: nowrap;
    align-self: center;
}

.sd-value {
    color: #344767;
    word-break: break-all;
    align-self: center;
}

/* ── Loader ──────────────────────────────────────────────────────────────── */
.spinner {
    display: inline-block;
    width: 16px; height: 16px;
    border: 2px solid rgba(255,255,255,.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .6s linear infinite;
    vertical-align: middle;
}

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

.page-empty {
    text-align: center;
    padding: 60px 24px;
    color: #9e9e9e;
}

.page-empty i { font-size: 3rem; margin-bottom: 12px; display: block; }
