/* ============================================================
   My Money Journal — floral pink/sage palette
   ============================================================ */

:root {
    --bg: #fdf6f0;
    --bg-soft: #faf3ed;
    --card: #ffffff;
    --ink: #4a3a2a;
    --ink-muted: #8a7866;
    --border: #ecd9c8;
    --primary: #e8a4a4;
    --primary-dark: #d88b8b;
    --primary-light: #f5d4d4;
    --primary-bg: #fce8e6;
    --sage: #a8b89d;
    --sage-dark: #8a9b7e;
    --sage-light: #d4dfca;
    --sage-bg: #eef2e7;
    --tan: #d4a574;
    --brown: #6b4f3a;
    --rose: #c98080;
    --lavender: #b5a8c9;
    --mint: #9bc7b8;
    --orange: #e8a878;
    --shadow: 0 2px 8px rgba(180, 140, 120, 0.08);
    --shadow-md: 0 4px 14px rgba(180, 140, 120, 0.12);
    --radius: 14px;
    --radius-sm: 8px;
}

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

html, body {
    background: var(--bg);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", sans-serif;
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
}

body {
    background-image:
        radial-gradient(circle at 10% 10%, rgba(232, 164, 164, 0.08) 0%, transparent 30%),
        radial-gradient(circle at 90% 20%, rgba(168, 184, 157, 0.08) 0%, transparent 30%),
        radial-gradient(circle at 50% 90%, rgba(212, 165, 116, 0.06) 0%, transparent 40%);
    padding: 24px 16px 40px;
}

.app {
    max-width: 1100px;
    margin: 0 auto;
    position: relative;
}

/* Background florals */
.bg-floral {
    position: fixed;
    font-size: 40px;
    color: var(--primary-light);
    opacity: 0.5;
    pointer-events: none;
    z-index: 0;
    user-select: none;
}
.bg-floral.top-left    { top: 30px;  left: 20px; }
.bg-floral.top-right   { top: 30px;  right: 20px; }
.bg-floral.bottom-left { bottom: 30px; left: 20px; }
.bg-floral.bottom-right{ bottom: 30px; right: 20px; }

/* ============================================================
   Header
   ============================================================ */
.app-header {
    text-align: center;
    padding: 30px 20px 20px;
    position: relative;
    z-index: 1;
}

.header-deco {
    display: inline-block;
    font-size: 28px;
    color: var(--primary);
    vertical-align: middle;
    margin: 0 12px;
    opacity: 0.7;
}

.title-script {
    display: inline-block;
    vertical-align: middle;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 42px;
    font-weight: 400;
    color: var(--brown);
    letter-spacing: 1px;
    line-height: 1;
}

.title-script em {
    font-style: italic;
    color: var(--primary-dark);
    font-weight: 400;
}

.tagline {
    color: var(--ink-muted);
    font-size: 13px;
    letter-spacing: 4px;
    margin-top: 8px;
    text-transform: lowercase;
}

/* ============================================================
   Ribbon (section header tag)
   ============================================================ */
.ribbon {
    display: inline-block;
    background: var(--primary);
    color: white;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    padding: 6px 18px;
    border-radius: 4px;
    position: relative;
    margin-bottom: 16px;
    box-shadow: 0 2px 4px rgba(180, 140, 120, 0.15);
}

.ribbon::before,
.ribbon::after {
    content: "";
    position: absolute;
    top: 0;
    width: 8px;
    height: 100%;
    background: inherit;
}
.ribbon::before { left: -4px; clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, 50% 50%); }
.ribbon::after  { right: -4px; clip-path: polygon(0 0, 100% 0, 100% 50%, 0 100%); }

.ribbon-income  { background: var(--sage); }
.ribbon-expense { background: var(--primary); }
.ribbon-balance { background: var(--tan); }
.ribbon-form    { background: var(--primary-dark); }

/* ============================================================
   Cards
   ============================================================ */
.card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    position: relative;
    z-index: 1;
}

/* ============================================================
   Summary Section
   ============================================================ */
.summary {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 22px;
}

.summary-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 18px 18px 16px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.summary-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.summary-value {
    font-family: Georgia, "Times New Roman", serif;
    font-size: 26px;
    font-weight: 600;
    color: var(--ink);
    margin-top: 6px;
    line-height: 1.1;
}

.summary-card.income  .summary-value { color: var(--sage-dark); }
.summary-card.expense .summary-value { color: var(--primary-dark); }
.summary-card.balance .summary-value { color: var(--brown); }

.summary-sub {
    font-size: 11px;
    color: var(--ink-muted);
    margin-top: 4px;
    text-transform: lowercase;
    letter-spacing: 0.5px;
}

/* ============================================================
   Two-column layout
   ============================================================ */
.two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    margin-bottom: 22px;
}

/* ============================================================
   Form
   ============================================================ */
.form-section .form-inner { margin-top: 8px; }

.type-toggle {
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: var(--bg-soft);
    border-radius: var(--radius-sm);
    padding: 4px;
    margin-bottom: 14px;
}

.type-btn {
    background: transparent;
    border: none;
    padding: 9px;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-muted);
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
    font-family: inherit;
}

.type-btn.active[data-type="income"]  { background: var(--sage); color: white; }
.type-btn.active[data-type="expense"] { background: var(--primary); color: white; }
.type-btn:not(.active):hover          { color: var(--ink); }

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.form-group { margin-bottom: 12px; }

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--ink-muted);
    margin-bottom: 5px;
    letter-spacing: 0.3px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    background: white;
    color: var(--ink);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(232, 164, 164, 0.18);
}

.submit-btn {
    width: 100%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    padding: 11px;
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    margin-top: 4px;
    transition: transform 0.15s, box-shadow 0.2s;
    font-family: inherit;
    letter-spacing: 0.5px;
}

.submit-btn:hover {
    box-shadow: 0 4px 10px rgba(216, 139, 139, 0.3);
    transform: translateY(-1px);
}
.submit-btn:active { transform: translateY(0); }

/* ============================================================
   Donut Chart
   ============================================================ */
.donut-wrap {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-top: 12px;
}

.donut-container {
    position: relative;
    width: 170px;
    height: 170px;
    flex-shrink: 0;
}

#donut {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.donut-track {
    fill: none;
    stroke: var(--bg-soft);
    stroke-width: 28;
}

.donut-segment {
    fill: none;
    stroke-width: 28;
    transition: stroke-width 0.2s;
    cursor: pointer;
}

.donut-segment:hover {
    stroke-width: 32;
}

.donut-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    pointer-events: none;
}

.donut-label {
    display: block;
    font-size: 11px;
    color: var(--ink-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.donut-value {
    display: block;
    font-family: Georgia, serif;
    font-size: 20px;
    font-weight: 600;
    color: var(--ink);
    margin-top: 2px;
}

.legend {
    list-style: none;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 170px;
    overflow-y: auto;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--ink);
    padding: 4px 6px;
    border-radius: 4px;
    transition: background 0.15s;
}

.legend-item:hover { background: var(--bg-soft); }

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

.legend-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.legend-pct {
    color: var(--ink-muted);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

/* ============================================================
   Section heads
   ============================================================ */
.section-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    flex-wrap: wrap;
    gap: 10px;
}

.filter-btns {
    display: flex;
    background: var(--bg-soft);
    border-radius: var(--radius-sm);
    padding: 3px;
}

.filter-btn {
    background: transparent;
    border: none;
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 500;
    color: var(--ink-muted);
    cursor: pointer;
    border-radius: 5px;
    transition: all 0.2s;
    font-family: inherit;
    letter-spacing: 0.3px;
}

.filter-btn.active {
    background: var(--card);
    color: var(--ink);
    box-shadow: var(--shadow);
}
.filter-btn:not(.active):hover { color: var(--ink); }

/* ============================================================
   Transactions list
   ============================================================ */
.transactions-section { margin-bottom: 22px; }

.table-wrap {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--card);
}

.txn-row {
    display: grid;
    grid-template-columns: 30px 100px 1fr 130px 110px 30px;
    gap: 10px;
    align-items: center;
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.txn-row:last-child { border-bottom: none; }

.txn-header {
    background: var(--bg-soft);
    color: var(--ink-muted);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.transaction-list {
    list-style: none;
}

.txn-row .num { text-align: right; }

.txn-check {
    width: 16px;
    height: 16px;
    border: 1.5px solid var(--primary);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: white;
}

.txn-check.income  { background: var(--sage); border-color: var(--sage); }
.txn-check.expense { background: var(--primary); border-color: var(--primary); }
.txn-check.none    { background: var(--bg-soft); border-color: var(--border); color: transparent; }

.txn-date {
    color: var(--ink-muted);
    font-variant-numeric: tabular-nums;
    font-size: 12px;
}

.txn-desc {
    font-weight: 500;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.txn-cat {
    font-size: 12px;
    color: var(--ink-muted);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.txn-cat-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.txn-amount {
    font-weight: 700;
    font-family: Georgia, serif;
    font-size: 15px;
    font-variant-numeric: tabular-nums;
}

.txn-amount.income  { color: var(--sage-dark); }
.txn-amount.expense { color: var(--primary-dark); }

.delete-btn {
    background: transparent;
    border: none;
    color: var(--ink-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    font-size: 16px;
    line-height: 1;
    transition: all 0.15s;
    font-family: inherit;
}

.delete-btn:hover {
    background: var(--primary-bg);
    color: var(--primary-dark);
}

/* ============================================================
   Empty state
   ============================================================ */
.empty-state {
    text-align: center;
    padding: 36px 20px;
    color: var(--ink-muted);
}

.empty-state.hidden { display: none; }

.empty-icon {
    font-size: 32px;
    display: block;
    color: var(--primary);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 14px;
    font-weight: 500;
    color: var(--ink);
    margin-bottom: 2px;
}

.empty-state small {
    font-size: 12px;
    color: var(--ink-muted);
}

/* ============================================================
   Calendar
   ============================================================ */
.cal-nav {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cal-title {
    font-family: Georgia, serif;
    font-size: 16px;
    color: var(--brown);
    font-weight: 600;
    min-width: 140px;
    text-align: center;
}

.cal-nav-btn {
    background: var(--bg-soft);
    border: 1px solid var(--border);
    color: var(--ink-muted);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    transition: all 0.15s;
    font-family: inherit;
}

.cal-nav-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.cal-grid-wrap {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 18px;
}

.cal-side { display: flex; flex-direction: column; gap: 12px; }

.cal-month-card {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border-radius: var(--radius-sm);
    padding: 18px;
    text-align: center;
    font-family: Georgia, serif;
    font-size: 22px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 2px;
    box-shadow: var(--shadow);
}

.cal-mini {
    background: var(--bg-soft);
    border-radius: var(--radius-sm);
    padding: 12px;
    border: 1px solid var(--border);
}

.cal-mini-row {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    padding: 4px 0;
    color: var(--ink-muted);
}

.cal-mini-row span:last-child {
    font-family: Georgia, serif;
    font-weight: 600;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}

.cal-mini-row.total {
    border-top: 1px dashed var(--border);
    margin-top: 6px;
    padding-top: 8px;
    font-weight: 600;
}

.cal-mini-row.total span {
    color: var(--brown);
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 1px;
}

.cal-weekdays,
.cal-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.cal-weekdays span {
    text-align: center;
    font-size: 10px;
    font-weight: 600;
    color: var(--ink-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 6px 0;
}

.cal-day {
    aspect-ratio: 1;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    color: var(--ink);
    position: relative;
    cursor: default;
    transition: all 0.15s;
}

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

.cal-day.today {
    background: var(--primary-bg);
    border-color: var(--primary);
    font-weight: 700;
    color: var(--primary-dark);
}

.cal-day.has-txn:hover {
    background: white;
    border-color: var(--primary);
    transform: scale(1.05);
    box-shadow: var(--shadow);
}

.cal-day-num { font-variant-numeric: tabular-nums; }

.cal-day-dots {
    position: absolute;
    bottom: 4px;
    display: flex;
    gap: 2px;
}

.cal-dot {
    width: 4px;
    height: 4px;
    border-radius: 50%;
}

/* ============================================================
   Footer
   ============================================================ */
.app-footer {
    text-align: center;
    padding: 24px 0 8px;
    color: var(--ink-muted);
    font-family: Georgia, serif;
    font-style: italic;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    opacity: 0.8;
}

.app-footer span:first-child,
.app-footer span:last-child {
    color: var(--primary);
    font-size: 16px;
    font-style: normal;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 900px) {
    .summary       { grid-template-columns: repeat(2, 1fr); }
    .two-col       { grid-template-columns: 1fr; }
    .cal-grid-wrap { grid-template-columns: 1fr; }
    .cal-side      { flex-direction: row; }
    .cal-side > *  { flex: 1; }
    .txn-row       { grid-template-columns: 30px 90px 1fr 90px 30px; }
    .txn-row .txn-cat,
    .txn-header span:nth-child(4) { display: none; }
}

@media (max-width: 540px) {
    body { padding: 16px 10px 30px; }
    .title-script  { font-size: 30px; }
    .header-deco   { font-size: 22px; margin: 0 6px; }
    .summary       { grid-template-columns: 1fr 1fr; gap: 10px; }
    .summary-value { font-size: 20px; }
    .donut-wrap    { flex-direction: column; align-items: center; }
    .cal-side      { flex-direction: column; }
    .bg-floral     { display: none; }
}
