* {
    box-sizing: border-box;
}

:root {
    --bg: #f2f6f9;
    --panel: #ffffff;
    --text: #1f2933;
    --muted: #5b6b7a;
    --line: #d8e0e8;
    --brand: #2667ff;
    --brand-strong: #1749bf;
    --ok: #1f9d55;
    --error: #c53030;
}

body {
    margin: 0;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    color: var(--text);
    background: linear-gradient(165deg, #eef4fb 0%, #f7fafc 45%, #e9f1f7 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ── Modern nav ── */
/* ── Site nav ── */
.site-nav {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: #1a3a5c;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

.site-nav-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.2rem;
    height: 60px;
}

.site-brand {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    font-size: 1.25rem;
    white-space: nowrap;
    flex-shrink: 0;
}

.site-brand:hover {
    opacity: 0.95;
}

.site-brand-logo {
    height: 54px;
    max-height: 56px;
    width: auto;
    display: block;
}

.site-brand-text {
    line-height: 1;
}

/* Desktop: show links, hide toggle */
.site-nav-toggle {
    display: none;
}

.site-nav-links {
    display: flex;
    align-items: center;
    gap: 4px;
}

.site-nav-group {
    position: relative;
}

.site-nav-group + .site-nav-group {
    margin-left: 8px;
    padding-left: 8px;
    border-left: 1px solid rgba(255,255,255,0.25);
}

.site-nav-group-title {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.24);
    color: #ffffff;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
}

.site-nav-group-title::after {
    content: "\25BE";
    font-size: 0.65rem;
    opacity: 0.9;
}

.site-nav-group-title:hover,
.site-nav-group.open .site-nav-group-title {
    background: rgba(255,255,255,0.24);
    border-color: rgba(255,255,255,0.36);
}

.site-nav-group-menu {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    min-width: 280px;
    max-width: min(92vw, 520px);
    max-height: min(62vh, 420px);
    padding: 8px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.2);
    background: #21486f;
    box-shadow: 0 10px 24px rgba(0,0,0,0.35);
    z-index: 1200;
    grid-template-columns: repeat(2, minmax(130px, 1fr));
    gap: 4px;
    overflow-y: auto;
}

.site-nav-group:hover .site-nav-group-menu,
.site-nav-group.open .site-nav-group-menu {
    display: grid;
}

.site-nav-group-menu a {
    width: 100%;
}

.site-nav-links a {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 8px;
    text-decoration: none;
    color: #ffffff;
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
    transition: background 0.2s;
}

.site-nav-links a:hover {
    background: rgba(255,255,255,0.18);
}

.site-nav-links a.active {
    background: rgba(255,255,255,0.25);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.3);
}

/* Tablet: hide text labels, keep icons */
@media (max-width: 820px) {
    .site-nav-links a .nav-label { display: none; }
    .site-nav-links a { padding: 8px 10px; }
    .site-nav-group-title {
        font-size: 0.72rem;
        padding: 8px;
    }
    .site-nav-group-menu a .nav-label { display: inline; }
    .site-nav-group + .site-nav-group {
        margin-left: 2px;
        padding-left: 2px;
        border-left: 0;
    }
}

/* Mobile: show toggle, hide links until open */
@media (max-width: 600px) {
    .site-brand-logo {
        height: 46px;
        max-height: 48px;
    }

    .site-brand-text {
        font-size: 1.05rem;
    }

    .site-nav-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        background: rgba(255,255,255,0.15);
        border: 1px solid rgba(255,255,255,0.3);
        color: #fff;
        font-size: 1.3rem;
        width: 42px;
        height: 42px;
        border-radius: 8px;
        cursor: pointer;
        flex-shrink: 0;
    }

    .site-nav-toggle:hover {
        background: rgba(255,255,255,0.25);
    }

    .site-nav-links {
        display: none;
        position: fixed;
        top: 60px;
        left: 0;
        right: 0;
        z-index: 999;
        background: #1a3a5c;
        flex-direction: column;
        align-items: stretch;
        gap: 4px;
        padding: 12px;
        border-top: 1px solid rgba(255,255,255,0.2);
        box-shadow: 0 6px 20px rgba(0,0,0,0.5);
        max-height: calc(100vh - 60px);
        overflow-y: auto;
    }

    .site-nav-group,
    .site-nav-group + .site-nav-group {
        position: static;
        margin: 0;
        padding: 0;
        border: 0;
        border-radius: 0;
    }

    .site-nav-links.open {
        display: flex;
    }

    .site-nav-group-title {
        width: 100%;
        justify-content: space-between;
        font-size: 0.82rem;
        color: rgba(255,255,255,0.92);
        padding: 10px 12px;
        border: 1px solid rgba(255,255,255,0.22);
    }

    .site-nav-group-menu {
        position: static;
        min-width: 0;
        max-width: none;
        max-height: none;
        margin-top: 4px;
        padding: 6px;
        border: 1px solid rgba(255,255,255,0.16);
        background: rgba(0,0,0,0.18);
        box-shadow: none;
        grid-template-columns: 1fr;
        overflow: visible;
    }

    .site-nav-group:hover .site-nav-group-menu {
        display: none;
    }

    .site-nav-group.open .site-nav-group-menu {
        display: grid;
    }

    .site-nav-links a {
        padding: 14px 16px;
        border-radius: 8px;
        font-size: 1rem;
        color: #ffffff;
    }

    .site-nav-links a .nav-label {
        display: inline;
    }
}
/* ── End site nav ── */

.container {
    max-width: 1200px;
    margin: 1rem auto;
    padding: 0 0.8rem 2rem;
    display: grid;
    gap: 1rem;
    width: 100%;
    flex: 1;
}

.site-footer {
    border-top: 1px solid var(--line);
    background: #ffffff;
}

.site-footer-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0.9rem 0.8rem 1.1rem;
    color: var(--muted);
    font-size: 0.88rem;
    text-align: center;
}

.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 0.9rem;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.05);
}

.card h2 {
    margin-top: 0;
    font-size: 1.05rem;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 0.8rem;
}

.metric-label {
    margin: 0;
    color: var(--muted);
    font-size: 0.85rem;
}

.metric-value {
    margin: 0.2rem 0 0;
    font-size: 1.3rem;
    font-weight: 700;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 0.7rem;
    align-items: end;
}

label {
    display: grid;
    gap: 0.25rem;
    font-size: 0.9rem;
    color: var(--muted);
}

input,
select,
textarea,
button {
    font: inherit;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0.45rem 0.55rem;
    background: #ffffff;
}

textarea {
    resize: vertical;
    min-height: 110px;
}

.inline-form {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 0.6rem;
}

.btn {
    border: none;
    background: var(--brand);
    color: #ffffff;
    padding: 0.5rem 0.9rem;
    border-radius: 8px;
    text-decoration: none;
    cursor: pointer;
}

.btn:hover {
    background: var(--brand-strong);
}

.btn-secondary {
    background: #6b7c8e;
}

.btn-secondary:hover {
    background: #556474;
}

.btn-danger {
    background: #c53030;
}

.btn-danger:hover {
    background: #9f2525;
}

.row-actions {
    display: flex;
    gap: 0.4rem;
    align-items: center;
}

.row-actions form {
    margin: 0;
}

.button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.home-banner {
    width: min(94%, 1280px);
    margin: 0.35rem auto 0.9rem;
    overflow: hidden;
    line-height: 0;
    border-radius: 14px;
}

.home-banner-image {
    width: 100%;
    height: auto;
    max-height: 400px;
    object-fit: contain;
    object-position: center center;
    display: block;
}

.home-hero-copy h1 {
    margin: 0 0 0.8rem;
    font-size: clamp(1.5rem, 2.7vw, 2.3rem);
    line-height: 1.2;
}

.home-hero-copy p {
    margin: 0 0 0.9rem;
    color: #2a3e52;
    font-size: 1rem;
    line-height: 1.65;
    max-width: 74ch;
}

.home-cta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    margin-top: 0.35rem;
}

.home-benefits h2,
.home-faq h2,
.home-final-cta h2 {
    margin: 0 0 0.75rem;
    font-size: clamp(1.2rem, 2vw, 1.7rem);
    line-height: 1.25;
}

.home-benefit-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.8rem;
}

.home-benefit-card {
    border: 1px solid #d6e1ec;
    border-radius: 12px;
    padding: 0.85rem;
    background: linear-gradient(180deg, #f8fbff 0%, #eef5fb 100%);
}

.home-benefit-card h3 {
    margin: 0 0 0.45rem;
    font-size: 1.03rem;
}

.home-benefit-card p {
    margin: 0;
    color: #354b61;
    line-height: 1.55;
}

.home-testimonial {
    border-left: 4px solid var(--brand);
    background: linear-gradient(120deg, #f6f9ff 0%, #edf4ff 100%);
}

.home-testimonial-quote {
    margin: 0;
    font-size: clamp(1.05rem, 1.8vw, 1.3rem);
    line-height: 1.55;
    color: #23384c;
    font-weight: 600;
}

.home-testimonial-author {
    margin: 0.65rem 0 0;
    color: #4a6177;
    font-size: 0.95rem;
}

.home-faq-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.8rem;
}

.home-faq-grid article {
    border: 1px solid #dce6f0;
    border-radius: 12px;
    padding: 0.8rem;
    background: #fbfdff;
}

.home-faq-grid h3 {
    margin: 0 0 0.45rem;
    font-size: 0.98rem;
}

.home-faq-grid p {
    margin: 0;
    color: #3b5369;
    line-height: 1.55;
}

.home-final-cta {
    background: linear-gradient(135deg, #f8fbff 0%, #eaf4ff 100%);
    border-color: #cfe0f2;
}

.home-final-cta p {
    margin: 0;
    color: #2d445a;
    line-height: 1.55;
}

.contact-card {
    max-width: 760px;
}

.contact-intro {
    margin: 0 0 0.9rem;
    color: #3a5268;
    line-height: 1.6;
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 700px;
}

th,
td {
    border: 1px solid var(--line);
    padding: 0.4rem 0.45rem;
    text-align: left;
    font-size: 0.86rem;
    white-space: nowrap;
}

td.note-cell {
    white-space: normal;
    min-width: 280px;
}

th {
    background: #edf3f8;
}

.totals-row {
    font-weight: 700;
    background: #f1f8ff;
}

.message {
    margin: 0 0 0.8rem;
    padding: 0.55rem 0.7rem;
    border-radius: 8px;
}

.message.ok {
    color: var(--ok);
    background: #e7f8ee;
}

.message.error {
    color: var(--error);
    background: #fdeaea;
}

.chart-wrap {
    max-width: 500px;
    margin: 0;
}

.chart-wrap.half-size {
    max-width: 250px;
}

.body-metrics-hero {
    background: radial-gradient(circle at 15% 20%, rgba(61, 128, 255, 0.22), transparent 45%),
                radial-gradient(circle at 92% 5%, rgba(43, 182, 115, 0.2), transparent 38%),
                linear-gradient(135deg, #ffffff 0%, #eef6ff 100%);
    border: 1px solid #c9ddf5;
}

.body-metrics-hero-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
}

.body-metrics-hero-head h2 {
    margin: 0;
}

.body-metrics-subtitle {
    margin: 0;
    color: #3b5877;
    font-size: 0.92rem;
}

.trend-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.34rem 0.65rem;
}

.is-good {
    color: #185b3f;
    background: #d9f3e6;
}

.is-bad {
    color: #8b1f1f;
    background: #f8dede;
}

.is-neutral {
    color: #36506c;
    background: #e7eef6;
}

.body-metrics-kpi-grid {
    margin-top: 0.95rem;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
}

.kpi-card {
    border: 1px solid #d6e6f7;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.86);
    padding: 0.75rem;
    box-shadow: 0 6px 16px rgba(16, 62, 116, 0.08);
    animation: kpi-rise 0.55s ease-out;
}

.kpi-label {
    margin: 0;
    font-size: 0.82rem;
    color: #46627f;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 700;
}

.kpi-value {
    margin: 0.3rem 0 0;
    font-size: clamp(1.25rem, 2.1vw, 1.75rem);
    font-weight: 800;
    color: #12375f;
    line-height: 1.1;
}

.kpi-change {
    margin: 0.5rem 0 0;
    border-radius: 8px;
    padding: 0.3rem 0.45rem;
    font-size: 0.84rem;
    font-weight: 600;
}

.kpi-secondary {
    margin: 0.32rem 0 0;
    color: #4d6682;
    font-size: 0.85rem;
}

.progress-grid-wrap {
    margin-top: 0.95rem;
    overflow-x: auto;
}

.progress-table {
    min-width: 560px;
}

.progress-table td,
.progress-table th {
    vertical-align: middle;
}

.progress-table .kpi-change {
    margin: 0;
    display: inline-flex;
    white-space: nowrap;
}

.progress-grid {
    min-width: 640px;
    border: 1px solid #d3e1f2;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.9);
}

.progress-row {
    display: grid;
    grid-template-columns: 1.25fr 1fr 1fr 1fr;
    align-items: center;
    gap: 0.6rem;
    padding: 0.56rem 0.7rem;
    border-top: 1px solid #e3edf8;
    font-size: 0.93rem;
    color: #173a60;
}

.progress-row:first-child {
    border-top: 0;
}

.progress-row-head {
    background: #eaf2fc;
    font-size: 0.79rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #3d5772;
}

.progress-metric {
    font-weight: 700;
}

.progress-row .kpi-change {
    margin: 0;
    display: inline-flex;
    width: fit-content;
    white-space: nowrap;
}

.body-metrics-chart-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.9rem;
}

@keyframes kpi-rise {
    from {
        transform: translateY(8px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes help-pulse {
    0%, 100% {
        box-shadow: 0 10px 28px rgba(15, 95, 180, 0.5), inset 0 0 0 0 rgba(255, 255, 255, 0.2);
    }
    50% {
        box-shadow: 0 10px 36px rgba(15, 95, 180, 0.75), inset 0 0 0 4px rgba(255, 255, 255, 0.3);
    }
}

.help-widget {
    position: fixed !important;
    right: 1.2rem !important;
    bottom: 1.2rem !important;
    z-index: 9999 !important;
}

.help-fab {
    width: 72px;
    height: 72px;
    border-radius: 999px;
    border: 0;
    background: linear-gradient(135deg, #0f5fb4 0%, #0b3d82 100%);
    color: #ffffff;
    font-size: 2.2rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 12px 32px rgba(15, 55, 128, 0.45);
    transition: all 0.3s ease;
    animation: help-pulse 2.5s infinite;
    display: flex;
    align-items: center;
    justify-content: center;
}

.help-fab:hover {
    transform: scale(1.08);
    filter: brightness(1.05);
}

.help-panel {
    position: absolute;
    right: 0;
    bottom: 68px;
    width: min(360px, calc(100vw - 1.4rem));
    max-height: min(70vh, 560px);
    overflow: auto;
    background: #ffffff;
    border: 1px solid #d6e3f2;
    border-radius: 14px;
    padding: 0.8rem;
    box-shadow: 0 16px 36px rgba(14, 36, 73, 0.26);
}

.help-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.6rem;
}

.help-panel-header h3 {
    margin: 0;
    font-size: 1rem;
}

.help-close {
    border: 0;
    background: transparent;
    color: #35506d;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    width: 30px;
    height: 30px;
    border-radius: 8px;
}

.help-close:hover {
    background: #edf4ff;
}

.help-intro {
    margin: 0.55rem 0 0.7rem;
    color: #335069;
    font-size: 0.92rem;
    line-height: 1.45;
}

.help-tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.35rem;
    margin-bottom: 0.75rem;
}

.help-tab {
    border: 1px solid #cddcee;
    background: #f5f9ff;
    color: #2d4c6a;
    border-radius: 8px;
    padding: 0.45rem 0.35rem;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
}

.help-tab.is-active {
    background: #195fd8;
    border-color: #195fd8;
    color: #ffffff;
}

.help-section h4 {
    margin: 0 0 0.35rem;
    font-size: 0.95rem;
}

.help-list {
    margin: 0;
    padding-left: 1.2rem;
    color: #243a52;
    line-height: 1.45;
}

.help-list li + li {
    margin-top: 0.38rem;
}

.help-faq-item {
    border: 1px solid #dbe7f5;
    border-radius: 10px;
    background: #fbfdff;
    padding: 0.6rem;
}

.help-faq-item + .help-faq-item {
    margin-top: 0.45rem;
}

.help-faq-item h4 {
    margin: 0 0 0.3rem;
    color: #1f3d5a;
    font-size: 0.9rem;
}

.help-faq-item p,
.help-section p {
    margin: 0;
    color: #37536e;
    line-height: 1.45;
    font-size: 0.9rem;
}

.help-section .btn {
    margin-top: 0.6rem;
    display: inline-block;
}

@media (max-width: 640px) {
    .site-header {
        padding: 0.75rem;
    }

    .site-header h1 {
        font-size: 1rem;
    }

    nav a {
        font-size: 0.83rem;
    }

    .container {
        margin-top: 0.7rem;
        padding: 0 0.45rem 1rem;
    }

    .home-banner {
        width: calc(100% - 0.9rem);
        margin-top: -0.4rem;
        margin-bottom: 0.55rem;
        border-radius: 10px;
    }

    .home-banner-image {
        max-height: 240px;
    }

    .home-benefit-grid,
    .home-faq-grid {
        grid-template-columns: 1fr;
    }

    .card {
        padding: 0.7rem;
    }

    .entry-form {
        grid-template-columns: 1fr;
    }

    table {
        min-width: 620px;
    }

    .help-widget {
        right: 0.7rem;
        bottom: 0.7rem;
    }

    .help-fab {
        width: 64px;
        height: 64px;
        font-size: 2rem;
    }

    .help-panel {
        width: min(360px, calc(100vw - 1rem));
        max-height: 74vh;
        padding: 0.7rem;
    }

    .body-metrics-chart-grid {
        grid-template-columns: 1fr;
    }

    .progress-grid {
        min-width: 560px;
    }

    .trend-pill {
        width: 100%;
        justify-content: center;
    }

}
