/* ======================================================
   智慧机井管理平台 - 移动端样式
   ====================================================== */

/* --- CSS Variables --- */
:root {
    --primary: #10b981;
    --primary-light: #34d399;
    --primary-dark: #059669;
    --primary-bg: rgba(16, 185, 129, 0.08);
    --secondary: #0ea5e9;
    --secondary-light: #38bdf8;
    --accent: #6366f1;
    --danger: #ef4444;
    --warning: #f59e0b;
    --success: #10b981;
    --bg: #f0f4f8;
    --bg-card: #ffffff;
    --text: #1e293b;
    --text-secondary: #64748b;
    --text-light: #94a3b8;
    --border: #e2e8f0;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 10px 30px rgba(0,0,0,0.12);
    --radius: 16px;
    --radius-sm: 10px;
    --radius-xs: 6px;
    --nav-height: 65px;
    --header-height: 140px;
}

/* --- Reset --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html { font-size: 16px; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* --- App Container --- */
.app-container {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    position: relative;
    background: var(--bg);
}

/* ===========================
   HEADER
   =========================== */
.header {
    background: linear-gradient(135deg, #059669 0%, #10b981 40%, #34d399 100%);
    color: #fff;
    padding: 10px 20px 15px;
    border-radius: 0 0 24px 24px;
    position: relative;
    z-index: 10;
    box-shadow: 0 4px 20px rgba(16, 185, 129, 0.35);
}

.header::before {
    content: '';
    position: absolute;
    top: -40px;
    right: -40px;
    width: 180px;
    height: 180px;
    background: rgba(255,255,255,0.07);
    border-radius: 50%;
    pointer-events: none;
}

.header::after {
    content: '';
    position: absolute;
    bottom: -20px;
    left: -30px;
    width: 120px;
    height: 120px;
    background: rgba(255,255,255,0.05);
    border-radius: 50%;
    pointer-events: none;
}

/* Brand Bar */
.header-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    position: relative;
    z-index: 1;
}

.brand-icon {
    font-size: 1rem;
    opacity: 0.9;
}

.brand-title {
    font-size: 0.85rem;
    font-weight: 500;
    opacity: 0.9;
    flex: 1;
    letter-spacing: 0.5px;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    z-index: 1;
    margin-bottom: 4px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255,255,255,0.22);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    border: 2px solid rgba(255,255,255,0.35);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.header-user .greeting {
    font-size: 0.82rem;
    opacity: 0.85;
    margin-bottom: 2px;
}

.header-user .user-name {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
    z-index: 1;
}

.role-badge {
    display: flex;
    align-items: center;
    gap: 5px;
    background: rgba(255,255,255,0.2);
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.78rem;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid rgba(255,255,255,0.2);
}
.role-badge:active { background: rgba(255,255,255,0.3); }

.role-badge.farmer-role {
    background: rgba(245, 158, 11, 0.3);
    border-color: rgba(245, 158, 11, 0.4);
}

.header-bell {
    position: relative;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.15);
    border-radius: 50%;
    cursor: pointer;
    color: inherit;
    text-decoration: none;
}
.header-bell:active { background: rgba(255,255,255,0.25); }

.badge-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    background: var(--danger);
    border-radius: 50%;
    border: 2px solid var(--primary);
}

.balance-strip {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 16px;
    padding: 12px 16px;
    background: rgba(255,255,255,0.15);
    border-radius: 14px;
    position: relative;
    z-index: 1;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.balance-info {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.balance-label {
    font-size: 0.8rem;
    opacity: 0.85;
}

.balance-amount {
    font-size: 0.95rem;
}
.balance-amount b {
    font-size: 1.4rem;
    font-weight: 700;
}

.btn-recharge {
    background: rgba(255,255,255,0.95);
    color: var(--primary-dark);
    border: none;
    padding: 7px 16px;
    border-radius: 20px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s;
    text-decoration: none;
}
.btn-recharge:active { transform: scale(0.95); }

/* ===========================
   ROLE PANEL
   =========================== */
.role-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    display: none;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s;
}
.role-panel.show { display: flex; }

.role-panel-inner {
    background: #fff;
    border-radius: var(--radius);
    padding: 24px;
    width: 90%;
    max-width: 360px;
    text-align: center;
}
.role-panel-inner h4 {
    margin-bottom: 20px;
    color: var(--text);
}

.role-options {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

.role-option {
    flex: 1;
    padding: 16px 10px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}
.role-option.active {
    border-color: var(--primary);
    background: var(--primary-bg);
}

.role-icon {
    width: 50px;
    height: 50px;
    margin: 0 auto 10px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff;
    font-size: 1.3rem;
}
.role-icon.farmer-icon {
    background: linear-gradient(135deg, var(--warning), #fbbf24);
}

.role-name {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 4px;
}
.role-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.btn-close-panel {
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 10px 40px;
    border-radius: 25px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-close-panel:active { transform: scale(0.95); }

/* ===========================
   PAGES
   =========================== */
.page {
    display: none;
    padding: 16px;
    padding-bottom: calc(var(--nav-height) + 20px);
    animation: pageIn 0.3s ease;
}
.page.active { display: block; }

@keyframes pageIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.page-bottom-space { height: 20px; }

/* ===========================
   WEATHER CARD
   =========================== */
.weather-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px;
    margin-top: -10px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
    overflow: hidden;
    position: relative;
}

.weather-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.weather-location {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}
.weather-location i { color: var(--danger); margin-right: 3px; }

.weather-temp {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.1;
}

.weather-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.weather-icon-big {
    font-size: 3rem;
    color: var(--warning);
    opacity: 0.85;
}

.weather-details {
    display: flex;
    gap: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 10px;
}

.weather-detail-item {
    font-size: 0.78rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
}
.weather-detail-item i {
    color: var(--secondary);
    font-size: 0.7rem;
}

.irrigation-tip {
    font-size: 0.82rem;
    color: var(--success);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ===========================
   SCAN HERO
   =========================== */
.scan-hero {
    text-align: center;
    padding: 30px 0;
    position: relative;
}

.scan-hero-bg {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 220px;
    height: 220px;
    background: radial-gradient(circle, rgba(14, 165, 233, 0.06) 0%, transparent 70%);
    border-radius: 50%;
}

.scan-btn-wrapper {
    position: relative;
    display: inline-block;
    margin-bottom: 16px;
}

.scan-ring {
    position: absolute;
    border-radius: 50%;
    border: 1.5px solid rgba(14, 165, 233, 0.15);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation: pulseRing 3s ease-in-out infinite;
}
.scan-ring-1 { width: 140px; height: 140px; animation-delay: 0s; }
.scan-ring-2 { width: 170px; height: 170px; animation-delay: 0.5s; }
.scan-ring-3 { width: 200px; height: 200px; animation-delay: 1s; }

@keyframes pulseRing {
    0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.4; }
    50% { transform: translate(-50%, -50%) scale(1.05); opacity: 0.8; }
}

.scan-btn {
    width: 110px;
    height: 110px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0ea5e9, #6366f1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 2.8rem;
    cursor: pointer;
    box-shadow: 0 8px 30px rgba(14, 165, 233, 0.4);
    transition: all 0.2s;
    position: relative;
    z-index: 2;
}
.scan-btn:active {
    transform: scale(0.92);
    box-shadow: 0 4px 15px rgba(14, 165, 233, 0.4);
}

.scan-text {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
}

.scan-subtext {
    font-size: 0.8rem;
    color: var(--text-light);
}

/* ===========================
   SECTION TITLE
   =========================== */
.section-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    margin-top: 8px;
}
.section-title > span {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
}
.section-title a {
    font-size: 0.8rem;
    color: var(--text-light);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 3px;
}

/* ===========================
   QUICK GRID
   =========================== */
.quick-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 20px;
    background: var(--bg-card);
    padding: 16px 12px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.quick-item {
    text-align: center;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    display: block;
}

.quick-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 8px;
    color: #fff;
    font-size: 1.2rem;
    transition: transform 0.2s;
}
.quick-item:active .quick-icon { transform: scale(0.9); }

.quick-item span {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Farmer only items hidden by default */
.farmer-only { display: none !important; }
.normal-only { display: block; }

body.role-farmer .farmer-only { display: block !important; }
body.role-farmer .quick-grid .farmer-only { display: block !important; }
body.role-farmer .normal-only { display: none !important; }

/* ===========================
   FARMER OVERVIEW
   =========================== */
.overview-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 14px;
}

.ov-card {
    background: var(--bg-card);
    padding: 14px 8px;
    border-radius: var(--radius-sm);
    text-align: center;
    box-shadow: var(--shadow-sm);
    border-left: 3px solid var(--border);
}
.ov-card.ov-total { border-left-color: var(--accent); }
.ov-card.ov-online { border-left-color: var(--success); }
.ov-card.ov-running { border-left-color: var(--secondary); }
.ov-card.ov-alert { border-left-color: var(--danger); }

.ov-num {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
}
.ov-card.ov-alert .ov-num { color: var(--danger); }

.ov-label {
    font-size: 0.72rem;
    color: var(--text-light);
    margin-top: 2px;
}

/* Power Bar */
.power-bar {
    background: var(--bg-card);
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    margin-bottom: 16px;
}

.power-bar-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.82rem;
    color: var(--text-secondary);
}
.power-value b { color: var(--secondary); font-size: 0.95rem; }

.power-bar-track {
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
}
.power-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success), var(--secondary));
    border-radius: 4px;
    transition: width 0.5s ease;
}

/* ===========================
   NEARBY WELLS
   =========================== */
.nearby-wells {
    margin-bottom: 16px;
}

.well-card {
    display: flex;
    align-items: center;
    background: var(--bg-card);
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: all 0.2s;
}
.well-card:active { transform: scale(0.98); }

.well-status {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 14px;
    flex-shrink: 0;
}
.well-status.online { background: var(--success); box-shadow: 0 0 6px rgba(16,185,129,0.5); }
.well-status.busy { background: var(--warning); box-shadow: 0 0 6px rgba(245,158,11,0.5); }
.well-status.offline { background: var(--text-light); }

.well-info { flex: 1; }

.well-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
}
.well-id {
    font-size: 0.72rem;
    color: var(--text-light);
    background: var(--bg);
    padding: 1px 6px;
    border-radius: 4px;
    margin-left: 6px;
}

.well-meta {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-top: 2px;
}
.well-meta i { margin-right: 2px; font-size: 0.7rem; }

.well-action {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--secondary), var(--accent));
    color: #fff;
    border-radius: 10px;
    font-size: 0.9rem;
}
.well-action.disabled {
    background: #e2e8f0;
    color: var(--text-light);
}

/* ===========================
   RUNNING DEVICES (Farmer)
   =========================== */
.device-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-card);
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    box-shadow: var(--shadow-sm);
}

.device-row-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.device-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.device-dot.running {
    background: var(--success);
    box-shadow: 0 0 6px rgba(16,185,129,0.5);
    animation: blink 1.5s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.device-row-name {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text);
}
.device-row-meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.btn-sm-stop {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.78rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s;
    font-weight: 500;
    white-space: nowrap;
}
.btn-sm-stop:active { background: rgba(239, 68, 68, 0.2); }

/* ===========================
   RECENT RECORDS
   =========================== */
.recent-records {
    margin-bottom: 16px;
}

.record-item {
    display: flex;
    align-items: center;
    background: var(--bg-card);
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    box-shadow: var(--shadow-sm);
}

.record-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: rgba(14, 165, 233, 0.1);
    color: var(--secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    margin-right: 12px;
    flex-shrink: 0;
}
.record-icon.recharge {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.record-info { flex: 1; }
.record-title {
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text);
}
.record-time {
    font-size: 0.75rem;
    color: var(--text-light);
    margin-top: 2px;
}
.record-cost {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
}
.record-cost.income { color: var(--success); }

/* ===========================
   NOTICE CARD
   =========================== */
.notice-card {
    background: linear-gradient(135deg, #fffbeb, #fef3c7);
    border: 1px solid #fde68a;
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    margin-top: 8px;
}
.notice-tag {
    font-size: 0.78rem;
    color: var(--warning);
    font-weight: 600;
    margin-bottom: 6px;
}
.notice-content {
    font-size: 0.82rem;
    color: #92400e;
    line-height: 1.6;
}

/* ===========================
   SUB HEADER (Inner Pages)
   =========================== */
.sub-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0 16px;
    position: sticky;
    top: 0;
    background: var(--bg);
    z-index: 50;
}
.sub-header a {
    color: var(--text);
    text-decoration: none;
    font-size: 1.1rem;
    padding: 4px 8px;
}
.sub-header h3 {
    font-size: 1.05rem;
    font-weight: 700;
}
.sub-header span {
    width: 32px;
    text-align: center;
    cursor: pointer;
    color: var(--text-secondary);
}

/* ===========================
   MAP CONTAINER (Nearby Page)
   =========================== */
.map-container {
    margin: 0 -16px;
    height: 280px;
    background: #e8f4f8;
    position: relative;
    overflow: hidden;
}

.map-placeholder {
    width: 100%;
    height: 100%;
    position: relative;
}

.map-bg {
    width: 100%;
    height: 100%;
    background:
        linear-gradient(90deg, rgba(148,163,184,0.08) 1px, transparent 1px),
        linear-gradient(rgba(148,163,184,0.08) 1px, transparent 1px);
    background-size: 30px 30px;
    position: relative;
}

.map-grid {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 30% 40%, rgba(16,185,129,0.05), transparent 50%),
        radial-gradient(circle at 70% 60%, rgba(14,165,233,0.05), transparent 50%);
}

.map-road {
    position: absolute;
    background: rgba(148,163,184,0.2);
}
.road-h { left: 0; right: 0; height: 3px; }
.road-v { top: 0; bottom: 0; width: 3px; }

.map-pin {
    position: absolute;
    transform: translate(-50%, -50%);
    z-index: 5;
    cursor: pointer;
    text-align: center;
}

.user-pin {
    z-index: 10;
    color: var(--accent);
    font-size: 1.3rem;
}

.user-pulse {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    background: rgba(99, 102, 241, 0.15);
    border-radius: 50%;
    animation: userPulse 2s infinite;
}

@keyframes userPulse {
    0% { transform: translate(-50%, -50%) scale(0.8); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1.8); opacity: 0; }
}

.well-pin {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    color: #fff;
    transition: transform 0.2s;
}
.well-pin.online { background: var(--success); box-shadow: 0 2px 8px rgba(16,185,129,0.4); }
.well-pin.busy { background: var(--warning); box-shadow: 0 2px 8px rgba(245,158,11,0.4); }
.well-pin.offline { background: var(--text-light); }
.well-pin:active { transform: translate(-50%, -50%) scale(1.2); }

.scan-device-pin {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    box-shadow: 0 2px 6px rgba(99,102,241,0.3);
}

.pin-label {
    display: block;
    font-size: 0.65rem;
    white-space: nowrap;
    color: var(--text);
    font-weight: 600;
    margin-top: 2px;
    text-shadow: 0 0 4px #fff, 0 0 4px #fff;
}

.map-legend {
    display: flex;
    gap: 12px;
    padding: 10px 16px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    margin: 0 -16px;
    overflow-x: auto;
}
.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
}
.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Nearby Detail List */
.nearby-detail-list {
    margin-top: 12px;
}

.well-detail-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-card);
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: all 0.2s;
}
.well-detail-card:active { transform: scale(0.98); }

.wdc-left {
    display: flex;
    align-items: center;
    gap: 12px;
}
.wdc-status {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.wdc-status.online { background: var(--success); }
.wdc-status.busy { background: var(--warning); }
.wdc-status.offline { background: var(--text-light); }

.wdc-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
}
.wdc-id {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 2px;
}
.wdc-right { text-align: right; }
.wdc-distance {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 3px;
}
.wdc-tag {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 500;
}
.wdc-tag.free { background: rgba(16,185,129,0.1); color: var(--success); }
.wdc-tag.busy { background: rgba(245,158,11,0.1); color: var(--warning); }
.wdc-tag.offline { background: rgba(148,163,184,0.1); color: var(--text-light); }

/* ===========================
   DEVICE CONTROL PAGE
   =========================== */
.control-device-info {
    display: flex;
    align-items: center;
    background: var(--bg-card);
    padding: 16px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.cdi-icon {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--secondary), var(--accent));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    margin-right: 14px;
}

.cdi-text { flex: 1; }
.cdi-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
}
.cdi-id {
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.cdi-signal {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    color: var(--success);
}

/* Status Ring */
.control-status-ring {
    text-align: center;
    margin: 20px 0;
}

.status-ring-outer {
    width: 160px;
    height: 160px;
    border-radius: 50%;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    background: conic-gradient(
        var(--border) 0deg,
        var(--border) 360deg
    );
    padding: 6px;
    transition: all 0.5s;
}
.status-ring-outer.running {
    background: conic-gradient(
        var(--success) 0deg,
        var(--primary-light) 120deg,
        var(--secondary) 240deg,
        var(--success) 360deg
    );
    animation: ringRotate 3s linear infinite;
}

@keyframes ringRotate {
    from { filter: hue-rotate(0deg); }
    to { filter: hue-rotate(360deg); }
}

.status-ring-inner {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.status-icon {
    font-size: 2.2rem;
    color: var(--text-light);
    margin-bottom: 6px;
    transition: color 0.3s;
}
.status-ring-outer.running .status-icon { color: var(--success); }

.status-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
}
.status-ring-outer.running .status-label { color: var(--success); }

/* Realtime Data */
.realtime-data {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}
.data-box {
    flex: 1;
    background: var(--bg-card);
    padding: 14px 8px;
    border-radius: var(--radius-sm);
    text-align: center;
    box-shadow: var(--shadow-sm);
}
.data-icon {
    font-size: 0.85rem;
    color: var(--secondary);
    margin-bottom: 6px;
}
.data-val {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text);
}
.data-val span { color: var(--secondary); }
.data-label {
    font-size: 0.72rem;
    color: var(--text-light);
    margin-top: 4px;
}

/* Irrigation Timer */
.irrigation-timer {
    background: linear-gradient(135deg, rgba(16,185,129,0.08), rgba(14,165,233,0.08));
    border: 1px solid rgba(16,185,129,0.2);
    padding: 16px;
    border-radius: var(--radius-sm);
    text-align: center;
    margin-bottom: 20px;
}
.timer-label { font-size: 0.82rem; color: var(--success); font-weight: 500; }
.timer-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    margin: 4px 0;
}
.timer-cost { font-size: 0.85rem; color: var(--text-secondary); }

/* Control Buttons */
.controls {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

.btn-control {
    flex: 1;
    padding: 16px;
    border: none;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
}
.btn-control:active { transform: scale(0.96); }
.btn-control:disabled {
    background: #e2e8f0 !important;
    color: #b2bec3 !important;
    box-shadow: none !important;
    cursor: not-allowed;
    transform: none !important;
}

.btn-start {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
}
.btn-stop {
    background: linear-gradient(135deg, #ef4444, #f87171);
    color: #fff;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.4);
}

/* Timer Setting */
.timer-setting {
    background: var(--bg-card);
    padding: 16px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
}

.timer-setting-label {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.timer-setting-label i { color: var(--secondary); }

.timer-options {
    display: flex;
    gap: 8px;
}

.timer-opt {
    flex: 1;
    padding: 10px 4px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    background: var(--bg);
    color: var(--text-secondary);
    font-size: 0.82rem;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
}
.timer-opt:active, .timer-opt.active {
    border-color: var(--secondary);
    color: var(--secondary);
    background: rgba(14,165,233,0.06);
}

/* ===========================
   FARM PAGE
   =========================== */
.farm-batch-btn {
    font-size: 1rem !important;
    color: var(--secondary) !important;
}

.farm-stats-bar {
    display: flex;
    align-items: center;
    background: var(--bg-card);
    padding: 16px;
    border-radius: var(--radius);
    margin-bottom: 12px;
    box-shadow: var(--shadow);
}
.fs-item {
    flex: 1;
    text-align: center;
}
.fs-val {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text);
}
.fs-label {
    font-size: 0.72rem;
    color: var(--text-light);
    margin-top: 2px;
}
.fs-divider {
    width: 1px;
    height: 28px;
    background: var(--border);
}

.farm-summary {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}
.farm-sum-card {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-card);
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
}
.farm-sum-card i { font-size: 1.4rem; }
.fsc-val {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
}
.fsc-val small { font-size: 0.75rem; font-weight: 400; color: var(--text-light); }
.fsc-label { font-size: 0.75rem; color: var(--text-secondary); }

/* Filter Tabs */
.filter-tabs {
    display: flex;
    gap: 6px;
}
.ft {
    padding: 4px 12px;
    border-radius: 14px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    background: var(--bg);
    cursor: pointer;
    transition: all 0.2s;
}
.ft.active {
    background: var(--primary);
    color: #fff;
}

/* Farm Device List */
.farm-device-list {
    padding: 0 0 16px;
}

.farm-device-item {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    margin-bottom: 10px;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    border-left: 3px solid var(--border);
}
.farm-device-item.running { border-left-color: var(--success); }
.farm-device-item.online { border-left-color: var(--secondary); }
.farm-device-item.alert { border-left-color: var(--danger); }

.fdi-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px 10px;
}

.fdi-left {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.88rem;
    color: var(--text);
    flex-wrap: wrap;
}

.fdi-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}
.fdi-dot.running { background: var(--success); animation: blink 1.5s infinite; }
.fdi-dot.online { background: var(--secondary); }
.fdi-dot.alert { background: var(--danger); animation: blink 1s infinite; }

.alert-tag {
    font-size: 0.72rem;
    color: var(--danger);
    background: rgba(239,68,68,0.08);
    padding: 2px 8px;
    border-radius: 4px;
    margin-left: 4px;
}

/* Switch Toggle */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 24px;
}
.slider::before {
    content: '';
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    transition: 0.3s;
    border-radius: 50%;
}
input:checked + .slider { background-color: var(--success); }
input:checked + .slider::before { transform: translateX(20px); }
.slider.disabled { background: #e2e8f0; cursor: not-allowed; }

.fdi-body {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0;
    padding: 0 16px 14px;
}
.fdi-stat {
    text-align: center;
    padding: 6px 0;
}
.fdi-stat span {
    display: block;
    font-size: 0.7rem;
    color: var(--text-light);
    margin-bottom: 2px;
}
.fdi-stat b {
    font-size: 0.82rem;
    color: var(--text);
}

/* ===========================
   HISTORY PAGE
   =========================== */
.history-summary {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff;
    padding: 20px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    box-shadow: 0 4px 15px rgba(16,185,129,0.3);
}
.hs-month {
    font-size: 0.85rem;
    opacity: 0.9;
    margin-bottom: 14px;
}
.hs-stats {
    display: flex;
    justify-content: space-around;
}
.hs-stat { text-align: center; }
.hs-val { font-size: 1.3rem; font-weight: 700; }
.hs-label { font-size: 0.75rem; opacity: 0.85; margin-top: 2px; }

.history-list {
    list-style: none;
}

.history-date-group {
    font-size: 0.8rem;
    color: var(--text-light);
    font-weight: 600;
    margin: 14px 0 8px;
    padding-left: 4px;
}

.history-item {
    display: flex;
    align-items: center;
    background: var(--bg-card);
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    box-shadow: var(--shadow-sm);
}

.hi-left {
    display: flex;
    align-items: center;
    flex: 1;
    gap: 12px;
}

.hi-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: rgba(14,165,233,0.1);
    color: var(--secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    flex-shrink: 0;
}
.hi-icon.recharge {
    background: rgba(16,185,129,0.1);
    color: var(--success);
}

.hi-title {
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text);
}
.hi-meta {
    font-size: 0.73rem;
    color: var(--text-light);
    margin-top: 2px;
}

.hi-cost {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
}
.hi-cost.income { color: var(--success); }

/* ===========================
   PROFILE PAGE
   =========================== */
.profile-header {
    text-align: center;
    padding: 20px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    margin: -16px -16px 0;
    padding-top: 30px;
    padding-bottom: 30px;
    border-radius: 0 0 30px 30px;
    color: #fff;
    box-shadow: 0 4px 15px rgba(16,185,129,0.3);
}

.profile-avatar {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    border: 3px solid rgba(255,255,255,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
    font-size: 1.8rem;
}

.profile-name { font-size: 1.15rem; font-weight: 700; }
.profile-phone { font-size: 0.85rem; opacity: 0.85; margin-top: 3px; }
.profile-role { font-size: 0.78rem; opacity: 0.75; margin-top: 3px; }

.profile-balance-card {
    background: var(--bg-card);
    margin: -18px 16px 16px;
    padding: 16px 20px;
    border-radius: var(--radius);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-lg);
    position: relative;
    z-index: 5;
}
.pbc-label { font-size: 0.82rem; color: var(--text-secondary); }
.pbc-amount {
    font-size: 1rem;
    color: var(--text);
    margin-top: 2px;
}
.pbc-amount span { font-size: 1.5rem; font-weight: 700; }

.pbc-btn {
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 8px 24px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}
.pbc-btn:active { transform: scale(0.95); }

.profile-stats {
    display: flex;
    background: var(--bg-card);
    margin: 0 16px 16px;
    padding: 14px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
}
.ps-item {
    flex: 1;
    text-align: center;
    border-right: 1px solid var(--border);
}
.ps-item:last-child { border-right: none; }
.ps-val { font-size: 1.15rem; font-weight: 700; color: var(--primary); }
.ps-label { font-size: 0.72rem; color: var(--text-light); margin-top: 2px; }

.profile-menu {
    margin: 0 16px;
}
.pm-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.15s;
    text-decoration: none;
    color: inherit;
}
.pm-item:first-child { border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.pm-item:last-child { border-radius: 0 0 var(--radius-sm) var(--radius-sm); border-bottom: none; }
.pm-item:active { background: var(--bg); }

.pm-left {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.92rem;
    color: var(--text);
}
.pm-left i { width: 20px; text-align: center; }
.pm-arrow { color: var(--text-light); font-size: 0.8rem; }

.pm-logout { margin-top: 16px; border-radius: var(--radius-sm) !important; }
.pm-logout .pm-left { color: var(--danger); }

.app-version {
    text-align: center;
    margin-top: 24px;
    font-size: 0.75rem;
    color: var(--text-light);
}

/* ===========================
   BOTTOM NAV
   =========================== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex;
    justify-content: space-around;
    align-items: flex-end;
    padding: 8px 0;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    border-top: 1px solid var(--border);
    z-index: 100;
    height: var(--nav-height);
}

.nav-item {
    text-decoration: none;
    color: var(--text-light);
    font-size: 0.68rem;
    text-align: center;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    transition: color 0.2s;
    padding-bottom: 2px;
}
.nav-item i { font-size: 1.2rem; }
.nav-item.active { color: var(--primary); }

.nav-scan { position: relative; }
.nav-scan-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0ea5e9, #6366f1);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    margin-top: -25px;
    box-shadow: 0 4px 15px rgba(14, 165, 233, 0.4);
    transition: transform 0.2s;
}
.nav-scan:active .nav-scan-btn { transform: scale(0.9); }
.nav-scan span { margin-top: 2px; }

/* ===========================
   MODALS
   =========================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    display: none;
    align-items: flex-end;
    justify-content: center;
}
.modal-overlay.show { display: flex; }

.modal-sheet {
    background: #fff;
    width: 100%;
    max-width: 480px;
    border-radius: 24px 24px 0 0;
    padding: 16px 20px 30px;
    animation: slideUp 0.3s ease;
    max-height: 85vh;
    overflow-y: auto;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.modal-handle {
    width: 36px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 0 auto 16px;
}

.modal-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text);
}
.modal-title i { color: var(--secondary); margin-right: 6px; }

.modal-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

/* Scan Options */
.scan-device-list { margin-bottom: 16px; }

.scan-option {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s;
}
.scan-option:has(input:checked) {
    border-color: var(--secondary);
    background: rgba(14,165,233,0.04);
}
.scan-option.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.scan-option input { margin-right: 12px; accent-color: var(--secondary); }

.scan-option-content { flex: 1; }
.scan-option-name { font-size: 0.9rem; font-weight: 600; color: var(--text); }
.scan-option-meta { font-size: 0.75rem; color: var(--text-secondary); margin-top: 2px; }

.scan-option-status {
    font-size: 0.72rem;
    padding: 3px 10px;
    border-radius: 10px;
    font-weight: 500;
}
.scan-option-status.free { background: rgba(16,185,129,0.1); color: var(--success); }
.scan-option-status.busy { background: rgba(245,158,11,0.1); color: var(--warning); }
.scan-option-status.offline { background: rgba(148,163,184,0.1); color: var(--text-light); }

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}
.modal-btn-cancel {
    flex: 1;
    padding: 14px;
    border: 1px solid var(--border);
    background: var(--bg);
    border-radius: 12px;
    font-size: 0.95rem;
    color: var(--text-secondary);
    cursor: pointer;
}
.modal-btn-confirm {
    flex: 2;
    padding: 14px;
    background: linear-gradient(135deg, var(--secondary), var(--accent));
    border: none;
    border-radius: 12px;
    color: #fff;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.modal-btn-confirm:active { transform: scale(0.98); }

.modal-btn-close {
    width: 100%;
    padding: 14px;
    border: 1px solid var(--border);
    background: var(--bg);
    border-radius: 12px;
    font-size: 0.95rem;
    color: var(--text-secondary);
    cursor: pointer;
    margin-top: 12px;
}

/* Recharge Amounts */
.recharge-amounts {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin: 16px 0;
}
.ra-item {
    padding: 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    text-align: center;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
    cursor: pointer;
    transition: all 0.2s;
}
.ra-item.active {
    border-color: var(--primary);
    background: var(--primary-bg);
    color: var(--primary);
}
.ra-item.custom { font-size: 0.85rem; font-weight: 500; color: var(--text-secondary); }

.recharge-method {
    margin: 16px 0 8px;
}
.rm-label {
    font-size: 0.88rem;
    font-weight: 600;
    margin-bottom: 10px;
}
.rm-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s;
}
.rm-option:has(input:checked) {
    border-color: var(--primary);
    background: rgba(16,185,129,0.04);
}
.rm-option input { accent-color: var(--primary); }

/* Notifications */
.notify-list { margin: 8px 0 4px; }

.notify-item {
    display: flex;
    gap: 12px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}
.notify-item:last-child { border-bottom: none; }
.notify-item.unread { position: relative; }
.notify-item.unread::before {
    content: '';
    position: absolute;
    left: -8px;
    top: 20px;
    width: 6px;
    height: 6px;
    background: var(--danger);
    border-radius: 50%;
}

.ni-icon { flex-shrink: 0; font-size: 1.1rem; margin-top: 2px; }
.ni-title { font-size: 0.9rem; font-weight: 600; color: var(--text); }
.ni-text { font-size: 0.82rem; color: var(--text-secondary); margin-top: 3px; line-height: 1.4; }
.ni-time { font-size: 0.72rem; color: var(--text-light); margin-top: 4px; }

/* ===========================
   TOAST
   =========================== */
.toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    background: rgba(30, 41, 59, 0.9);
    color: #fff;
    padding: 14px 24px;
    border-radius: 12px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s;
}
.toast.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

/* ===========================
   UTILITY
   =========================== */
.hidden { display: none !important; }

/* Scrollbar */
::-webkit-scrollbar { width: 0; height: 0; }

/* ===========================
   RESPONSIVE
   =========================== */
@media (max-width: 380px) {
    .weather-details { gap: 8px; flex-wrap: wrap; }
    .quick-grid { gap: 8px; }
    .quick-icon { width: 42px; height: 42px; }
    .overview-cards { grid-template-columns: repeat(2, 1fr); }
}
