/* ============================================
   WEATHER STATION — Complete CSS v1
   Dark Glassmorphism + Animations
   ============================================ */

/* Google Fonts loaded via <link> in index.html — no @import needed */

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg: #07090f;
    --bg2: #0c1120;
    --glass: rgba(255, 255, 255, 0.04);
    --glass2: rgba(255, 255, 255, 0.07);
    --border: rgba(255, 255, 255, 0.08);
    --border2: rgba(255, 255, 255, 0.14);
    --text: #f0f4ff;
    --text2: #94a3b8;
    --text3: #475569;
    --gap: 18px;
    --r: 16px;
    --r2: 10px;
    --t: all 0.3s cubic-bezier(.4, 0, .2, 1);
    --font-ar: 'Tajawal', sans-serif;
    --font-en: 'Inter', sans-serif;
    /* colors */
    --c-temp: #f97316;
    --c-hum: #06b6d4;
    --c-pres: #8b5cf6;
    --c-purple: #8b5cf6;
    --c-wind: #10b981;
    --c-uv: #fbbf24;
    --c-rain: #3b82f6;
    --c-amber: #f59e0b;
    --c-blue: #3b82f6;
    --c-green: #10b981;
    --c-red: #ef4444;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-ar);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    direction: rtl;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 70% 50% at 15% 5%, rgba(59, 130, 246, .08) 0%, transparent 60%),
        radial-gradient(ellipse 50% 40% at 85% 90%, rgba(139, 92, 246, .06) 0%, transparent 60%),
        radial-gradient(ellipse 40% 35% at 50% 50%, rgba(6, 182, 212, .04) 0%, transparent 60%);
    pointer-events: none;
    z-index: 0;
}

.app {
    position: relative;
    z-index: 1;
}

.hidden {
    display: none !important;
}

code {
    background: rgba(59, 130, 246, .15);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: .8rem;
    color: var(--c-blue);
}

/* ══ LOADING ══ */
.loading-screen {
    position: fixed;
    inset: 0;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 24px;
    z-index: 9999;
}

.loading-orb {
    position: absolute;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(59, 130, 246, .15), transparent 70%);
    border-radius: 50%;
    animation: orbPulse 3s ease-in-out infinite;
}

@keyframes orbPulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 1
    }

    50% {
        transform: scale(1.2);
        opacity: .6
    }
}

.loading-content {
    text-align: center;
    z-index: 1;
}

.loading-emoji {
    font-size: 4rem;
    animation: floaty 2s ease-in-out infinite;
    filter: drop-shadow(0 0 20px rgba(59, 130, 246, .5));
}

.loading-spinner {
    width: 44px;
    height: 44px;
    border: 3px solid rgba(59, 130, 246, .2);
    border-top-color: var(--c-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 16px auto;
}

.loading-content p {
    color: var(--text2);
    font-size: 1rem;
}

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

@keyframes floaty {

    0%,
    100% {
        transform: translateY(0)
    }

    50% {
        transform: translateY(-12px)
    }
}

/* ══ ALERTS ══ */
.alerts-container {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 8000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: min(500px, 90vw);
    pointer-events: none;
}

.alert-toast {
    background: rgba(13, 20, 33, .97);
    backdrop-filter: blur(20px);
    border: 1px solid;
    border-radius: var(--r2);
    padding: 12px 18px;
    font-size: .88rem;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: toastIn .3s ease;
    pointer-events: all;
    box-shadow: 0 8px 30px rgba(0, 0, 0, .4);
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(-10px)
    }

    to {
        opacity: 1;
        transform: translateY(0)
    }
}

.alert-toast.danger {
    border-color: rgba(239, 68, 68, .4);
    color: #fca5a5;
}

.alert-toast.warning {
    border-color: rgba(251, 191, 36, .4);
    color: #fde68a;
}

.alert-toast.info {
    border-color: rgba(59, 130, 246, .4);
    color: #93c5fd;
}

.alert-toast.success {
    border-color: rgba(16, 185, 129, .4);
    color: #6ee7b7;
}

.alert-close {
    margin-right: auto;
    cursor: pointer;
    opacity: .6;
    background: none;
    border: none;
    color: inherit;
    font-size: 1rem;
}

/* ══ HEADER ══ */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(7, 9, 15, .88);
    backdrop-filter: blur(24px);
    border-bottom: 1px solid var(--border);
    overflow: hidden;
}

.header-weather-bg {
    position: absolute;
    inset: 0;
    opacity: .06;
    transition: background 1.5s ease;
    pointer-events: none;
}

.header-inner {
    padding: 14px 24px;
    position: relative;
    z-index: 1;
}

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

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-icon {
    font-size: 2.6rem;
    animation: floaty 4s ease-in-out infinite;
    filter: drop-shadow(0 0 12px rgba(59, 130, 246, .4));
}

.brand-text h1 {
    font-size: 1.4rem;
    font-weight: 800;
    background: linear-gradient(135deg, #fff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.brand-sub {
    color: var(--text3);
    font-size: .78rem;
}

/* على الديسكتوب: أظهر النسخة الكاملة، أخفِ نسخة الموبايل */
.brand-sub--mobile {
    display: none;
}

.brand-sub--desktop {
    display: block;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.pill-tag {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 50px;
    background: rgba(16, 185, 129, .12);
    border: 1px solid rgba(16, 185, 129, .3);
    color: var(--c-green);
    font-size: .78rem;
    font-weight: 500;
}

.blink-dot {
    width: 7px;
    height: 7px;
    background: var(--c-green);
    border-radius: 50%;
    animation: blink 2s ease-in-out infinite;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
        transform: scale(1)
    }

    50% {
        opacity: .4;
        transform: scale(.8)
    }
}

.clock-box {
    text-align: center;
}

.clock-time {
    font-family: var(--font-en);
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--c-blue), var(--c-hum));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1;
}

.clock-date {
    font-size: .7rem;
    color: var(--text3);
    margin-top: 2px;
}

.icon-btn {
    padding: 7px 14px;
    border-radius: 50px;
    background: linear-gradient(135deg, rgba(59, 130, 246, .15), rgba(139, 92, 246, .15));
    border: 1px solid rgba(59, 130, 246, .3);
    color: var(--text);
    font-family: var(--font-ar);
    font-size: .82rem;
    cursor: pointer;
    transition: var(--t);
    font-weight: 500;
}

.icon-btn:hover {
    background: linear-gradient(135deg, rgba(59, 130, 246, .3), rgba(139, 92, 246, .3));
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(59, 130, 246, .25);
}

.csv-btn {
    background: linear-gradient(135deg, rgba(16, 185, 129, .15), rgba(6, 182, 212, .12));
    border-color: rgba(16, 185, 129, .3);
}

.csv-btn:hover {
    background: linear-gradient(135deg, rgba(16, 185, 129, .3), rgba(6, 182, 212, .2));
    box-shadow: 0 4px 16px rgba(16, 185, 129, .2);
}

/* Condition Bar */
.condition-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, .03);
    border: 1px solid var(--border);
    border-radius: var(--r2);
    padding: 10px 16px;
    flex-wrap: wrap;
    gap: 12px;
}

.condition-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.condition-icon {
    font-size: 1.6rem;
    filter: drop-shadow(0 0 8px rgba(255, 220, 50, .4));
}

.condition-text {
    font-size: .95rem;
    font-weight: 700;
    color: var(--text);
}

.condition-right {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.mini-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.ms-label {
    font-size: .65rem;
    color: var(--text3);
}

.ms-val {
    font-size: .88rem;
    font-weight: 700;
    color: var(--text);
    font-family: var(--font-en);
}

.countdown-badge {
    padding: 4px 12px;
    border-radius: 50px;
    background: rgba(59, 130, 246, .1);
    border: 1px solid rgba(59, 130, 246, .2);
    color: var(--c-blue);
    font-size: .75rem;
    font-weight: 600;
    white-space: nowrap;
}

/* ══ MAIN ══ */
.main {
    max-width: 1700px;
    margin: 0 auto;
    padding: 22px var(--gap);
}

.section {
    margin-bottom: 28px;
}

.sec-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text2);
    margin-bottom: 14px;
    letter-spacing: .2px;
}

.sec-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    flex-wrap: wrap;
    gap: 10px;
}

/* ══ PRIMARY CARDS (ring) ══ */
.primary-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--gap);
}

.pcard {
    position: relative;
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 22px 18px;
    display: flex;
    align-items: center;
    gap: 16px;
    overflow: hidden;
    transition: var(--t);
    backdrop-filter: blur(10px);
}

.pcard:hover {
    transform: translateY(-4px);
    border-color: var(--border2);
    box-shadow: 0 12px 40px rgba(0, 0, 0, .35);
}

.pcard-bg {
    position: absolute;
    top: -40px;
    left: -20px;
    width: 150px;
    height: 150px;
    border-radius: 50%;
    opacity: .08;
    pointer-events: none;
    transition: opacity .3s;
}

.pcard:hover .pcard-bg {
    opacity: .15;
}

#pc-temp .pcard-bg {
    background: var(--c-temp);
}

#pc-hum .pcard-bg {
    background: var(--c-hum);
}

#pc-pres .pcard-bg {
    background: var(--c-pres);
}

#pc-wind .pcard-bg {
    background: var(--c-wind);
}

.pcard-ring {
    position: relative;
    width: 100px;
    height: 100px;
    flex-shrink: 0;
}

.ring-svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.ring-track {
    fill: none;
    stroke: rgba(255, 255, 255, .06);
    stroke-width: 8;
}

.ring-fill {
    fill: none;
    stroke: var(--c-temp);
    stroke-width: 8;
    stroke-linecap: round;
    transition: stroke-dasharray 1.2s cubic-bezier(.4, 0, .2, 1);
}

.ring-content {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
}

.ring-emoji {
    font-size: 1.1rem;
}

.ring-val {
    font-size: 1.5rem;
    font-weight: 800;
    font-family: var(--font-en);
    line-height: 1;
}

.ring-unit {
    font-size: .65rem;
    color: var(--text2);
    font-family: var(--font-en);
}

#pc-temp .ring-val {
    color: var(--c-temp);
}

#pc-hum .ring-val {
    color: var(--c-hum);
}

#pc-pres .ring-val {
    color: var(--c-pres);
}

#pc-wind .ring-val {
    color: var(--c-wind);
}

.pcard-info {
    flex: 1;
}

.pcard-name {
    font-size: .82rem;
    color: var(--text2);
    font-weight: 500;
    margin-bottom: 6px;
}

.pcard-status {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 50px;
    background: rgba(255, 255, 255, .05);
    font-size: .75rem;
    color: var(--text2);
    margin-bottom: 8px;
    border: 1px solid var(--border);
}

.pcard-range {
    font-size: .7rem;
    color: var(--text3);
    font-family: var(--font-en);
}

/* ══ SECONDARY CARDS ══ */
.secondary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--gap);
}

.scard {
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: var(--t);
    backdrop-filter: blur(10px);
    overflow: hidden;
    min-width: 0;
}

.scard:hover {
    background: var(--glass2);
    border-color: var(--border2);
    transform: translateY(-2px);
}

.scard-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.scard-icon {
    font-size: 1.8rem;
    flex-shrink: 0;
    filter: drop-shadow(0 0 6px rgba(255, 255, 255, .15));
}

.scard-name {
    font-size: .82rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.scard-sub {
    font-size: .7rem;
    color: var(--text3);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.scard-right {
    text-align: center;
    flex-shrink: 0;
}

.scard-val {
    font-size: 1.6rem;
    font-weight: 800;
    font-family: var(--font-en);
    color: var(--text);
    display: flex;
    align-items: baseline;
    gap: 4px;
    justify-content: center;
}

.scard-unit {
    font-size: .72rem;
    color: var(--text2);
    font-weight: 400;
}

.badge {
    margin-top: 6px;
    padding: 3px 10px;
    border-radius: 50px;
    font-size: .7rem;
    font-weight: 600;
    background: rgba(59, 130, 246, .15);
    color: var(--c-blue);
    border: 1px solid rgba(59, 130, 246, .25);
    white-space: nowrap;
}

/* Compass */
.compass-wrap {
    flex-shrink: 0;
}

.compass-circle {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, .1);
    background: rgba(255, 255, 255, .04);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.compass-n,
.compass-s,
.compass-e,
.compass-w {
    position: absolute;
    font-size: .45rem;
    font-weight: 700;
    color: var(--text3);
    font-family: var(--font-en);
}

.compass-n {
    top: 2px;
    left: 50%;
    transform: translateX(-50%);
    color: #ef4444;
}

.compass-s {
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
}

.compass-e {
    right: 2px;
    top: 50%;
    transform: translateY(-50%);
}

.compass-w {
    left: 2px;
    top: 50%;
    transform: translateY(-50%);
}

.compass-needle-wrap {
    width: 100%;
    height: 100%;
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 1.2s cubic-bezier(.4, 0, .2, 1);
}

.compass-needle {
    width: 3px;
    height: 18px;
    border-radius: 2px;
    background: linear-gradient(to top, rgba(239, 68, 68, .8) 50%, rgba(255, 255, 255, .4) 50%);
}

/* ══ CHART TOOLBAR ══ */
.chart-toolbar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.metric-pills,
.period-pills {
    display: flex;
    gap: 4px;
}

.mpill,
.ppill {
    padding: 5px 12px;
    border-radius: 50px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text2);
    font-family: var(--font-ar);
    font-size: .75rem;
    cursor: pointer;
    transition: var(--t);
    font-weight: 500;
}

.mpill:hover,
.ppill:hover {
    border-color: var(--c-blue);
    color: var(--text);
}

.mpill.active {
    background: rgba(59, 130, 246, .2);
    border-color: var(--c-blue);
    color: var(--text);
}

.ppill.active {
    background: rgba(139, 92, 246, .2);
    border-color: var(--c-pres);
    color: var(--text);
}

/* ══ NO-SENSOR OVERLAY ══ */
.mc-body {
    position: relative;
}

.no-sensor-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: rgba(7, 9, 15, .75);
    backdrop-filter: blur(6px);
    border-radius: var(--r2);
    color: var(--text3);
    font-size: .8rem;
    font-weight: 500;
    pointer-events: none;
    z-index: 2;
}

.no-sensor-overlay::before {
    content: '📡';
    font-size: 1.4rem;
    opacity: .5;
}

/* ══ MAIN CHART ══ */
.main-chart-card {
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 20px;
    backdrop-filter: blur(10px);
}

.main-chart-card canvas {
    max-height: 280px;
}

/* ══ MINI CHARTS ══ */
.mini-charts-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--gap);
}

.mini-chart-card {
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: var(--r);
    overflow: hidden;
    transition: var(--t);
    backdrop-filter: blur(10px);
}

.mini-chart-card:hover {
    border-color: var(--border2);
}

.mc-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-size: .8rem;
    color: var(--text2);
    font-weight: 500;
}

.mc-body {
    padding: 12px;
}

.mc-body canvas {
    max-height: 140px;
}

/* ══ BOTTOM GRID ══ */
.bottom-grid {
    display: grid;
    grid-template-columns: 1fr 320px 260px;
    gap: var(--gap);
    align-items: stretch;
}

/* Stats table */
.stats-box {
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: var(--r);
    overflow: hidden;
    backdrop-filter: blur(10px);
}

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

table#stats-tbl {
    width: 100%;
    border-collapse: collapse;
    font-size: .82rem;
}

#stats-tbl thead {
    background: rgba(59, 130, 246, .06);
}

#stats-tbl th {
    padding: 10px 14px;
    text-align: start;
    color: var(--text2);
    font-size: .72rem;
    font-weight: 600;
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
}

#stats-tbl td {
    padding: 10px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, .03);
    font-family: var(--font-en);
    white-space: nowrap;
}

#stats-tbl td:first-child {
    font-family: var(--font-ar);
    color: var(--text2);
}

#stats-tbl tr:hover td {
    background: rgba(255, 255, 255, .03);
}

.mid-cell {
    text-align: center;
    color: var(--text3);
    padding: 20px !important;
}

/* Recent */
.recent-box {
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 16px;
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
}

.recent-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
    flex: 1;
    overflow-y: auto;
}

.recent-list::-webkit-scrollbar {
    width: 3px;
}

.recent-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, .1);
    border-radius: 2px;
}

.recent-item {
    background: rgba(255, 255, 255, .03);
    border: 1px solid rgba(255, 255, 255, .05);
    border-radius: var(--r2);
    padding: 9px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: var(--t);
    animation: slideIn .3s ease;
}

.recent-item:hover {
    background: rgba(255, 255, 255, .06);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-8px)
    }

    to {
        opacity: 1;
        transform: translateX(0)
    }
}

.r-time {
    font-size: .68rem;
    color: var(--text3);
    font-family: var(--font-en);
    flex-shrink: 0;
}

.r-vals {
    display: flex;
    gap: 10px;
    flex: 1;
    justify-content: space-evenly;
}

.r-v {
    text-align: center;
    flex: 1;
}

.r-n {
    font-family: var(--font-en);
    font-size: .85rem;
    font-weight: 600;
}

.r-l {
    font-size: .6rem;
    color: var(--text3);
}

/* Summary box */
.summary-box {
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 16px;
    backdrop-filter: blur(10px);
}

.summary-items {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 12px;
}

.rain-analytics {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.rain-analytics-title {
    font-size: .82rem;
    font-weight: 700;
    color: var(--text2);
    margin-bottom: 10px;
}

.rain-row {
    margin-bottom: 10px;
}

.rain-row-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.rain-label {
    font-size: .74rem;
    color: var(--text2);
}

.rain-value {
    font-size: .74rem;
    font-family: var(--font-en);
    color: var(--text);
    font-weight: 700;
}

.rain-track {
    width: 100%;
    height: 7px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .08);
    margin-top: 6px;
    overflow: hidden;
}

.rain-fill {
    height: 100%;
    border-radius: 999px;
    transition: width .5s ease;
}

.rain-days-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.rain-day-item {
    display: grid;
    grid-template-columns: 90px 1fr auto;
    align-items: center;
    gap: 8px;
}

.rain-day-label {
    font-size: .7rem;
    color: var(--text2);
}

.rain-day-track {
    width: 100%;
    height: 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .08);
    overflow: hidden;
}

.rain-day-fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #38bdf8, #6366f1);
    transition: width .5s ease;
}

.rain-day-value {
    font-size: .72rem;
    color: var(--text);
    font-family: var(--font-en);
    font-weight: 700;
}

.sum-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, .03);
    border: 1px solid rgba(255, 255, 255, .05);
    border-radius: var(--r2);
}

.sum-icon {
    font-size: 1.2rem;
}

.sum-text {
    flex: 1;
}

.sum-label {
    font-size: .72rem;
    color: var(--text3);
}

.sum-val {
    font-size: .9rem;
    font-weight: 600;
    color: var(--text);
}

/* ══ FOOTER ══ */
.footer {
    text-align: center;
    padding: 20px;
    color: var(--text3);
    font-size: .78rem;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

.footer-sep {
    opacity: .3;
}

/* ══ ERROR ══ */
.err-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .85);
    backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.err-box {
    background: rgba(15, 20, 35, .97);
    border: 1px solid rgba(239, 68, 68, .3);
    border-radius: var(--r);
    padding: 36px;
    max-width: 440px;
    width: 90%;
    text-align: center;
    box-shadow: 0 0 50px rgba(239, 68, 68, .15);
}

.err-box h2 {
    color: var(--c-red);
    margin: 12px 0 8px;
}

.err-box p {
    color: var(--text2);
    font-size: .88rem;
}

.err-box button {
    margin-top: 20px;
    padding: 10px 28px;
    background: linear-gradient(135deg, var(--c-blue), var(--c-pres));
    border: none;
    border-radius: 50px;
    color: #fff;
    font-family: var(--font-ar);
    font-size: .9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--t);
}

.err-box button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, .4);
}

/* ══ RESPONSIVE ══ */
@media (max-width:1400px) {
    .primary-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .secondary-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .mini-charts-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .bottom-grid {
        grid-template-columns: 1fr;
    }
}

/* ── Tablet ── 900px rules merged with 1400px above; unique rules below ──  */
@media (max-width:900px) {
    .header-inner {
        padding: 12px 16px;
    }

    .brand-text h1 {
        font-size: 1.15rem;
    }
}

/* ══════════════════════════════════════
   MOBILE — تصميم موبايل احترافي
══════════════════════════════════════ */
@media (max-width:768px) {

    /* ─────── الهيدر ─────── */
    .header-inner {
        padding: 10px 14px;
    }

    .header-top {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        flex-wrap: nowrap;
        margin-bottom: 8px;
    }

    .brand {
        gap: 3px;
        min-width: 0;
        flex: 1;
    }

    #weather-icon-main {
        display: none;
    }

    .brand-text h1 {
        font-size: .95rem;
        font-weight: 800;
        /* لون أبيض مباشر — gradient-clip غير موثوق على الموبايل */
        background: none;
        -webkit-text-fill-color: #f0f4ff;
        color: #f0f4ff;
        white-space: normal;
        line-height: 1.3;
    }

    .brand-sub--desktop {
        display: none;
    }

    .brand-sub--mobile {
        display: block;
        font-size: .65rem;
        font-weight: 500;
        color: #8b9ab5;
        white-space: normal;
        line-height: 1.3;
        letter-spacing: .2px;
    }

    .header-actions {
        display: flex;
        align-items: center;
        gap: 5px;
        flex-shrink: 0;
        flex-wrap: nowrap;
    }

    .clock-box {
        order: -1;
        text-align: center;
    }

    .clock-time {
        font-size: .9rem;
        line-height: 1;
    }

    .clock-date {
        font-size: .56rem;
        margin-top: 2px;
        opacity: .7;
    }

    .icon-btn {
        padding: 5px 9px;
        font-size: .72rem;
    }

    .pill-tag {
        padding: 4px 8px;
        font-size: .7rem;
    }

    .blink-dot {
        width: 6px;
        height: 6px;
    }


    #btn-csv {
        display: inline-flex;
        padding: 4px 10px;
        font-size: .68rem;
    }

    /* ─────── شريط الحالة ─────── */
    .condition-bar {
        flex-wrap: wrap;
        gap: 8px;
        padding: 10px 14px;
    }

    .condition-left {
        gap: 8px;
        flex: 1;
        min-width: 0;
    }

    .condition-text {
        font-size: .85rem;
        font-weight: 700;
    }

    .condition-right {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 6px;
    }

    .mini-stat {
        align-items: center;
    }

    .ms-label {
        font-size: .6rem;
        text-align: center;
    }

    .ms-val {
        font-size: .8rem;
        font-weight: 700;
    }

    .countdown-badge {
        grid-column: span 4;
        text-align: center;
        font-size: .7rem;
    }

    /* ─────── المحتوى الرئيسي ─────── */
    .main {
        padding: 14px 12px;
    }

    .section {
        margin-bottom: 20px;
    }

    .sec-title {
        font-size: .9rem;
        margin-bottom: 12px;
    }

    /* ═══════════════════════════════════
       البطاقات الرئيسية — شبكة 2×2
       كل بطاقة: Ring فوق، المعلومات تحت
    ═══════════════════════════════════ */
    .primary-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    .pcard {
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding: 18px 10px 14px;
        gap: 10px;
        border-radius: 18px;
    }

    .pcard-bg {
        top: -20px;
        left: -20px;
        width: 100px;
        height: 100px;
    }

    .pcard-ring {
        width: 88px;
        height: 88px;
        flex-shrink: 0;
    }

    .ring-val {
        font-size: 1.4rem;
    }

    .ring-emoji {
        font-size: 1rem;
    }

    .ring-unit {
        font-size: .62rem;
    }

    .pcard-info {
        width: 100%;
    }

    .pcard-name {
        font-size: .78rem;
        margin-bottom: 5px;
        font-weight: 600;
    }

    .pcard-status {
        font-size: .68rem;
        padding: 3px 8px;
        margin-bottom: 5px;
    }

    .pcard-range {
        font-size: .62rem;
    }

    /* ═══════════════════════════════════
       البطاقات الثانوية — شبكة 2×2
    ═══════════════════════════════════ */
    .secondary-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    .scard {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        padding: 14px 12px;
        border-radius: 16px;
    }

    .scard-left {
        flex-direction: row;
        align-items: center;
        gap: 8px;
        width: 100%;
    }

    .scard-icon {
        font-size: 1.5rem;
    }

    .scard-name {
        font-size: .76rem;
        font-weight: 700;
    }

    .scard-sub {
        font-size: .62rem;
        margin-top: 1px;
    }

    .scard-right {
        width: 100%;
        text-align: right;
    }

    .scard-val {
        font-size: 1.45rem;
        justify-content: flex-end;
    }

    .scard-unit {
        font-size: .65rem;
    }

    .badge {
        font-size: .62rem;
        padding: 2px 8px;
        margin-top: 4px;
    }

    /* البوصلة — حجم أصغر على الموبايل */
    .compass-wrap {
        flex-shrink: 0;
    }

    .compass-circle {
        width: 42px;
        height: 42px;
    }

    .compass-needle {
        width: 2px;
        height: 14px;
    }

    .compass-n,
    .compass-s,
    .compass-e,
    .compass-w {
        font-size: .38rem;
    }

    /* ─────── الرسم البياني الرئيسي ─────── */
    .sec-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .chart-toolbar {
        flex-direction: column;
        gap: 8px;
        width: 100%;
    }

    .metric-pills,
    .period-pills {
        flex-wrap: wrap;
        gap: 5px;
    }

    .mpill,
    .ppill {
        padding: 5px 12px;
        font-size: .72rem;
    }

    .main-chart-card {
        padding: 14px 10px;
    }

    .main-chart-card canvas {
        max-height: 220px;
    }

    /* ─────── الرسوم الصغيرة ─────── */
    .mini-charts-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .mc-header {
        font-size: .8rem;
        padding: 10px 14px;
    }

    .mc-body canvas {
        max-height: 130px;
    }

    /* ─────── القسم السفلي ─────── */
    .bottom-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    #stats-tbl {
        min-width: 360px;
    }

    #stats-tbl th,
    #stats-tbl td {
        padding: 8px 10px;
        font-size: .76rem;
    }

    .recent-list {
        max-height: 260px;
    }

    .r-time {
        font-size: .65rem;
    }

    .r-n {
        font-size: .8rem;
    }

    .sum-val {
        font-size: .85rem;
    }

    .sum-label {
        font-size: .68rem;
    }

    /* ─────── الفوتر ─────── */
    .footer {
        font-size: .72rem;
        flex-direction: column;
        gap: 4px;
        padding: 16px 12px;
    }

    .footer-sep {
        display: none;
    }
}

/* ── Small Mobile (≤480px) ── */
@media (max-width:480px) {
    .header-inner {
        padding: 8px 10px;
    }

    .brand-text h1 {
        font-size: .88rem;
    }

    .icon-btn {
        padding: 4px 7px;
        font-size: .68rem;
    }

    .clock-time {
        font-size: .84rem;
    }

    .pcard-ring {
        width: 78px;
        height: 78px;
    }

    .ring-val {
        font-size: 1.25rem;
    }

    .condition-right {
        grid-template-columns: repeat(2, 1fr);
    }

    .countdown-badge {
        grid-column: span 2;
    }

    .scard-val {
        font-size: 1.3rem;
    }
}

/* ── Very Small Mobile (≤360px) ── */
@media (max-width:360px) {
    #btn-refresh {
        display: none;
    }

    .brand-text h1 {
        font-size: .82rem;
    }

    .clock-time {
        font-size: .8rem;
    }

    .icon-btn {
        padding: 4px 6px;
        font-size: .64rem;
    }

    .pcard-ring {
        width: 68px;
        height: 68px;
    }

    .ring-val {
        font-size: 1.1rem;
    }

    .scard-val {
        font-size: 1.15rem;
    }

    .primary-grid {
        gap: 8px;
    }

    .secondary-grid {
        gap: 8px;
    }
}

/* ══ THEME / LANG BUTTONS ══ */
.theme-btn {
    background: linear-gradient(135deg, rgba(251, 191, 36, .15), rgba(249, 115, 22, .12));
    border-color: rgba(251, 191, 36, .3);
}

.theme-btn:hover {
    background: linear-gradient(135deg, rgba(251, 191, 36, .3), rgba(249, 115, 22, .2));
    box-shadow: 0 4px 16px rgba(251, 191, 36, .2);
}

.lang-btn {
    background: linear-gradient(135deg, rgba(139, 92, 246, .15), rgba(59, 130, 246, .12));
    border-color: rgba(139, 92, 246, .3);
    font-family: var(--font-en);
    font-weight: 700;
    letter-spacing: .5px;
}

.lang-btn:hover {
    background: linear-gradient(135deg, rgba(139, 92, 246, .3), rgba(59, 130, 246, .2));
    box-shadow: 0 4px 16px rgba(139, 92, 246, .2);
}

/* ══ LIGHT THEME ══ */
body.light {
    --bg: #f0f4f8;
    --bg2: #e2e8f0;
    --glass: rgba(255, 255, 255, 0.7);
    --glass2: rgba(255, 255, 255, 0.85);
    --border: rgba(0, 0, 0, 0.08);
    --border2: rgba(0, 0, 0, 0.14);
    --text: #1e293b;
    --text2: #475569;
    --text3: #94a3b8;
}

body.light {
    background: var(--bg);
    color: var(--text);
}

body.light::before {
    background:
        radial-gradient(ellipse 70% 50% at 15% 5%, rgba(59, 130, 246, .06) 0%, transparent 60%),
        radial-gradient(ellipse 50% 40% at 85% 90%, rgba(139, 92, 246, .04) 0%, transparent 60%),
        radial-gradient(ellipse 40% 35% at 50% 50%, rgba(6, 182, 212, .03) 0%, transparent 60%);
}

body.light .loading-screen {
    background: var(--bg);
}

body.light .loading-orb {
    background: radial-gradient(circle, rgba(59, 130, 246, .08), transparent 70%);
}

body.light .header {
    background: rgba(255, 255, 255, .85);
}

body.light .brand-text h1 {
    background: linear-gradient(135deg, #1e293b, #475569);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: #1e293b;
}

body.light .ring-track {
    stroke: rgba(0, 0, 0, .06);
}

body.light .pcard:hover {
    box-shadow: 0 12px 40px rgba(0, 0, 0, .08);
}

body.light .alert-toast {
    background: rgba(255, 255, 255, .97);
}

body.light .condition-bar {
    background: rgba(0, 0, 0, .03);
}

body.light .pcard-status {
    background: rgba(0, 0, 0, .04);
    border-color: rgba(0, 0, 0, .08);
}

body.light .recent-item {
    background: rgba(0, 0, 0, .03);
    border-color: rgba(0, 0, 0, .05);
}

body.light .recent-item:hover {
    background: rgba(0, 0, 0, .06);
}

body.light .sum-item {
    background: rgba(0, 0, 0, .03);
    border-color: rgba(0, 0, 0, .05);
}

body.light #stats-tbl thead {
    background: rgba(59, 130, 246, .06);
}

body.light #stats-tbl td {
    border-bottom-color: rgba(0, 0, 0, .04);
}

body.light #stats-tbl tr:hover td {
    background: rgba(0, 0, 0, .03);
}

body.light .compass-circle {
    border-color: rgba(0, 0, 0, .12);
    background: rgba(0, 0, 0, .04);
}

body.light .compass-needle {
    background: linear-gradient(to top, rgba(239, 68, 68, .8) 50%, rgba(0, 0, 0, .3) 50%);
}

body.light .err-box {
    background: rgba(255, 255, 255, .97);
    border-color: rgba(239, 68, 68, .2);
    box-shadow: 0 0 50px rgba(0, 0, 0, .08);
}

body.light .err-box h2 {
    color: var(--c-red);
}

body.light .icon-btn {
    color: var(--text);
}

body.light .mpill,
body.light .ppill {
    color: var(--text2);
}

body.light .mpill.active {
    background: rgba(59, 130, 246, .12);
    color: var(--text);
}

body.light .ppill.active {
    background: rgba(139, 92, 246, .12);
    color: var(--text);
}

body.light .recent-list::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, .15);
}

/* ══════════════════════════════════════════════
   FORECAST — 7-Day Weather Forecast Section
   ══════════════════════════════════════════════ */

.forecast-section {
    padding-bottom: 10px;
}

.forecast-subtitle {
    font-size: .78rem;
    color: #64748b;
    margin: -10px 0 14px 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.forecast-row-label {
    font-size: .82rem;
    font-weight: 700;
    color: var(--text2);
    margin: 14px 0 10px;
}

.forecast-row-label:first-of-type {
    margin-top: 0;
}

.forecast-cards {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 10px;
    scroll-snap-type: x mandatory;
}

.forecast-cards::-webkit-scrollbar {
    height: 4px;
}

.forecast-cards::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, .1);
    border-radius: 2px;
}

.forecast-loading {
    width: 100%;
    text-align: center;
    padding: 40px;
    color: #64748b;
    font-size: .88rem;
}

.fc-card {
    flex: 0 0 154px;
    min-width: 154px;
    border-radius: 18px;
    background: var(--glass2);
    border: 1px solid var(--border);
    padding: 18px 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    scroll-snap-align: start;
    transition: var(--t);
    position: relative;
    overflow: hidden;
}

.fc-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(59, 130, 246, .04) 0%, transparent 50%);
    pointer-events: none;
}

.fc-card:hover {
    transform: translateY(-4px);
    border-color: rgba(59, 130, 246, .3);
    box-shadow: 0 8px 24px rgba(59, 130, 246, .1);
}

.fc-card.today {
    border-color: rgba(59, 130, 246, .35);
    background: linear-gradient(180deg, rgba(59, 130, 246, .1) 0%, var(--glass2) 100%);
    box-shadow: 0 4px 20px rgba(59, 130, 246, .12);
}

.fc-card.today::after {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 3px;
    border-radius: 0 0 4px 4px;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6);
}

/* Selected state */
.fc-card.selected {
    border-color: rgba(59, 130, 246, .5);
    background: linear-gradient(180deg, rgba(59, 130, 246, .15) 0%, var(--glass2) 100%);
    box-shadow: 0 4px 24px rgba(59, 130, 246, .2);
}

body.light .fc-card.selected {
    border-color: rgba(59, 130, 246, .5);
    background: linear-gradient(180deg, rgba(59, 130, 246, .15) 0%, rgba(255, 255, 255, .9) 100%);
}

/* Day name */
.fc-day {
    font-size: .82rem;
    font-weight: 700;
    color: var(--text);
}

.fc-date {
    font-size: .68rem;
    color: #64748b;
    margin-top: -6px;
}

/* Weather icon */
.fc-icon {
    font-size: 2.4rem;
    line-height: 1;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, .2));
}

/* Temperature */
.fc-temps {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.fc-temp-max {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--text);
}

.fc-temp-min {
    font-size: .88rem;
    font-weight: 500;
    color: #64748b;
}

/* Precipitation bar */
.fc-rain-bar {
    width: 100%;
    height: 4px;
    border-radius: 3px;
    background: rgba(255, 255, 255, .06);
    overflow: hidden;
}

.fc-rain-fill {
    height: 100%;
    border-radius: 3px;
    background: linear-gradient(90deg, #3b82f6, #06b6d4);
    transition: width .6s ease;
}

/* Details grid */
.fc-details {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.fc-detail {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: .68rem;
}

.fc-detail-label {
    color: #64748b;
}

.fc-detail-value {
    color: var(--text);
    font-weight: 600;
}

/* Sunrise/Sunset */
.fc-sun {
    display: flex;
    gap: 10px;
    font-size: .64rem;
    color: #64748b;
}

.fc-sun span {
    display: flex;
    align-items: center;
    gap: 3px;
}

/* ── Light Theme Forecast ── */
body.light .fc-card {
    background: rgba(255, 255, 255, .7);
    border-color: rgba(0, 0, 0, .06);
}

body.light .fc-card:hover {
    border-color: rgba(59, 130, 246, .25);
    box-shadow: 0 8px 24px rgba(0, 0, 0, .06);
}

body.light .fc-card.today {
    background: linear-gradient(180deg, rgba(59, 130, 246, .06) 0%, rgba(255, 255, 255, .7) 100%);
    border-color: rgba(59, 130, 246, .25);
}

body.light .fc-rain-bar {
    background: rgba(0, 0, 0, .06);
}

body.light .forecast-cards::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, .12);
}

body.light .fch-card {
    background: rgba(255, 255, 255, .6);
    border-color: rgba(0, 0, 0, .05);
}

body.light .fch-card.now {
    background: linear-gradient(180deg, rgba(59, 130, 246, .08) 0%, rgba(255, 255, 255, .6) 100%);
}

/* ── Hourly cards ── */
.fch-card {
    flex: 0 0 88px;
    min-width: 88px;
    border-radius: 14px;
    background: var(--glass2);
    border: 1px solid var(--border);
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    scroll-snap-align: start;
    transition: var(--t);
}

.fch-card:hover {
    transform: translateY(-3px);
    border-color: rgba(59, 130, 246, .25);
}

.fch-card.now {
    border-color: rgba(59, 130, 246, .35);
    background: linear-gradient(180deg, rgba(59, 130, 246, .1) 0%, var(--glass2) 100%);
    box-shadow: 0 2px 12px rgba(59, 130, 246, .1);
}

.fch-card.now::after {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 2px;
    border-radius: 0 0 3px 3px;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6);
}

.fch-hour {
    font-size: .72rem;
    font-weight: 600;
    color: var(--text2);
}

.fch-icon {
    font-size: 1.5rem;
    line-height: 1;
}

.fch-temp {
    font-size: 1rem;
    font-weight: 800;
    color: var(--text);
}

.fch-rain {
    font-size: .62rem;
    color: #3b82f6;
    font-weight: 600;
}

/* Hourly extra details */
.fch-extra {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    margin-top: 4px;
    padding-top: 6px;
    border-top: 1px solid rgba(255, 255, 255, .05);
    width: 100%;
}

body.light .fch-extra {
    border-top: 1px solid rgba(0, 0, 0, .05);
}

.fce-rain {
    font-size: .64rem;
    color: #3b82f6;
    font-weight: 600;
}

.fce-wind {
    font-size: .64rem;
    color: #64748b;
}

.fce-hum {
    font-size: .64rem;
    color: #0ea5e9;
}

/* ── Responsive Forecast ── */
@media (max-width: 768px) {
    .forecast-section {
        padding: 0 16px 24px;
    }

    .fc-card {
        flex: 0 0 138px;
        min-width: 138px;
        padding: 14px 12px;
    }

    .fc-icon {
        font-size: 2rem;
    }

    .fc-temp-max {
        font-size: 1.15rem;
    }

    .fch-card {
        flex: 0 0 76px;
        min-width: 76px;
    }
}

/* ══ LTR (English) ══ */
body.ltr {
    direction: ltr;
}

body.ltr .header-actions {
    justify-content: flex-start;
}

/* text-align: start already handles LTR/RTL automatically */

/* ══════════════════════════════════════════════
   AI CHAT — Premium Glassmorphism Chat UI
   ══════════════════════════════════════════════ */

/* ── Floating Action Button ── */
.ai-fab {
    position: fixed;
    bottom: 24px;
    left: 24px;
    z-index: 5000;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 22px 14px 16px;
    border-radius: 60px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    color: #fff;
    cursor: pointer;
    box-shadow:
        0 4px 24px rgba(59, 130, 246, .4),
        0 0 0 0 rgba(59, 130, 246, .3);
    transition: all .3s cubic-bezier(.4, 0, .2, 1);
    border: none;
    font-family: var(--font-ar);
    user-select: none;
}

.ai-fab:hover {
    transform: translateY(-3px) scale(1.04);
    box-shadow:
        0 8px 32px rgba(59, 130, 246, .5),
        0 0 0 4px rgba(59, 130, 246, .15);
}

.ai-fab svg {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

.ai-fab-label {
    font-size: .88rem;
    font-weight: 700;
    white-space: nowrap;
}

.ai-fab-pulse {
    position: absolute;
    inset: -4px;
    border-radius: 60px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    opacity: 0;
    animation: fabPulse 3s ease-in-out infinite;
    pointer-events: none;
    z-index: -1;
}

@keyframes fabPulse {
    0% {
        opacity: 0;
        transform: scale(1);
    }

    50% {
        opacity: .25;
        transform: scale(1.12);
    }

    100% {
        opacity: 0;
        transform: scale(1.25);
    }
}

/* ── Chat Panel ── */
.ai-panel {
    position: fixed;
    bottom: 90px;
    left: 24px;
    z-index: 5001;
    width: 420px;
    max-width: calc(100vw - 32px);
    height: 580px;
    max-height: calc(100vh - 130px);
    border-radius: 20px;
    background: rgba(10, 14, 26, .96);
    backdrop-filter: blur(30px);
    border: 1px solid rgba(255, 255, 255, .1);
    box-shadow:
        0 20px 60px rgba(0, 0, 0, .6),
        0 0 0 1px rgba(255, 255, 255, .05) inset;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: panelSlideUp .35s cubic-bezier(.4, 0, .2, 1);
    transform-origin: bottom left;
}

@keyframes panelSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.ai-panel.hidden {
    display: none !important;
}

/* ── Panel Header ── */
.ai-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    background: linear-gradient(135deg, rgba(59, 130, 246, .12), rgba(139, 92, 246, .08));
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    flex-shrink: 0;
}

.ai-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ai-avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ai-avatar svg {
    width: 22px;
    height: 22px;
    color: #fff;
}

.ai-header-title {
    font-size: .95rem;
    font-weight: 700;
    color: #f0f4ff;
}

.ai-header-sub {
    font-size: .72rem;
    color: #64748b;
    display: flex;
    align-items: center;
    gap: 5px;
}

.ai-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #10b981;
    display: inline-block;
    animation: blink 2s ease-in-out infinite;
}

.ai-header-actions {
    display: flex;
    gap: 6px;
}

.ai-header-btn {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: rgba(255, 255, 255, .06);
    border: 1px solid rgba(255, 255, 255, .08);
    color: #94a3b8;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--t);
}

.ai-header-btn:hover {
    background: rgba(255, 255, 255, .12);
    color: #f0f4ff;
}

.ai-header-btn svg {
    width: 16px;
    height: 16px;
}

/* ── Messages Area ── */
.ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.ai-messages::-webkit-scrollbar {
    width: 4px;
}

.ai-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, .1);
    border-radius: 2px;
}

/* Welcome */
.ai-welcome {
    text-align: center;
    padding: 30px 20px 10px;
}

.ai-welcome-icon {
    font-size: 3rem;
    margin-bottom: 12px;
    animation: floaty 3s ease-in-out infinite;
}

.ai-welcome-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: #f0f4ff;
    margin-bottom: 6px;
}

.ai-welcome-sub {
    font-size: .8rem;
    color: #64748b;
    line-height: 1.6;
}

/* Suggestion Chips */
.ai-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    padding: 10px 0;
}

.ai-chip {
    padding: 8px 14px;
    border-radius: 50px;
    background: rgba(59, 130, 246, .08);
    border: 1px solid rgba(59, 130, 246, .2);
    color: #93c5fd;
    font-size: .76rem;
    font-family: var(--font-ar);
    cursor: pointer;
    transition: var(--t);
    white-space: nowrap;
}

.ai-chip:hover {
    background: rgba(59, 130, 246, .18);
    border-color: rgba(59, 130, 246, .4);
    color: #bfdbfe;
    transform: translateY(-1px);
}

/* Message Bubbles */
.ai-msg {
    display: flex;
    gap: 10px;
    max-width: 88%;
    animation: msgFadeIn .3s ease;
}

@keyframes msgFadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ai-msg.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.ai-msg-avatar {
    width: 30px;
    height: 30px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: .9rem;
}

.ai-msg.bot .ai-msg-avatar {
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
}

.ai-msg.user .ai-msg-avatar {
    background: linear-gradient(135deg, #10b981, #06b6d4);
}

.ai-msg-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: .85rem;
    line-height: 1.65;
    word-break: break-word;
}

.ai-msg.bot .ai-msg-bubble {
    background: rgba(255, 255, 255, .06);
    border: 1px solid rgba(255, 255, 255, .08);
    color: #e2e8f0;
    border-top-right-radius: 4px;
}

.ai-msg.user .ai-msg-bubble {
    background: linear-gradient(135deg, rgba(59, 130, 246, .2), rgba(139, 92, 246, .15));
    border: 1px solid rgba(59, 130, 246, .25);
    color: #f0f4ff;
    border-top-left-radius: 4px;
}

/* Typing Indicator */
.ai-typing {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 14px 18px;
}

.ai-typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #64748b;
    animation: typingBounce 1.4s ease-in-out infinite;
}

.ai-typing-dot:nth-child(2) {
    animation-delay: .2s;
}

.ai-typing-dot:nth-child(3) {
    animation-delay: .4s;
}

@keyframes typingBounce {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: .4;
    }

    30% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

/* ── Input Area ── */
.ai-input-area {
    padding: 12px 16px 14px;
    border-top: 1px solid rgba(255, 255, 255, .08);
    background: rgba(0, 0, 0, .2);
    flex-shrink: 0;
}

.ai-input-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, .06);
    border: 1px solid rgba(255, 255, 255, .1);
    border-radius: 14px;
    padding: 4px 4px 4px 14px;
    transition: border-color .2s;
}

.ai-input-wrap:focus-within {
    border-color: rgba(59, 130, 246, .5);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, .1);
}

.ai-input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: #f0f4ff;
    font-family: var(--font-ar);
    font-size: .88rem;
    padding: 8px 0;
}

.ai-input::placeholder {
    color: #475569;
}

.ai-send-btn {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    border: none;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--t);
    flex-shrink: 0;
}

.ai-send-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 16px rgba(59, 130, 246, .4);
}

.ai-send-btn:disabled {
    opacity: .4;
    cursor: not-allowed;
    transform: none;
}

.ai-send-btn svg {
    width: 18px;
    height: 18px;
}

.ai-disclaimer {
    text-align: center;
    font-size: .65rem;
    color: #475569;
    margin-top: 8px;
}

/* ── AI Error Message ── */
.ai-msg.error .ai-msg-bubble {
    background: rgba(239, 68, 68, .1);
    border-color: rgba(239, 68, 68, .25);
    color: #fca5a5;
}

/* ── Light Theme for AI Chat ── */
body.light .ai-panel {
    background: rgba(255, 255, 255, .97);
    border-color: rgba(0, 0, 0, .1);
    box-shadow: 0 20px 60px rgba(0, 0, 0, .15);
}

body.light .ai-panel-header {
    background: linear-gradient(135deg, rgba(59, 130, 246, .06), rgba(139, 92, 246, .04));
    border-bottom-color: rgba(0, 0, 0, .06);
}

body.light .ai-header-title {
    color: #1e293b;
}

body.light .ai-header-sub {
    color: #94a3b8;
}

body.light .ai-header-btn {
    background: rgba(0, 0, 0, .04);
    border-color: rgba(0, 0, 0, .06);
    color: #64748b;
}

body.light .ai-header-btn:hover {
    background: rgba(0, 0, 0, .08);
    color: #1e293b;
}

body.light .ai-welcome-title {
    color: #1e293b;
}

body.light .ai-welcome-sub {
    color: #94a3b8;
}

body.light .ai-chip {
    background: rgba(59, 130, 246, .06);
    border-color: rgba(59, 130, 246, .15);
    color: #3b82f6;
}

body.light .ai-chip:hover {
    background: rgba(59, 130, 246, .12);
    color: #2563eb;
}

body.light .ai-msg.bot .ai-msg-bubble {
    background: rgba(0, 0, 0, .04);
    border-color: rgba(0, 0, 0, .06);
    color: #334155;
}

body.light .ai-msg.user .ai-msg-bubble {
    background: linear-gradient(135deg, rgba(59, 130, 246, .12), rgba(139, 92, 246, .08));
    border-color: rgba(59, 130, 246, .15);
    color: #1e293b;
}

body.light .ai-input-area {
    background: rgba(0, 0, 0, .02);
    border-top-color: rgba(0, 0, 0, .06);
}

body.light .ai-input-wrap {
    background: rgba(0, 0, 0, .04);
    border-color: rgba(0, 0, 0, .1);
}

body.light .ai-input-wrap:focus-within {
    border-color: rgba(59, 130, 246, .4);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, .08);
}

body.light .ai-input {
    color: #1e293b;
}

body.light .ai-input::placeholder {
    color: #94a3b8;
}

body.light .ai-disclaimer {
    color: #94a3b8;
}

body.light .ai-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, .12);
}

body.light .ai-msg.error .ai-msg-bubble {
    background: rgba(239, 68, 68, .06);
    color: #dc2626;
}

/* ── Responsive AI Chat ── */
@media (max-width: 768px) {
    .ai-fab {
        bottom: 16px;
        left: 16px;
        padding: 12px 16px 12px 12px;
    }

    .ai-fab svg {
        width: 20px;
        height: 20px;
    }

    .ai-fab-label {
        font-size: .78rem;
    }

    .ai-panel {
        bottom: 0;
        left: 0;
        width: 100vw;
        max-width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }

    .ai-panel-header {
        padding: 14px 16px;
    }

    .ai-msg {
        max-width: 92%;
    }
}

@media (max-width: 480px) {
    .ai-fab-label {
        display: none;
    }

    .ai-fab {
        padding: 14px;
        border-radius: 50%;
    }
}

/* ══════════════════════════════════════════════
   SETTINGS PANEL — Admin Control Styles
   ══════════════════════════════════════════════ */

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: var(--gap);
}

.settings-card {
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: var(--r);
    overflow: hidden;
    backdrop-filter: blur(10px);
    transition: var(--t);
}

.settings-card:hover {
    border-color: var(--border2);
}

.sc-header {
    padding: 14px 18px;
    background: linear-gradient(135deg, rgba(59, 130, 246, .08), rgba(139, 92, 246, .05));
    border-bottom: 1px solid var(--border);
    font-size: .9rem;
    font-weight: 700;
    color: var(--text);
}

.sc-body {
    padding: 18px;
}

/* Form Controls */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: .82rem;
    color: var(--text2);
    margin-bottom: 6px;
    font-weight: 500;
}

.custom-select,
.custom-input {
    width: 100%;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, .05);
    color: var(--text);
    font-family: var(--font-ar);
    font-size: .88rem;
    outline: none;
    transition: border-color .2s;
    appearance: auto;
}

.custom-select:focus,
.custom-input:focus {
    border-color: rgba(59, 130, 246, .5);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, .1);
}

body.light .custom-select,
body.light .custom-input {
    background: rgba(0, 0, 0, .04);
    border-color: rgba(0, 0, 0, .1);
    color: var(--text);
}

.btn-primary {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    color: #fff;
    font-family: var(--font-ar);
    font-size: .9rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--t);
    margin-top: 8px;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, .35);
}

.btn-primary:disabled {
    opacity: .5;
    cursor: not-allowed;
    transform: none;
}

.btn-sm {
    padding: 6px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, .05);
    color: var(--text2);
    font-family: var(--font-ar);
    font-size: .75rem;
    cursor: pointer;
    transition: var(--t);
}

.btn-sm:hover {
    background: rgba(59, 130, 246, .15);
    border-color: rgba(59, 130, 246, .3);
    color: var(--text);
}

/* ── Toggle Switches ── */
.toggle-header {
    font-size: .82rem;
    font-weight: 600;
    color: var(--text2);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.toggle-divider {
    height: 1px;
    background: var(--border);
    margin: 12px 0;
}

.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, .03);
}

.toggle-row:last-child {
    border-bottom: none;
}

.toggle-row.system-toggle {
    padding: 10px 0;
}

.toggle-row.system-toggle .toggle-label {
    font-weight: 700;
    font-size: .88rem;
    color: var(--text);
}

.toggle-label {
    font-size: .82rem;
    color: var(--text2);
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

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

.toggle-slider {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, .1);
    border-radius: 24px;
    cursor: pointer;
    transition: background .3s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform .3s;
}

.toggle-switch input:checked+.toggle-slider {
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
}

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

body.light .toggle-slider {
    background: rgba(0, 0, 0, .1);
}

/* ── Model List ── */
.model-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.model-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-radius: 10px;
    background: rgba(255, 255, 255, .03);
    border: 1px solid rgba(255, 255, 255, .05);
    transition: var(--t);
}

.model-item:hover {
    background: rgba(255, 255, 255, .06);
    border-color: rgba(255, 255, 255, .1);
}

.model-item.model-active {
    background: rgba(16, 185, 129, .08);
    border-color: rgba(16, 185, 129, .25);
}

.model-item.model-active .model-priority {
    background: rgba(16, 185, 129, .2);
    color: #10b981;
}

.model-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.model-name {
    font-family: var(--font-en);
    font-size: .82rem;
    font-weight: 600;
    color: var(--text);
}

.model-stats {
    font-size: .68rem;
    color: var(--text3);
    font-family: var(--font-en);
}

.model-priority {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: rgba(255, 255, 255, .06);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .72rem;
    font-weight: 700;
    color: var(--text3);
    font-family: var(--font-en);
    flex-shrink: 0;
}

.model-note {
    margin-top: 12px;
    font-size: .72rem;
    color: var(--text3);
    padding: 10px;
    border-radius: 8px;
    background: rgba(59, 130, 246, .05);
    border: 1px solid rgba(59, 130, 246, .1);
}

body.light .model-item {
    background: rgba(0, 0, 0, .02);
    border-color: rgba(0, 0, 0, .05);
}

body.light .model-item.model-active {
    background: rgba(16, 185, 129, .05);
    border-color: rgba(16, 185, 129, .2);
}

/* ── Retention Chips ── */
.retention-label {
    font-size: .82rem;
    color: var(--text2);
    margin-bottom: 10px;
    font-weight: 500;
}

.retention-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.retention-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 50px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, .03);
    cursor: pointer;
    transition: var(--t);
    font-size: .78rem;
    color: var(--text2);
    user-select: none;
}

.retention-chip input {
    display: none;
}

.retention-chip:hover {
    border-color: rgba(59, 130, 246, .3);
    background: rgba(59, 130, 246, .06);
}

.retention-chip.selected {
    background: rgba(59, 130, 246, .15);
    border-color: rgba(59, 130, 246, .4);
    color: #93c5fd;
}

body.light .retention-chip.selected {
    background: rgba(59, 130, 246, .1);
    color: #2563eb;
}

.retention-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
}

/* ══════════════════════════════════════════════
   ABOUT PAGE — Enhanced Design
   ══════════════════════════════════════════════ */

.about-section {
    display: flex;
    flex-direction: column;
    gap: var(--gap);
    max-width: 700px;
    margin: 0 auto;
}

.about-card {
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 28px 24px;
    backdrop-filter: blur(10px);
    text-align: center;
    transition: var(--t);
}

.about-card:hover {
    border-color: var(--border2);
}

.about-logo {
    font-size: 3.5rem;
    margin-bottom: 12px;
    animation: floaty 4s ease-in-out infinite;
    filter: drop-shadow(0 0 15px rgba(59, 130, 246, .3));
}

.about-card h2 {
    font-size: 1.4rem;
    font-weight: 800;
    background: linear-gradient(135deg, #f0f4ff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 4px;
}

body.light .about-card h2 {
    background: linear-gradient(135deg, #1e293b, #475569);
    -webkit-background-clip: text;
    background-clip: text;
}

.about-version {
    font-size: .82rem;
    color: var(--c-blue);
    font-weight: 600;
    margin-bottom: 12px;
    font-family: var(--font-en);
}

.about-desc {
    font-size: .88rem;
    color: var(--text2);
    line-height: 1.7;
    margin-bottom: 20px;
}

.about-card-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 16px;
    text-align: center;
}

.about-card-device,
.about-card-tech {
    text-align: right;
}

.about-details {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 16px;
}

.about-dt {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: rgba(255, 255, 255, .03);
    border: 1px solid rgba(255, 255, 255, .05);
    border-radius: 10px;
}

body.light .about-dt {
    background: rgba(0, 0, 0, .02);
    border-color: rgba(0, 0, 0, .05);
}

.dt-label {
    font-size: .82rem;
    color: var(--text3);
    flex-shrink: 0;
}

.dt-val {
    font-size: .88rem;
    font-weight: 600;
    color: var(--text);
}

/* Tech Grid */
.tech-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.tech-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background: rgba(255, 255, 255, .03);
    border: 1px solid rgba(255, 255, 255, .05);
    border-radius: 12px;
    transition: var(--t);
}

.tech-item:hover {
    background: rgba(59, 130, 246, .06);
    border-color: rgba(59, 130, 246, .15);
    transform: translateY(-1px);
}

body.light .tech-item {
    background: rgba(0, 0, 0, .02);
    border-color: rgba(0, 0, 0, .05);
}

.tech-icon {
    font-size: 1.3rem;
    flex-shrink: 0;
}

.tech-name {
    font-size: .78rem;
    font-weight: 600;
    color: var(--text2);
    font-family: var(--font-en);
}

/* ══════════════════════════════════════════════
   BOTTOM NAVIGATION — Premium Tab Bar
   ══════════════════════════════════════════════ */

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 200;
    display: flex;
    align-items: flex-end;
    justify-content: space-around;
    background: rgba(7, 9, 15, .95);
    backdrop-filter: blur(24px);
    border-top: 1px solid rgba(255, 255, 255, .08);
    padding: 6px 8px 8px;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
}

body.light .bottom-nav {
    background: rgba(255, 255, 255, .95);
    border-top-color: rgba(0, 0, 0, .08);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    background: none;
    border: none;
    color: var(--text3);
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 12px;
    transition: var(--t);
    font-family: var(--font-ar);
    min-width: 52px;
    position: relative;
}

.nav-item .nav-icon {
    font-size: 1.2rem;
    line-height: 1;
    transition: transform .2s;
}

.nav-item .nav-label {
    font-size: .62rem;
    font-weight: 600;
    white-space: nowrap;
}

.nav-item.active {
    color: #3b82f6;
}

.nav-item.active .nav-icon {
    transform: scale(1.15);
}

.nav-item.active::after {
    content: '';
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 3px;
    border-radius: 0 0 4px 4px;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6);
}

body.light .nav-item {
    color: #94a3b8;
}

body.light .nav-item.active {
    color: #3b82f6;
}

/* AI FAB Button in Nav */
.nav-fab {
    position: relative;
    margin-top: -18px;
}

.nav-fab-inner {
    width: 50px;
    height: 50px;
    border-radius: 16px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(59, 130, 246, .4);
    transition: var(--t);
}

.nav-fab-inner svg {
    width: 22px;
    height: 22px;
    color: #fff;
}

.nav-fab.active .nav-fab-inner {
    box-shadow: 0 4px 25px rgba(59, 130, 246, .6), 0 0 0 3px rgba(59, 130, 246, .2);
}

.nav-fab:hover .nav-fab-inner {
    transform: translateY(-3px) scale(1.05);
}

.nav-fab .nav-label {
    margin-top: 4px;
}

/* AI Embedded Panel  */
.embedded-ai-panel {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 230px);
    min-height: 400px;
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: var(--r);
    overflow: hidden;
    backdrop-filter: blur(10px);
}

/* Tab panes */
.tab-pane {
    animation: tabFadeIn .3s ease;
}

.tab-pane.hidden {
    display: none !important;
}

@keyframes tabFadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Add bottom padding for nav bar */
.main {
    padding-bottom: 80px;
}

.footer {
    margin-bottom: 70px;
}

/* ══ DESKTOP: Show nav as top-style bar ══ */
@media (min-width: 769px) {
    .bottom-nav {
        position: fixed;
        bottom: auto;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1100;
        display: flex;
        justify-content: center;
        gap: 6px;
        padding: 10px 24px;
        background: rgba(10, 14, 26, .92);
        backdrop-filter: blur(20px);
        border-bottom: 1px solid rgba(255, 255, 255, .06);
        border-top: none;
        border-radius: 0;
    }

    body.light .bottom-nav {
        background: rgba(255, 255, 255, .92);
        border-bottom-color: rgba(0, 0, 0, .06);
    }

    .nav-item {
        flex-direction: row;
        gap: 6px;
        padding: 8px 18px;
        border-radius: 12px;
        min-width: auto;
    }

    .nav-item .nav-label {
        font-size: .82rem;
        font-weight: 500;
        display: inline;
    }

    .nav-item.active .nav-label {
        font-weight: 700;
    }

    .nav-fab {
        order: 0;
        margin: 0;
    }

    .nav-fab-inner {
        width: 38px;
        height: 38px;
        border-radius: 12px;
    }

    .main {
        padding-top: 70px;
        padding-bottom: 22px;
    }

    .header {
        top: 56px;
    }

    .footer {
        margin-bottom: 0;
    }

    .embedded-ai-panel {
        height: calc(100vh - 240px);
    }
}

/* ══════════════════════════════════════════════
   MOBILE — Enhanced Tab Layout
   ══════════════════════════════════════════════ */
@media (max-width: 768px) {

    /* Show bottom nav */
    .bottom-nav {
        display: flex;
    }

    /* Hide the old AI FAB (we use nav tab instead) */
    .ai-fab {
        display: none !important;
    }

    /* Main padding for bottom nav */
    .main {
        padding-bottom: 80px;
    }

    /* Embedded AI Panel — fill available space */
    .embedded-ai-panel {
        height: calc(100vh - 200px);
        min-height: 350px;
        border-radius: 16px;
    }

    /* Settings responsive */
    .settings-grid {
        grid-template-columns: 1fr;
    }

    /* About responsive */
    .about-section {
        max-width: 100%;
    }

    .tech-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .about-card {
        padding: 22px 18px;
    }

    .about-logo {
        font-size: 2.8rem;
    }

    .about-card h2 {
        font-size: 1.2rem;
    }

    /* Forecast section fix */
    .forecast-section {
        padding: 0 4px 24px;
    }
}

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

    .nav-item {
        padding: 6px 8px;
        min-width: 44px;
    }

    .nav-item .nav-label {
        font-size: .58rem;
    }

    .nav-fab-inner {
        width: 46px;
        height: 46px;
        border-radius: 14px;
    }
}

/* ══════════════════════════════════════════
   HISTORY TAB — Saved Data Browser
   ══════════════════════════════════════════ */

.history-filters {
    display: flex;
    align-items: flex-end;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 18px;
    padding: 18px;
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: var(--r);
    backdrop-filter: blur(10px);
}

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

.hf-group label {
    font-size: .78rem;
    color: var(--text2);
    font-weight: 600;
}

.hf-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.hf-chip {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 5px 12px;
    border-radius: 50px;
    background: rgba(255, 255, 255, .05);
    border: 1px solid var(--border);
    color: var(--text2);
    font-size: .75rem;
    cursor: pointer;
    transition: var(--t);
    font-family: var(--font-ar);
    user-select: none;
}

.hf-chip input[type="checkbox"] {
    display: none;
}

.hf-chip:hover {
    border-color: var(--c-blue);
    color: var(--text);
}

.hf-chip.selected {
    background: rgba(59, 130, 246, .15);
    border-color: rgba(59, 130, 246, .4);
    color: var(--text);
}

.custom-select {
    padding: 7px 14px;
    border-radius: 10px;
    background: rgba(255, 255, 255, .05);
    border: 1px solid var(--border);
    color: var(--text);
    font-family: var(--font-ar);
    font-size: .82rem;
    cursor: pointer;
    transition: var(--t);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 10px center;
    padding-left: 28px;
}

.custom-select:focus {
    border-color: var(--c-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, .15);
}

.custom-select option {
    background: #0c1120;
    color: var(--text);
}

.btn-primary {
    padding: 8px 20px;
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(59, 130, 246, .8), rgba(139, 92, 246, .8));
    border: none;
    color: #fff;
    font-family: var(--font-ar);
    font-size: .82rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--t);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(59, 130, 246, .35);
}

.btn-primary:disabled {
    opacity: .5;
    cursor: not-allowed;
    transform: none;
}

.btn-sm {
    padding: 6px 16px;
    font-size: .78rem;
}

.history-table-wrap {
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: var(--r);
    overflow: hidden;
    backdrop-filter: blur(10px);
    margin-bottom: 14px;
}

.history-table-wrap table {
    width: 100%;
    border-collapse: collapse;
    font-size: .82rem;
}

.history-table-wrap thead {
    background: rgba(59, 130, 246, .06);
}

.history-table-wrap th {
    padding: 10px 14px;
    text-align: right;
    color: var(--text2);
    font-size: .72rem;
    font-weight: 600;
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
}

.history-table-wrap td {
    padding: 9px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, .03);
    font-family: var(--font-en);
    white-space: nowrap;
    font-size: .8rem;
}

.history-table-wrap tr:hover td {
    background: rgba(255, 255, 255, .03);
}

.history-table-wrap .r-time {
    font-family: var(--font-en);
    color: var(--text2);
    font-size: .72rem;
}

.history-table-wrap .mid-cell {
    text-align: center;
    color: var(--text3);
    padding: 30px !important;
    font-family: var(--font-ar);
}

.history-actions {
    display: flex;
    align-items: center;
    gap: 14px;
}

.history-count {
    font-size: .8rem;
    color: var(--text2);
    font-family: var(--font-en);
}

/* History tab mobile */
@media (max-width: 768px) {
    .history-filters {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        padding: 14px;
    }

    .hf-chips {
        gap: 5px;
    }

    .hf-chip {
        padding: 4px 10px;
        font-size: .7rem;
    }

    .history-table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .history-table-wrap table {
        min-width: 400px;
    }

    .history-table-wrap th,
    .history-table-wrap td {
        padding: 8px 10px;
        font-size: .75rem;
    }

    .history-actions {
        flex-wrap: wrap;
        gap: 10px;
    }
}

/* ══ LIGHT MODE — History Tab ══ */
body.light .history-filters {
    background: rgba(0, 0, 0, .03);
    border-color: rgba(0, 0, 0, .08);
}

body.light .hf-chip {
    background: rgba(0, 0, 0, .04);
    border-color: rgba(0, 0, 0, .1);
    color: #475569;
}

body.light .hf-chip.selected {
    background: rgba(59, 130, 246, .1);
    border-color: rgba(59, 130, 246, .3);
    color: #1e40af;
}

body.light .custom-select {
    background-color: rgba(0, 0, 0, .03);
    border-color: rgba(0, 0, 0, .1);
    color: #1e293b;
}

body.light .custom-select option {
    background: #fff;
    color: #1e293b;
}

body.light .history-table-wrap {
    background: rgba(0, 0, 0, .02);
    border-color: rgba(0, 0, 0, .08);
}

body.light .history-table-wrap thead {
    background: rgba(59, 130, 246, .04);
}

body.light .history-table-wrap th {
    color: #475569;
    border-color: rgba(0, 0, 0, .06);
}

body.light .history-table-wrap td {
    border-color: rgba(0, 0, 0, .04);
}

/* ══════════════════════════════════════════
   SETTINGS LOCK — Password Protection
   ══════════════════════════════════════════ */
.settings-lock-overlay {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    padding: 24px;
}

.lock-card {
    text-align: center;
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 48px 36px;
    max-width: 420px;
    width: 100%;
    backdrop-filter: blur(20px);
    box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
}

.lock-icon {
    font-size: 4rem;
    margin-bottom: 16px;
    animation: lockPulse 2s ease infinite;
}

@keyframes lockPulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

.lock-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
}

.lock-sub {
    font-size: .85rem;
    color: var(--text2);
    margin-bottom: 24px;
}

.lock-input-wrap {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
}

.lock-input {
    flex: 1;
    padding: 12px 18px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, .05);
    color: var(--text);
    font-size: 1rem;
    font-family: var(--font-en);
    outline: none;
    transition: var(--t);
    text-align: center;
    letter-spacing: 4px;
}

.lock-input:focus {
    border-color: var(--c-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, .2);
}

.lock-btn {
    width: 100%;
    padding: 14px 24px;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(59, 130, 246, .8), rgba(139, 92, 246, .8));
    border: none;
    color: #fff;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--t);
    font-family: var(--font-ar);
    margin-bottom: 8px;
}

.lock-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, .4);
}

.lock-error {
    color: #ef4444;
    font-size: .82rem;
    padding: 8px;
    animation: shakeError .4s ease;
}

@keyframes shakeError {

    0%,
    100% {
        transform: translateX(0)
    }

    25% {
        transform: translateX(-8px)
    }

    75% {
        transform: translateX(8px)
    }
}

/* ══ MODAL ══ */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 9000;
    background: rgba(0, 0, 0, .6);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: modalFadeIn .25s ease;
}

@keyframes modalFadeIn {
    from {
        opacity: 0
    }

    to {
        opacity: 1
    }
}

.modal-card {
    background: var(--card-bg, #111827);
    border: 1px solid var(--border);
    border-radius: 20px;
    width: 100%;
    max-width: 500px;
    box-shadow: 0 25px 80px rgba(0, 0, 0, .5);
    overflow: hidden;
    animation: modalSlideUp .3s ease;
}

@keyframes modalSlideUp {
    from {
        transform: translateY(30px);
        opacity: 0
    }

    to {
        transform: translateY(0);
        opacity: 1
    }
}

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

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, .06);
    color: var(--text2);
    font-size: 1.3rem;
    cursor: pointer;
    transition: var(--t);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: rgba(239, 68, 68, .15);
    color: #ef4444;
}

.modal-body {
    padding: 24px;
}

.modal-desc {
    font-size: .85rem;
    color: var(--text2);
    margin-bottom: 18px;
}

.retention-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
}

.btn-secondary {
    padding: 8px 20px;
    border-radius: 10px;
    background: rgba(255, 255, 255, .06);
    border: 1px solid var(--border);
    color: var(--text2);
    font-family: var(--font-ar);
    font-size: .82rem;
    cursor: pointer;
    transition: var(--t);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, .1);
    color: var(--text);
}

.mq-status-info {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.mq-status-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, .04);
}

.mq-label {
    color: var(--text2);
    font-size: .82rem;
}

.mq-value {
    color: var(--text);
    font-size: .85rem;
    font-weight: 600;
    font-family: var(--font-en);
}

.mq-note {
    padding: 10px 14px;
    background: rgba(245, 158, 11, .08);
    border: 1px solid rgba(245, 158, 11, .2);
    border-radius: 10px;
    font-size: .78rem;
    color: #f59e0b;
    margin-top: 4px;
}

/* ══ NAV SVG ICONS ══ */
.nav-icon svg {
    width: 22px;
    height: 22px;
    color: var(--text2);
    transition: all .25s ease;
}

.nav-item.active .nav-icon svg {
    color: var(--c-blue);
    filter: drop-shadow(0 0 6px rgba(59, 130, 246, .4));
}

.nav-item:hover .nav-icon svg {
    color: var(--text);
}

/* ══ MOBILE NAV REDESIGN ══ */
@media (max-width: 768px) {
    .bottom-nav {
        gap: 2px;
        padding: 6px 8px 10px;
        border-radius: 22px 22px 0 0;
        background: rgba(10, 14, 26, .95);
        border-top: 1px solid rgba(255, 255, 255, .06);
        backdrop-filter: blur(24px);
    }

    .nav-item {
        padding: 6px 6px 3px;
        border-radius: 14px;
        min-width: 48px;
    }

    .nav-icon svg {
        width: 20px;
        height: 20px;
    }

    .nav-item.active .nav-icon svg {
        transform: scale(1.15);
    }

    .nav-item .nav-label {
        font-size: .6rem;
        font-weight: 500;
        opacity: .65;
    }

    .nav-item.active .nav-label {
        opacity: 1;
        font-weight: 700;
        color: var(--c-blue);
    }

    .nav-item.active {
        background: rgba(59, 130, 246, .12);
    }

    .nav-fab {
        margin: -8px 4px 0;
    }

    .nav-fab-inner {
        width: 50px;
        height: 50px;
        border-radius: 16px;
        box-shadow: 0 4px 20px rgba(59, 130, 246, .3);
    }
}

/* ══ LIGHT MODE — Lock & Modal ══ */
body.light .lock-card {
    background: rgba(255, 255, 255, .9);
    border-color: rgba(0, 0, 0, .08);
}

body.light .lock-input {
    background: rgba(0, 0, 0, .04);
    border-color: rgba(0, 0, 0, .1);
    color: #1e293b;
}

body.light .modal-card {
    background: #fff;
    border-color: rgba(0, 0, 0, .08);
}

body.light .btn-secondary {
    background: rgba(0, 0, 0, .04);
    border-color: rgba(0, 0, 0, .1);
    color: #475569;
}

body.light .mq-note {
    background: rgba(245, 158, 11, .06);
    border-color: rgba(245, 158, 11, .15);
}

body.light .bottom-nav {
    background: rgba(255, 255, 255, .95);
    border-top-color: rgba(0, 0, 0, .06);
}

body.light .nav-item.active {
    background: rgba(59, 130, 246, .08);
}

/* ══ TOGGLE SWITCH ══ */
.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
}

.toggle-label {
    color: var(--text);
    font-size: .88rem;
}

.toggle-switch {
    position: relative;
    width: 48px;
    height: 26px;
    cursor: pointer;
}

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

.toggle-slider {
    position: absolute;
    inset: 0;
    border-radius: 26px;
    background: rgba(255, 255, 255, .1);
    border: 1px solid var(--border);
    transition: .3s ease;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--text2);
    left: 3px;
    top: 2px;
    transition: .3s ease;
}

.toggle-switch input:checked+.toggle-slider {
    background: linear-gradient(135deg, rgba(59, 130, 246, .6), rgba(139, 92, 246, .6));
    border-color: rgba(59, 130, 246, .4);
}

.toggle-switch input:checked+.toggle-slider::before {
    transform: translateX(22px);
    background: #fff;
}

body.light .toggle-slider {
    background: rgba(0, 0, 0, .08);
    border-color: rgba(0, 0, 0, .1);
}

body.light .toggle-slider::before {
    background: #94a3b8;
}

body.light .toggle-switch input:checked+.toggle-slider {
    background: linear-gradient(135deg, rgba(59, 130, 246, .7), rgba(139, 92, 246, .7));
}

/* ══ SETTINGS LOCK OVERLAY ══ */
.settings-lock-overlay {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    padding: 40px 20px;
}

.settings-lock-overlay.hidden {
    display: none !important;
}

.lock-card {
    background: rgba(12, 17, 32, 0.95);
    backdrop-filter: blur(24px);
    border: 1px solid var(--border2);
    border-radius: 24px;
    padding: 40px 36px;
    text-align: center;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.lock-icon {
    font-size: 3.5rem;
    margin-bottom: 16px;
    filter: drop-shadow(0 0 20px rgba(59, 130, 246, 0.3));
    animation: floaty 3s ease-in-out infinite;
}

.lock-title {
    font-size: 1.4rem;
    font-weight: 800;
    background: linear-gradient(135deg, #fff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
}

.lock-sub {
    color: var(--text2);
    font-size: 0.88rem;
    margin-bottom: 24px;
}

.lock-input-wrap {
    margin-bottom: 16px;
}

.lock-input {
    width: 100%;
    padding: 14px 18px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border);
    color: var(--text);
    font-family: var(--font-ar);
    font-size: 1rem;
    text-align: center;
    outline: none;
    transition: var(--t);
    letter-spacing: 2px;
}

.lock-input:focus {
    border-color: rgba(59, 130, 246, 0.5);
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.15);
    background: rgba(255, 255, 255, 0.08);
}

.lock-input::placeholder {
    color: var(--text3);
    letter-spacing: 0;
}

.lock-btn {
    width: 100%;
    padding: 14px;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.8), rgba(139, 92, 246, 0.8));
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: #fff;
    font-family: var(--font-ar);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--t);
}

.lock-btn:hover {
    background: linear-gradient(135deg, rgba(59, 130, 246, 1), rgba(139, 92, 246, 1));
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(59, 130, 246, 0.4);
}

.lock-btn:active {
    transform: translateY(0);
}

.lock-error {
    margin-top: 14px;
    padding: 10px 16px;
    border-radius: 10px;
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
    font-size: 0.85rem;
    font-weight: 600;
    animation: fadeIn 0.3s ease;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    10%,
    30%,
    50%,
    70%,
    90% {
        transform: translateX(-6px);
    }

    20%,
    40%,
    60%,
    80% {
        transform: translateX(6px);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ══ RAIN CARDS — نفس مظهر باقي البطاقات ══ */
.rain-today-card,
.rain-card {
    border-color: var(--border) !important;
}

.rain-today-card:hover,
.rain-card:hover {
    border-color: var(--border2) !important;
    box-shadow: none;
}

.rain-today-card .scard-val span:first-child,
.rain-card .scard-val span:first-child {
    color: var(--text);
    -webkit-text-fill-color: var(--text);
    background: none;
    -webkit-background-clip: unset;
    background-clip: unset;
}

/* ══ SETTINGS GRID IMPROVEMENTS ══ */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: var(--gap);
}

.settings-card {
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: var(--r);
    overflow: hidden;
    transition: var(--t);
}

.settings-card:hover {
    border-color: var(--border2);
}

.sc-header {
    padding: 14px 18px;
    font-size: 0.9rem;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid var(--border);
}

.sc-body {
    padding: 16px 18px;
}

.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    font-size: 0.82rem;
    color: var(--text2);
    margin-bottom: 6px;
    font-weight: 500;
}

.custom-input {
    width: 100%;
    padding: 10px 14px;
    border-radius: var(--r2);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: var(--text);
    font-family: var(--font-en);
    font-size: 0.9rem;
    outline: none;
    transition: var(--t);
}

.custom-input:focus {
    border-color: rgba(59, 130, 246, 0.4);
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.1);
}

.custom-select {
    width: 100%;
    padding: 10px 14px;
    border-radius: var(--r2);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: var(--text);
    font-family: var(--font-ar);
    font-size: 0.88rem;
    outline: none;
    cursor: pointer;
    transition: var(--t);
}

.custom-select:focus {
    border-color: rgba(59, 130, 246, 0.4);
}

.custom-select option {
    background: #1e293b;
    color: var(--text);
}

.btn-primary {
    padding: 10px 20px;
    border-radius: var(--r2);
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.7), rgba(139, 92, 246, 0.7));
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: #fff;
    font-family: var(--font-ar);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--t);
    width: 100%;
}

.btn-primary:hover {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.9), rgba(139, 92, 246, 0.9));
    box-shadow: 0 4px 16px rgba(59, 130, 246, 0.3);
    transform: translateY(-1px);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-sm {
    padding: 6px 14px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border);
    color: var(--text2);
    font-family: var(--font-ar);
    font-size: 0.78rem;
    cursor: pointer;
    transition: var(--t);
}

.btn-sm:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text);
}

.btn-secondary {
    padding: 10px 20px;
    border-radius: var(--r2);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border);
    color: var(--text2);
    font-family: var(--font-ar);
    font-size: 0.88rem;
    cursor: pointer;
    transition: var(--t);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Model list */
.model-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.model-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-radius: var(--r2);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    transition: var(--t);
}

.model-item.model-active {
    border-color: rgba(16, 185, 129, 0.3);
    background: rgba(16, 185, 129, 0.06);
}

.model-name {
    font-family: var(--font-en);
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text);
}

.model-stats {
    font-size: 0.7rem;
    color: var(--text3);
    margin-top: 3px;
}

.model-priority {
    font-family: var(--font-en);
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text3);
    padding: 4px 10px;
    border-radius: 50px;
    background: rgba(255, 255, 255, 0.05);
}

.model-note {
    font-size: 0.78rem;
    color: var(--text3);
    padding: 8px 12px;
    border-radius: 8px;
    background: rgba(59, 130, 246, 0.06);
    border: 1px solid rgba(59, 130, 246, 0.12);
}



/* Toggle system highlight */
.system-toggle {
    padding: 10px 0 !important;
}

.system-toggle .toggle-label {
    font-weight: 700;
    font-size: 0.95rem !important;
}

.toggle-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 0 8px;
}

.toggle-header {
    font-size: 0.78rem;
    color: var(--text3);
    margin-bottom: 8px;
    font-weight: 600;
}

/* Retention chips */
.retention-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 8px 0;
}

.retention-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 50px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: var(--t);
    font-size: 0.78rem;
    color: var(--text2);
}

.retention-chip.selected {
    background: rgba(59, 130, 246, 0.15);
    border-color: rgba(59, 130, 246, 0.3);
    color: #93c5fd;
}

.retention-chip input {
    display: none;
}

.retention-label {
    font-size: 0.82rem;
    color: var(--text2);
    margin-bottom: 6px;
}

.retention-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

/* ══ MODAL ══ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9000;
    padding: 20px;
}

.modal-card {
    background: rgba(12, 17, 32, 0.98);
    border: 1px solid var(--border2);
    border-radius: 20px;
    max-width: 500px;
    width: 100%;
    overflow: hidden;
}

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

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text2);
    font-size: 1.4rem;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    transition: var(--t);
}

.modal-close:hover {
    color: var(--c-red);
}

.modal-body {
    padding: 22px;
}

.modal-desc {
    font-size: 0.88rem;
    color: var(--text2);
    margin-bottom: 18px;
}

.modal-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding: 14px 22px;
    border-top: 1px solid var(--border);
}

/* Light mode adjustments */
body.light .settings-card {
    background: rgba(0, 0, 0, .02);
    border-color: rgba(0, 0, 0, .06);
}

body.light .sc-header {
    background: rgba(0, 0, 0, .03);
    border-color: rgba(0, 0, 0, .06);
}

body.light .custom-input {
    background: rgba(0, 0, 0, .03);
    border-color: rgba(0, 0, 0, .08);
    color: #1e293b;
}

body.light .custom-select {
    background: rgba(0, 0, 0, .03);
    border-color: rgba(0, 0, 0, .08);
    color: #1e293b;
}

body.light .retention-chip {
    background: rgba(0, 0, 0, .03);
    border-color: rgba(0, 0, 0, .06);
}

body.light .retention-chip.selected {
    background: rgba(59, 130, 246, .1);
}

/* ══ SENSOR HISTORY DASHBOARD ══ */
.sensor-history-section {
    padding-bottom: 24px;
}

.sh-header {
    flex-wrap: wrap;
    gap: 12px;
}

.sh-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
    width: 100%;
    justify-content: space-between;
}

.sh-toolbar-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.sh-select-wrap {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    min-width: 200px;
}

.sh-select-label {
    font-size: 0.78rem;
    color: var(--text2);
    font-weight: 600;
}

.sh-sensor-select {
    width: 100%;
    max-width: 420px;
}

.sh-sync-line {
    font-size: 0.82rem;
    color: var(--text2);
    margin: 8px 0 14px;
    min-height: 1.2em;
}

.sh-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.sh-stats-grid--3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 520px) {
    .sh-stats-grid--3 {
        grid-template-columns: 1fr;
    }
}

.sh-date-input {
    max-width: 240px;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.3);
    color: var(--text);
    font-family: var(--font-en);
    transition: all 0.3s ease;
}

.sh-date-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
    outline: none;
}

.sh-rollups-hint {
    font-size: 0.82rem;
    color: #fbbf24;
    margin: 0 0 12px;
    padding: 10px 12px;
    border-radius: var(--r2);
    border: 1px solid rgba(251, 191, 36, 0.25);
    background: rgba(251, 191, 36, 0.06);
    line-height: 1.45;
}

body.light .sh-date-input {
    background: rgba(255, 255, 255, 0.8);
    border-color: rgba(0, 0, 0, 0.1);
    color: #1e293b;
}

body.light .sh-date-input:focus {
    border-color: #3b82f6;
    background: #ffffff;
}

.sh-stat-card {
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 14px 16px;
    transition: var(--t);
}

.sh-stat-card:hover {
    border-color: var(--border2);
    background: var(--glass2);
}

.sh-stat-label {
    font-size: 0.78rem;
    color: var(--text2);
    margin-bottom: 8px;
}

.sh-stat-val {
    font-size: 1.35rem;
    font-weight: 800;
    font-family: var(--font-en);
    color: var(--c-blue);
    letter-spacing: -0.02em;
}

.sh-table-title {
    margin-bottom: 10px;
    margin-top: 4px;
}

.sh-table-wrap {
    border-radius: var(--r);
    border: 1px solid var(--border);
    overflow: hidden;
    background: rgba(0, 0, 0, 0.15);
    max-height: min(55vh, 420px);
    overflow-y: auto;
}

.sh-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.sh-table thead th {
    position: sticky;
    top: 0;
    background: rgba(12, 17, 32, 0.98);
    padding: 12px 14px;
    text-align: right;
    border-bottom: 1px solid var(--border);
    color: var(--text2);
    font-weight: 600;
    z-index: 1;
}

body.ltr .sh-table thead th {
    text-align: left;
}

.sh-table tbody td {
    padding: 10px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.sh-table tbody tr:hover td {
    background: rgba(59, 130, 246, 0.06);
}

.sh-cell-time {
    color: var(--text2);
    font-family: var(--font-en);
    white-space: nowrap;
}

.sh-cell-val {
    font-weight: 700;
    font-family: var(--font-en);
    color: var(--text);
}

body.light .sh-table-wrap {
    background: rgba(0, 0, 0, 0.02);
}

body.light .sh-table thead th {
    background: rgba(255, 255, 255, 0.95);
}

/* Sensor history — نطاق متعدد الحساسات + لوحة فلاتر */
.sh-toolbar--summary {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    margin-bottom: 4px;
}

.sh-filter-summary {
    flex: 1;
    min-width: 180px;
    margin: 0;
    font-size: 0.82rem;
    color: var(--text2);
    line-height: 1.45;
}

.sh-raw-note {
    font-size: 0.78rem;
    color: var(--text3);
    margin: 0 0 12px;
}

.sh-drawer-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 110;
}

.sh-drawer-backdrop--open {
    display: block;
}

.sh-filter-panel {
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 24px;
    background: linear-gradient(145deg, rgba(30, 41, 59, 0.6), rgba(15, 23, 42, 0.8));
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    padding: 24px;
    margin-bottom: 24px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

body.light .sh-filter-panel {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.9), rgba(248, 250, 252, 0.95));
    border: 1px solid rgba(0, 0, 0, 0.05);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.05), inset 0 1px 0 rgba(255, 255, 255, 1);
}

.sh-filter-panel:hover {
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

body.light .sh-filter-panel:hover {
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.08), inset 0 1px 0 rgba(255, 255, 255, 1);
}

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

.sh-drawer-title {
    font-weight: 700;
    font-size: 0.95rem;
}

.sh-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 18px;
    padding-bottom: 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

body.light .sh-presets {
    border-bottom-color: rgba(0, 0, 0, 0.06);
}

.sh-preset-btn {
    border-radius: 50px;
    padding: 8px 18px;
    font-weight: 600;
    letter-spacing: 0.02em;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.03);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body.light .sh-preset-btn:not(.sh-preset-active) {
    border-color: rgba(0, 0, 0, 0.08);
    background: rgba(0, 0, 0, 0.03);
}

.sh-preset-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.05);
}

body.light .sh-preset-btn:not(.sh-preset-active):hover {
    background: rgba(0, 0, 0, 0.06);
}

.sh-preset-btn.sh-preset-active {
    border-color: transparent;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.sh-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}

.sh-field-label {
    font-size: 0.78rem;
    color: var(--text2);
    font-weight: 600;
}

.sh-custom-range {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.sh-sensor-checkboxes {
    display: flex;
    flex-wrap: wrap;
    flex-direction: row;
    gap: 8px;
    padding: 8px 0;
}

.sh-cb-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.88rem;
    cursor: pointer;
}

.sh-filter-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.sh-stats-container {
    margin-bottom: 16px;
}

.sh-stats-title {
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--text2);
}

.sh-per-sensor-stats {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
}

.sh-sensor-stat-block {
    border: 1px solid var(--border);
    border-radius: var(--r2);
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.12);
}

body.light .sh-sensor-stat-block {
    background: rgba(0, 0, 0, 0.03);
}

.sh-sensor-stat-name {
    font-size: 0.8rem;
    font-weight: 700;
    margin-bottom: 6px;
}

.sh-mini-stats {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.82rem;
    font-family: var(--font-en);
    color: var(--text);
}

.sh-chart-block {
    margin-bottom: 16px;
}

.sh-chart-heading {
    margin-bottom: 8px;
}

.sh-chart-wrap {
    position: relative;
    height: min(320px, 45vh);
    width: 100%;
}

.sh-table-wrap--wide {
    overflow-x: auto;
    max-height: min(55vh, 420px);
    overflow-y: auto;
}

.sh-only-mobile {
    display: none;
}

@media (max-width: 768px) {
    .sh-only-mobile {
        display: inline-flex;
    }

    .sh-filter-panel {
        position: fixed;
        top: 0;
        bottom: 0;
        width: min(100%, 360px);
        max-width: 100vw;
        margin: 0;
        z-index: 120;
        overflow-y: auto;
        right: 0;
        left: auto;
        transform: translateX(100%);
        transition: transform 0.22s ease;
        border-radius: 0;
        border-inline-start: 1px solid var(--border);
    }

    /* إلغاء تأثير hover الذي يتعارض مع الموقع الثابت على الموبايل */
    .sh-filter-panel:hover {
        transform: translateX(100%);
        box-shadow: none;
    }

    .sh-filter-panel.sh-filter-panel--open:hover {
        transform: translateX(0) !important;
    }

    .sh-filter-panel.sh-filter-panel--open {
        transform: translateX(0) !important;
    }

    .sh-drawer-header .sh-only-mobile {
        display: inline-flex;
    }

    /* زر الإغلاق — حجم لمس كبير ومرئي */
    #sh-drawer-close {
        min-width: 44px;
        min-height: 44px;
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        touch-action: manipulation;
        -webkit-tap-highlight-color: rgba(59, 130, 246, .2);
        position: relative;
        z-index: 130;
    }

    /* تحسين جدول السجلات على الموبايل */
    .sh-table-wrap--wide {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-height: 50vh;
    }

    .sh-table {
        min-width: 500px;
        font-size: 0.76rem;
    }

    .sh-table th,
    .sh-table td {
        padding: 8px 10px;
        white-space: nowrap;
    }

    .sh-per-sensor-stats {
        grid-template-columns: 1fr;
    }

    .sh-stats-card {
        padding: 12px 14px;
    }

    .sh-chart-wrap {
        height: min(250px, 40vh);
    }

    .sh-toolbar--summary {
        flex-direction: column;
        gap: 8px;
    }
}

body.sh-drawer-lock {
    overflow: hidden;
}

@media (min-width: 769px) {
    .sh-drawer-backdrop {
        display: none !important;
    }

    .sh-drawer-header .sh-only-mobile {
        display: none !important;
    }
}

/* سجل الحساسات — تنسيق أوضح */
.sensor-history-section .sh-layout {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.sh-table-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sh-stats-container {
    margin-bottom: 0;
}

.sh-stats-card {
    border: 1px solid var(--border);
    border-radius: var(--r);
    background: linear-gradient(165deg, rgba(59, 130, 246, 0.06), rgba(0, 0, 0, 0.08));
    padding: 16px 18px;
}

body.light .sh-stats-card {
    background: linear-gradient(165deg, rgba(59, 130, 246, 0.06), rgba(255, 255, 255, 0.9));
}

.sh-stats-heading {
    margin: 0 0 14px;
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.02em;
}

.sh-per-sensor-stats {
    gap: 12px;
}

.sh-sensor-stat-block {
    padding: 12px 14px;
    border-radius: var(--r2);
    background: rgba(0, 0, 0, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

body.light .sh-sensor-stat-block {
    background: rgba(255, 255, 255, 0.65);
    border-color: rgba(0, 0, 0, 0.06);
}

.sh-sensor-stat-name {
    font-size: 0.84rem;
    margin-bottom: 10px;
    color: var(--text2);
}

.sh-stat-metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

@media (max-width: 520px) {
    .sh-stat-metrics {
        grid-template-columns: 1fr;
    }
}

.sh-stat-metric {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px 10px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
}

body.light .sh-stat-metric {
    background: rgba(0, 0, 0, 0.03);
}

.sh-stat-metric-label {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text3);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.sh-stat-metric-val {
    font-size: 1rem;
    font-weight: 800;
    font-family: var(--font-en);
    color: var(--text);
}

.sh-chart-block {
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 12px 14px 16px;
    background: var(--glass);
}

.sh-chart-heading {
    margin-bottom: 10px !important;
}

.export-range-hint {
    font-size: 0.82rem;
    color: var(--c-blue);
    margin: 0 0 12px;
    padding: 10px 12px;
    border-radius: var(--r2);
    border: 1px solid rgba(59, 130, 246, 0.25);
    background: rgba(59, 130, 246, 0.08);
    line-height: 1.45;
}

body.light .export-range-hint {
    color: #1d4ed8;
}

/* ═══════════════════════════════════════════
   لوحة التحكم الإدارية v1 (ws-dash) — متناغمة مع البطاقات الزجاجية
   ═══════════════════════════════════════════ */

.ws-dash {
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 20px 22px;
    backdrop-filter: blur(12px);
}

.ws-dash--gate {
    border-color: rgba(139, 92, 246, 0.28);
    background: linear-gradient(155deg, rgba(139, 92, 246, 0.09), var(--glass));
}

.ws-dash-gate-head {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 18px;
}

.ws-dash-gate-icon {
    font-size: 2rem;
    line-height: 1;
    filter: drop-shadow(0 0 10px rgba(139, 92, 246, 0.35));
}

.ws-dash-gate-title {
    margin: 0 0 6px !important;
    font-size: 1.15rem !important;
}

.ws-dash-gate-desc {
    font-size: 0.86rem;
    color: var(--text2);
    line-height: 1.45;
    margin: 0;
}

.ws-dash-gate-form {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.ws-dash-gate-form .ws-dash-input {
    flex: 1 1 200px;
}

.ws-dash--panel {
    border-color: rgba(59, 130, 246, 0.22);
    background: linear-gradient(160deg, rgba(59, 130, 246, 0.06), var(--glass));
}

.ws-dash-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
}

.ws-dash-panel-title {
    margin: 0 0 4px !important;
    font-size: 1.2rem !important;
}

.ws-dash-panel-sub {
    margin: 0;
    font-size: 0.82rem;
    color: var(--text2);
}

.ws-dash-iconbtn {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: 1px solid rgba(239, 68, 68, 0.35);
    background: rgba(239, 68, 68, 0.12);
    color: var(--text);
    font-size: 1.15rem;
    cursor: pointer;
    transition: var(--t);
}

.ws-dash-iconbtn:hover {
    background: rgba(239, 68, 68, 0.22);
    transform: scale(1.04);
}

.ws-dash-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 14px;
}

.ws-dash-tile {
    border: 1px solid var(--border);
    border-radius: var(--r2);
    background: rgba(0, 0, 0, 0.2);
    padding: 14px 16px;
}

body.light .ws-dash-tile {
    background: rgba(255, 255, 255, 0.55);
}

.ws-dash-tile--wide {
    grid-column: 1 / -1;
}

.ws-dash-tile-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.ws-dash-tile-head h4 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--text);
}

.ws-dash-tile-ic {
    font-size: 1.25rem;
    line-height: 1;
}

.ws-dash-tile-body--stack {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ws-dash-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--r2);
    border: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.15);
    margin-bottom: 10px;
}

body.light .ws-dash-row {
    background: rgba(0, 0, 0, 0.03);
}

.ws-dash-row:last-child {
    margin-bottom: 0;
}

.ws-dash-label {
    font-weight: 700;
    font-size: 0.88rem;
    color: var(--text);
}

.ws-dash-hint {
    font-size: 0.78rem;
    color: var(--text2);
    margin-top: 2px;
}

.ws-dash-input {
    width: 100%;
    padding: 11px 14px;
    border-radius: var(--r2);
    border: 1px solid var(--border2);
    background: rgba(0, 0, 0, 0.28);
    color: var(--text);
    font-size: 0.92rem;
    outline: none;
    transition: var(--t);
}

body.light .ws-dash-input {
    background: rgba(255, 255, 255, 0.85);
    color: #0f172a;
}

.ws-dash-input:focus {
    border-color: var(--c-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
}

.ws-dash-input--num {
    font-family: var(--font-en);
    font-weight: 700;
}

.ws-dash-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.ws-dash-chip {
    padding: 7px 12px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--glass2);
    color: var(--text2);
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--t);
}

.ws-dash-chip:hover,
.ws-dash-chip:focus-visible {
    border-color: var(--c-blue);
    color: var(--text);
}

.ws-dash-btn {
    padding: 10px 16px;
    border-radius: var(--r2);
    font-size: 0.82rem;
    font-weight: 800;
    border: none;
    cursor: pointer;
    transition: var(--t);
    white-space: nowrap;
}

.ws-dash-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none !important;
}

.ws-dash-btn--primary {
    background: linear-gradient(135deg, var(--c-blue), #2563eb);
    color: #fff;
}

.ws-dash-btn--primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(59, 130, 246, 0.35);
}

.ws-dash-btn--danger {
    background: linear-gradient(135deg, var(--c-red), #b91c1c);
    color: #fff;
}

.ws-dash-btn--danger:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(239, 68, 68, 0.35);
}

.ws-dash-btn--ok {
    background: linear-gradient(135deg, var(--c-green), #047857);
    color: #fff;
}

.ws-dash-btn--ok:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(16, 185, 129, 0.3);
}

.ws-dash-btn--warn {
    background: linear-gradient(135deg, #f59e0b, #b45309);
    color: #fff;
}

.ws-dash-btn--warn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(245, 158, 11, 0.3);
}

.ws-dash-btn--ghost {
    background: rgba(148, 163, 184, 0.12);
    color: var(--text2);
    border: 1px solid var(--border);
}

.ws-dash-btn--ghost:hover:not(:disabled) {
    background: rgba(148, 163, 184, 0.22);
    color: var(--text);
}

.ws-dash-footnote {
    font-size: 0.78rem;
    color: var(--text2);
    margin: 4px 0 0;
}

.ws-dash-footnote strong {
    color: var(--text);
    font-family: var(--font-en);
}

.ws-dash-msg {
    font-size: 0.84rem;
    padding: 10px 12px;
    border-radius: var(--r2);
    text-align: center;
}

.ws-dash-msg.success {
    background: rgba(16, 185, 129, 0.14);
    color: var(--c-green);
    border: 1px solid rgba(16, 185, 129, 0.35);
}

.ws-dash-msg.error {
    background: rgba(239, 68, 68, 0.12);
    color: #fecaca;
    border: 1px solid rgba(239, 68, 68, 0.35);
}

body.light .ws-dash-msg.error {
    color: #b91c1c;
}

.ws-dash-alert {
    margin-top: 10px;
    font-size: 0.82rem;
    font-weight: 700;
}

.ws-dash-alert--err {
    color: var(--c-red);
}

.ws-dash-meta {
    margin-top: 8px;
    font-size: 0.78rem;
    color: var(--text2);
}

.ws-dash-archive {
    margin-top: 4px;
}

.ws-dash-select {
    border-radius: var(--r2);
}

.ws-dash-status {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ws-dash-status-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    font-size: 0.86rem;
    color: var(--text2);
}

.ws-dash-pill {
    font-size: 0.78rem;
    font-weight: 800;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.15);
    color: var(--text);
}

.ws-dash-mono {
    font-family: var(--font-en);
    font-size: 0.84rem;
    color: var(--text);
}

/* ── Monthly Archive Section ── */
.monthly-archive-card {
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--border2);
    border-radius: var(--r2);
    padding: 20px;
    margin-bottom: 16px;
}

body.light .monthly-archive-card {
    background: rgba(255, 255, 255, 0.6);
}

.archive-countdown {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
    padding: 16px;
    background: rgba(59, 130, 246, 0.1);
    border-radius: var(--r2);
    border-left: 4px solid var(--c-blue);
}

.countdown-icon {
    font-size: 2rem;
}

.countdown-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.countdown-label {
    font-size: 0.85rem;
    color: var(--text2);
}

.countdown-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--c-blue);
}

.archive-current-month {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    padding: 12px 16px;
    background: rgba(139, 92, 246, 0.1);
    border-radius: var(--r2);
}

.current-month-label {
    font-size: 0.9rem;
    color: var(--text2);
}

.current-month-value {
    font-weight: 700;
    color: var(--c-purple);
}

.current-month-records {
    font-size: 0.85rem;
    color: var(--text2);
    margin-left: auto;
}

.archive-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.archive-hint {
    font-size: 0.8rem;
    color: var(--text2);
    line-height: 1.5;
    padding: 12px;
    margin-bottom: 8px;
    background: rgba(245, 158, 11, 0.1);
    border-radius: var(--r2);
    border-right: 3px solid #f59e0b;
}

.archive-hint:last-child {
    margin-bottom: 0;
}

.archive-hint-warning {
    background: rgba(239, 68, 68, 0.1);
    border-right-color: var(--c-red);
    color: var(--c-red);
}

/* ── Month Selector ── */
.month-selector-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    padding: 12px 16px;
    background: rgba(59, 130, 246, 0.08);
    border-radius: var(--r2);
    flex-wrap: wrap;
}

.month-selector-label {
    font-size: 0.9rem;
    color: var(--text2);
    white-space: nowrap;
}

.month-select {
    flex: 1;
    min-width: 200px;
    padding: 10px 14px;
    border: 1px solid var(--border2);
    border-radius: var(--r2);
    background: rgba(0, 0, 0, 0.25);
    color: var(--text);
    font-size: 0.9rem;
    font-family: var(--font);
    outline: none;
    cursor: pointer;
}

body.light .month-select {
    background: rgba(255, 255, 255, 0.7);
    color: #1a1a1a;
}

.month-select:focus {
    border-color: var(--c-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.month-select option {
    background: var(--bg2);
    color: var(--text);
    padding: 8px;
}

.selected-month-status {
    font-size: 0.85rem;
    color: var(--c-amber);
    font-weight: 500;
}

.archive-result {
    margin-bottom: 16px;
    padding: 16px;
    background: rgba(16, 185, 129, 0.1);
    border-radius: var(--r2);
    border-right: 3px solid #10b981;
}

.archive-result.hidden {
    display: none;
}

.archive-success {
    color: var(--text);
}

.archive-success ul {
    margin-top: 8px;
    padding-right: 20px;
}

.archive-success li {
    margin-bottom: 4px;
}

.archive-error {
    color: var(--c-red);
    font-weight: 600;
}

.archived-months-list {
    margin-top: 16px;
    padding: 16px;
    background: rgba(148, 163, 184, 0.1);
    border-radius: var(--r2);
}

.archived-months-list.hidden {
    display: none;
}

.archived-months-list h6 {
    margin-bottom: 12px;
    color: var(--text);
}

.archived-months-list ul {
    list-style: none;
    padding: 0;
}

.archived-months-list li {
    padding: 8px 12px;
    margin-bottom: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--r2);
    font-size: 0.9rem;
}

body.light .archived-months-list li {
    background: rgba(0, 0, 0, 0.05);
}

.preset-btn {
    padding: 8px 14px;
    background: rgba(59, 130, 246, 0.12);
    border: 1px solid rgba(59, 130, 246, 0.25);
    border-radius: 20px;
    color: var(--c-blue);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--t);
}

.preset-btn:hover {
    background: rgba(59, 130, 246, 0.25);
    transform: translateY(-1px);
}

/* ═══════════════════════════════════════════
   MODALS
   ═══════════════════════════════════════════ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
}

.modal-box {
    background: var(--bg2);
    border: 1px solid var(--border2);
    border-radius: var(--r);
    padding: 28px 32px;
    max-width: 420px;
    width: 100%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

.modal-danger {
    background: linear-gradient(165deg, rgba(239, 68, 68, 0.08), var(--bg2));
    border-color: rgba(239, 68, 68, 0.3);
}

.modal-icon {
    font-size: 3.5rem;
    margin-bottom: 16px;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 12px;
}

.modal-desc {
    font-size: 0.9rem;
    color: var(--text2);
    line-height: 1.6;
    margin-bottom: 20px;
}

.modal-desc strong {
    color: var(--c-red);
    font-weight: 700;
}

.modal-confirm-input {
    margin-bottom: 24px;
    text-align: right;
}

.modal-confirm-input label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
}

.confirm-input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--c-red);
    border-radius: var(--r2);
    background: rgba(0, 0, 0, 0.25);
    color: var(--text);
    font-size: 1.1rem;
    font-weight: 700;
    font-family: var(--font-en);
    text-align: center;
    text-transform: uppercase;
    outline: none;
    transition: var(--t);
}

body.light .confirm-input {
    background: rgba(255, 255, 255, 0.7);
    color: #1a1a1a;
}

.confirm-input:focus {
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.15);
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.modal-btn {
    padding: 12px 24px;
    border-radius: var(--r2);
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--t);
    border: none;
}

.modal-btn-secondary {
    background: rgba(148, 163, 184, 0.15);
    color: var(--text2);
    border: 1px solid var(--border);
}

.modal-btn-secondary:hover {
    background: rgba(148, 163, 184, 0.25);
}

.modal-btn-danger {
    background: linear-gradient(135deg, var(--c-red), #dc2626);
    color: white;
}

.modal-btn-danger:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.35);
}

.modal-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

@media (max-width: 480px) {
    .modal-box {
        padding: 24px 20px;
    }

    .modal-actions {
        flex-direction: column;
    }

    .modal-btn {
        width: 100%;
    }

    .ws-dash-row {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }

    .ws-dash-gate-form {
        flex-direction: column;
    }

    .ws-dash-gate-form .ws-dash-btn {
        width: 100%;
    }
}

/* ══════════════════════════════════════════════
   MOBILE FIX v1 — Tüm mobil sorunların düzeltmesi
   ══════════════════════════════════════════════ */

@media (max-width: 768px) {

    /* ─────── HEADER düzeltmesi — daha düzenli ─────── */
    .header-top {
        flex-wrap: wrap !important;
        gap: 6px;
    }

    .header-actions {
        flex-wrap: wrap !important;
        gap: 4px;
        justify-content: flex-start;
    }

    /* Bağlantı durumu pill'ini küçült */
    .pill-tag {
        padding: 3px 6px;
        font-size: .62rem;
        max-width: 130px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .pill-tag .blink-dot {
        width: 5px;
        height: 5px;
    }

    /* Butonları küçült */
    .header-actions .icon-btn {
        padding: 4px 8px;
        font-size: .68rem;
    }

    /* Saat kutusunu küçült */
    .clock-time {
        font-size: .82rem;
    }

    .clock-date {
        font-size: .52rem;
    }

    /* ─────── CONDITION BAR — ikon küçültme + grid düzeni ─────── */
    .condition-bar {
        padding: 8px 12px;
        gap: 8px;
    }

    .condition-icon {
        font-size: 1.1rem !important;
    }

    .condition-text {
        font-size: .8rem;
    }

    .condition-left {
        gap: 6px;
    }

    .condition-right {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 4px;
    }

    .mini-stat {
        align-items: center;
    }

    .ms-label {
        font-size: .55rem;
        text-align: center;
        line-height: 1.2;
    }

    .ms-val {
        font-size: .72rem;
        font-weight: 700;
    }

    .countdown-badge {
        grid-column: span 4;
        text-align: center;
        font-size: .68rem;
        padding: 3px 8px;
    }

    /* ─────── SENSOR HISTORY (السجل) — kompakt düzen ─────── */
    .sh-toolbar--summary {
        flex-direction: column;
        gap: 8px;
    }

    .sh-filter-summary {
        font-size: .72rem;
        line-height: 1.35;
        min-width: 0;
        max-height: 3.8em;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 3;
        line-clamp: 3;
        -webkit-box-orient: vertical;
    }

    .sh-toolbar-actions {
        display: flex;
        gap: 6px;
        width: 100%;
    }

    .sh-toolbar-actions .icon-btn {
        flex: 1;
        text-align: center;
        justify-content: center;
        padding: 8px 10px;
        font-size: .76rem;
    }

    .sh-sync-line {
        font-size: .72rem;
    }

    .sh-raw-note {
        font-size: .7rem;
        margin-bottom: 8px;
    }

    /* İstatistik kartları daha kompakt */
    .sh-per-sensor-stats {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .sh-sensor-stat-block {
        padding: 8px 10px;
    }

    .sh-sensor-stat-name {
        font-size: .76rem;
        margin-bottom: 6px;
    }

    .sh-stat-metric {
        padding: 6px 8px;
    }

    .sh-stat-metric-label {
        font-size: .65rem;
    }

    .sh-stat-metric-val {
        font-size: .88rem;
    }

    /* Grafik yüksekliği */
    .sh-chart-wrap {
        height: min(250px, 40vh);
    }

    /* Tablo kompakt */
    .sh-table {
        font-size: .78rem;
    }

    .sh-table thead th {
        padding: 8px 10px;
        font-size: .72rem;
    }

    .sh-table tbody td {
        padding: 6px 10px;
    }

    /* ─────── FILTER DRAWER — kapatma butonu ─────── */
    #sh-drawer-close {
        min-width: 48px;
        min-height: 48px;
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        padding: 10px 20px;
        font-size: 0.9rem;
        font-weight: 800;
        background: rgba(239, 68, 68, 0.18);
        border: 2px solid rgba(239, 68, 68, 0.4);
        color: #ef4444;
        border-radius: 14px;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
        z-index: 999;
        position: relative;
        pointer-events: auto !important;
    }

    #sh-drawer-close:active {
        background: rgba(239, 68, 68, 0.35);
        transform: scale(0.92);
    }

    /* Çekmece başlığı — yapışkan */
    .sh-filter-panel .sh-drawer-header {
        position: sticky;
        top: 0;
        z-index: 10;
        padding: 16px 4px 12px;
        background: inherit;
        border-bottom: 1px solid var(--border);
        margin-bottom: 14px;
    }

    .sh-filter-panel {
        padding: 16px 18px;
    }

    /* Uygula butonu — tam genişlik */
    #sh-drawer-apply {
        min-height: 48px;
        font-size: 0.9rem;
        width: 100%;
    }

    #sh-btn-open-filters {
        min-height: 40px;
        padding: 8px 16px;
        font-size: .82rem;
    }

    /* ─────── ADMIN PANEL — tek sütun ─────── */
    .ws-dash-grid {
        grid-template-columns: 1fr;
    }

    .ws-dash {
        padding: 16px 14px;
    }

    .ws-dash-presets {
        gap: 6px;
    }

    .ws-dash-chip {
        padding: 8px 14px;
        font-size: .76rem;
    }

    /* ─────── GENEL ─────── */
    .main {
        overflow-x: hidden;
    }

    .forecast-cards {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x mandatory;
        padding-bottom: 6px;
    }

    .forecast-card {
        scroll-snap-align: start;
        flex-shrink: 0;
    }

    .sh-table-wrap--wide {
        -webkit-overflow-scrolling: touch;
    }
}

/* ─────── Küçük ekranlar (≤ 480px) ─────── */
@media (max-width: 480px) {
    .header-top {
        gap: 4px;
    }

    .brand-text h1 {
        font-size: .82rem;
    }

    .brand-sub--mobile {
        font-size: .58rem;
    }

    .header-actions .icon-btn {
        padding: 3px 6px;
        font-size: .62rem;
    }

    .pill-tag {
        max-width: 110px;
        font-size: .58rem;
    }

    .condition-icon {
        font-size: .95rem !important;
    }

    .condition-text {
        font-size: .72rem;
    }

    .condition-right {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }

    .countdown-badge {
        grid-column: span 2;
    }

    #sh-drawer-close {
        padding: 8px 16px;
        font-size: 0.85rem;
        min-width: 48px;
        min-height: 48px;
    }

    .sh-filter-panel {
        width: 100% !important;
        max-width: 100vw !important;
        padding: 14px 14px;
    }

    .sh-presets {
        gap: 5px;
    }

    .sh-preset-btn {
        padding: 6px 12px;
        font-size: .74rem;
    }

    .sh-date-input {
        max-width: 100%;
    }

    .sh-per-sensor-stats {
        grid-template-columns: 1fr;
    }

    .sh-toolbar-actions .icon-btn {
        padding: 6px 8px;
        font-size: .7rem;
    }
}



/* ═══════════════════════════════════════════
   Compact Admin Gate — mobile password section
   ═══════════════════════════════════════════ */
.ws-dash-gate-head--compact {
    margin-bottom: 12px;
}

.ws-dash-gate-form--compact {
    gap: 8px;
}

.ws-dash-input--compact {
    padding: 10px 14px;
    font-size: 0.88rem;
}

@media (max-width: 768px) {
    .ws-dash--gate {
        padding: 16px 14px;
    }

    .ws-dash-gate-head--compact {
        margin-bottom: 10px;
        gap: 10px;
    }

    .ws-dash-gate-icon {
        font-size: 1.6rem;
    }

    .ws-dash-gate-title {
        font-size: 1rem !important;
    }

    .ws-dash-gate-desc {
        font-size: 0.78rem;
    }

    .ws-dash-input--compact {
        padding: 10px 12px;
        font-size: 0.85rem;
    }

    .ws-dash-gate-form--compact .ws-dash-input {
        flex: 1 1 140px;
        max-height: 44px;
    }

    .ws-dash-gate-form--compact .ws-dash-btn {
        padding: 10px 14px;
        font-size: 0.8rem;
    }
}

/* ═══════════════════════════════════════════
   Mobile Header — collapsible summary
   ═══════════════════════════════════════════ */
@media (max-width: 640px) {
    .header {
        padding-bottom: 8px;
    }

    .header-inner {
        padding: 8px 12px;
    }

    .header-top {
        gap: 8px;
        margin-bottom: 6px;
    }

    .weather-summary {
        padding: 8px 12px;
        margin: 0 -4px;
        border-radius: 12px;
    }

    .summary-item {
        min-width: 0;
    }

    .summary-val {
        font-size: 1rem;
    }

    .header-bottom {
        padding: 6px 0 4px;
        gap: 6px;
    }

    .brand-name {
        font-size: 0.95rem;
    }

    .brand-sub {
        font-size: 0.68rem;
    }
}

/* ═══════════════════════════════════════════
   Filter Drawer — mobile fixes
   ═══════════════════════════════════════════ */
@media (max-width: 768px) {
    .sh-filter-panel {
        padding: 18px 14px;
    }

    .sh-drawer-header {
        padding-bottom: 10px;
        margin-bottom: 14px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    }

    .sh-drawer-header .icon-btn {
        background: rgba(239, 68, 68, 0.15);
        border: 1px solid rgba(239, 68, 68, 0.35);
        color: #ef4444;
        font-weight: 700;
        padding: 8px 16px;
        border-radius: 10px;
        min-width: 70px;
        text-align: center;
    }

    .sh-drawer-header .icon-btn:active {
        background: rgba(239, 68, 68, 0.3);
        transform: scale(0.96);
    }

    .sh-filter-actions {
        position: sticky;
        bottom: 0;
        background: linear-gradient(to top, rgba(15, 23, 42, 0.98) 70%, transparent);
        padding: 14px 0 8px;
        margin-top: 14px;
        z-index: 2;
    }

    body.light .sh-filter-actions {
        background: linear-gradient(to top, rgba(248, 250, 252, 0.98) 70%, transparent);
    }

    .sh-filter-actions .btn-primary {
        flex: 1;
        padding: 12px 16px;
        font-size: 0.9rem;
    }
}

/* ═══════════════════════════════════════════
   Sensor History — No Data Indicator
   ═══════════════════════════════════════════ */
.sh-no-data-msg {
    text-align: center;
    padding: 32px 16px;
    color: var(--text3);
    font-size: 0.92rem;
    font-weight: 600;
    border: 1px dashed var(--border);
    border-radius: var(--r);
    background: rgba(0, 0, 0, 0.1);
    margin: 12px 0;
}

.sh-no-data-msg .sh-no-data-icon {
    font-size: 2rem;
    display: block;
    margin-bottom: 8px;
}

/* ═══════════════════════════════════════════
   Collapsible Condition Bar — mobile only
   ═══════════════════════════════════════════ */
.cond-toggle-btn {
    display: none;
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--text2);
    font-size: 0.7rem;
    border-radius: 6px;
    padding: 2px 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-inline-start: auto;
}

.cond-toggle-btn:active {
    transform: scale(0.92);
}

body.light .cond-toggle-btn {
    border-color: rgba(0, 0, 0, 0.12);
}

@media (max-width: 768px) {
    .cond-toggle-btn {
        display: inline-flex;
        align-items: center;
    }

    .condition-right {
        max-height: 0;
        overflow: hidden;
        opacity: 0;
        transition: max-height 0.35s ease, opacity 0.25s ease, margin 0.3s ease;
        margin-top: 0;
    }

    .condition-right.cond-expanded {
        max-height: 200px;
        opacity: 1;
        margin-top: 8px;
    }

    .cond-toggle-btn.cond-expanded {
        transform: rotate(180deg);
    }
}

/* ══════════════════════════════════════════
   Footer Copyright Style
   ══════════════════════════════════════════ */
.footer-copy {
    color: #8b5cf6;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    font-size: .76rem;
    letter-spacing: .1px;
}

/* ══════════════════════════════════════════
   MOBILE HEADER — النسخة النهائية
   الحاسب: كما هو تماماً
   الموبايل:
     سطر 1 → اسم المحطة فقط (بدون اسم المصمم)
     سطر 2 → فاتح | EN | ● متصل/غير متصل | الساعة
   ══════════════════════════════════════════ */
@media (max-width: 768px) {

    /* إخفاء اسم المصمم على الموبايل — نهائي */
    .brand-sub {
        display: none !important;
    }

    /* الهيدر العلوي: عمودين منفصلين */
    .header-top {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 5px;
        padding: 8px 12px;
    }

    /* السطر الأول: الشعار + اسم المحطة */
    .brand {
        display: flex;
        align-items: center;
        gap: 7px;
        width: 100%;
    }

    .brand-text h1 {
        font-size: 1.02rem;
        font-weight: 800;
        background: none !important;
        -webkit-text-fill-color: #f0f4ff !important;
        color: #f0f4ff !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        line-height: 1.2;
    }

    /* السطر الثاني: الأزرار + حالة الاتصال + الساعة */
    .header-actions {
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: flex-start;
        gap: 6px;
        flex-wrap: nowrap;
        width: 100%;
    }

    /* ترتيب العناصر في الصف الثاني:
       1. فاتح/داكن
       2. EN/AR
       3. ● متصل (pill)
       4. الساعة (تتمدد لملء المساحة) */
    .header-actions .theme-btn {
        order: 1;
    }

    .header-actions .lang-btn {
        order: 2;
    }

    #conn-status {
        order: 3;
    }

    .clock-box {
        order: 4;
        flex: 1;
        text-align: end;
    }

    /* حجم الأزرار على الموبايل */
    .header-actions .icon-btn {
        padding: 5px 10px;
        font-size: .70rem;
        white-space: nowrap;
        flex-shrink: 0;
    }

    /* شارة حالة الاتصال */
    #conn-status {
        padding: 4px 8px;
        font-size: .65rem;
        flex-shrink: 0;
        max-width: 140px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    #conn-status .blink-dot {
        width: 5px;
        height: 5px;
        flex-shrink: 0;
    }

    /* الساعة */
    .clock-time {
        font-size: .85rem;
        line-height: 1;
    }

    .clock-date {
        font-size: .54rem;
        opacity: .65;
        margin-top: 1px;
    }
}

/* Password Toggle Styles */
.pwd-wrapper {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
}

.pwd-wrapper input {
    flex: 1;
    padding-inline-end: 48px !important;
}

/* Premium Glassmorphic Password Toggle */
.pwd-toggle {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 8px;
    outline: none;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    width: 34px;
    height: 34px;
}

html[dir="rtl"] .pwd-toggle {
    left: 6px;
    right: auto;
}

html[dir="ltr"] .pwd-toggle {
    right: 6px;
    left: auto;
}

.pwd-toggle:hover {
    color: var(--primary);
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2), inset 0 0 0 1px rgba(255, 255, 255, 0.1);
    transform: translateY(-50%) scale(1.05);
}

.pwd-toggle:active {
    transform: translateY(-50%) scale(0.95);
}

.pwd-toggle svg {
    width: 18px;
    height: 18px;
    opacity: 0.8;
    transition: all 0.3s ease;
}

.pwd-toggle:hover svg {
    opacity: 1;
    transform: scale(1.1);
}

input[type="password"]::-ms-reveal,
input[type="password"]::-ms-clear {
    display: none;
}

input[type="password"]::-webkit-reveal {
    display: none;
}


/* == DOCUMENTATION MODULE == */
.docs-section {
    padding: 10px 0
}

.docs-cat-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 24px
}

.docs-cat-btn {
    position: relative;
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 28px 20px;
    text-align: center;
    cursor: pointer;
    transition: var(--t);
    overflow: hidden;
    backdrop-filter: blur(10px);
    color: var(--text);
    font-family: var(--font-ar)
}

.docs-cat-btn:hover {
    transform: translateY(-3px);
    border-color: var(--border2);
    box-shadow: 0 8px 32px rgba(0, 0, 0, .3)
}

.docs-cat-btn.active {
    border-color: rgba(59, 130, 246, .5);
    background: rgba(59, 130, 246, .08)
}

.docs-cat-btn .docs-cat-icon {
    font-size: 2.4rem;
    margin-bottom: 10px;
    display: block
}

.docs-cat-btn .docs-cat-label {
    font-size: 1.1rem;
    font-weight: 700
}

.docs-cat-btn .docs-cat-sub {
    font-size: .78rem;
    color: var(--text2);
    margin-top: 4px
}

.docs-subnav {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap
}

.docs-subnav-btn {
    padding: 8px 18px;
    border-radius: 50px;
    background: var(--glass);
    border: 1px solid var(--border);
    color: var(--text2);
    font-family: var(--font-ar);
    font-size: .85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--t)
}

.docs-subnav-btn:hover {
    background: var(--glass2);
    color: var(--text)
}

.docs-subnav-btn.active {
    background: rgba(59, 130, 246, .15);
    border-color: rgba(59, 130, 246, .4);
    color: #93c5fd
}

.docs-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 50px;
    background: var(--glass);
    border: 1px solid var(--border);
    color: var(--text2);
    font-family: var(--font-ar);
    font-size: .85rem;
    cursor: pointer;
    transition: var(--t);
    margin-bottom: 16px
}

.docs-back-btn:hover {
    background: var(--glass2);
    color: var(--text)
}

.docs-panel {
    display: none;
    animation: fadeSlideIn .35s ease
}

.docs-panel.active {
    display: block
}

@keyframes fadeSlideIn {
    from {
        opacity: 0;
        transform: translateY(12px)
    }

    to {
        opacity: 1;
        transform: translateY(0)
    }
}

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

.docs-sensor-card {
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 20px;
    cursor: pointer;
    transition: var(--t);
    backdrop-filter: blur(10px);
    overflow: hidden;
    position: relative
}

.docs-sensor-card:hover {
    transform: translateY(-3px);
    border-color: var(--border2);
    box-shadow: 0 8px 30px rgba(0, 0, 0, .3)
}

.docs-sensor-card .ds-icon {
    font-size: 2rem;
    margin-bottom: 8px
}

.docs-sensor-card .ds-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text)
}

.docs-sensor-card .ds-model {
    font-size: .75rem;
    color: var(--text3);
    font-family: var(--font-en);
    margin-top: 2px
}

.docs-sensor-card .ds-brief {
    font-size: .82rem;
    color: var(--text2);
    margin-top: 8px;
    line-height: 1.5
}

.docs-detail {
    animation: fadeSlideIn .35s ease
}

.docs-detail-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap
}

.docs-detail-header .dd-icon {
    font-size: 3rem
}

.docs-detail-header .dd-title {
    font-size: 1.4rem;
    font-weight: 800
}

.docs-detail-header .dd-model {
    font-size: .85rem;
    color: var(--text3);
    font-family: var(--font-en)
}

.docs-img-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 20px
}

.docs-img-placeholder {
    aspect-ratio: 4/3;
    background: var(--glass);
    border: 2px dashed var(--border2);
    border-radius: var(--r2);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text3);
    font-size: .85rem;
    gap: 6px;
    transition: var(--t);
    overflow: hidden
}

.docs-img-placeholder img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--r2)
}

.docs-img-placeholder:hover {
    border-color: rgba(59, 130, 246, .4);
    background: rgba(59, 130, 246, .04)
}

.docs-info-section {
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 20px;
    margin-bottom: 16px
}

.docs-info-section h4 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--c-blue);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px
}

.docs-info-section p,
.docs-info-section li {
    font-size: .88rem;
    color: var(--text2);
    line-height: 1.8
}

.docs-info-section ul {
    list-style: none;
    padding: 0
}

.docs-info-section ul li::before {
    content: '|';
    color: var(--c-blue);
    font-weight: bold;
    margin-left: 8px
}

html[dir='ltr'] .docs-info-section ul li::before {
    margin-left: 0;
    margin-right: 8px
}

.docs-specs-table {
    width: 100%;
    border-collapse: collapse
}

.docs-specs-table tr {
    border-bottom: 1px solid var(--border)
}

.docs-specs-table tr:last-child {
    border-bottom: none
}

.docs-specs-table td {
    padding: 8px 4px;
    font-size: .85rem;
    color: var(--text2)
}

.docs-specs-table td:first-child {
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    width: 40%
}

.docs-wiring-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px
}

.docs-wiring-table th {
    background: rgba(59, 130, 246, .1);
    padding: 10px 12px;
    font-size: .82rem;
    font-weight: 700;
    color: #93c5fd;
    text-align: right;
    border-bottom: 2px solid rgba(59, 130, 246, .2)
}

html[dir='ltr'] .docs-wiring-table th {
    text-align: left
}

.docs-wiring-table td {
    padding: 10px 12px;
    font-size: .85rem;
    color: var(--text2);
    border-bottom: 1px solid var(--border)
}

.docs-wiring-table tr:hover td {
    background: rgba(255, 255, 255, .02)
}

.docs-pin-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 50px;
    font-family: var(--font-en);
    font-size: .8rem;
    font-weight: 700
}

.docs-pin-badge.analog {
    background: rgba(139, 92, 246, .15);
    color: #c4b5fd;
    border: 1px solid rgba(139, 92, 246, .3)
}

.docs-pin-badge.digital {
    background: rgba(16, 185, 129, .15);
    color: #6ee7b7;
    border: 1px solid rgba(16, 185, 129, .3)
}

.docs-pin-badge.i2c {
    background: rgba(6, 182, 212, .15);
    color: #67e8f9;
    border: 1px solid rgba(6, 182, 212, .3)
}

.docs-arduino-hero {
    background: linear-gradient(135deg, rgba(16, 185, 129, .08), rgba(59, 130, 246, .08));
    border: 1px solid rgba(16, 185, 129, .2);
    border-radius: var(--r);
    padding: 28px;
    margin-bottom: 20px;
    text-align: center
}

.docs-arduino-hero .dah-icon {
    font-size: 3rem;
    margin-bottom: 10px
}

.docs-arduino-hero .dah-title {
    font-size: 1.3rem;
    font-weight: 800;
    margin-bottom: 6px
}

.docs-arduino-hero .dah-sub {
    font-size: .9rem;
    color: var(--text2);
    line-height: 1.7
}

.docs-sw-card {
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 24px;
    margin-bottom: 16px
}

.docs-sw-card h4 {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px
}

.docs-sw-card p {
    font-size: .88rem;
    color: var(--text2);
    line-height: 1.8;
    margin-bottom: 10px
}

.docs-sw-card ul {
    list-style: none;
    padding: 0
}

.docs-sw-card ul li {
    font-size: .85rem;
    color: var(--text2);
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px
}

.docs-sw-card ul li:last-child {
    border-bottom: none
}

@media(max-width:600px) {
    .docs-cat-grid {
        grid-template-columns: 1fr
    }

    .docs-sensor-grid {
        grid-template-columns: 1fr
    }

    .docs-img-grid {
        grid-template-columns: 1fr
    }

    .docs-detail-header .dd-title {
        font-size: 1.1rem
    }
}

/* == DOCS MODULE v1- Premium Redesign == */
.docs-sensor-card {
    position: relative;
    overflow: hidden
}

.docs-sensor-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(59, 130, 246, .08) 0%, transparent 70%);
    transition: all .5s ease;
    pointer-events: none
}

.docs-sensor-card:hover::before {
    top: -30%;
    right: -30%;
    opacity: 1
}

.docs-sensor-card .ds-icon {
    font-size: 2.6rem;
    margin-bottom: 10px;
    filter: drop-shadow(0 0 12px rgba(59, 130, 246, .3));
    transition: transform .3s ease
}

.docs-sensor-card:hover .ds-icon {
    transform: scale(1.15) rotate(-5deg)
}

.docs-cat-btn {
    position: relative;
    overflow: hidden
}

.docs-cat-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(59, 130, 246, .06), rgba(139, 92, 246, .06));
    opacity: 0;
    transition: opacity .4s
}

.docs-cat-btn:hover::before {
    opacity: 1
}

.docs-cat-btn .docs-cat-icon {
    filter: drop-shadow(0 0 15px rgba(59, 130, 246, .3));
    transition: transform .4s ease
}

.docs-cat-btn:hover .docs-cat-icon {
    transform: scale(1.2) translateY(-4px)
}

.docs-detail-header {
    background: linear-gradient(135deg, rgba(59, 130, 246, .06), rgba(139, 92, 246, .04));
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 24px;
    margin-bottom: 20px
}

.docs-detail-header .dd-icon {
    font-size: 3.5rem;
    filter: drop-shadow(0 0 16px rgba(59, 130, 246, .4));
    animation: floaty 3s ease-in-out infinite
}

.docs-info-section {
    position: relative;
    overflow: hidden;
    transition: var(--t)
}

.docs-info-section:hover {
    border-color: var(--border2);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, .2)
}

.docs-info-section h4 {
    font-size: 1.05rem;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 14px
}

.docs-img-placeholder {
    min-height: 180px;
    font-size: .9rem;
    background: linear-gradient(135deg, rgba(59, 130, 246, .03), rgba(139, 92, 246, .03));
    border-color: rgba(59, 130, 246, .2);
    transition: all .3s ease
}

.docs-img-placeholder:hover {
    border-color: rgba(59, 130, 246, .5);
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(59, 130, 246, .1)
}

.docs-img-placeholder.has-img {
    border-style: solid;
    border-color: var(--border)
}

.docs-usage-section {
    background: linear-gradient(135deg, rgba(16, 185, 129, .06), rgba(6, 182, 212, .06));
    border: 1px solid rgba(16, 185, 129, .2);
    border-radius: var(--r);
    padding: 20px;
    margin-bottom: 16px
}

.docs-usage-section h4 {
    color: var(--c-green);
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(16, 185, 129, .15)
}

.docs-usage-section p {
    font-size: .88rem;
    color: var(--text2);
    line-height: 1.9
}

.docs-arduino-hero {
    position: relative;
    overflow: hidden;
    padding: 36px 28px
}

.docs-arduino-hero::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 30% 50%, rgba(16, 185, 129, .08), transparent 50%);
    animation: orbPulse 6s ease-in-out infinite;
    pointer-events: none
}

.docs-subnav-btn {
    position: relative;
    overflow: hidden
}

.docs-subnav-btn::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: var(--c-blue);
    transition: all .3s ease;
    transform: translateX(-50%)
}

.docs-subnav-btn.active::after {
    width: 60%
}

.docs-sw-card {
    position: relative;
    overflow: hidden;
    transition: var(--t)
}

.docs-sw-card:hover {
    border-color: var(--border2);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, .2)
}

.docs-sw-card h4 {
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border)
}

/* == Usage Section Premium == */
.docs-usage-section {
    position: relative;
    overflow: hidden
}

.docs-usage-section::before {
    content: '';
    position: absolute;
    top: -60%;
    right: -40%;
    width: 120%;
    height: 120%;
    background: radial-gradient(circle, rgba(16, 185, 129, .06), transparent 60%);
    pointer-events: none;
    animation: orbPulse 8s ease-in-out infinite
}

.docs-usage-section h4::before {
    content: '';
    display: inline-block;
    width: 4px;
    height: 20px;
    background: linear-gradient(180deg, var(--c-green), var(--c-hum));
    border-radius: 4px;
    margin-left: 8px
}

html[dir='ltr'] .docs-usage-section h4::before {
    margin-left: 0;
    margin-right: 8px
}

.docs-usage-section p {
    position: relative;
    padding: 16px 20px;
    background: rgba(16, 185, 129, .04);
    border-radius: var(--r2);
    border-right: 3px solid rgba(16, 185, 129, .3);
    font-size: .9rem;
    line-height: 2
}

html[dir='ltr'] .docs-usage-section p {
    border-right: none;
    border-left: 3px solid rgba(16, 185, 129, .3)
}

/* == Usage Flow Steps == */
.docs-usage-flow {
    display: flex;
    flex-direction: column;
    gap: 12px
}

.usage-step {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 14px 16px;
    background: rgba(16, 185, 129, .04);
    border-radius: var(--r2);
    border: 1px solid rgba(16, 185, 129, .08);
    transition: all .3s ease;
    position: relative;
    overflow: hidden
}

.usage-step::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(16, 185, 129, .04), transparent);
    opacity: 0;
    transition: opacity .3s
}

.usage-step:hover::before {
    opacity: 1
}

.usage-step:hover {
    border-color: rgba(16, 185, 129, .2);
    transform: translateX(4px)
}

html[dir='rtl'] .usage-step:hover {
    transform: translateX(-4px)
}

.usage-num {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(16, 185, 129, .15), rgba(6, 182, 212, .15));
    color: var(--c-green);
    font-weight: 800;
    font-size: .95rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid rgba(16, 185, 129, .25);
    box-shadow: 0 0 12px rgba(16, 185, 129, .1)
}

.usage-step div {
    font-size: .85rem;
    color: var(--text2);
    line-height: 1.7
}

.usage-step strong {
    color: var(--text);
    font-size: .9rem;
    display: block;
    margin-bottom: 2px
}

/* == Image Grid Spacing == */
.docs-img-grid {
    gap: 16px !important;
    margin: 16px 0 20px
}

.docs-img-placeholder img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--r2)
}

/* == AI Chat Enhanced Formatting == */
.ai-msg-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, .06);
    font-size: .7rem;
    color: var(--text3);
    opacity: .7
}

.ai-model-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    background: linear-gradient(135deg, rgba(139, 92, 246, .12), rgba(59, 130, 246, .12));
    border: 1px solid rgba(139, 92, 246, .2);
    border-radius: 10px;
    font-size: .65rem;
    color: rgba(139, 92, 246, .9);
    font-weight: 600;
    letter-spacing: .3px
}

.ai-h3 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
    margin: 12px 0 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border)
}

.ai-h4 {
    font-size: .95rem;
    font-weight: 600;
    color: var(--c-blue);
    margin: 10px 0 4px
}

.ai-hr {
    border: none;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border), transparent);
    margin: 12px 0
}

.ai-list {
    margin: 6px 0;
    padding-right: 20px;
    list-style: none
}

html[dir='ltr'] .ai-list {
    padding-right: 0;
    padding-left: 20px
}

.ai-list li {
    position: relative;
    padding: 3px 0;
    line-height: 1.6
}

.ai-list li::before {
    content: '?';
    position: absolute;
    right: -16px;
    color: var(--c-blue);
    font-weight: bold
}

html[dir='ltr'] .ai-list li::before {
    right: auto;
    left: -16px
}

.ai-table-wrap {
    overflow-x: auto;
    margin: 8px 0;
    border-radius: var(--r2);
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
    position: relative
}

.ai-table-wrap::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 20px;
    background: linear-gradient(to left, var(--bg2), transparent);
    pointer-events: none;
    opacity: 0;
    transition: opacity .3s
}

.ai-table-wrap.has-scroll::after {
    opacity: 1
}

.ai-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .8rem;
    min-width: 280px
}

.ai-table th {
    background: rgba(59, 130, 246, .1);
    padding: 8px 10px;
    text-align: right;
    font-weight: 600;
    border-bottom: 2px solid var(--border);
    white-space: nowrap
}

html[dir='ltr'] .ai-table th {
    text-align: left
}

.ai-table td {
    padding: 6px 10px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap
}

.ai-table tr:hover td {
    background: rgba(59, 130, 246, .04)
}

@media(max-width:600px) {
    .ai-table {
        font-size: .7rem
    }

    .ai-table th,
    .ai-table td {
        padding: 5px 6px
    }
}

.ai-code-block {
    background: rgba(0, 0, 0, .3);
    border: 1px solid var(--border);
    border-radius: var(--r2);
    padding: 12px;
    margin: 8px 0;
    overflow-x: auto;
    font-family: 'Fira Code', monospace;
    font-size: .78rem;
    line-height: 1.6;
    direction: ltr;
    text-align: left
}

.ai-inline-code {
    background: rgba(139, 92, 246, .1);
    border: 1px solid rgba(139, 92, 246, .15);
    padding: 1px 6px;
    border-radius: 4px;
    font-family: 'Fira Code', monospace;
    font-size: .82em;
    direction: ltr
}

/* == Docs System Overview Styles == */
.docs-sys-section {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--r2);
    padding: 20px;
    margin-bottom: 16px
}

.docs-sys-hero {
    text-align: center;
    padding: 24px 16px
}

.docs-sys-hero-icon {
    font-size: 3rem;
    margin-bottom: 8px;
    filter: drop-shadow(0 4px 12px rgba(59, 130, 246, .3))
}

.docs-sys-hero h3 {
    font-size: 1.3rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--c-blue), var(--c-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0 0 10px
}

.docs-sys-hero-sub {
    color: var(--text2);
    font-size: .88rem;
    line-height: 1.7;
    max-width: 600px;
    margin: 0 auto
}

.docs-sys-section h4 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 14px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border)
}

/* Flow diagram */
.docs-sys-flow {
    display: flex;
    flex-direction: column;
    gap: 14px
}

.docs-flow-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center
}

.docs-flow-box {
    flex: 1;
    min-width: 120px;
    max-width: 180px;
    padding: 14px 10px;
    border-radius: var(--r2);
    text-align: center;
    border: 1px solid var(--border);
    transition: transform .2s, box-shadow .2s
}

.docs-flow-box:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, .2)
}

.docs-flow-box.hw {
    background: linear-gradient(135deg, rgba(16, 185, 129, .08), rgba(16, 185, 129, .02));
    border-color: rgba(16, 185, 129, .25)
}

.docs-flow-box.cloud {
    background: linear-gradient(135deg, rgba(59, 130, 246, .08), rgba(59, 130, 246, .02));
    border-color: rgba(59, 130, 246, .25)
}

.docs-flow-box.web {
    background: linear-gradient(135deg, rgba(139, 92, 246, .08), rgba(139, 92, 246, .02));
    border-color: rgba(139, 92, 246, .25)
}

.docs-flow-box.ai {
    background: linear-gradient(135deg, rgba(245, 158, 11, .08), rgba(245, 158, 11, .02));
    border-color: rgba(245, 158, 11, .25)
}

.docs-flow-box.proxy {
    background: linear-gradient(135deg, rgba(239, 68, 68, .08), rgba(239, 68, 68, .02));
    border-color: rgba(239, 68, 68, .25)
}

.docs-flow-box.forecast {
    background: linear-gradient(135deg, rgba(6, 182, 212, .08), rgba(6, 182, 212, .02));
    border-color: rgba(6, 182, 212, .25)
}

.docs-flow-icon {
    font-size: 1.6rem;
    margin-bottom: 4px
}

.docs-flow-title {
    font-weight: 700;
    font-size: .82rem;
    margin-bottom: 2px
}

.docs-flow-desc {
    font-size: .7rem;
    color: var(--text3);
    line-height: 1.3
}

.docs-flow-arrow {
    font-size: 1.4rem;
    color: var(--c-blue);
    font-weight: bold;
    min-width: 24px;
    text-align: center;
    opacity: .6
}

@media(max-width:600px) {
    .docs-flow-row {
        flex-direction: column
    }

    .docs-flow-arrow {
        transform: rotate(90deg)
    }

    .docs-flow-box {
        max-width: 100%;
        min-width: 0
    }
}

/* Timeline */
.docs-timeline {
    position: relative;
    padding: 4px 0
}

.docs-timeline-item {
    display: flex;
    gap: 16px;
    position: relative
}

.docs-timeline-rail {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
    width: 44px
}

.docs-timeline-num {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    font-weight: 800;
    color: #fff;
    background: linear-gradient(135deg, var(--c-blue), var(--c-purple));
    box-shadow: 0 4px 14px rgba(99, 102, 241, .35);
    position: relative;
    z-index: 2
}

.docs-timeline-line {
    width: 2px;
    flex: 1;
    background: linear-gradient(180deg, var(--c-blue), var(--c-purple));
    opacity: .3;
    min-height: 16px
}

.docs-timeline-card {
    flex: 1;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--r2);
    padding: 14px 16px;
    margin-bottom: 12px;
    transition: transform .2s, border-color .2s, box-shadow .2s
}

.docs-timeline-card:hover {
    transform: translateX(-4px);
    border-color: rgba(99, 102, 241, .4);
    box-shadow: 0 4px 18px rgba(99, 102, 241, .1)
}

html[dir='ltr'] .docs-timeline-card:hover {
    transform: translateX(4px)
}

.docs-timeline-card-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px
}

.docs-timeline-icon {
    font-size: 1.25rem
}

.docs-timeline-card-head strong {
    font-size: .92rem;
    color: var(--text)
}

.docs-timeline-card p {
    margin: 0;
    font-size: .82rem;
    line-height: 1.7;
    color: var(--text2)
}

.docs-timeline-item.last .docs-timeline-card {
    margin-bottom: 0
}

/* Tech grid */
.docs-tech-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px
}

.docs-tech-card {
    padding: 14px;
    border-radius: var(--r2);
    border: 1px solid var(--border);
    background: var(--bg2);
    text-align: center;
    transition: transform .2s, border-color .2s
}

.docs-tech-card:hover {
    transform: translateY(-2px);
    border-color: var(--c-blue)
}

.docs-tech-icon {
    font-size: 1.6rem;
    margin-bottom: 4px
}

.docs-tech-name {
    font-weight: 700;
    font-size: .82rem;
    margin-bottom: 2px
}

.docs-tech-role {
    font-size: .72rem;
    color: var(--text3);
    line-height: 1.3
}

/* Sections list */
.docs-sections-list {
    display: flex;
    flex-direction: column;
    gap: 0
}

.docs-section-item {
    display: flex;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    align-items: flex-start
}

.docs-section-item:last-child {
    border-bottom: none
}

.docs-sec-icon {
    font-size: 1.4rem;
    min-width: 32px;
    text-align: center;
    flex-shrink: 0
}

.docs-section-item div {
    font-size: .84rem;
    line-height: 1.6;
    color: var(--text2)
}

.docs-section-item strong {
    color: var(--text)
}

/* Security list */
.docs-security-list {
    list-style: none;
    padding: 0;
    margin: 0
}

.docs-security-list li {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: .84rem;
    line-height: 1.6;
    color: var(--text2)
}

.docs-security-list li:last-child {
    border-bottom: none
}