html { font-family: sans-serif; background: #eee; padding: 1rem; }
body { max-width: 960px; margin: 0 auto; background: white; }
h1 { font-family: serif; color: #377ba8; margin: 1rem 0; }
a { color: #377ba8; }
hr { border: none; border-top: 1px solid lightgray; }
nav { background: lightgray; display: flex; align-items: center; padding: 0 0.5rem; }
nav h1 { flex: auto; margin: 0; }
nav h1 a { text-decoration: none; padding: 0.25rem 0.5rem; }
nav ul  { display: flex; list-style: none; margin: 0; padding: 0; }
nav ul li a, nav ul li span, header .action { display: block; padding: 0.5rem; }
.content { padding: 0 1rem 1rem; }
.content > header { border-bottom: 1px solid lightgray; display: flex; align-items: flex-end; }
.content > header h1 { flex: auto; margin: 1rem 0 0.25rem 0; }
.flash { margin: 1em 0; padding: 1em; background: #cae6f6; border: 1px solid #377ba8; }
.post > header { display: flex; align-items: flex-end; font-size: 0.85em; }
.post > header > div:first-of-type { flex: auto; }
.post > header h1 { font-size: 1.5em; margin-bottom: 0; }
.post .about { color: slategray; font-style: italic; }
.post .body { white-space: pre-line; }
.content:last-child { margin-bottom: 0; }
.content form { margin: 1em 0; display: flex; flex-direction: column; }
.content label { font-weight: bold; margin-bottom: 0.5em; }
.content input, .content textarea { margin-bottom: 1em; }
.content textarea { min-height: 12em; resize: vertical; }
input.danger { color: #cc2f2e; }
input[type=submit] { align-self: start; min-width: 10em; }

/* Admin */
table { width: 100%; border-collapse: collapse; margin: 1rem 0; }
th, td { text-align: left; padding: 0.5rem 0.75rem; border-bottom: 1px solid #ddd; }
th { background: #f5f5f5; }
td form { display: flex; gap: 0.5rem; margin: 0; }
td input[type=password] { flex: 1; }

/* Budget — stat cards */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1rem; margin: 1rem 0 1.5rem; }
.stat-card { background: #f8f9fb; border: 1px solid #e2e6ea; border-radius: 8px; padding: 1rem 1.25rem; }
.stat-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: slategray; margin-bottom: 4px; }
.stat-value { font-size: 1.5rem; font-weight: 700; }
.stat-value.green  { color: #22c55e; }
.stat-value.red    { color: #ef4444; }
.stat-value.orange { color: #f97316; }
.stat-value.blue   { color: #377ba8; }

/* Budget — progress bar */
.budget-progress { margin: 0 0 1.5rem; }
.progress-label { display: flex; justify-content: space-between; font-size: 12px; font-weight: 600; color: slategray; margin-bottom: 4px; }
.progress-wrap { background: #e2e6ea; border-radius: 99px; height: 8px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 99px; transition: width 0.4s; }
.progress-bar.green  { background: #22c55e; }
.progress-bar.orange { background: #f97316; }
.progress-bar.red    { background: #ef4444; }

/* Budget — frequency badges */
.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 20px; white-space: nowrap; }
.badge-monthly     { background: #eef2fe; color: #3b6ff0; }
.badge-quarterly   { background: #fff7ed; color: #f97316; }
.badge-half-yearly { background: #f5f3ff; color: #8b5cf6; }
.badge-yearly      { background: #f0fdf4; color: #22c55e; }

/* Budget — upcoming rows */
.upcoming-header { display: grid; grid-template-columns: 1fr auto auto 64px; gap: 12px; padding: 4px 12px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: slategray; }
.upcoming-row { display: grid; grid-template-columns: 1fr auto auto 64px; gap: 12px; align-items: center; padding: 10px 12px; background: #f8f9fb; border: 1px solid #e2e6ea; border-left: 4px solid transparent; border-radius: 6px; margin-bottom: 6px; }
.item-name { font-weight: 500; }
.item-sub  { font-size: 12px; color: slategray; margin-top: 2px; }
.day-badge { font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 99px; background: #e2e6ea; color: slategray; text-align: center; }
.day-badge--urgent { background: #fde2e2; color: #b91c1c; }
.upcoming-row--large { background: #fffbeb; border-color: #fbbf24; }
.alert-warning { background: #fffbeb; border: 1px solid #fbbf24; border-radius: 6px; padding: 10px 14px; color: #92400e; font-size: 14px; margin-bottom: 12px; }

/* Budget — expandable account cards for upcoming large expenses */
.large-account-card { background: #f8f9fb; border: 1px solid #e2e6ea; border-left: 4px solid transparent;
                       border-radius: 6px; margin-bottom: 8px; overflow: hidden; }
.large-account-header { display: grid; grid-template-columns: 1fr auto auto auto 24px; gap: 12px;
                          align-items: center; padding: 12px 14px; cursor: pointer; }
.large-account-header:hover { background: #f0f2f5; }
.large-account-title { display: flex; align-items: center; }
.large-account-total { font-weight: 700; font-size: 1rem; }
.large-account-arrow { font-size: 12px; color: slategray; transition: transform 0.2s; text-align: center; }
.large-account--open .large-account-arrow { transform: rotate(180deg); }
.large-account-body { display: none; padding: 0 14px 14px; }
.large-account--open .large-account-body { display: block; }
.large-account-contributions { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.large-account-contributions strong { font-size: 12px; color: slategray; margin-right: 4px; }
.contrib-chip { display: inline-block; font-size: 13px; padding: 4px 10px; border-radius: 20px;
                 background: #e2e6ea; color: #333; }
.contrib-chip--you { background: #377ba8; color: white; font-weight: 600; }

/* Budget — horizontal add/edit forms */
.form-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-bottom: 12px; }
.form-row > div { display: flex; flex-direction: column; }
.form-row label { font-size: 13px; font-weight: 600; color: slategray; margin-bottom: 4px; }
.form-row input, .form-row select { margin: 0; }

/* Budget — income form */
.income-form { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; margin: 1rem 0; }
.income-form label { font-weight: bold; margin: 0; }
.income-form input[type=number] { width: 10em; margin: 0; }
.income-form input[type=submit] { min-width: auto; align-self: auto; }

/* Budget — summary + table actions */
.budget-summary { margin: 1rem 0; border-top: 2px solid #377ba8; padding-top: 0.75rem; }
.budget-summary p { margin: 0.25rem 0; }
.budget-summary strong { display: inline-block; min-width: 220px; }
.budget-actions { display: flex; gap: 0.5rem; align-items: center; }
.budget-actions form { margin: 0; display: inline; }

/* Budget — page tab navigation (Dashboard / Calendar) */
.budget-tabs { display: flex; gap: 0; margin: 0 0 1.5rem; border-bottom: 2px solid #e2e6ea; }
.budget-tab { display: block; padding: 0.5rem 1.25rem; font-weight: 600; font-size: 14px;
               text-decoration: none; color: slategray; border-bottom: 2px solid transparent;
               margin-bottom: -2px; }
.budget-tab.active { color: #377ba8; border-bottom-color: #377ba8; }
.budget-tab:hover:not(.active) { color: #222; }

/* Budget — settings form */
.settings-form { margin: 1rem 0 1.5rem; display: flex; flex-direction: column; gap: 0.75rem; }
.settings-row { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.settings-row label { font-weight: bold; margin: 0; min-width: 160px; }
.settings-row input[type=number] { width: 5em; margin: 0; }
.settings-check-label { display: flex; align-items: center; gap: 0.5rem; font-weight: normal !important;
                          cursor: pointer; min-width: unset !important; }
.settings-hint { font-size: 12px; color: slategray; }

/* Budget — calendar controls */
.cal-controls { display: flex; justify-content: space-between; align-items: center;
                 margin: 0 0 1.5rem; flex-wrap: wrap; gap: 0.75rem; }
.cal-scope-tabs { display: flex; gap: 0.25rem; }
.cal-scope-tab { padding: 0.35rem 0.9rem; border-radius: 20px; font-size: 13px; font-weight: 600;
                  text-decoration: none; color: slategray; background: #f0f0f0; }
.cal-scope-tab.active { background: #377ba8; color: white; }
.cal-nav { display: flex; gap: 0.5rem; align-items: center; }
.cal-nav-btn { padding: 0.35rem 0.75rem; border-radius: 6px; font-size: 13px; font-weight: 600;
                text-decoration: none; background: #f0f0f0; color: #377ba8; }
.cal-nav-btn:hover { background: #e2e6ea; }
.cal-period-label { font-weight: 700; font-size: 14px; color: #333; padding: 0 0.25rem; }

/* Budget — calendar month container */
.cal-months-grid { margin: 0 0 1.5rem; overflow: hidden; }
.cal-months-monthly  { display: block; }
.cal-months-quarterly { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 2rem; }
.cal-months-yearly    { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 2rem; }
.cal-month { min-width: 0; }
.cal-month-title { font-size: 1rem; font-weight: 700; color: #377ba8; margin: 0 0 0.5rem; }

/* Budget — calendar grid */
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; }
.cal-dow { text-align: center; font-size: 11px; font-weight: 700; text-transform: uppercase;
            letter-spacing: 0.5px; color: slategray; padding: 4px 0; }
.cal-cell { background: #f8f9fb; border: 1px solid #e2e6ea; border-radius: 4px;
             min-height: 70px; padding: 4px; overflow: hidden; }
.cal-cell-empty { background: transparent; border-color: transparent; min-height: 70px; }
.cal-cell-today { background: #eef4fb; border-color: #377ba8; }
.cal-day-num { display: block; font-size: 11px; font-weight: 700; color: slategray; margin-bottom: 3px; }
.cal-cell-today .cal-day-num { color: #377ba8; }

/* Budget — expense chips on calendar */
.cal-chip { border-radius: 3px; padding: 2px 4px; margin-bottom: 2px; font-size: 10px;
             line-height: 1.3; display: block; overflow: hidden; cursor: default; }
.cal-chip-agg { cursor: pointer; }
.cal-chip-agg:hover { opacity: 0.85; }
.cal-chip-name   { display: block; font-weight: 600; white-space: nowrap;
                    overflow: hidden; text-overflow: ellipsis; }
.cal-chip-amount { display: block; opacity: 0.8; }

/* Budget — calendar expand panel */
.cal-expand { display: none; margin-bottom: 2px; }
.cal-expand-open { display: block; }
.cal-expand-item { font-size: 9px; padding: 1px 4px; color: #555;
                    border-left: 2px solid currentColor; margin-left: 2px; margin-bottom: 1px; }

/* Budget — account color dot */
.account-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%;
                margin-right: 6px; vertical-align: middle; }
.text-muted { color: slategray; }

/* Budget — inline edit form for accounts */
.inline-edit-form { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.inline-edit-form input[type=text] { width: auto; margin: 0; }
.inline-edit-form input[type=color] { width: 2rem; height: 1.5rem; padding: 0; margin: 0; border: 1px solid #ddd; cursor: pointer; }

/* Gallery */
.album-list { list-style: none; padding: 0; }
.album-list li { padding: 0.4rem 0; border-bottom: 1px solid #eee; }
.album-list li a { font-size: 1.1em; }
.image-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; padding: 1rem 0; }
.image-grid figure { margin: 0; text-align: center; }
.image-grid img { width: 100%; height: 160px; object-fit: cover; border: 1px solid #ddd; border-radius: 4px; }
.image-grid figcaption { font-size: 0.75em; color: slategray; margin-top: 0.25em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }