:root {
    --primary: #00f2fe;
    --secondary: #4facfe;
    --bg: #0a0a0c;
    --card-bg: rgba(255, 255, 255, 0.05);
    --text: #ffffff;
    --text-dim: #a0a0a0;
    --glass: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg);
    color: var(--text);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Strict no-scroll */
    position: fixed;
    width: 100%;
}

.dashboard {
    padding: 0.4rem;
    padding-top: calc(0.4rem + env(safe-area-inset-top));
    padding-bottom: calc(0.4rem + env(safe-area-inset-bottom));
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 0.2rem;
    max-width: 500px;
    margin: 0 auto;
    width: 100%;
    overflow: hidden;
}

header {
    margin-bottom: 0.2rem;
    /* Shrunk spacing */
}

.header-main {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    width: 100%;
}

.header-content-grid {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.header-content-grid h1 {
    font-size: 0.9rem;
    font-weight: 700;
    margin: 0;
    white-space: nowrap;
    letter-spacing: -0.5px;
}

#local-timer {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
    font-family: 'Courier New', Courier, monospace;
}

#country-tag {
    font-size: 0.6rem;
    color: var(--primary);
    /* Matched to timer color */
    opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.subtitle {
    font-size: 0.65rem;
    margin: 0;
    opacity: 0.8;
}

.disclaimer-bottom {
    font-size: 0.62rem;
    /* Increased size */
    color: var(--text);
    /* Use system text color */
    background: rgba(45, 90, 39, 0.15);
    /* Subtle medical green background */
    border: 1px dashed rgba(255, 215, 0, 0.4);
    /* Gold dashed border */
    padding: 6px;
    border-radius: 6px;
    text-align: center;
    line-height: 1.35;
    margin-top: 5px;
    width: 100%;
    font-weight: 700;
    /* Extra bold */
}

#temp-card {
    border-left: 3px solid #ff5722;
    grid-column: span 2;
    /* Spans across to fit nicely at the bottom */
}

.dev-tag {
    font-size: 0.6rem;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    gap: 8px;
}

.dev-tag b {
    color: var(--text);
    font-weight: 700;
}

.wa-link {
    color: #25D366;
    /* Set to primary WhatsApp green natively */
    opacity: 1;
    transition: transform 0.2s ease;
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.1);
    /* Subtle light background to pop icon */
    padding: 2px;
    border-radius: 4px;
}

.wa-link:hover {
    transform: scale(1.2);
    box-shadow: 0 0 10px rgba(37, 211, 102, 0.4);
}

.rahmah-logo-container {
    width: 45px;
    height: 45px;
    min-width: 45px;
    min-height: 45px;
    border-radius: 50%;
    overflow: hidden;
    background: #FFD700;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.4);
    flex-shrink: 0;
}

.rahmah-logo-container svg {
    width: 90%;
    height: 90%;
    object-fit: contain;
}

.rahmah-logo-container:hover {
    transform: scale(1.05);
}

h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 1px;
    background: linear-gradient(to right, #ffffff, #e0e0e0);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

header .subtitle {
    font-size: 0.7rem;
    opacity: 0.7;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.25rem;
    margin: 0.1rem 0;
}

.stat-card {
    background: var(--card-bg);
    backdrop-filter: blur(6px);
    border: 1px solid var(--glass-border);
    border-radius: 6px;
    padding: 0.25rem 0.35rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.stat-card h3 {
    font-size: 0.65rem;
    text-transform: uppercase;
    color: var(--text-dim);
    margin-bottom: 0.2rem;
}

.stat-value {
    font-size: 0.95rem;
    font-weight: 700;
}

.stat-secondary {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 500;
    margin-top: -0.1rem;
    margin-bottom: 0.3rem;
    letter-spacing: 0.5px;
}

.stat-unit-small {
    font-size: 0.5rem;
    color: var(--text-dim);
    margin-left: 1px;
}

.stat-unit {
    font-size: 0.6rem;
    color: var(--text-dim);
}

.reg-label {
    font-size: 0.5rem;
    color: var(--primary);
    display: block;
    font-weight: 400;
    margin-top: 2px;
}

.stat-card .subtitle {
    font-size: 0.55rem;
    margin-top: 0.2rem;
}

/* Trend Chart Styles */
.trend-section {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 0.4rem;
    margin-bottom: 0.2rem;
}

.trend-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.trend-header h3 {
    font-size: 0.65rem;
    text-transform: uppercase;
    color: var(--text-dim);
}

.trend-header h3 small {
    display: block;
    font-size: 0.5rem;
    color: var(--primary);
    text-transform: none;
    margin-top: 2px;
}

.chart-legend {
    display: flex;
    gap: 0.5rem;
}

.legend-item {
    font-size: 0.5rem;
    display: flex;
    align-items: center;
    gap: 3px;
    color: var(--text-dim);
}

.dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.dot.hr {
    background: var(--primary);
    box-shadow: 0 0 5px var(--primary);
}

.dot.spo2 {
    background: #ffab00;
    box-shadow: 0 0 5px #ffab00;
}

.trend-chart-area {
    width: 100%;
    height: 48px;
    position: relative;
    border-left: 1px solid rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

#trend-svg {
    width: 100%;
    height: 100%;
}

.chart-empty {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.6rem;
    color: var(--text-dim);
    text-align: center;
    width: 80%;
}

.action-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.profile-btn {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    color: var(--text);
    padding: 0.5rem;
    border-radius: 10px;
    font-size: 0.6rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
}

.profile-btn svg {
    width: 16px;
    height: 16px;
    fill: var(--primary);
}

.intel-btn {
    border-color: #ffd70033;
}

/* SOS Button Styles */
.sos-container {
    margin: 0.5rem 0;
    width: 100%;
}

.sos-btn {
    background: rgba(255, 59, 48, 0.1);
    border: 1px solid rgba(255, 59, 48, 0.3);
    color: #ff3b30;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.8rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.sos-btn:hover {
    background: rgba(255, 59, 48, 0.2);
    transform: translateY(-2px);
}

.sos-btn svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.sos-pulse {
    position: absolute;
    width: 100%;
    height: 100%;
    background: rgba(255, 59, 48, 0.2);
    top: 0;
    left: 0;
    animation: sos-pulse 2s infinite;
    pointer-events: none;
}

@keyframes sos-pulse {
    0% {
        transform: scale(1);
        opacity: 0.5;
    }

    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

.scan-section {
    background: linear-gradient(180deg, rgba(79, 172, 254, 0.05), transparent);
    border-top: 1px solid var(--glass-border);
    padding: 0.4rem;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-around;
    gap: 0.5rem;
    margin-top: auto;
    /* Push to very bottom */
}

#camera-container {
    width: 50px;
    /* Even smaller scanner */
    height: 50px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid var(--primary);
    position: relative;
    flex-shrink: 0;
}

video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.scan-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 15px rgba(79, 172, 254, 0.3);
}

.scan-button svg {
    width: 28px;
    height: 28px;
    fill: white;
}

.scan-info {
    flex: 1;
    text-align: left;
}

#scan-status {
    font-size: 0.9rem;
    margin-bottom: 0.2rem;
    color: var(--primary);
}

#scan-instruction {
    font-size: 0.65rem;
}

/* Intelligence Modal Styles */
.intel-content {
    width: 95% !important;
    max-width: 550px;
    max-height: 85vh;
    overflow-y: auto;
    padding-top: 1rem !important;
}

.intel-grid {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    margin-top: 1rem;
}

.intel-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 12px;
    padding: 1rem;
    position: relative;
    padding-left: 3.5rem;
}

.intel-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.5rem;
}

.intel-card h4 {
    font-size: 0.9rem;
    color: var(--primary);
    margin: 0 0 0.3rem 0;
}

.intel-card p {
    font-size: 0.7rem;
    color: var(--text-dim);
    line-height: 1.5;
    margin: 0;
}

.intel-card strong {
    color: #fff;
    font-weight: 600;
}

.disclaimer {
    font-size: 0.55rem;
    color: var(--text-dim);
    text-align: center;
    margin-top: 0.5rem;
    padding: 0 1rem;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: #111;
    border: 1px solid var(--glass-border);
    padding: 1.5rem;
    border-radius: 20px;
    width: 85%;
}

.modal-content h2 {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
}

.form-group {
    margin-top: 1rem;
}

.form-group label {
    font-size: 0.7rem;
    color: var(--text-dim);
    display: block;
    margin-bottom: 0.3rem;
}

.form-group input,
.form-group select {
    width: 100%;
    background: #222;
    border: 1px solid var(--glass-border);
    padding: 0.6rem;
    border-radius: 8px;
    color: white;
}

.save-btn {
    width: 100%;
    background: linear-gradient(to right, var(--primary), var(--secondary));
    border: none;
    padding: 0.8rem;
    border-radius: 10px;
    color: white;
    font-weight: 700;
    margin-top: 1.5rem;
}