@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Manrope:wght@500;600;700;800&display=swap');

:root {
    --ink: #252722;
    --muted: #6b706c;
    --paper: #f5f6f4;
    --surface: #ffffff;
    --line: #e0e3df;
    --primary: rgb(175 1 2);
    --primary-hover: #850102;
    --secondary: #d3ad45;
    --green-accent: #32734f;
    --blue-accent: #24689a;
    --gold: #d3ad45;
    --red: #a63d36;
    --shadow: 0 14px 36px rgba(37, 39, 34, .08);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background: var(--paper);
    font: 15px/1.5 'DM Sans', sans-serif;
}
h1, h2, h3, strong, .brand { font-family: 'Manrope', sans-serif; }
h1, h2, h3, p { margin-top: 0; }
a { color: var(--ink); text-decoration: none; }
a:hover { color: var(--primary); }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.topbar {
    min-height: 68px;
    padding: 0 clamp(18px, 4vw, 56px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink);
}
.brand { display: inline-flex; align-items: center; }
.brand img { display: block; width: 150px; height: 62px; object-fit: contain; }
.topbar-nav { display: flex; align-items: center; gap: 18px; margin-left: auto; margin-right: 22px; }
.topbar-nav a { padding: 8px 0; color: var(--muted); font-size: 14px; font-weight: 600; }
.topbar-nav a:hover { color: var(--primary); }
.topbar-user { display: flex; align-items: center; gap: 18px; font-size: 14px; }
.topbar-user form { margin: 0; }
.profile-link { color: var(--ink); }
.page-shell { width: min(1180px, calc(100% - 36px)); margin: 34px auto 70px; }
.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.page-actions { display: flex; align-items: center; gap: 9px; }
.page-heading h1 { margin: 0; font-size: clamp(24px, 3vw, 32px); line-height: 1.15; }
.eyebrow { margin-bottom: 7px; color: var(--primary); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.muted { color: var(--muted); }
.button {
    min-height: 40px;
    padding: 9px 15px;
    border: 1px solid transparent;
    border-radius: 5px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    cursor: pointer;
    font-weight: 700;
    transition: background .16s ease, border-color .16s ease, transform .16s ease;
}
.button:hover { transform: translateY(-1px); }
.button:not(.button-primary):not(.button-danger):not(.button-quiet) { border-color: var(--line); background: var(--surface); color: var(--ink); }
.button:not(.button-primary):not(.button-danger):not(.button-quiet):hover { background: #f3f4f1; }
.button-primary { background: var(--primary); color: #fff; }
.button-primary:hover { background: var(--primary-hover); }
.button-quiet { min-height: 34px; padding: 6px 10px; border-color: var(--line); background: transparent; color: var(--ink); }
.button-quiet:hover { background: #f3f4f1; }
.row-actions .button-primary { border-color: #dce5ec; background: #f0f4f7; color: var(--blue-accent); }
.row-actions .button-primary:hover { border-color: #c9d8e2; background: #e7eef3; color: #194f78; }
.button-danger { border-color: #e6c6c3; background: #fff8f7; color: var(--red); }
.button-small { min-height: 32px; padding: 5px 9px; font-size: 13px; }
.button-wide { width: 100%; margin-top: 8px; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.search-form { display: flex; width: min(510px, 100%); gap: 8px; }
.field, input, select, textarea {
    width: 100%;
    min-height: 42px;
    padding: 9px 12px;
    border: 1px solid #cbd6cc;
    border-radius: 4px;
    background: #fff;
    color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(175,1,2,.16); border-color: var(--primary); }
.table-wrap { overflow: auto; border: 1px solid var(--line); background: var(--surface); }
table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { padding: 13px 15px; border-bottom: 1px solid #e8ede7; vertical-align: middle; }
th { color: var(--muted); background: #f8faf7; font-size: 11px; font-weight: 700; text-transform: uppercase; }
tbody tr:last-child td { border-bottom: 0; }
.row-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; }
.row-actions form { margin: 0; }
.form-panel, .summary-panel { padding: clamp(18px, 3vw, 28px); border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 17px 20px; }
.form-field { display: grid; gap: 6px; }
.form-field label, .login-form label { color: #36443d; font-size: 13px; font-weight: 700; }
.form-field-full { grid-column: 1 / -1; }
.form-field-checkbox { align-content: end; }
.check-control { min-height: 42px; display: inline-flex; align-items: center; gap: 9px; color: var(--ink); font-size: 14px; }
.check-control input { width: 17px; min-height: 17px; height: 17px; margin: 0; accent-color: var(--primary); }
.section-divider { margin: 26px 0 18px; border: 0; border-top: 1px solid var(--line); }
.section-title { margin-bottom: 16px; font-size: 18px; }
.form-actions { display: flex; justify-content: end; gap: 9px; margin-top: 22px; }
.notice { margin-bottom: 18px; padding: 12px 15px; border: 1px solid; border-radius: 4px; }
.notice p { margin: 0; }
.notice p + p { margin-top: 4px; }
.notice-success { border-color: #b6d6c6; background: #edf7f0; color: #22573f; }
.notice-error { border-color: #e8c1bd; background: #fff3f1; color: #80342e; }
.pagination { margin-top: 18px; overflow-x: auto; }
.pagination nav { width: 100%; }
.pagination nav > div:first-child { display: none; }
.pagination nav > div:last-child { display: flex; width: 100%; justify-content: center; }
.pagination nav > div:last-child > div:first-child { display: none; }
.pagination nav > div:last-child > div:last-child { display: flex; align-items: center; gap: 4px; }
.pagination nav a,
.pagination nav span[aria-current="page"] span,
.pagination nav span[aria-disabled="true"] span {
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border: 1px solid var(--line);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    color: var(--ink);
    font-size: 13px;
    line-height: 1;
}
.pagination nav span[aria-current="page"] span { border-color: var(--primary); background: var(--primary); color: #fff; }
.pagination nav span[aria-disabled="true"] span { color: #8b9690; background: #f7f8f6; }
.pagination nav a:hover { border-color: var(--primary); color: var(--primary); }
.pagination svg { width: 16px !important; height: 16px !important; max-width: 16px; max-height: 16px; display: inline-block; flex: 0 0 16px; vertical-align: middle; }
.login-layout { min-height: min(650px, calc(100vh - 130px)); display: grid; grid-template-columns: 1.1fr .9fr; background: var(--surface); box-shadow: var(--shadow); }
.login-aside { padding: clamp(32px, 7vw, 86px); display: flex; flex-direction: column; justify-content: center; color: #fff; background: linear-gradient(135deg, #282a26, #363832), repeating-linear-gradient(45deg, transparent, transparent 12px, rgba(255,255,255,.035) 13px, rgba(255,255,255,.035) 14px); }
.login-logo { display: block; width: min(220px, 100%); height: 90px; margin-bottom: 28px; object-fit: contain; object-position: left center; }
.login-aside .eyebrow { color: var(--secondary); }
.login-aside h1 { max-width: 460px; margin-bottom: 14px; font-size: clamp(36px, 5vw, 58px); line-height: 1.04; }
.login-aside-note { max-width: 330px; margin: 0; color: #d4e4dc; }
.login-form { width: min(360px, calc(100% - 48px)); margin: auto; display: grid; gap: 10px; }
.login-form h2 { margin-bottom: 10px; font-size: 25px; }
.login-form label:not(:first-of-type) { margin-top: 8px; }
.calendar-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.calendar-meta { display: flex; gap: 10px; align-items: center; }
.calendar-meta select { width: 132px; }
.totals { display: flex; gap: 10px; }
.total-chip { min-width: 145px; padding: 10px 13px; border: 1px solid var(--line); background: #fff; }
.total-chip span { display: block; color: var(--muted); font-size: 11px; }
.total-chip strong { display: block; margin-top: 2px; font-size: 17px; }
.month-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.month-card { min-height: 132px; padding: 17px; border: 1px solid var(--line); background: #fff; color: var(--ink); text-align: left; cursor: pointer; transition: border-color .15s, box-shadow .15s, transform .15s; }
.month-card:hover { transform: translateY(-2px); border-color: var(--secondary); box-shadow: var(--shadow); }
.month-card.is-paid { border-top: 3px solid var(--green-accent); }
.month-card.is-empty { border-top: 3px solid #c4cfc5; }
.month-name { display: block; color: var(--muted); font-size: 12px; }
.month-value { display: block; margin-top: 18px; font-family: 'Manrope', sans-serif; font-size: 22px; font-weight: 800; }
.month-count { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; }
.modal-backdrop { position: fixed; inset: 0; z-index: 20; display: none; align-items: center; justify-content: center; padding: 16px; background: rgba(18,31,26,.55); }
.modal-backdrop.is-open { display: flex; }
.modal { width: min(560px, 100%); max-height: 90vh; overflow: auto; background: #fff; box-shadow: 0 24px 70px rgba(0,0,0,.24); }
.modal-header, .modal-footer { padding: 16px 20px; display: flex; align-items: center; justify-content: space-between; gap: 10px; border-bottom: 1px solid var(--line); }
.modal-footer { justify-content: end; border-top: 1px solid var(--line); border-bottom: 0; }
.modal-body { padding: 20px; }
.contribution-section + .contribution-section { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.entry-row { display: grid; grid-template-columns: 1fr 160px auto; align-items: end; gap: 10px; padding: 13px 0; border-bottom: 1px solid #e8ede7; }
.entry-row:first-child { padding-top: 0; }
.entry-date { color: var(--muted); font-size: 12px; }
.empty-state { padding: 35px 20px; color: var(--muted); text-align: center; }
.status-tag { padding: 4px 8px; border-radius: 3px; background: #edf4ef; color: var(--green-accent); font-size: 11px; font-weight: 700; }
.status-tag.inactive { background: #f2eeee; color: #775654; }

@media (max-width: 760px) {
    .topbar { padding: 6px 12px; flex-wrap: wrap; gap: 4px 10px; }
    .brand img { width: 108px; height: 44px; }
    .topbar-nav { gap: 10px; margin: 0 auto 0 0; }
    .topbar-nav a { font-size: 12px; }
    .topbar-user { gap: 8px; margin-left: auto; font-size: 12px; }
    .profile-link { max-width: 78px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .page-shell { width: min(100% - 24px, 600px); margin-top: 22px; }
    .page-heading, .toolbar, .calendar-toolbar { align-items: stretch; flex-direction: column; }
    .page-actions { width: 100%; flex-wrap: wrap; }
    .search-form { width: 100%; }
    .form-grid { grid-template-columns: 1fr; }
    .form-field-full { grid-column: auto; }
    .login-layout { min-height: auto; grid-template-columns: 1fr; }
    .login-aside { min-height: 230px; padding: 30px 26px; }
    .login-logo { width: 168px; height: 68px; margin-bottom: 20px; }
    .login-aside h1 { font-size: 39px; }
    .login-form { padding: 32px 0; }
    .month-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .month-card { min-height: 116px; padding: 13px; }
    .month-value { font-size: 19px; }
    .pagination nav > div:last-child > div:last-child { flex-wrap: wrap; justify-content: center; }
    .totals { flex-wrap: wrap; }
    .total-chip { flex: 1; }
    .entry-row { grid-template-columns: 1fr 132px; }
    .entry-row .button { grid-column: 1 / -1; }
}