:root {
    --teal: #4db6ac;
    --teal-dark: #00897b;
    --teal-light: #b2dfdb;
    --teal-bg: #e0f2f1;
    --warm: #fff8e1;
    --text: #37474f;
    --text-light: #607d8b;
    --white: #ffffff;
    --shadow: 0 2px 16px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
}

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

html { scroll-behavior: smooth; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    color: var(--text);
    line-height: 1.6;
    overflow-x: hidden;
}

/* ── NAV ── */
nav {
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 100;
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(10px);
    box-shadow: 0 1px 8px rgba(0,0,0,0.06);
    transition: background 0.3s;
}
.nav-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}
.nav-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--teal-dark);
}
.nav-logo img { height: 40px; }
.nav-logo span {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}
.nav-links { display: flex; gap: 28px; list-style: none; }
.nav-links a {
    text-decoration: none;
    color: var(--text-light);
    font-size: 0.95rem;
    font-weight: 500;
    transition: color 0.2s;
}
.nav-links a:hover { color: var(--teal-dark); }
.nav-cta {
    background: var(--teal);
    color: var(--white) !important;
    padding: 8px 20px;
    border-radius: 24px;
    font-weight: 600 !important;
    transition: background 0.2s, transform 0.2s;
}
.nav-cta:hover { background: var(--teal-dark); transform: translateY(-1px); }

.hamburger {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
}
.hamburger span {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--text);
    margin: 6px 0;
    transition: 0.3s;
}

/* ── HERO ── */
.hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 120px 24px 80px;
    background: linear-gradient(160deg, var(--teal-bg) 0%, var(--white) 50%, var(--warm) 100%);
    position: relative;
    overflow: hidden;
}
.hero::before {
    content: '';
    position: absolute;
    top: -200px;
    right: -200px;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(77,182,172,0.12) 0%, transparent 70%);
}
.hero::after {
    content: '';
    position: absolute;
    bottom: -150px;
    left: -150px;
    width: 500px;
    height: 500px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(77,182,172,0.08) 0%, transparent 70%);
}
.hero-content { max-width: 800px; position: relative; z-index: 1; }
.hero-content img {
    height: 80px;
    margin-bottom: 24px;
}
.hero h1 {
    font-size: clamp(2rem, 5vw, 3.2rem);
    font-weight: 800;
    color: var(--text);
    line-height: 1.2;
    margin-bottom: 16px;
}
.hero h1 em {
    font-style: normal;
    color: var(--teal-dark);
}
.hero p {
    font-size: 1.2rem;
    color: var(--text-light);
    max-width: 560px;
    margin: 0 auto 36px;
}
.hero-buttons { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 32px;
    border-radius: 32px;
    text-decoration: none;
    font-weight: 600;
    font-size: 1rem;
    transition: all 0.25s;
    cursor: pointer;
    border: none;
}
.btn-primary {
    background: var(--teal);
    color: var(--white);
    box-shadow: 0 4px 16px rgba(77,182,172,0.35);
}
.btn-primary:hover {
    background: var(--teal-dark);
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(77,182,172,0.4);
}
.btn-secondary {
    background: var(--white);
    color: var(--teal-dark);
    border: 2px solid var(--teal-light);
}
.btn-secondary:hover {
    border-color: var(--teal);
    background: var(--teal-bg);
    transform: translateY(-2px);
}

/* ── SECTION COMMON ── */
section { padding: 100px 24px; }
.section-inner {
    max-width: 1200px;
    margin: 0 auto;
}
.section-header {
    text-align: center;
    margin-bottom: 64px;
}
.section-header h2 {
    font-size: clamp(1.6rem, 3vw, 2.4rem);
    font-weight: 700;
    margin-bottom: 12px;
}
.section-header p {
    color: var(--text-light);
    font-size: 1.1rem;
    max-width: 560px;
    margin: 0 auto;
}

/* ── FEATURES ── */
#features { background: var(--white); }
.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 32px;
}
.feature-card {
    background: var(--white);
    border: 1px solid #e8eef1;
    border-radius: 16px;
    padding: 36px 28px;
    transition: transform 0.25s, box-shadow 0.25s;
}
.feature-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}
.feature-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    margin-bottom: 20px;
}
.feature-card h3 {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 8px;
}
.feature-card p {
    color: var(--text-light);
    font-size: 0.95rem;
    line-height: 1.7;
}

.fi-share { background: #e8f5e9; color: #2e7d32; }
.fi-map { background: #e3f2fd; color: #1565c0; }
.fi-mesh { background: #fce4ec; color: #c62828; }
.fi-house { background: #fff3e0; color: #e65100; }
.fi-chat { background: #f3e5f5; color: #6a1b9a; }
.fi-box { background: #e0f2f1; color: #00695c; }

/* ── SHARING TYPES ── */
#sharing { background: var(--teal-bg); }
.sharing-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 20px;
    max-width: 800px;
    margin: 0 auto;
}
.share-type {
    text-align: center;
    padding: 28px 16px;
    background: var(--white);
    border-radius: 16px;
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: default;
}
.share-type:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow);
}
.share-type .emoji {
    font-size: 2.2rem;
    display: block;
    margin-bottom: 10px;
}
.share-type span {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text);
}

/* ── MESH ── */
#mesh { background: var(--white); }
.mesh-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 64px;
    align-items: center;
}
.mesh-text h2 {
    font-size: clamp(1.6rem, 3vw, 2.2rem);
    font-weight: 700;
    margin-bottom: 16px;
}
.mesh-text p {
    color: var(--text-light);
    font-size: 1.05rem;
    line-height: 1.8;
    margin-bottom: 24px;
}
.mesh-features { list-style: none; }
.mesh-features li {
    padding: 10px 0;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    font-size: 0.95rem;
}
.mesh-features li .check {
    color: var(--teal);
    font-weight: bold;
    font-size: 1.2rem;
    line-height: 1.4;
}
.mesh-visual {
    display: flex;
    align-items: center;
    justify-content: center;
}
.mesh-diagram {
    width: 100%;
    max-width: 400px;
    aspect-ratio: 1;
    background: var(--teal-bg);
    border-radius: 50%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}
.mesh-diagram::before {
    content: '';
    position: absolute;
    width: 70%;
    height: 70%;
    border: 2px dashed var(--teal-light);
    border-radius: 50%;
}
.mesh-node {
    position: absolute;
    width: 48px;
    height: 48px;
    background: var(--white);
    border: 3px solid var(--teal);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    box-shadow: var(--shadow);
}
.mesh-node:nth-child(1) { top: 8%; left: 50%; transform: translateX(-50%); }
.mesh-node:nth-child(2) { top: 35%; right: 6%; }
.mesh-node:nth-child(3) { bottom: 12%; right: 18%; }
.mesh-node:nth-child(4) { bottom: 12%; left: 18%; }
.mesh-node:nth-child(5) { top: 35%; left: 6%; }
.mesh-center {
    width: 72px;
    height: 72px;
    background: var(--teal);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    color: var(--white);
    box-shadow: 0 4px 20px rgba(77,182,172,0.4);
    z-index: 1;
}

/* ── PLATFORMS ── */
#platforms { background: linear-gradient(160deg, var(--teal-bg) 0%, var(--warm) 100%); }
.platforms-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 32px;
    max-width: 900px;
    margin: 0 auto;
}
.platform-card {
    text-align: center;
    background: var(--white);
    border-radius: 20px;
    padding: 48px 28px;
    box-shadow: var(--shadow);
    transition: transform 0.25s;
}
.platform-card:hover { transform: translateY(-4px); }
.platform-card .icon {
    font-size: 3rem;
    margin-bottom: 16px;
    display: block;
}
.platform-card h3 {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 8px;
}
.platform-card p {
    color: var(--text-light);
    font-size: 0.9rem;
}

/* ── NEIGHBOURHOOD VIEW ── */
#neighbourhood-view {
    background: var(--white);
}
.neighbourhood-map-wrap {
    position: relative;
    max-width: 1100px;
    margin: 0 auto;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    border: 1px solid #e0e0e0;
}
.neighbourhood-map-wrap iframe {
    width: 100%;
    height: 70vh;
    min-height: 500px;
    border: none;
    display: block;
}
.map-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: 600;
    color: var(--teal-dark);
    z-index: 10;
    backdrop-filter: blur(2px);
}

/* ── MAP PREVIEW ── */
#map-preview { background: var(--white); }
.map-frame {
    max-width: 960px;
    margin: 0 auto;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    border: 1px solid #e0e0e0;
}
.map-frame-bar {
    background: #f5f5f5;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.map-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}
.map-dot-r { background: #ef5350; }
.map-dot-y { background: #fdd835; }
.map-dot-g { background: #66bb6a; }
.map-frame iframe {
    width: 100%;
    height: 480px;
    border: none;
    display: block;
}

/* ── OPEN SOURCE ── */
#opensource { background: var(--teal-bg); }
.opensource-content {
    text-align: center;
    max-width: 640px;
    margin: 0 auto;
}
.opensource-content .badge {
    display: inline-block;
    font-size: 3rem;
    margin-bottom: 16px;
}
.opensource-content h2 {
    font-size: clamp(1.6rem, 3vw, 2.2rem);
    font-weight: 700;
    margin-bottom: 12px;
}
.opensource-content p {
    color: var(--text-light);
    font-size: 1.05rem;
    line-height: 1.8;
    margin-bottom: 32px;
}
.tech-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-top: 32px;
}
.tech-tag {
    background: var(--white);
    color: var(--text);
    padding: 8px 18px;
    border-radius: 24px;
    font-size: 0.85rem;
    font-weight: 600;
    border: 1px solid #e0e0e0;
}

/* ── CTA ── */
.cta-section {
    padding: 100px 24px;
    text-align: center;
    background: linear-gradient(160deg, var(--teal-dark) 0%, var(--teal) 100%);
    color: var(--white);
}
.cta-section h2 {
    font-size: clamp(1.6rem, 3vw, 2.4rem);
    font-weight: 700;
    margin-bottom: 12px;
}
.cta-section p {
    font-size: 1.1rem;
    opacity: 0.9;
    margin-bottom: 36px;
    max-width: 480px;
    margin-left: auto;
    margin-right: auto;
}
.cta-section .btn-primary {
    background: var(--white);
    color: var(--teal-dark);
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}
.cta-section .btn-primary:hover {
    background: var(--teal-bg);
    box-shadow: 0 6px 24px rgba(0,0,0,0.2);
}

/* ── FOOTER ── */
footer {
    background: var(--text);
    color: rgba(255,255,255,0.7);
    padding: 48px 24px;
}
.footer-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 24px;
}
.footer-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}
.footer-brand img { height: 32px; filter: brightness(10); }
.footer-brand span { font-weight: 600; color: var(--white); }
.footer-links { display: flex; gap: 24px; list-style: none; }
.footer-links a {
    color: rgba(255,255,255,0.6);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s;
}
.footer-links a:hover { color: var(--white); }
.footer-copy { font-size: 0.85rem; width: 100%; text-align: center; margin-top: 24px; padding-top: 24px; border-top: 1px solid rgba(255,255,255,0.1); }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
    .nav-links { display: none; }
    .hamburger { display: block; }
    .nav-links.open {
        display: flex;
        flex-direction: column;
        position: absolute;
        top: 64px;
        left: 0;
        right: 0;
        background: var(--white);
        padding: 24px;
        box-shadow: var(--shadow);
        gap: 16px;
    }
    .nav-logo { flex: 1; min-width: 0; }
    .nav-logo img { max-width: 140px; height: auto; }
    .nav-user-name { display: none; }
    .hero h1 br { display: none; }
    .hero { padding: 100px 16px 60px; }
    .hero-content img { height: 60px; }
    .mesh-layout {
        grid-template-columns: 1fr;
        gap: 40px;
    }
    .mesh-visual { order: -1; }
    .platforms-grid {
        grid-template-columns: 1fr;
        max-width: 360px;
    }
    .features-grid {
        grid-template-columns: 1fr;
    }
    .sharing-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .map-frame iframe { height: 320px; }
    .neighbourhood-map-wrap iframe { min-height: 400px; height: 60vh; }
    .footer-inner { flex-direction: column; text-align: center; }
    .footer-links { flex-wrap: wrap; justify-content: center; }
}

/* ── LOGIN MODAL ── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}
.modal-overlay.open { display: flex; }
.modal {
    background: var(--white);
    border-radius: 20px;
    padding: 40px 36px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
    position: relative;
    animation: modalIn 0.3s ease;
}
@keyframes modalIn {
    from { opacity: 0; transform: translateY(20px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-light);
    line-height: 1;
    padding: 4px;
}
.modal-close:hover { color: var(--text); }
.modal h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text);
}
.modal .subtitle {
    color: var(--text-light);
    font-size: 0.95rem;
    margin-bottom: 28px;
}
.form-group {
    margin-bottom: 18px;
}
.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}
.form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    font-size: 1rem;
    font-family: inherit;
    color: var(--text);
    transition: border-color 0.2s;
    outline: none;
}
.form-group input:focus {
    border-color: var(--teal);
}
.form-error {
    color: #c62828;
    font-size: 0.85rem;
    margin-bottom: 12px;
    min-height: 20px;
}
.btn-login {
    width: 100%;
    padding: 14px;
    border-radius: 12px;
    background: var(--teal);
    color: var(--white);
    font-size: 1rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: background 0.2s;
}
.btn-login:hover { background: var(--teal-dark); }
.btn-login:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
.modal-footer {
    text-align: center;
    margin-top: 16px;
    font-size: 0.85rem;
    color: var(--text-light);
}
.modal-footer a {
    color: var(--teal-dark);
    text-decoration: none;
    font-weight: 600;
}
.modal-footer a:hover { text-decoration: underline; }

/* ── USER PROFILE NAV ── */
.nav-user {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    position: relative;
}
.nav-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--teal-light);
    color: var(--teal-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    overflow: hidden;
}
.nav-user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.nav-user-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.nav-user-dropdown {
    display: none;
    position: absolute;
    top: 48px;
    right: 0;
    background: var(--white);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    overflow: hidden;
    z-index: 110;
}
.nav-user-dropdown.open { display: block; }
.dropdown-header {
    padding: 16px;
    border-bottom: 1px solid #e8eef1;
}
.dropdown-header .fullname {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text);
}
.dropdown-header .username {
    font-size: 0.8rem;
    color: var(--text-light);
}
.dropdown-header .household {
    font-size: 0.8rem;
    color: var(--teal-dark);
    margin-top: 4px;
}
.dropdown-item {
    display: block;
    width: 100%;
    padding: 12px 16px;
    background: none;
    border: none;
    text-align: left;
    font-size: 0.9rem;
    font-family: inherit;
    color: var(--text);
    cursor: pointer;
    transition: background 0.15s;
}
.dropdown-item:hover {
    background: var(--teal-bg);
}
.dropdown-item.danger { color: #c62828; }
.dropdown-item.danger:hover { background: #fce4ec; }

/* ── ANIMATIONS ── */
.fade-up {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}
.fade-up.visible {
    opacity: 1;
    transform: translateY(0);
}
