:root {
    --bg: #f6f2ea;
    --card: #ffffff;
    --surface: rgba(255, 255, 255, 0.9);
    --text: #1f2328;
    --muted: #6b7178;
    --primary: #1f8a70;
    --primary-strong: #176f5a;
    --accent: #f4a261;
    --ring: rgba(31, 138, 112, 0.25);
    --border: rgba(27, 31, 35, 0.12);
    --shadow: 0 24px 40px rgba(20, 24, 32, 0.12);
    --font-heading: "Space Grotesk", sans-serif;
    --font-body: "Source Sans 3", sans-serif;
}

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

body {
    font-family: var(--font-body);
    color: var(--text);
    background: radial-gradient(circle at top left, #f3e6d7 0%, rgba(243, 230, 215, 0) 55%),
        linear-gradient(180deg, #f7f2ec 0%, #eef1f4 55%, #e7f2ee 100%);
    min-height: 100vh;
}

body::before,
body::after {
    content: "";
    position: fixed;
    width: 320px;
    height: 320px;
    border-radius: 50%;
    filter: blur(20px);
    opacity: 0.35;
    z-index: -1;
}

body::before {
    background: #f4a261;
    top: -120px;
    right: -80px;
}

body::after {
    background: #1f8a70;
    bottom: -140px;
    left: -100px;
}

#app {
    min-height: 100vh;
}

.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding: 28px clamp(16px, 4vw, 40px) 40px;
}

.top-nav {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.site-nav {
    position: relative;
    display: flex;
    align-items: center;
}

.menu-toggle {
    width: 72px;
    height: 72px;
    padding: 0 16px;
    border: 1px solid var(--border);
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.86);
    box-shadow: var(--shadow);
    cursor: pointer;
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
    backdrop-filter: blur(14px);
    transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.menu-toggle:hover {
    transform: translateY(-1px);
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 18px 34px rgba(20, 24, 32, 0.16);
}

.menu-toggle__line {
    width: 100%;
    height: 5px;
    border-radius: 999px;
    background: #2f3135;
    transition: transform 0.18s ease, opacity 0.18s ease;
}

.menu-toggle.is-open .menu-toggle__line:nth-child(1) {
    transform: translateY(13px) rotate(45deg);
}

.menu-toggle.is-open .menu-toggle__line:nth-child(2) {
    opacity: 0;
}

.menu-toggle.is-open .menu-toggle__line:nth-child(3) {
    transform: translateY(-13px) rotate(-45deg);
}

.site-sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(20, 24, 32, 0.34);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
    z-index: 39;
}

.site-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: min(360px, calc(100vw - 24px));
    height: 100vh;
    padding: 28px 20px 24px;
    background:
        radial-gradient(circle at top left, rgba(244, 162, 97, 0.16) 0%, rgba(244, 162, 97, 0) 42%),
        linear-gradient(180deg, rgba(247, 242, 236, 0.98) 0%, rgba(238, 241, 244, 0.98) 100%);
    border-right: 1px solid rgba(27, 31, 35, 0.1);
    box-shadow: 24px 0 48px rgba(20, 24, 32, 0.18);
    transform: translateX(calc(-100% - 24px));
    transition: transform 0.24s ease;
    z-index: 40;
    overflow-y: auto;
}

body.sidebar-open {
    overflow: hidden;
}

body.sidebar-open .site-sidebar {
    transform: translateX(0);
}

body.sidebar-open .site-sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
}

.site-sidebar__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
}

.site-sidebar__brand {
    font-family: var(--font-heading);
    font-size: 24px;
    font-weight: 700;
    line-height: 1.1;
    color: var(--text);
    text-decoration: none;
    max-width: 220px;
}

.site-sidebar__brand:hover {
    color: var(--primary-strong);
}

.site-sidebar__close {
    width: 42px;
    height: 42px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.88);
    color: var(--text);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    transition: transform 0.15s ease, background 0.15s ease;
}

.site-sidebar__close:hover {
    transform: translateY(-1px);
    background: #fff;
}

.site-sidebar__nav {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.site-nav-link,
.site-nav-sublink,
.site-nav-group summary {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 54px;
    padding: 14px 16px;
    border: 1px solid transparent;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.72);
    color: var(--text);
    font-weight: 600;
    text-decoration: none;
    box-shadow: 0 10px 20px rgba(20, 24, 32, 0.06);
    transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.site-nav-link:hover,
.site-nav-sublink:hover,
.site-nav-group summary:hover {
    transform: translateX(2px);
    background: rgba(255, 255, 255, 0.92);
}

.site-nav-link.is-active,
.site-nav-sublink.is-active,
.site-nav-group.is-active summary {
    border-color: rgba(31, 138, 112, 0.28);
    background: rgba(31, 138, 112, 0.13);
    color: var(--primary-strong);
}

.site-nav-link--muted {
    color: var(--muted);
}

.site-nav-group {
    border: 1px solid rgba(27, 31, 35, 0.08);
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.5);
    overflow: hidden;
}

.site-nav-group summary {
    list-style: none;
    cursor: pointer;
    font-family: var(--font-heading);
    font-size: 16px;
    justify-content: space-between;
    box-shadow: none;
    border-radius: 0;
    background: transparent;
}

.site-nav-group summary::-webkit-details-marker {
    display: none;
}

.site-nav-group summary::after {
    content: "+";
    font-size: 22px;
    line-height: 1;
    color: var(--primary-strong);
}

.site-nav-group[open] summary::after {
    content: "−";
}

.site-nav-submenu {
    display: grid;
    gap: 8px;
    padding: 0 12px 12px;
}

.site-nav-sublink {
    position: relative;
    min-height: 48px;
    padding: 12px 14px 12px 24px;
    font-size: 14px;
    background: rgba(246, 242, 234, 0.88);
    box-shadow: none;
}

.site-nav-sublink::before {
    content: "";
    position: absolute;
    left: 12px;
    top: 50%;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: rgba(31, 138, 112, 0.3);
    transform: translateY(-50%);
}

.site-nav-sublink.is-active::before {
    background: var(--primary);
}

.nav-btn {
    border: 1px solid transparent;
    border-radius: 999px;
    padding: 10px 18px;
    background: var(--surface);
    color: var(--text);
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 10px 18px rgba(20, 24, 32, 0.08);
    transition: background 0.15s ease, transform 0.15s ease, border 0.15s ease;
}

.nav-btn:hover {
    background: #f3f4f2;
    transform: translateY(-1px);
}

.nav-btn.is-active {
    border-color: rgba(31, 138, 112, 0.4);
    background: rgba(31, 138, 112, 0.15);
    color: var(--primary-strong);
}

.page-header {
    text-align: center;
    padding: 28px 20px;
    background: var(--surface);
    border-radius: 18px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.logo {
    margin-bottom: 12px;
}

.page-header h1 {
    font-family: var(--font-heading);
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
}

.subtitle {
    color: var(--muted);
    font-size: 15px;
}

.description {
    color: var(--muted);
    font-size: 15px;
    max-width: 520px;
    margin: 12px auto 0;
    line-height: 1.6;
}

button {
    font-family: inherit;
}

.icon-btn,
.month-pill {
    border: none;
    border-radius: 999px;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.icon-btn {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: #f1f4f3;
    display: grid;
    place-items: center;
    font-weight: 700;
    color: var(--text);
}

.icon-btn:hover {
    background: #e6eceb;
}

.icon-btn.is-disabled,
.icon-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.app-main {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 24px;
}

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.panel {
    background: var(--card);
    border-radius: 18px;
    padding: 18px;
    border: 1px solid var(--border);
    box-shadow: 0 16px 30px rgba(22, 28, 35, 0.08);
}

.panel-title {
    font-family: var(--font-heading);
    font-weight: 600;
    margin-bottom: 8px;
}

.selected-date {
    font-size: 18px;
    font-weight: 600;
}

.month-pill-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.month-pill {
    text-align: left;
    padding: 10px 14px;
    background: #f2f4f4;
    border-radius: 14px;
    font-weight: 600;
    color: var(--text);
}

.month-pill:hover {
    background: #e6eceb;
}

.month-pill.is-active {
    background: rgba(31, 138, 112, 0.16);
    color: var(--primary-strong);
}

.calendar-area {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.calendar-card {
    background: var(--card);
    border-radius: 24px;
    padding: 20px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.calendar-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}

.month-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.month-label {
    font-family: var(--font-heading);
    font-size: 20px;
    font-weight: 600;
}

.weekday-row {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
    font-size: 12px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 10px;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
}

.day {
    min-height: 100px;
    border-radius: 16px;
    border: 1px solid transparent;
    background: #f7f8f7;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    transition: border 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.day:hover {
    border-color: var(--primary);
    box-shadow: 0 10px 16px rgba(31, 138, 112, 0.2);
    transform: translateY(-1px);
}

.day--empty {
    background: transparent;
    border: none;
    cursor: default;
    pointer-events: none;
}

.day--muted {
    color: var(--muted);
    background: #f0f1f0;
}

.day--today {
    border: 2px solid var(--accent);
    box-shadow: none;
}

.day--selected {
    background: var(--primary);
    color: white;
    box-shadow: 0 12px 22px rgba(31, 138, 112, 0.35);
}

.day--future,
.day:disabled {
    color: #9aa0a6;
    background: #ececec;
    cursor: not-allowed;
    box-shadow: none;
}

.day--future:hover,
.day:disabled:hover {
    border-color: transparent;
    transform: none;
}

/* Holiday styling */
.day--holiday {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.day-number {
    font-weight: 600;
}

.holiday-label {
    font-size: 10px;
    font-weight: 600;
    color: #c05e1a;
    line-height: 1.2;
    text-align: center;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.day--selected .holiday-label {
    color: rgba(255, 255, 255, 0.85);
}

.day--future.day--holiday .holiday-label {
    color: #9aa0a6;
}

.day--has-markers {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.activity-markers {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.activity-marker {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    display: inline-block;
}

.marker-drinking {
    background: #02006c;
}

.marker-gambling {
    background: #d97706;
}

/* No-activity X indicators on calendar days */
.no-drink-x {
    font-size: 12px;
    font-weight: 700;
    color: #d32f2f;
    line-height: 1;
}

.no-gamble-x {
    font-size: 12px;
    font-weight: 700;
    color: #1565c0;
    line-height: 1;
}

.day--selected .no-drink-x {
    color: #ff8a80;
}

.day--selected .no-gamble-x {
    color: #82b1ff;
}

/* Entry summary sidebar */
.entry-summary {
    margin-top: 8px;
}

.marker-legend {
    margin-top: 20px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.legend-title {
    font-family: var(--font-heading);
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 6px;
}

.entry-empty {
    color: var(--muted);
    font-size: 14px;
}

.entry-section {
    margin-bottom: 12px;
}

.entry-section-title {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 15px;
    color: var(--primary-strong);
    margin-bottom: 4px;
}

.entry-row {
    font-size: 14px;
    padding: 2px 0;
}

.entry-label {
    font-weight: 600;
}

button:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--ring);
}

@media (max-width: 980px) {
    .app-main {
        grid-template-columns: 1fr;
    }

    .sidebar {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .sidebar .panel {
        flex: 1 1 220px;
    }

    .month-pill-list {
        flex-direction: row;
        flex-wrap: wrap;
    }
}

@media (max-width: 640px) {
    .page-header {
        text-align: left;
    }

    .calendar-toolbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .weekday-row,
    .calendar-grid {
        gap: 6px;
    }

    .day {
        min-height: 48px;
        font-size: 14px;
    }
}

.home-main {
    display: flex;
    justify-content: center;
}

.panel-text {
    color: var(--muted);
    margin-bottom: 16px;
}

.nav-btn,
.nav-btn:visited {
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

/* Modal Box */
.modal-content {
    background: white;
    padding: 30px;
    border-radius: 20px;
    width: 90%;
    max-width: 400px;
    box-shadow: var(--shadow);
    max-height: 90vh;       /* Never taller than 90% of view */
    overflow-y: auto;       /* Scroll inside if too tall */
    display: flex;
    flex-direction: column;
}

.modal-input {
    width: 100%;
    padding: 12px;
    margin: 10px 0 20px 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 16px;
}

/* Hide number input spinner arrows in all browsers */
.modal-input[type="number"]::-webkit-inner-spin-button,
.modal-input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.modal-input[type="number"] {
    -moz-appearance: textfield;
}

.modal-actions {
    display: flex;
    gap: 12px;
}

.modal-actions button {
    flex: 1;
}

.modal-mode-text {
    margin: 8px 0 14px;
    color: var(--muted);
    font-size: 13px;
}

/* Instructions page */
.instructions-content {
    max-width: 800px;
    margin: 0 auto;
    line-height: 1.8;
    font-size: 15px;
    color: var(--text);
}

.instructions-content p {
    margin-bottom: 16px;
}

.instructions-content h2 {
    font-family: var(--font-heading);
    font-size: 22px;
    font-weight: 700;
    color: var(--primary-strong);
    margin: 28px 0 12px;
}

.instructions-content ol {
    padding-left: 24px;
    margin-bottom: 16px;
}

.instructions-content ol > li {
    margin-bottom: 12px;
}

.instructions-content ul {
    list-style: disc;
    padding-left: 24px;
    margin-top: 8px;
}

.instructions-content ul > li {
    margin-bottom: 12px;
}

.instructions-example {
    color: var(--primary-strong);
    font-style: italic;
    margin: 4px 0 8px;
    font-size: 14px;
}

.instructions-note {
    color: var(--muted);
    margin: 4px 0 8px;
    font-size: 14px;
    line-height: 1.7;
}

/* FAQ accordion items */
.faq-item {
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 10px;
    margin-bottom: 10px;
    padding: 0;
    overflow: hidden;
}

.faq-item summary {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 15px;
    padding: 14px 18px;
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 10px;
    user-select: none;
}

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

.faq-item summary::before {
    content: '+';
    font-size: 18px;
    line-height: 1;
    color: var(--primary, #6c63ff);
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.faq-item[open] summary::before {
    content: '−';
}

.faq-item p {
    margin: 0 18px 10px;
}

.faq-item p:first-of-type {
    margin-top: 4px;
}

/* Hide sections until their checkbox is checked */
.section-disabled {
    display: none;
}

/* ── Auth pages ──────────────────────────────────────────── */
.auth-wrapper {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 8px 0 40px;
}

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

.auth-title {
    font-family: var(--font-heading);
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
}

.auth-subtitle {
    color: var(--muted);
    font-size: 14px;
    margin-bottom: 24px;
}

.auth-footer {
    text-align: center;
    margin-top: 20px;
    font-size: 14px;
    color: var(--muted);
}

.auth-link {
    color: var(--primary);
    font-weight: 600;
    text-decoration: none;
}

.auth-link:hover {
    text-decoration: underline;
}

/* Form elements */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 16px;
}

.form-label {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text);
}

.form-input {
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-family: var(--font-body);
    font-size: 15px;
    color: var(--text);
    background: #fafafa;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    outline: none;
}

.form-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--ring);
    background: #fff;
}

.form-hint {
    margin-top: 5px;
    font-size: 12px;
    color: var(--muted);
    line-height: 1.5;
}

/* Error list */
.error-list {
    list-style: none;
    background: #fff3f3;
    border: 1px solid #f5c6c6;
    border-radius: 10px;
    padding: 12px 16px;
    margin-bottom: 20px;
}

.error-item {
    color: #c0392b;
    font-size: 14px;
    padding: 2px 0;
}

.error-item + .error-item {
    margin-top: 4px;
}

/* Primary submit button */
.btn-primary {
    width: 100%;
    padding: 12px;
    background: var(--primary);
    color: #fff;
    font-family: var(--font-heading);
    font-size: 15px;
    font-weight: 600;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    margin-top: 8px;
    transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.btn-primary:hover {
    background: var(--primary-strong);
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(31, 138, 112, 0.3);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    padding: 12px 16px;
    background: #eef3f1;
    color: var(--text);
    font-family: var(--font-heading);
    font-size: 15px;
    font-weight: 600;
    border: 1px solid rgba(31, 138, 112, 0.22);
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.btn-secondary:hover {
    background: #e1ece8;
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(31, 138, 112, 0.16);
}

/* Reset filters link button */
.btn-tertiary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 16px;
    background: transparent;
    color: var(--muted);
    font-family: var(--font-heading);
    font-size: 15px;
    font-weight: 600;
    border: 1px dashed rgba(27, 31, 35, 0.2);
    border-radius: 10px;
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.btn-tertiary:hover {
    background: rgba(31, 138, 112, 0.06);
    color: var(--text);
    border-color: rgba(31, 138, 112, 0.35);
}

/* Reports page layout */
.report-page {
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.page-content {
    width: 100%;
}

.report-header {
    text-align: center;
    margin: 36px auto 28px;
    padding: 0 20px;
}

.report-header h1 {
    font-family: var(--font-heading);
    font-size: clamp(36px, 5vw, 56px);
    margin-bottom: 12px;
}

.report-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 24px;
    margin-bottom: 28px;
}

.report-card,
.report-table-card {
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid var(--border);
    border-radius: 24px;
    box-shadow: var(--shadow);
}

.report-card {
    padding: 28px;
}

.report-card h2,
.report-table-card h2 {
    font-family: var(--font-heading);
    font-size: 22px;
    margin-bottom: 8px;
}

.report-card-copy {
    color: var(--muted);
    font-size: 15px;
    line-height: 1.6;
}

.report-form {
    margin-top: 22px;
}

.report-checkbox {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 6px 0 18px;
    color: var(--text);
    font-size: 14px;
}

.report-checkbox input {
    margin-top: 2px;
}

.report-actions {
    display: grid;
    /* Reset + View + Download */
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.report-actions .btn-tertiary,
.report-actions .btn-primary,
.report-actions .btn-secondary {
    width: 100%;
    margin-top: 0;
}

.report-table-card {
    padding: 24px;
}

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

.report-filter-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
}

.filter-pill {
    display: inline-flex;
    align-items: center;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(31, 138, 112, 0.12);
    color: var(--primary-strong);
    font-size: 13px;
    font-weight: 600;
}

.status-banner {
    max-width: 1200px;
    margin: 0 auto 18px;
    padding: 14px 18px;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 12px 24px rgba(20, 24, 32, 0.08);
    font-weight: 600;
}

.status-banner--success {
    color: var(--primary-strong);
    border-color: rgba(31, 138, 112, 0.25);
    background: rgba(31, 138, 112, 0.1);
}

.status-banner--error {
    color: #9f2a2a;
    border-color: rgba(159, 42, 42, 0.2);
    background: rgba(217, 79, 79, 0.12);
}

.expense-page {
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.expense-header {
    margin-bottom: 18px;
}

.expense-month-card,
.expense-card-header,
.expense-month-form {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.expense-month-card {
    padding: 24px 28px;
    margin-bottom: 22px;
}

.expense-month-group {
    margin-bottom: 0;
    min-width: min(280px, 100%);
}

.expense-summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
    margin-bottom: 24px;
}

.expense-summary-card {
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 20px 22px;
    box-shadow: 0 16px 28px rgba(20, 24, 32, 0.08);
}

.expense-summary-label {
    display: block;
    font-size: 14px;
    color: var(--muted);
    margin-bottom: 8px;
}

.expense-summary-value {
    font-family: var(--font-heading);
    font-size: clamp(24px, 3vw, 32px);
    line-height: 1.1;
}

.expense-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
    gap: 24px;
    align-items: start;
}

.expense-form-card,
.expense-chart-card {
    padding: 28px;
}

.expense-card-header {
    margin-bottom: 24px;
}

.expense-download-btn {
    text-decoration: none;
    white-space: nowrap;
}

.expense-form {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.expense-section {
    background: #f9fbfa;
    border: 1px solid rgba(31, 138, 112, 0.12);
    border-radius: 20px;
    padding: 20px;
}

.expense-section--income {
    background: linear-gradient(135deg, rgba(31, 138, 112, 0.08), rgba(255, 255, 255, 0.98));
}

.expense-section-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}

.expense-section-title-row h3 {
    font-family: var(--font-heading);
    font-size: 22px;
}

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

.expense-field-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px;
    border-radius: 16px;
    background: #fff;
    border: 1px solid rgba(27, 31, 35, 0.08);
}

.expense-field-label {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.4;
}

.expense-input-wrap {
    position: relative;
}

.expense-input-prefix {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    font-weight: 600;
}

.expense-input {
    padding-left: 30px;
}

.expense-form-actions {
    display: flex;
    justify-content: flex-end;
}

.expense-form-actions .btn-primary {
    width: auto;
    min-width: 180px;
    margin-top: 0;
}

.expense-chart-wrap {
    display: grid;
    gap: 22px;
}

.expense-pie-shell {
    position: relative;
    width: min(320px, 100%);
    aspect-ratio: 1 / 1;
    margin: 0 auto;
}

.expense-pie-chart {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: linear-gradient(135deg, #eef3f1, #dce8e2);
    box-shadow: inset 0 0 0 1px rgba(31, 138, 112, 0.18);
}

.expense-pie-center {
    position: absolute;
    inset: 50%;
    width: 42%;
    height: 42%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.96);
    display: grid;
    place-items: center;
    text-align: center;
    padding: 10px;
    box-shadow: 0 8px 18px rgba(20, 24, 32, 0.08);
}

.expense-pie-center span {
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.expense-pie-center strong {
    font-family: var(--font-heading);
    font-size: 18px;
    line-height: 1.2;
}

.expense-chart-legend {
    display: grid;
    gap: 12px;
}

.expense-legend-row,
.expense-legend-identity {
    display: flex;
    align-items: center;
}

.expense-legend-row {
    justify-content: space-between;
    gap: 14px;
    padding: 12px 14px;
    border-radius: 14px;
    background: #f8faf9;
    border: 1px solid rgba(27, 31, 35, 0.08);
}

.expense-legend-identity {
    gap: 10px;
}

.expense-legend-swatch {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.expense-legend-label,
.expense-legend-value {
    font-size: 14px;
}

.expense-legend-label {
    font-weight: 600;
}

.expense-legend-value {
    color: var(--muted);
    text-align: right;
}

.report-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: #fff;
}

.report-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 960px;
}

.report-table th,
.report-table td {
    padding: 12px 14px;
    border-bottom: 1px solid rgba(27, 31, 35, 0.08);
    text-align: left;
    font-size: 14px;
    white-space: nowrap;
}

.report-table th {
    background: #f5f7f6;
    font-family: var(--font-heading);
    font-size: 13px;
    letter-spacing: 0.03em;
}

.report-table tbody tr:hover {
    background: #f8fbfa;
}

.report-empty {
    padding: 30px 18px;
    border: 1px dashed rgba(31, 138, 112, 0.25);
    border-radius: 18px;
    color: var(--muted);
    text-align: center;
    background: rgba(255, 255, 255, 0.55);
}

@media (max-width: 520px) {
    .form-row {
        grid-template-columns: 1fr;
    }

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

    .report-card,
    .report-table-card {
        padding: 20px;
    }

    .report-table-header {
        flex-direction: column;
    }

    .expense-month-card,
    .expense-card-header,
    .expense-month-form {
        flex-direction: column;
        align-items: stretch;
    }

    .expense-form-card,
    .expense-chart-card,
    .expense-month-card {
        padding: 20px;
    }

    .expense-pie-shell {
        width: min(260px, 100%);
    }

    .expense-legend-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .expense-legend-value {
        text-align: left;
    }
}

@media (max-width: 980px) {
    .expense-summary-grid,
    .expense-layout,
    .expense-field-grid {
        grid-template-columns: 1fr;
    }
}
