:root {
    --primary: #0077b6;
    --accent: #20a39e;
    --dark: #1b4965;
    --light: #f4f7f9;
    --success: #2ecc71;
    --warning: #f39c12;
    --danger: #e74c3c;
    --gray-300: #dee2e6;
    --gray-500: #90a4ae;
    --gray-700: #455a64;
    --card-shadow: 0 4px 16px rgba(0,0,0,0.08);
    --card-radius: 14px;
    --transition-base: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: -apple-system, 'Segoe UI', system-ui, sans-serif;
    margin: 0;
    background: var(--light);
    scroll-behavior: smooth;
}

/* SITE NAV */
.site-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 30px;
    background: rgba(27, 73, 101, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}
.site-nav-brand {
    color: white;
    font-weight: 800;
    font-size: 1.1rem;
    text-decoration: none;
    letter-spacing: 0.5px;
}
.site-nav-link {
    color: white;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    padding: 8px 20px;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 8px;
    transition: all 0.2s;
}
.site-nav-link:hover {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.6);
}

/* HERO SECTION */
.hero {
    position: relative;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    background: #1b4965 url('hero-bg.jpg') center/cover no-repeat;
    color: white;
    padding: 20px;
}

.hero::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 1;
}

.hero-content {
    position: relative;
    z-index: 2;
    max-width: 900px;
}

.main-logo {
    max-width: 480px;
    height: auto;
    margin-bottom: 10px;
    filter: drop-shadow(0 10px 20px rgba(0,0,0,0.3));
}

.hero h1 {
    font-size: clamp(2.5rem, 6vw, 4rem);
    font-weight: 800;
    margin: 0 0 20px 0;
    text-shadow: 0 4px 15px rgba(0,0,0,0.5);
}

.hero p {
    font-size: clamp(1.1rem, 2.5vw, 1.5rem);
    margin-bottom: 40px;
    text-shadow: 0 2px 10px rgba(0,0,0,0.5);
    opacity: 0.95;
}

.cta-btn {
    background: var(--accent);
    color: white;
    padding: 18px 45px;
    border-radius: 50px;
    text-decoration: none;
    font-weight: bold;
    font-size: 1.1rem;
    transition: 0.3s;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.cta-btn:hover {
    background: #1a8a86;
    transform: translateY(-3px);
}

.hero-wave {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 80px;
    z-index: 2;
}

/* DASHBOARD SECTION */
.dashboard-container {
    max-width: 1100px;
    margin: -60px auto 80px;
    padding: 0 20px;
    position: relative;
    z-index: 10;
}

.grid {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 25px;
}

.card, .chart-box {
    background: white;
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    padding: 32px;
    box-sizing: border-box;
}

.card { border-top: 4px solid var(--accent); text-align: center; }
.card-label { font-weight: 800; color: var(--accent); letter-spacing: 2px; font-size: 0.75rem; text-transform: uppercase; }
.card-device { color: var(--gray-500); margin-top: 5px; }
.salinity-value { font-size: 5rem; font-weight: 900; color: var(--dark); margin: 15px 0; }
.unit { font-size: 1.5rem; color: var(--gray-500); }

.freshness {
    margin-top: 35px;
    padding-top: 20px;
    border-top: 1px solid var(--gray-300);
    font-size: 0.85rem;
    color: var(--gray-500);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}
.freshness-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    background: var(--gray-300);
}
.freshness-dot.live {
    background: var(--success);
    box-shadow: 0 0 0 0 rgba(46, 204, 113, 0.4);
    animation: pulse 2s infinite;
}
.freshness-dot.stale { background: var(--warning); }
.freshness-dot.offline { background: var(--danger); }

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(46, 204, 113, 0.4); }
    70% { box-shadow: 0 0 0 8px rgba(46, 204, 113, 0); }
    100% { box-shadow: 0 0 0 0 rgba(46, 204, 113, 0); }
}

.freshness-detail { width: 100%; font-size: 0.75rem; color: var(--gray-500); text-align: center; margin-top: 4px; }
.chart-label { font-weight: 800; color: var(--dark); margin-bottom: 25px; letter-spacing: 1px; font-size: 0.85rem; }
.chart-subtitle { font-size: 0.75rem; color: var(--gray-500); margin-top: -18px; margin-bottom: 18px; letter-spacing: 0.5px; }

/* Stats row */
.stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-top: 25px;
}
.stat-card {
    background: white;
    border-radius: 10px;
    padding: 20px 14px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.stat-label { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 1.5px; color: var(--gray-500); margin-bottom: 8px; }
.stat-value { font-size: 1.8rem; font-weight: 800; color: var(--dark); }
.stat-unit { font-size: 0.75rem; color: var(--gray-500); margin-top: 4px; }

/* Connection badge */
.connection-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: white;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--gray-700);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    margin-bottom: 20px;
}
.connection-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--warning);
}
.connection-badge.connected .connection-dot { background: var(--success); }
.connection-badge.disconnected .connection-dot { background: var(--danger); }

/* Mailing list */
.mailing-list {
    background: var(--dark);
    padding: 80px 20px;
    text-align: center;
}
.mailing-list-content {
    max-width: 520px;
    margin: 0 auto;
}
.mailing-list-title {
    color: white;
    font-size: 1.8rem;
    font-weight: 800;
    margin: 0 0 12px;
}
.mailing-list-sub {
    color: rgba(255,255,255,0.7);
    font-size: 1rem;
    margin: 0 0 30px;
    line-height: 1.6;
}
.mailing-list-form {
    display: flex;
    gap: 10px;
    max-width: 440px;
    margin: 0 auto;
}
.mailing-list-form input {
    flex: 1;
    padding: 14px 18px;
    border: 2px solid rgba(255,255,255,0.15);
    border-radius: 12px;
    background: rgba(255,255,255,0.1);
    color: white;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}
.mailing-list-form input::placeholder { color: rgba(255,255,255,0.4); }
.mailing-list-form input:focus { border-color: var(--accent); }
.mailing-list-form button {
    padding: 14px 28px;
    border: none;
    border-radius: 12px;
    background: var(--accent);
    color: white;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
    white-space: nowrap;
}
.mailing-list-form button:hover { background: #1a8a86; transform: translateY(-2px); }
.mailing-list-form button:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.mailing-list-msg {
    margin-top: 16px;
    font-size: 0.9rem;
    min-height: 1.4em;
}
.mailing-list-msg.success { color: var(--success); }
.mailing-list-msg.error { color: #ff6b6b; }

/* Footer */
.site-footer {
    background: var(--dark);
    color: rgba(255,255,255,0.7);
    padding: 48px 20px;
    text-align: center;
}
.footer-brand { font-size: 1.2rem; font-weight: 800; color: white; letter-spacing: 1px; margin-bottom: 8px; }
.footer-tagline { font-size: 0.9rem; margin-bottom: 12px; }
.footer-tech { font-size: 0.75rem; opacity: 0.5; }
.footer-links { margin-top: 16px; display: flex; justify-content: center; gap: 24px; }
.footer-links a { color: rgba(255,255,255,0.5); font-size: 0.8rem; text-decoration: none; }
.footer-links a:hover { color: rgba(255,255,255,0.8); }

/* LEGAL PAGES */
.legal-container {
    max-width: 720px;
    margin: 40px auto 60px;
    padding: 0 20px;
}
.legal-card {
    background: white;
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    padding: 40px 36px;
}
.legal-card h1 {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--dark);
    margin: 0 0 8px;
}
.legal-updated {
    font-size: 0.85rem;
    color: var(--gray-500);
    margin: 0 0 32px;
}
.legal-card h2 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--dark);
    margin: 28px 0 12px;
}
.legal-card h3 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--gray-700);
    margin: 20px 0 8px;
}
.legal-card p, .legal-card li {
    font-size: 0.9rem;
    color: var(--gray-700);
    line-height: 1.7;
    margin: 0 0 12px;
}
.legal-card ul {
    padding-left: 20px;
    margin: 0 0 12px;
}
.legal-card a {
    color: var(--accent);
    text-decoration: none;
}
.legal-card a:hover {
    text-decoration: underline;
}

/* Entrance animations */
@keyframes fadeSlideUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}
.animate-in { opacity: 0; }
.animate-in.visible { animation: fadeSlideUp 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards; }
.stats-row .animate-in.visible:nth-child(2) { animation-delay: 0.1s; }
.stats-row .animate-in.visible:nth-child(3) { animation-delay: 0.2s; }
.stats-row .animate-in.visible:nth-child(4) { animation-delay: 0.3s; }

@media (prefers-reduced-motion: reduce) {
    .animate-in { opacity: 1; }
    .animate-in.visible { animation: none; }
}

/* Skeleton loading */
@keyframes shimmer {
    0% { background-position: -200px 0; }
    100% { background-position: calc(200px + 100%) 0; }
}
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e8ecef 50%, #f0f0f0 75%);
    background-size: 200px 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: 8px;
    color: transparent !important;
}
.skeleton * { visibility: hidden; }
.skeleton-block { display: inline-block; min-width: 80px; min-height: 1em; }
.skeleton-number { min-height: 5rem; min-width: 180px; display: block; margin: 15px auto; }
.skeleton-chart { height: 380px; width: 100%; border-radius: 12px; }

/* Error banner */
.error-banner {
    background: var(--danger);
    color: white;
    padding: 14px 24px;
    border-radius: 12px;
    margin-bottom: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    display: none;
    align-items: center;
    gap: 10px;
}
.error-banner.visible { display: flex; }
.error-spinner {
    width: 16px; height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Value props banner */
.value-props {
    max-width: 1100px;
    margin: 0 auto;
    padding: 60px 20px 20px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0;
    position: relative;
    z-index: 10;
}
.value-prop {
    text-align: center;
    padding: 20px;
    border-right: 1px solid var(--gray-300);
}
.value-prop:last-child { border-right: none; }
.value-prop-number {
    font-size: 2.2rem;
    font-weight: 900;
    color: var(--accent);
    line-height: 1.1;
}
.value-prop-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-top: 6px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Features section */
.features-section {
    max-width: 1100px;
    margin: 0 auto;
    padding: 80px 20px;
}
.features-section-title {
    text-align: center;
    font-size: 2rem;
    font-weight: 800;
    color: var(--dark);
    margin-bottom: 12px;
}
.features-section-sub {
    text-align: center;
    color: var(--gray-500);
    font-size: 1.05rem;
    margin-bottom: 50px;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}
.features-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 30px;
}
.feature-card {
    background: white;
    border-radius: 12px;
    padding: 28px 24px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.06);
    border-left: 3px solid var(--accent);
}
.feature-icon {
    font-size: 1.4rem;
    margin-bottom: 12px;
    color: var(--accent);
}
.feature-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 10px;
}
.feature-desc {
    font-size: 0.9rem;
    color: var(--gray-500);
    line-height: 1.6;
}

/* PROFILE PAGE */
.profile-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 30px;
    background: var(--dark);
}
.profile-nav-logo { height: 36px; width: auto; }
.profile-nav-brand { text-decoration: none; }
.profile-nav-right { display: flex; align-items: center; gap: 12px; }
.nav-email { color: rgba(255,255,255,0.7); font-size: 0.85rem; }
.btn-logout {
    background: none;
    border: 1px solid rgba(255,255,255,0.3);
    color: white;
    padding: 6px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}
.btn-logout:hover { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.6); }

.profile-container {
    max-width: 560px;
    margin: 60px auto;
    padding: 0 20px;
}
.profile-card {
    background: white;
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    padding: 36px 32px;
}
.profile-card h2 {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--dark);
    margin: 0 0 32px;
}
.form-group { margin-bottom: 24px; }
.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--gray-700);
    margin-bottom: 8px;
}
.form-group input,
.form-group select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--gray-300);
    border-radius: 8px;
    font-size: 1rem;
    color: var(--dark);
    background: white;
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
}
.form-group input:focus,
.form-group select:focus { border-color: var(--accent); }
.form-hint { font-size: 0.8rem; color: var(--gray-500); margin-top: 6px; line-height: 1.5; }

.input-row { display: flex; gap: 8px; align-items: center; }
.input-row input { flex: 1; }
.input-prefix { font-weight: 700; color: var(--gray-700); font-size: 1rem; padding: 0 4px; flex-shrink: 0; }

.btn-primary {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 8px;
    background: var(--accent);
    color: white;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s;
}
.btn-primary:hover { background: #1a8a86; }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-secondary {
    padding: 10px 18px;
    border: 2px solid var(--accent);
    border-radius: 8px;
    background: white;
    color: var(--accent);
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}
.btn-secondary:hover { background: var(--accent); color: white; }
.btn-secondary:disabled { opacity: 0.6; cursor: not-allowed; }

.form-msg { font-size: 0.85rem; margin-top: 12px; min-height: 1.2em; }
.form-msg.error { color: var(--danger); }
.form-msg.success { color: var(--success); }

.auth-toggle { text-align: center; font-size: 0.9rem; color: var(--gray-500); margin-top: 20px; }
.auth-toggle a { color: var(--accent); font-weight: 600; text-decoration: none; }
.auth-toggle a:hover { text-decoration: underline; }

.phone-status { margin-top: 8px; }
.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.badge-verified { background: rgba(46,204,113,0.1); color: var(--success); }
.badge-unverified { background: rgba(243,156,18,0.1); color: var(--warning); }
.badge-alert { background: rgba(231,76,60,0.1); color: var(--danger); }
.badge-normal { background: rgba(32,163,158,0.1); color: var(--accent); }
.badge-inactive { background: rgba(144,164,174,0.1); color: var(--gray-500); }

.alert-state-display {
    padding: 16px;
    background: var(--light);
    border-radius: 12px;
    font-size: 0.9rem;
    color: var(--gray-700);
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.profile-divider {
    border: none;
    border-top: 1px solid rgba(144,164,174,0.2);
    margin: 28px 0;
}

.user-device-item {
    background: var(--light);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
}

.user-device-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    color: var(--gray-700);
}

.user-device-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.user-device-controls label {
    font-size: 0.85rem;
    color: var(--gray-500);
    white-space: nowrap;
}

.user-device-controls input {
    width: 100px;
    padding: 8px 12px;
    border: 1px solid rgba(144,164,174,0.3);
    border-radius: 8px;
    background: var(--dark);
    color: var(--light);
    font-size: 0.9rem;
}

.btn-danger {
    padding: 8px 16px;
    background: rgba(231,76,60,0.1);
    color: var(--danger);
    border: 1px solid rgba(231,76,60,0.3);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: background 0.2s;
}

.btn-danger:hover {
    background: rgba(231,76,60,0.2);
}

.add-device-row {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 16px;
}

.add-device-row select {
    flex: 1;
}

/* DASHBOARD PAGE */
.dash-container {
    max-width: 1100px;
    margin: 40px auto 80px;
    padding: 0 20px;
}

.dash-device-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.dash-tab {
    padding: 8px 18px;
    border: 2px solid var(--gray-300);
    border-radius: 8px;
    background: white;
    color: var(--gray-700);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.dash-tab:hover { border-color: var(--accent); color: var(--accent); }
.dash-tab.active { background: var(--accent); color: white; border-color: var(--accent); }
.dash-tab-alert { border-color: var(--danger); color: var(--danger); }
.dash-tab-alert.active { background: var(--danger); border-color: var(--danger); color: white; }

.dash-nav-link {
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 8px;
    transition: all 0.2s;
}
.dash-nav-link:hover { color: white; background: rgba(255,255,255,0.1); }

.dash-reading-row {
    display: flex;
    justify-content: center;
    gap: 32px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--gray-300);
}

.dash-reading-item { text-align: center; }

.dash-reading-label {
    display: block;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--gray-500);
    margin-bottom: 4px;
}

.dash-reading-value {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--dark);
}

.dash-reading-unit {
    font-size: 0.85rem;
    color: var(--gray-500);
}

/* Responsive */
@media (max-width: 900px) {
    .grid { grid-template-columns: 1fr; }
    .hero { height: 70vh; min-height: 500px; padding: 80px 20px 120px; }
    .dashboard-container { margin-top: 20px; padding: 0 12px; }
    .card, .chart-box { padding: 24px 16px; border-radius: 10px; }
    .salinity-value { font-size: 3.5rem; }
    .stats-row { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .stat-card { padding: 18px 12px; }
    .stat-value { font-size: 1.4rem; }
    .cta-btn { padding: 16px 36px; font-size: 1rem; }
    .hero-wave { height: 50px; }
    .main-logo { max-width: 200px; }
    .value-props { grid-template-columns: repeat(2, 1fr); padding: 40px 12px 10px; }
    .value-prop { padding: 16px 12px; }
    .value-prop:nth-child(2) { border-right: none; }
    .value-prop:nth-child(1), .value-prop:nth-child(2) { border-bottom: 1px solid var(--gray-300); }
    .value-prop-number { font-size: 1.8rem; }
    .features-section { padding: 50px 16px; }
    .features-grid { grid-template-columns: 1fr; gap: 20px; }
    .features-section-title { font-size: 1.5rem; }
    .mailing-list { padding: 50px 16px; }
    .mailing-list-title { font-size: 1.4rem; }
    .mailing-list-form { flex-direction: column; }
    .site-nav { padding: 12px 16px; }
    .profile-nav { padding: 12px 16px; }
    .profile-card { padding: 28px 16px; border-radius: 10px; }
    .profile-container { margin: 30px auto; }
    .input-row { flex-wrap: wrap; }
}
