/* CSS Variables for Premium Dark Glassmorphism Theme */
:root {
    --bg-color: #0b0f19;
    --card-bg: rgba(22, 28, 45, 0.7);
    --card-border: rgba(255, 255, 255, 0.08);
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    
    /* Decibel dynamic colors */
    --color-safe: #10b981;    /* Green */
    --color-warning: #f59e0b; /* Amber */
    --color-danger: #ef4444;  /* Red */
    
    /* Neon Glows */
    --glow-safe: 0 0 20px rgba(16, 185, 129, 0.4);
    --glow-warning: 0 0 20px rgba(245, 158, 11, 0.4);
    --glow-danger: 0 0 20px rgba(239, 68, 68, 0.4);
    
    --primary-gradient: linear-gradient(135deg, #00f2fe 0%, #4facfe 100%);
    --primary-glow: 0 0 15px rgba(79, 172, 254, 0.5);
    
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
}

h1, h2, h3, h4 {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
}

/* App Container Layout */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 20px;
    max-width: 1280px;
    margin: 0 auto;
    gap: 20px;
}

/* Header */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    backdrop-filter: blur(12px);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text-primary);
    transition: var(--transition-smooth);
}

.logo:hover {
    opacity: 0.9;
    transform: scale(1.02);
}

.logo-icon {
    font-size: 24px;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 2px 8px rgba(79, 172, 254, 0.4));
}

.logo-text {
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    font-size: 22px;
    letter-spacing: 1px;
}

.header-title {
    font-size: 20px;
    font-weight: 600;
    display: none; /* Hide on small mobile, show on tablet */
}

@media (min-width: 768px) {
    .header-title {
        display: block;
    }
}

.header-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-secondary);
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.status-dot.online {
    background-color: var(--color-safe);
    box-shadow: 0 0 10px var(--color-safe);
    animation: pulse 1.5s infinite;
}

.status-dot.offline {
    background-color: var(--color-danger);
    box-shadow: 0 0 10px var(--color-danger);
}

/* Main Layout Grid */
.app-main {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    flex-grow: 1;
}

/* Panels */
.meter-panel {
    display: flex;
    flex-direction: column;
}

.details-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

@media (min-width: 992px) {
    .app-main {
        grid-template-columns: 440px 1fr;
        gap: 20px;
    }
}

/* Cards Design (Glassmorphism) */
.glass-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    padding: 24px;
    backdrop-filter: blur(16px) saturate(180%);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.card-title {
    font-size: 18px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--card-border);
    padding-bottom: 10px;
}

.card-title i {
    color: #4facfe;
}

/* Meter Panel (Gauge Card) */
.main-meter-card {
    min-height: auto;
    justify-content: flex-start;
    gap: 12px;
    align-items: center;
    position: relative;
}

/* Mic Permission Prompt Overlay */
.permission-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(11, 15, 25, 0.95);
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    text-align: center;
    gap: 20px;
    transition: var(--transition-smooth);
}

.permission-overlay.hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(1.05);
}

.mic-icon-pulse {
    font-size: 64px;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: float 3s ease-in-out infinite;
}

/* Gauge SVG */
.gauge-container {
    position: relative;
    width: 250px;
    height: 250px;
    margin: 10px auto;
}

.gauge-svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg); /* align starting point at bottom */
}

.gauge-track {
    fill: none;
    stroke: rgba(255, 255, 255, 0.05);
    stroke-width: 12;
}

.gauge-fill {
    fill: none;
    stroke-width: 12;
    stroke-linecap: round;
    stroke-dasharray: 534; /* 2 * PI * r (r=85) -> ~534 */
    stroke-dashoffset: 534; /* fully hidden initially */
    transition: stroke-dashoffset 0.1s ease-out, stroke 0.3s ease;
}

.gauge-fill.level-safe { stroke: var(--color-safe); filter: drop-shadow(0 0 8px var(--color-safe)); }
.gauge-fill.level-warning { stroke: var(--color-warning); filter: drop-shadow(0 0 8px var(--color-warning)); }
.gauge-fill.level-danger { stroke: var(--color-danger); filter: drop-shadow(0 0 8px var(--color-danger)); }

.gauge-content {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.db-number {
    font-family: 'Outfit', sans-serif;
    font-size: 48px;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -1px;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.1);
}

.db-unit {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 600;
    letter-spacing: 1px;
    margin-top: 2px;
}

/* Badges */
.badge {
    margin-top: 10px;
    padding: 6px 14px;
    border-radius: 50px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: var(--transition-smooth);
}

.badge-safe { background-color: rgba(16, 185, 129, 0.15); color: var(--color-safe); border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-warning { background-color: rgba(245, 158, 11, 0.15); color: var(--color-warning); border: 1px solid rgba(245, 158, 11, 0.3); }
.badge-danger { background-color: rgba(239, 68, 68, 0.15); color: var(--color-danger); border: 1px solid rgba(239, 68, 68, 0.3); }

/* Stats grid */
.stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    width: 100%;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    padding: 12px 6px;
    margin: 15px 0;
}

.stat-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.stat-box:last-child {
    border-right: none;
}

.stat-label {
    font-size: 10px;
    color: var(--text-secondary);
    font-weight: 700;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.stat-value {
    font-family: 'Outfit', sans-serif;
    font-size: 20px;
    font-weight: 600;
}

.stat-unit {
    font-size: 10px;
    color: var(--text-secondary);
}

/* Calibration section */
.calibration-section {
    width: 100%;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 16px;
    padding: 16px;
}

.calibration-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.section-sub-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.calibration-badge {
    background: rgba(79, 172, 254, 0.15);
    color: #4facfe;
    border: 1px solid rgba(79, 172, 254, 0.3);
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
}

.slider-container {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.slider-label {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 600;
    width: 20px;
}

.range-slider {
    flex-grow: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    outline: none;
    transition: background 0.3s;
}

.range-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #4facfe;
    box-shadow: 0 0 8px rgba(79, 172, 254, 0.8);
    cursor: pointer;
    transition: transform 0.1s;
}

.range-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.section-desc {
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Button stylings */
.btn {
    font-family: 'Outfit', sans-serif;
    font-size: 14px;
    font-weight: 600;
    padding: 11px 22px;
    border: 1px solid transparent;
    border-radius: 12px;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    white-space: nowrap;
    user-select: none;
}

.btn-glow {
    background: var(--primary-gradient);
    color: #fff;
    padding: 12px 26px;
    box-shadow: var(--primary-glow);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-glow:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 0 25px rgba(79, 172, 254, 0.7);
}

.btn-glow:active:not(:disabled) {
    transform: translateY(0);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.16);
    color: var(--text-primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(8px);
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.16);
    border-color: rgba(255, 255, 255, 0.3);
    color: #ffffff;
    transform: translateY(-2px);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.btn-secondary:active:not(:disabled) {
    transform: translateY(0);
    background: rgba(255, 255, 255, 0.12);
}

.controls-row {
    display: flex;
    gap: 12px;
    width: 100%;
}

.btn-control {
    flex-grow: 1;
    padding: 14px;
    background: var(--primary-gradient);
    color: white;
    font-size: 15px;
    box-shadow: var(--primary-glow);
}

.btn-control:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 0 20px rgba(79, 172, 254, 0.6);
}

.btn-control.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    box-shadow: none;
}

.btn-control.btn-secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.btn:disabled, button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* Charts Panel */
.chart-card {
    min-height: 220px;
}

.chart-container {
    width: 100%;
    height: 150px;
    position: relative;
}

#noise-chart {
    width: 100% !important;
    height: 100% !important;
}

/* Tabs UI for legislation */
.tabs-header {
    display: flex;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 4px;
    margin-bottom: 20px;
}

.tab-btn {
    flex-grow: 1;
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 10px;
    font-weight: 600;
    font-size: 13px;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.tab-btn.active {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
    animation: fadeIn 0.4s ease-out;
}

/* Diagnostic Box */
.legislation-diagnostic {
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 20px;
    border: 1px solid transparent;
    transition: var(--transition-smooth);
}

.legislation-diagnostic.diag-safe {
    background: rgba(16, 185, 129, 0.08);
    border-color: rgba(16, 185, 129, 0.2);
}

.legislation-diagnostic.diag-warning {
    background: rgba(245, 158, 11, 0.08);
    border-color: rgba(245, 158, 11, 0.2);
}

.legislation-diagnostic.diag-danger {
    background: rgba(239, 68, 68, 0.08);
    border-color: rgba(239, 68, 68, 0.2);
}

.diagnostic-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
}

.status-icon {
    font-size: 20px;
    margin-top: 2px;
}

.diag-safe .status-icon { color: var(--color-safe); }
.diag-warning .status-icon { color: var(--color-warning); }
.diag-danger .status-icon { color: var(--color-danger); }

.diagnostic-title {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 2px;
}

.diagnostic-desc {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.limit-bar-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 12px;
}

.limit-bar-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
}

.limit-bar-badge {
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
}

.diag-safe .limit-bar-badge { background: rgba(16, 185, 129, 0.15); color: var(--color-safe); }
.diag-warning .limit-bar-badge { background: rgba(245, 158, 11, 0.15); color: var(--color-warning); }
.diag-danger .limit-bar-badge { background: rgba(239, 68, 68, 0.15); color: var(--color-danger); }

/* Reference Tables */
.reference-panel h4 {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 10px;
    font-weight: 600;
}

.table-responsive {
    overflow-x: auto;
}

.ref-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.ref-table th, .ref-table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.ref-table th {
    font-weight: 600;
    color: var(--text-secondary);
    background: rgba(0, 0, 0, 0.1);
}

.ref-table tr.active-limit {
    background: rgba(79, 172, 254, 0.08);
    font-weight: 600;
    color: #4facfe;
}

.ref-table tr.active-limit td {
    border-bottom-color: rgba(79, 172, 254, 0.2);
}

/* Zone & Period filters */
.filters-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

@media (min-width: 480px) {
    .filters-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.filter-group label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
}

/* Standardizing Input/Select Fields for Dark Mode contrast (hidden-admin-setup requirements) */
.custom-select, .form-input {
    width: 100%;
    background-color: #121824;
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 10px;
    font-size: 13px;
    outline: none;
    transition: var(--transition-smooth);
}

.custom-select:focus, .form-input:focus {
    border-color: #4facfe;
    box-shadow: 0 0 8px rgba(79, 172, 254, 0.3);
}

/* Footer styling */
.app-footer {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
    justify-content: center;
    padding: 20px;
    text-align: center;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    backdrop-filter: blur(12px);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.footer-links-row {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px 14px;
    margin-bottom: 4px;
}

.footer-nav-link {
    color: #94a3b8 !important;
    text-decoration: none;
    font-size: 12px;
    font-weight: 600;
    transition: var(--transition-smooth);
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.footer-nav-link:hover {
    color: #38bdf8 !important;
}

.footer-sep {
    color: rgba(255, 255, 255, 0.2);
    font-size: 10px;
}

.footer-copyright, .footer-support {
    font-size: 11px;
    color: #64748b;
    line-height: 1.5;
}

.footer-link {
    color: #38bdf8 !important;
    text-decoration: none;
    font-weight: 600;
    transition: var(--transition-smooth);
}

.footer-link:hover {
    color: #00f2fe !important;
    text-decoration: underline;
}

/* Modal overlays (login, admin) */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(5, 7, 12, 0.85);
    backdrop-filter: blur(10px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    transition: var(--transition-smooth);
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-card {
    width: 100%;
    max-width: 440px;
    border-radius: 24px;
    background: rgba(18, 24, 38, 0.95);
    border: 1px solid var(--card-border);
    padding: 30px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
    transform: scale(0.95);
    transition: var(--transition-smooth);
}

.modal-overlay:not(.hidden) .modal-card {
    transform: scale(1);
}

.admin-panel-card {
    max-width: 600px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--card-border);
    padding-bottom: 12px;
}

.modal-header h2 {
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.btn-close:hover {
    color: var(--text-primary);
}

/* Forms in modals */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.form-group label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-input {
    padding: 12px;
    background-color: #0b0f19 !important;
    border-color: rgba(255, 255, 255, 0.08) !important;
    font-size: 14px;
}

.inline-group {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
}

.inline-group label {
    font-size: 13px;
}

.error-message {
    color: var(--color-danger);
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 12px;
    text-align: center;
}

.error-message.hidden {
    display: none;
}

.w-full {
    width: 100%;
}

.w-24 {
    width: 96px;
}

/* Admin Sections */
.admin-tab-section {
    margin-bottom: 24px;
    border-bottom: 1px solid var(--card-border);
    padding-bottom: 20px;
}

.admin-tab-section:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.admin-tab-section h3 {
    font-size: 14px;
    margin-bottom: 12px;
    color: #4facfe;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.admin-btn-row {
    display: flex;
    gap: 12px;
    margin-top: 12px;
}

.admin-btn-row .btn {
    flex-grow: 1;
    padding: 10px;
    font-size: 13px;
}

/* Diagnostics Table */
.diagnostics-table {
    width: 100%;
    font-size: 12px;
}

.diagnostics-table td {
    padding: 6px 0;
}

.diagnostics-table td:last-child {
    text-align: right;
    font-family: monospace;
    color: #4facfe;
    font-size: 13px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 20px;
    border-top: 1px solid var(--card-border);
    padding-top: 16px;
}

/* Animations */
@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.7; }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes float {
    0% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
    100% { transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- SOUND METER PRO ENHANCEMENTS --- */

/* WakeLock Indicator Badge */
.wakelock-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 20px;
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.35);
    animation: pulse 2s infinite;
}

.wakelock-badge.hidden {
    display: none !important;
}

/* Audio Configuration Bar (Weighting & Speed Pills) */
.audio-config-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    gap: 8px;
    margin-bottom: 8px;
}

.pill-group {
    display: inline-flex;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    padding: 3px;
    gap: 2px;
}

.pill-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 16px;
    cursor: pointer;
    transition: var(--transition-smooth);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.pill-btn:hover {
    color: var(--text-primary);
}

.pill-btn.active {
    background: var(--primary-gradient);
    color: #ffffff;
    box-shadow: 0 0 10px rgba(79, 172, 254, 0.4);
    border-color: rgba(255, 255, 255, 0.2);
}

/* 4-column Stats Row */
.stats-row.stats-grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    width: 100%;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 16px;
    padding: 12px 6px;
    margin: 12px 0;
}

.stats-row.stats-grid-4 .stat-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    padding: 0 4px;
}

.stats-row.stats-grid-4 .stat-box:last-child {
    border-right: none;
}

/* Report Action Button Prominent */
.btn-report-prominent {
    width: 100%;
    margin-top: 10px;
    padding: 13px 18px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #ffffff;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.3px;
    box-shadow: 0 0 16px rgba(16, 185, 129, 0.35);
    border: 1px solid rgba(16, 185, 129, 0.5);
    border-radius: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition-smooth);
}

.btn-report-prominent:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 30px rgba(16, 185, 129, 0.75);
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
}

.btn-header-report {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.4);
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 700;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition-smooth);
    white-space: nowrap;
}

.btn-header-report:hover {
    background: #10b981;
    color: #ffffff;
    box-shadow: 0 0 14px rgba(16, 185, 129, 0.5);
    transform: translateY(-1px);
}

.header-right-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

@media (max-width: 600px) {
    #btn-header-report {
        display: none !important;
    }
    .header-right-group {
        gap: 6px;
    }
}

/* Alarm & Vibration Section */
.alarm-section {
    width: 100%;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    padding: 10px 14px;
    margin-top: 10px;
}

.alarm-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.alarm-controls {
    display: flex;
    align-items: center;
    gap: 6px;
}

.alarm-sym {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 700;
}

.alarm-input {
    width: 52px;
    background: #0b0f19;
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #ffffff;
    border-radius: 8px;
    padding: 4px 6px;
    font-size: 13px;
    text-align: center;
    font-weight: 700;
    outline: none;
}

.alarm-input:focus {
    border-color: #ef4444;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.4);
}

.alarm-unit {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 600;
}

/* Switch Toggle Component */
.switch-toggle {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
    margin-left: 6px;
    cursor: pointer;
}

.switch-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.switch-slider {
    position: absolute;
    inset: 0;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    transition: 0.3s;
}

.switch-slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    border-radius: 50%;
    transition: 0.3s;
}

input:checked + .switch-slider {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.5);
}

input:checked + .switch-slider:before {
    transform: translateX(16px);
}

/* Alarm Active Flash Animation */
.alarm-flash {
    animation: alarmGlow 0.5s infinite alternate !important;
    border-color: rgba(239, 68, 68, 0.8) !important;
}

@keyframes alarmGlow {
    0% { box-shadow: 0 0 15px rgba(239, 68, 68, 0.3); }
    100% { box-shadow: 0 0 40px rgba(239, 68, 68, 0.9); }
}

/* Chart Header & Mode Tabs */
.chart-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--card-border);
    padding-bottom: 10px;
}

.no-border-padding {
    border-bottom: none !important;
    padding-bottom: 0 !important;
    margin-bottom: 0 !important;
}

.chart-mode-tabs {
    display: inline-flex;
    gap: 3px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    padding: 3px;
}

.chart-mode-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 600;
    padding: 5px 12px;
    border-radius: 16px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition-smooth);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.chart-mode-btn:hover {
    color: var(--text-primary);
}

.chart-mode-btn.active {
    background: var(--primary-gradient);
    color: #ffffff;
    box-shadow: 0 0 10px rgba(79, 172, 254, 0.4);
    border-color: rgba(255, 255, 255, 0.2);
}

/* Dosimeter Widget */
.dosimeter-widget {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 14px;
    padding: 14px;
    margin-bottom: 16px;
}

.dosimeter-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.dosimeter-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.dose-badge {
    font-size: 12px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 6px;
}

.dose-bar-track {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.dose-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #10b981 0%, #f59e0b 70%, #ef4444 100%);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.dose-details {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-secondary);
    gap: 8px;
    flex-wrap: wrap;
}

.dose-details strong {
    color: var(--text-primary);
}

@media (max-width: 480px) {
    .dose-details {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 6px 8px;
    }
    .dose-details span:last-child {
        grid-column: span 2;
    }
}

/* Report Modal & Printable Layout */
.report-modal-card {
    max-width: 820px;
    width: 100%;
    max-height: 90vh;
    max-height: 90dvh;
    display: flex;
    flex-direction: column;
    padding: 24px;
    box-sizing: border-box;
}

.report-scroll-container {
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 6px;
    flex-grow: 1;
    margin-bottom: 12px;
    width: 100%;
    box-sizing: border-box;
}

.report-document {
    background: #ffffff;
    color: #111827;
    border-radius: 14px;
    padding: 26px;
    font-size: 13px;
    box-shadow: 0 4px 25px rgba(0, 0, 0, 0.35);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
}

.report-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #0f172a;
    padding-bottom: 12px;
    margin-bottom: 16px;
}

.report-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.report-logo .logo-icon {
    font-size: 32px;
    color: #0284c7;
    -webkit-text-fill-color: initial;
}

.report-brand {
    font-size: 20px;
    font-weight: 800;
    font-family: 'Outfit', sans-serif;
    color: #0f172a;
    letter-spacing: 0.5px;
}

.report-subbrand {
    font-size: 11px;
    color: #64748b;
    font-weight: 500;
}

.report-doc-id {
    text-align: right;
    font-size: 12px;
    color: #475569;
}

.report-sec-title {
    font-size: 13px;
    font-weight: 700;
    color: #0f172a;
    background: #f1f5f9;
    padding: 6px 12px;
    border-left: 4px solid #0284c7;
    border-radius: 4px;
    margin: 16px 0 10px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.report-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.report-field {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.report-field label {
    font-size: 10px;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
}

.report-input {
    padding: 7px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 12px;
    color: #0f172a;
    background: #f8fafc;
    outline: none;
}

.report-input:focus {
    border-color: #0284c7;
    background: #ffffff;
}

.report-metrics-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 10px;
    text-align: center;
}

.report-metric-box {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.report-metric-box.highlight {
    background: #e0f2fe;
    border-radius: 6px;
    padding: 4px;
}

.rep-lbl {
    font-size: 9px;
    font-weight: 700;
    color: #64748b;
}

.rep-val {
    font-size: 15px;
    font-weight: 800;
    color: #0f172a;
}

.report-sub-details {
    display: flex;
    justify-content: space-around;
    font-size: 11px;
    color: #475569;
    margin-top: 10px;
    padding-top: 6px;
    border-top: 1px dashed #e2e8f0;
}

.report-chart-box {
    width: 100%;
    background: #0b0f19;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 4px;
}

.report-chart-img {
    width: 100%;
    height: auto;
    max-height: 190px;
    object-fit: contain;
    display: block;
}

.report-compliance-box {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.rep-comp-item {
    padding: 12px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
}

.rep-comp-item h4 {
    font-size: 12px;
    margin-bottom: 6px;
    color: #0f172a;
}

.rep-comp-item p {
    font-size: 11px;
    color: #334155;
    line-height: 1.45;
}

.report-textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 12px;
    color: #0f172a;
    background: #f8fafc;
    resize: vertical;
    font-family: inherit;
    outline: none;
}

.report-textarea:focus {
    border-color: #0284c7;
    background: #ffffff;
}

.report-signatures {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 36px;
    margin-top: 36px;
    text-align: center;
}

.sig-line {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sig-border {
    border-bottom: 1px solid #94a3b8;
    margin-bottom: 4px;
}

.sig-line span {
    font-size: 10px;
    color: #64748b;
    text-transform: uppercase;
    font-weight: 600;
}

.report-footer {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    align-items: center;
    flex-wrap: wrap;
}

.report-footer .btn {
    padding: 11px 22px;
    font-size: 14px;
    letter-spacing: 0.2px;
}

.report-footer .btn i {
    font-size: 14px;
}

@media (max-width: 600px) {
    .report-footer {
        flex-direction: column;
        gap: 10px;
    }
    .report-footer .btn {
        width: 100%;
        justify-content: center;
    }
}

/* Print Media Styles (A4 formatting) */
@media print {
    body * {
        visibility: hidden;
    }
    #report-modal, #report-modal * {
        visibility: visible;
    }
    #report-modal {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        height: auto;
        background: #ffffff !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    .report-modal-card {
        max-width: 100% !important;
        max-height: none !important;
        padding: 0 !important;
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
    }
    .report-scroll-container {
        overflow: visible !important;
        padding: 0 !important;
    }
    .report-document {
        padding: 0 !important;
        box-shadow: none !important;
        border-radius: 0 !important;
    }
    .no-print {
        display: none !important;
    }
    .report-header {
        flex-direction: row !important;
        align-items: center !important;
    }
    .report-doc-id {
        text-align: right !important;
    }
    .report-form-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 10px !important;
    }
    .report-metrics-grid {
        grid-template-columns: repeat(6, 1fr) !important;
        gap: 6px !important;
    }
    .report-compliance-box {
        grid-template-columns: 1fr 1fr !important;
        gap: 12px !important;
    }
    .report-signatures {
        grid-template-columns: 1fr 1fr !important;
        gap: 36px !important;
        margin-top: 36px !important;
    }
    .report-input, .report-textarea {
        border: none !important;
        background: transparent !important;
        padding: 2px 0 !important;
        color: #000000 !important;
    }
}

/* --- FOOTER LINKS & LEGAL PAGES --- */
.footer-links-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.footer-nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 12px;
    font-weight: 600;
    transition: var(--transition-smooth);
}

.footer-nav-link:hover, .footer-nav-link.active {
    color: #4facfe;
    text-decoration: underline;
}

.footer-sep {
    color: rgba(255, 255, 255, 0.2);
    font-size: 10px;
}

/* Legal & Support Layout */
.legal-page {
    max-width: 860px;
    margin: 0 auto 40px;
    width: 100%;
}

.legal-back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #4facfe;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 16px;
    transition: var(--transition-smooth);
}

.legal-back-link:hover {
    color: #00f2fe;
    transform: translateX(-3px);
}

.legal-card {
    padding: 36px;
}

.legal-card h1 {
    font-size: 28px;
    font-weight: 800;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.legal-subtitle {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 24px;
    border-bottom: 1px solid var(--card-border);
    padding-bottom: 12px;
}

.legal-content h2 {
    font-size: 18px;
    margin-top: 28px;
    margin-bottom: 10px;
    color: #4facfe;
    font-weight: 700;
}

.legal-content h3 {
    font-size: 14px;
    margin-top: 20px;
    margin-bottom: 8px;
    color: var(--text-primary);
    font-weight: 600;
}

.legal-content p {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-secondary);
    margin-bottom: 14px;
}

.legal-content ul {
    margin-left: 20px;
    margin-bottom: 16px;
    color: var(--text-secondary);
}

.legal-content li {
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 8px;
}

.legal-content code {
    background: rgba(0, 0, 0, 0.4);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 12px;
    color: #00f2fe;
    border: 1px solid rgba(0, 242, 254, 0.2);
}

/* =======================================================
   MOBILE GENERAL REFINEMENTS (Max-width: 600px)
   ======================================================= */
@media (max-width: 600px) {
    .app-container {
        padding: 10px;
        gap: 12px;
    }
    .app-header {
        padding: 10px 14px;
        margin-bottom: 12px;
    }
    .header-title {
        display: none !important;
    }
    #btn-header-report {
        display: none !important;
    }
    .header-right-group {
        gap: 6px;
    }
    .glass-card {
        padding: 16px;
        border-radius: 16px;
    }
    .card-title {
        font-size: 16px;
        margin-bottom: 14px;
    }
    .audio-config-bar {
        flex-direction: column;
        align-items: center;
        gap: 8px;
    }
    .stats-row.stats-grid-4 {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px 0 !important;
        padding: 10px 4px !important;
    }
    .stats-row.stats-grid-4 .stat-box:nth-child(1),
    .stats-row.stats-grid-4 .stat-box:nth-child(3) {
        border-right: 1px solid rgba(255, 255, 255, 0.06) !important;
    }
    .stats-row.stats-grid-4 .stat-box:nth-child(2),
    .stats-row.stats-grid-4 .stat-box:nth-child(4) {
        border-right: none !important;
    }
    .stats-row.stats-grid-4 .stat-box:nth-child(1),
    .stats-row.stats-grid-4 .stat-box:nth-child(2) {
        border-bottom: 1px solid rgba(255, 255, 255, 0.06) !important;
        padding-bottom: 8px !important;
    }
    .stats-row.stats-grid-4 .stat-box:nth-child(3),
    .stats-row.stats-grid-4 .stat-box:nth-child(4) {
        padding-top: 6px !important;
    }
    .stat-value {
        font-size: 18px !important;
    }
    .controls-row {
        gap: 8px;
    }
    .btn-control {
        padding: 12px;
        font-size: 14px;
    }
    .btn-report-prominent {
        padding: 12px 14px;
        font-size: 13.5px;
        margin-top: 8px;
    }
    .alarm-section {
        padding: 8px 12px;
    }
    .calibration-section {
        padding: 10px 12px;
    }
    .app-footer {
        padding: 16px 12px;
    }

    /* Report Modal Mobile Optimization */
    .modal-overlay {
        padding: 6px !important;
        align-items: center !important;
        justify-content: center !important;
    }
    .report-modal-card {
        padding: 14px 10px !important;
        max-height: 94vh !important;
        max-height: 94dvh !important;
        max-width: 100% !important;
        width: 100% !important;
        margin: 0 !important;
        border-radius: 16px !important;
    }
    .report-scroll-container {
        padding: 0 2px 0 0 !important;
        overflow-x: hidden !important;
        overflow-y: auto !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }
    .report-document {
        padding: 14px 10px !important;
        border-radius: 10px !important;
        font-size: 11px !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        overflow-x: hidden !important;
    }
    .report-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 6px !important;
        padding-bottom: 8px !important;
        margin-bottom: 10px !important;
    }
    .report-logo .logo-icon {
        font-size: 24px !important;
    }
    .report-brand {
        font-size: 16px !important;
    }
    .report-doc-id {
        text-align: left !important;
        font-size: 10.5px !important;
    }
    .report-sec-title {
        font-size: 11px !important;
        padding: 4px 8px !important;
        margin: 10px 0 6px 0 !important;
    }
    .report-form-grid {
        grid-template-columns: 1fr !important;
        gap: 8px !important;
        min-width: 0 !important;
    }
    .report-field {
        min-width: 0 !important;
    }
    .report-field label {
        font-size: 9px !important;
    }
    .report-input {
        font-size: 12px !important;
        padding: 6px 8px !important;
        width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
    }
    .report-metrics-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 4px !important;
        padding: 8px 3px !important;
        min-width: 0 !important;
    }
    .report-metric-box {
        min-width: 0 !important;
    }
    .rep-lbl {
        font-size: 8px !important;
    }
    .rep-val {
        font-size: 12.5px !important;
    }
    .report-sub-details {
        flex-direction: column !important;
        gap: 3px !important;
        font-size: 10px !important;
    }
    .report-compliance-box {
        grid-template-columns: 1fr !important;
        gap: 8px !important;
        min-width: 0 !important;
    }
    .rep-comp-item {
        padding: 8px 10px !important;
        min-width: 0 !important;
    }
    .rep-comp-item h4 {
        font-size: 11px !important;
        margin-bottom: 4px !important;
    }
    .rep-comp-item p {
        font-size: 10px !important;
    }
    .report-textarea {
        font-size: 11px !important;
        padding: 6px 8px !important;
        min-width: 0 !important;
    }
    .report-signatures {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
        margin-top: 18px !important;
        min-width: 0 !important;
    }
    .sig-line {
        min-width: 0 !important;
    }
    .report-footer {
        flex-direction: column !important;
        gap: 8px !important;
        padding-top: 10px !important;
        margin-top: 8px !important;
    }
    .report-footer .btn {
        width: 100% !important;
        justify-content: center !important;
        padding: 10px 14px !important;
        font-size: 13px !important;
    }
}
