:root {
    --aj-navy: #0f2f4a;
    --aj-navy-dark: #081a2d;
    --aj-teal: #0b3f34;
    --aj-teal-light: #1f8f5f;
    --aj-bg: #f7faf9;
    --aj-muted: #52616b;
    --aj-border: #dce8e2;
    --aj-soft: #e5f4ec;
    --aj-card-soft: #f8faf9;
    --aj-danger-bg: #fff1f2;
    --aj-danger-text: #9f1239;
    --aj-danger-border: #fecdd3;
    --aj-shadow: 0 20px 60px rgba(15, 23, 42, 0.08);
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--aj-bg);
    color: var(--aj-navy-dark);
}

.page {
    min-height: 100vh;
    padding: 24px;
}

.shell {
    max-width: 1100px;
    margin: 0 auto;
}

.card {
    background: #ffffff;
    border-radius: 28px;
    padding: 36px;
    box-shadow: var(--aj-shadow);
}

h1 {
    margin: 0 0 12px;
    font-size: 38px;
    line-height: 1.1;
    color: var(--aj-navy-dark);
}

.intro,
p {
    color: var(--aj-muted);
    font-size: 17px;
    line-height: 1.6;
}

.aj-navbar {
    max-width: 1100px;
    margin: 0 auto 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    position: relative;
}

.aj-brand img {
    height: 52px;
    display: block;
}

.aj-menu {
    display: flex;
    align-items: center;
    gap: 10px;
}

.aj-menu a {
    text-decoration: none;
    color: var(--aj-muted);
    font-weight: 800;
    padding: 10px 12px;
    border-radius: 999px;
}

.aj-menu a:hover,
.aj-menu .logout {
    background: var(--aj-card-soft);
    border: 1px solid var(--aj-border);
}

.aj-menu a.active {
    background: transparent;
    color: var(--aj-teal);
    border-bottom: 3px solid var(--aj-teal);
    border-radius: 0;
}

.aj-menu-button {
    display: none;
    border: 0;
    background: var(--aj-soft);
    color: var(--aj-teal);
    border-radius: 14px;
    padding: 10px 14px;
    font-size: 22px;
    font-weight: 900;
    cursor: pointer;
}

.button,
button.button {
    display: inline-block;
    padding: 16px 20px;
    border: 0;
    border-radius: 18px;
    background: var(--aj-teal);
    color: #ffffff;
    font-size: 17px;
    font-weight: 900;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
}

.button:hover,
button.button:hover {
    background: #083229;
}

.button.secondary,
.secondary {
    background: var(--aj-card-soft);
    color: var(--aj-navy-dark);
    border: 1px solid var(--aj-border);
}

.button.secondary:hover,
.secondary:hover {
    background: #eef3f0;
}

.success,
.notice {
    padding: 14px 16px;
    border-radius: 16px;
    background: var(--aj-soft);
    color: var(--aj-teal);
    font-weight: 750;
    line-height: 1.5;
}

.error {
    padding: 14px 16px;
    border-radius: 16px;
    background: var(--aj-danger-bg);
    border: 1px solid var(--aj-danger-border);
    color: var(--aj-danger-text);
    font-weight: 800;
    line-height: 1.5;
}

input[type="date"],
input[type="number"],
input[type="time"],
input[type="text"],
input[type="password"],
textarea,
select {
    width: 100%;
    box-sizing: border-box;
    padding: 13px 14px;
    border: 1px solid var(--aj-border);
    border-radius: 14px;
    font-size: 15px;
    background: #ffffff;
    color: var(--aj-navy-dark);
}

input[type="range"] {
    width: 100%;
    accent-color: var(--aj-teal-light);
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 800;
    color: var(--aj-navy-dark);
}

.filters {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 12px;
    margin-bottom: 32px;
}

.chart-card,
.action-card,
.slider-card {
    background: var(--aj-card-soft);
    border: 1px solid var(--aj-border);
}

.chart-card {
    padding: 24px;
    border-radius: 24px;
    background: var(--aj-card-soft);
    border: 1px solid var(--aj-border);
    margin-top: 12px;
}

.chart-line,
.chart-line-multi {
    fill: none !important;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.chart-line {
    stroke: var(--aj-teal);
}

.chart-line-multi {
    stroke-width: 3;
}

.chart-dot {
    fill: var(--aj-teal);
    stroke: #ffffff;
    stroke-width: 3;
}

.chart-card.wide {
    grid-column: 1 / -1;
    margin-top: 16px;
}

@media (max-width: 700px) {
    .page {
        padding: 16px;
    }

    .card {
        padding: 26px;
        border-radius: 22px;
    }

    h1 {
        font-size: 29px;
    }

    .aj-navbar {
        align-items: flex-start;
    }

    .aj-brand img {
        height: 46px;
    }

    .aj-menu-button {
        display: block;
    }

    .aj-menu {
        display: none;
        position: absolute;
        left: 0;
        right: 0;
        top: 64px;
        padding: 16px;
        background: #ffffff;
        border-radius: 22px;
        box-shadow: 0 20px 60px rgba(15, 23, 42, 0.12);
        flex-direction: column;
        align-items: stretch;
        z-index: 1000;
    }

    body.menu-open .aj-menu {
        display: flex;
    }

    .aj-menu a {
        padding: 14px;
    }
}

/* App homepage */
.app-chart-card {
    margin-top: 28px;
    padding: 24px;
    border-radius: 24px;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 14px;
}

.chart-title {
    font-size: 20px;
    font-weight: 900;
}

.chart-subtitle {
    color: var(--aj-muted);
    margin-top: 4px;
}

.chart-latest {
    font-size: 34px;
    font-weight: 950;
    color: var(--aj-teal);
    white-space: nowrap;
}

.chart-empty {
    padding: 18px;
    border-radius: 18px;
    background: #ffffff;
    border: 1px dashed #d7ded9;
    color: var(--aj-muted);
    font-weight: 700;
}

.chart-svg-wrap {
    overflow-x: auto;
}

.chart-svg {
    width: 100%;
    min-width: 520px;
    height: auto;
    display: block;
}

.chart-axis-text {
    font-size: 12px;
    fill: #7b8794;
}

.chart-grid-line {
    stroke: #dfe7e2;
    stroke-width: 1;
}

.actions {
    margin-top: 30px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.action-card {
    display: block;
    text-decoration: none;
    color: inherit;
    padding: 22px;
    border-radius: 22px;
    background: var(--aj-card-soft);
    border: 1px solid var(--aj-border);
}

.action-card strong {
    display: block;
    margin-bottom: 8px;
    font-size: 18px;
    color: var(--aj-navy-dark);
}

.action-card span {
    display: block;
    color: var(--aj-muted);
    line-height: 1.5;
}

.action-card.primary,
.primary {
    background: var(--aj-teal);
    color: #ffffff;
    border: 0;
}

.action-card.primary strong,
.primary strong {
    color: #ffffff;
}

.action-card.primary span,
.primary span {
    color: #e8fff7;
}

@media (max-width: 700px) {
    .chart-header {
        flex-direction: column;
    }

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

    .chart-svg {
        min-width: 0;
        width: 100%;
    }

    .app-chart-card,
    .chart-card {
        padding: 18px;
    }

    .chart-latest {
        font-size: 28px;
    }

    .chart-svg-wrap {
        overflow-x: hidden;
    }
}

/* extra spacing charts page */
.chart-grid {
    margin-top: 12px;
}

/* Daily journal page */
.date-row {
    margin-bottom: 28px;
    max-width: 220px;
}

.notice {
    margin-bottom: 26px;
}

textarea {
    min-height: 88px;
    resize: vertical;
}

.core-card {
    border: 1px solid var(--aj-border);
    border-radius: 24px;
    padding: 24px;
    background: #ffffff;
}

.section-title {
    margin: 0 0 6px;
    font-size: 20px;
    font-weight: 900;
}

.section-subtitle {
    margin: 0 0 24px;
    color: #7b8794;
}

.slider-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 22px;
}

.slider-card {
    padding: 20px;
    border-radius: 20px;
}

.slider-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    font-weight: 900;
}

.slider-value {
    font-size: 30px;
    color: var(--aj-teal-light);
    font-weight: 900;
}

.range-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 13px;
    color: #7b8794;
}

.feeling-box {
    margin-top: 24px;
    padding: 22px;
    border-radius: 22px;
    background: var(--aj-soft);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.feeling-score {
    font-size: 36px;
    font-weight: 950;
    color: var(--aj-teal-light);
}

.details-title {
    margin: 34px 0 16px;
    text-align: center;
}

.details-title span {
    display: inline-block;
    padding: 12px 20px;
    border-radius: 999px;
    background: var(--aj-soft);
    border: 1px solid var(--aj-border);
    color: var(--aj-teal);
    font-weight: 800;
}

.optional-list {
    display: grid;
    gap: 14px;
}

details.module {
    border: 1px solid var(--aj-border);
    border-radius: 20px;
    background: #ffffff;
    overflow: hidden;
}

details.module summary {
    list-style: none;
    cursor: pointer;
    padding: 18px 20px;
    display: grid;
    grid-template-columns: 48px 1fr auto;
    gap: 14px;
    align-items: center;
}

details.module summary::-webkit-details-marker {
    display: none;
}

.icon {
    width: 44px;
    height: 44px;
    border-radius: 15px;
    display: grid;
    place-items: center;
    background: var(--aj-soft);
    font-size: 22px;
}

.icon.has-data {
    background: var(--aj-teal);
    color: #ffffff;
}

.icon.partial-data {
    background: var(--aj-soft);
    color: var(--aj-teal);
    border: 1px solid #b7e3cc;
}

.module-name {
    font-size: 18px;
    font-weight: 900;
}

.module-desc {
    color: #7b8794;
    margin-top: 2px;
}

.chevron {
    color: var(--aj-teal);
    font-size: 20px;
    font-weight: 900;
}

.module-body {
    padding: 0 20px 20px 82px;
}

.field-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
    margin-top: 12px;
}

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

.field {
    margin-bottom: 14px;
}

.mini-slider .slider-value {
    font-size: 22px;
}

.message {
    margin-bottom: 22px;
    padding: 14px;
    border-radius: 14px;
    font-weight: 800;
}

.savebar {
    margin-top: 28px;
    display: flex;
    gap: 14px;
}

.savebar .button {
    flex: 1;
}

@media (max-width: 900px) {
    .slider-grid,
    .field-grid,
    .field-grid.two {
        grid-template-columns: 1fr;
    }

    .module-body {
        padding: 0 20px 20px 20px;
    }

    details.module summary {
        grid-template-columns: 44px 1fr auto;
    }
}

@media (max-width: 600px) {
    .feeling-box {
        align-items: flex-start;
        gap: 12px;
        flex-direction: column;
    }

    .savebar {
        position: sticky;
        bottom: 14px;
        flex-direction: column;
    }
}

/* Missing days page */
.day-list {
    display: grid;
    gap: 14px;
}

.day-card {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 18px;
    align-items: center;
    padding: 20px;
    border-radius: 22px;
    background: var(--aj-card-soft);
    border: 1px solid var(--aj-border);
}

.day-title {
    font-size: 20px;
    font-weight: 950;
    margin-bottom: 8px;
    color: var(--aj-navy-dark);
}

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

.badge {
    display: inline-block;
    padding: 7px 10px;
    border-radius: 999px;
    background: #fff7ed;
    color: #9a3412;
    border: 1px solid #fed7aa;
    font-size: 13px;
    font-weight: 800;
}

.badge.medication {
    background: var(--aj-soft);
    color: var(--aj-teal);
    border-color: #b7e3cc;
}

.empty-state {
    padding: 22px;
    border-radius: 22px;
    background: var(--aj-soft);
    border: 1px solid var(--aj-border);
    color: var(--aj-teal);
    font-weight: 750;
    line-height: 1.5;
}

@media (max-width: 700px) {
    .day-card {
        grid-template-columns: 1fr;
    }

    .day-card .button {
        text-align: center;
        width: 100%;
        box-sizing: border-box;
    }
}

/* Export page */
.meta-box {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 26px;
}

.meta-item {
    padding: 16px;
    border-radius: 18px;
    background: var(--aj-card-soft);
    border: 1px solid var(--aj-border);
}

.meta-item small {
    display: block;
    color: #7b8794;
    margin-bottom: 6px;
    font-weight: 800;
}

.meta-item div {
    font-weight: 900;
    word-break: break-all;
}

.export-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.export-card {
    padding: 22px;
    border-radius: 22px;
    background: var(--aj-card-soft);
    border: 1px solid var(--aj-border);
    text-align: left;
    cursor: pointer;
    font: inherit;
    color: inherit;
}

.export-card strong {
    display: block;
    margin-bottom: 8px;
    font-size: 18px;
}

.export-card span {
    display: block;
    min-height: 54px;
    color: var(--aj-muted);
    line-height: 1.5;
}

.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(15, 23, 42, 0.42);
    padding: 24px;
    align-items: center;
    justify-content: center;
}

.modal-backdrop.is-visible {
    display: flex;
}

.modal-box {
    width: 100%;
    max-width: 520px;
    background: #ffffff;
    border-radius: 28px;
    padding: 28px;
    box-shadow: 0 30px 90px rgba(15, 23, 42, 0.28);
}

.modal-title {
    font-size: 26px;
    font-weight: 950;
    margin-bottom: 8px;
}

.modal-text {
    color: var(--aj-muted);
    line-height: 1.5;
    margin-bottom: 20px;
}

.format-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.format-option {
    border: 1px solid var(--aj-border);
    background: var(--aj-card-soft);
    border-radius: 18px;
    padding: 16px;
    cursor: pointer;
    font-weight: 900;
    text-align: center;
}

.format-option.is-selected {
    background: var(--aj-soft);
    border-color: var(--aj-teal);
    color: var(--aj-teal);
}

.modal-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

@media (max-width: 760px) {
    .meta-box,
    .export-grid,
    .format-grid,
    .modal-actions {
        grid-template-columns: 1fr;
    }

    .modal-box {
        padding: 24px;
        border-radius: 24px;
    }
}

/* Medication profile page */
.profile-list {
    margin-top: 32px;
}

.profile-card {
    border: 1px solid var(--aj-border);
    border-radius: 16px;
    padding: 18px;
    margin-top: 14px;
    background: var(--aj-card-soft);
}

.profile-title {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-weight: 800;
    margin-bottom: 10px;
    color: var(--aj-navy-dark);
}

.profile-meta {
    color: var(--aj-muted);
    margin-bottom: 10px;
}

.moment-row {
    padding: 10px 0;
    border-top: 1px solid var(--aj-border);
    color: var(--aj-muted);
}

.profile-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 14px;
}

.danger-button {
    width: 100%;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid var(--aj-danger-border);
    background: var(--aj-danger-bg);
    color: var(--aj-danger-text);
    font-weight: 900;
    cursor: pointer;
}

.edit-link,
.button-link,
.cancel-link,
.add-profile-link {
    display: block;
    text-align: center;
    text-decoration: none;
    font-weight: 900;
}

.edit-link,
.button-link {
    padding: 12px;
    border-radius: 12px;
    background: #ffffff;
    color: var(--aj-navy-dark);
    border: 1px solid var(--aj-border);
}

.cancel-link {
    margin-top: 10px;
    color: var(--aj-muted);
    text-align: left;
}

.add-profile-link {
    padding: 14px;
    border-radius: 12px;
    background: var(--aj-teal);
    color: #ffffff;
    margin: 16px 0;
}

.form-card {
    border: 1px solid var(--aj-border);
    border-radius: 16px;
    padding: 18px;
    background: #ffffff;
    margin-top: 16px;
}

.medication-profile-actions {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
    margin-top: 16px;
}

.alert {
    padding: 14px;
    border-radius: 14px;
    margin: 16px 0;
    font-weight: 800;
}

.alert-success {
    background: var(--aj-soft);
    color: var(--aj-teal);
    border: 1px solid #cdebdc;
}

.alert-error {
    background: var(--aj-danger-bg);
    color: var(--aj-danger-text);
    border: 1px solid var(--aj-danger-border);
}

@media (max-width: 650px) {
    .medication-profile-actions,
    .profile-actions {
        grid-template-columns: 1fr;
    }
}


/* Footer */
.aj-footer {
    max-width: 1100px;
    margin: 24px auto 0;
    padding: 22px 8px;
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 18px;
    color: var(--aj-muted);
    font-size: 14px;
    border-top: 1px solid var(--aj-border);
}

.aj-footer strong {
    color: var(--aj-navy-dark);
}

.aj-footer a {
    color: var(--aj-teal);
    font-weight: 800;
    text-decoration: none;
}

.aj-footer a:hover {
    text-decoration: underline;
}

@media (max-width: 700px) {
    .aj-footer {
        grid-template-columns: 1fr;
        text-align: left;
        gap: 12px;
    }
}

/* About page */
.about-page h2 {
    margin: 0 0 10px;
    color: var(--aj-navy-dark);
    font-size: 22px;
}

.about-section {
    margin-top: 26px;
    padding-top: 24px;
    border-top: 1px solid var(--aj-border);
}

.about-section p {
    margin: 0;
}

.about-callout {
    margin-top: 30px;
    padding: 22px;
    border-radius: 22px;
    background: var(--aj-soft);
    color: var(--aj-teal);
    font-size: 18px;
    line-height: 1.5;
    font-weight: 800;
}

.about-visual img {
    width: 100%;
    height: auto;
    border-radius: 20px;
    display: block;

}

/* Authentication screens */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.auth-card {
    width: 100%;
    max-width: 560px;
}

.recovery-card {
    max-width: 620px;
}

.auth-card h1 {
    margin: 0 0 16px;
    font-size: 34px;
    line-height: 1.15;
}

.auth-card input {
    padding: 15px 16px;
    border-radius: 16px;
    font-size: 16px;
}

.auth-card .button {
    margin-top: 24px;
    width: 100%;
    box-sizing: border-box;
}

.auth-card .button.secondary {
    margin-top: 12px;
}

.auth-card .notice,
.auth-card .error,
.auth-card .success {
    margin-top: 18px;
}

.pin-card {
    width: 100%;
    max-width: 520px;
}

.pin-card input[type="password"] {
    padding: 15px 16px;
    border-radius: 16px;
    font-size: 22px;
    letter-spacing: 5px;
    text-align: center;
}

.pin-card .button {
    margin-top: 28px;
    width: 100%;
    box-sizing: border-box;
}

.small {
    margin-top: 16px;
    font-size: 13px;
    color: #7b8794;
    text-align: center;
}

.token-box {
    margin-top: 12px;
    padding: 14px;
    border-radius: 14px;
    background: var(--aj-card-soft);
    border: 1px solid var(--aj-border);
    word-break: break-all;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    color: var(--aj-navy-dark);
}

@media (max-width: 600px) {
    .auth-page {
        padding: 16px;
    }

    .auth-card,
    .pin-card {
        padding: 26px;
        border-radius: 22px;
    }

    .auth-card h1 {
        font-size: 28px;
    }
}