:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-soft: #f9fafb;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --line: #eef0f3;
  --primary: #111827;
  --primary-hover: #000000;
  --income: #047857;
  --expense: #b91c1c;
  --warning: #b45309;
  --critical: #7f1d1d;
  --transfer: #1f4f7a;
  --radius-lg: 24px;
  --radius-md: 16px;
  --shadow-soft: 0 20px 60px rgba(15, 23, 42, 0.08);
  --shadow-card: 0 12px 30px rgba(15, 23, 42, 0.05);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; }
body { font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif; background: var(--bg); color: var(--text); }
a { color: inherit; text-decoration: none; }
.container { width: min(1180px, calc(100% - 40px)); margin: 0 auto; }
.topbar { position: sticky; top: 0; z-index: 20; backdrop-filter: saturate(180%) blur(18px); background: rgba(245,245,247,.82); border-bottom: 1px solid rgba(229,231,235,.75); }
.nav { height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { display: flex; align-items: center; gap: 12px; font-weight: 720; letter-spacing: -0.02em; }
.brand-mark { width: 34px; height: 34px; border-radius: 11px; background: linear-gradient(145deg, #111827, #374151); box-shadow: inset 0 1px 0 rgba(255,255,255,.18); }
.navlinks { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.navlinks a { font-size: 13px; color: #4b5563; padding: 9px 12px; border-radius: 999px; }
.navlinks a.active, .navlinks a:hover { background: #ffffff; color: #111827; box-shadow: 0 6px 18px rgba(15,23,42,.06); }
.navright { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.page { padding: 34px 0 54px; }
.page-header { display: flex; justify-content: space-between; gap: 24px; align-items: flex-end; margin-bottom: 24px; }
.kicker { margin: 0 0 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .14em; font-size: 12px; font-weight: 700; }
h1 { margin: 0; font-size: clamp(30px, 4vw, 48px); line-height: 1.06; letter-spacing: -0.05em; }
h2 { margin: 0 0 16px; font-size: 21px; line-height: 1.2; letter-spacing: -0.03em; }
h3 { margin: 0 0 10px; font-size: 16px; letter-spacing: -0.02em; }
p { line-height: 1.62; }
.subtle { color: var(--muted); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); }
.card-pad { padding: 22px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.metric { padding: 20px; min-height: 132px; display: flex; flex-direction: column; justify-content: space-between; }
.metric-label { color: var(--muted); font-size: 13px; font-weight: 650; }
.metric-value { font-size: 28px; font-weight: 760; letter-spacing: -0.04em; }
.metric-note { color: var(--muted); font-size: 12px; }
.metric.income { border-left: 4px solid var(--income); }
.metric.expense { border-left: 4px solid var(--expense); }
.metric.warning { border-left: 4px solid var(--warning); }
.metric.transfer { border-left: 4px solid var(--transfer); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 999px; padding: 10px 15px; font-size: 13px; font-weight: 700; cursor: pointer; background: var(--primary); color: #fff; transition: .18s ease; }
.btn:hover { background: var(--primary-hover); }
.btn.secondary { background: #fff; color: #111827; border-color: var(--border); }
.btn.secondary:hover { background: #f9fafb; }
.btn.danger { background: #991b1b; color: #fff; }
.btn.small { padding: 7px 11px; font-size: 12px; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.period-filter { display: flex; align-items: end; gap: 10px; padding: 12px; border-radius: 18px; background: #fff; border: 1px solid var(--border); box-shadow: var(--shadow-card); }
.form-row { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0,1fr)); }
.form-field { display: flex; flex-direction: column; gap: 7px; }
label { font-size: 12px; color: #4b5563; font-weight: 700; }
input, select, textarea { width: 100%; border: 1px solid var(--border); background: #fff; border-radius: 14px; padding: 11px 12px; font: inherit; color: var(--text); outline: none; }
textarea { min-height: 92px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: #9ca3af; box-shadow: 0 0 0 4px rgba(17,24,39,.06); }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 18px; background: #fff; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 14px 15px; text-align: left; border-bottom: 1px solid var(--line); font-size: 13px; vertical-align: middle; }
th { color: #6b7280; font-weight: 750; background: #fbfbfc; }
tr:last-child td { border-bottom: 0; }
.amount { font-variant-numeric: tabular-nums; font-weight: 720; }
.amount.income { color: var(--income); }
.amount.expense { color: var(--expense); }
.amount.transfer { color: var(--transfer); }
.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 5px 9px; font-size: 11px; font-weight: 750; background: #f3f4f6; color: #374151; border: 1px solid #e5e7eb; text-transform: capitalize; }
.badge.income, .badge.safe, .badge.approved, .badge.active, .badge.completed { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; }
.badge.expense, .badge.rejected, .badge.over { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.badge.warning, .badge.pending, .badge.partial { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.badge.critical { background: #7f1d1d; color: #fff; border-color: #7f1d1d; }
.badge.transfer, .badge.draft { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.alert { border-radius: 18px; padding: 14px 16px; margin-bottom: 16px; border: 1px solid var(--border); background: #fff; color: #374151; }
.alert.error { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.alert.success { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; }
.auth-shell { min-height: 100vh; display:flex; align-items:center; justify-content:center; padding: 32px; background: radial-gradient(circle at top, #ffffff 0, #f5f5f7 55%, #eceff3 100%); }
.auth-card { width: min(460px,100%); padding: 28px; }
.auth-title { font-size: 30px; letter-spacing: -0.04em; margin: 0 0 8px; }
.auth-subtitle { color: var(--muted); margin: 0 0 24px; }
.progress { height: 10px; background: #f3f4f6; border-radius: 999px; overflow: hidden; }
.progress span { display:block; height:100%; background:#111827; border-radius:999px; }
.progress.warning span { background: var(--warning); }
.progress.over span, .progress.critical span { background: var(--expense); }
.section-stack { display:grid; gap:18px; margin-top:18px; }
.split { display:flex; align-items:center; justify-content:space-between; gap:16px; }
.footer-note { padding: 24px 0; color: var(--muted); font-size: 12px; text-align:center; }
@media (max-width: 900px) { .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; } .page-header { align-items: stretch; flex-direction: column; } .nav { height: auto; padding: 14px 0; align-items:flex-start; flex-direction: column; } .navright { width:100%; justify-content:space-between; } .form-row { grid-template-columns: 1fr; } }


/* v0.2 Financial Period Filter */
.period-filter-v02 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    min-width: 440px;
    padding: 10px 10px 10px 16px;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 28px;
    background: rgba(255, 255, 255, 0.86);
    box-shadow: 0 18px 48px rgba(15, 23, 42, 0.08);
    backdrop-filter: blur(16px);
}

.period-copy {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 150px;
}

.period-eyebrow {
    font-size: 10px;
    line-height: 1;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #8a94a6;
}

.period-copy strong {
    font-size: 14px;
    line-height: 1.25;
    font-weight: 800;
    color: #111827;
    white-space: nowrap;
}

.period-copy small {
    font-size: 11px;
    line-height: 1.25;
    font-weight: 600;
    color: #7a8495;
    white-space: nowrap;
}

.period-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.period-select {
    appearance: none;
    -webkit-appearance: none;
    min-width: 150px;
    height: 42px;
    padding: 0 38px 0 14px;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 22px;
    background-color: #f8fafc;
    background-image:
        linear-gradient(45deg, transparent 50%, #64748b 50%),
        linear-gradient(135deg, #64748b 50%, transparent 50%);
    background-position:
        calc(100% - 18px) 18px,
        calc(100% - 13px) 18px;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    color: #111827;
    font-size: 13px;
    font-weight: 750;
    outline: none;
    cursor: pointer;
}

.period-select.compact {
    min-width: 96px;
}

.period-select:focus {
    border-color: rgba(15, 23, 42, 0.22);
    box-shadow: 0 0 0 4px rgba(15, 23, 42, 0.06);
}

.period-apply {
    height: 42px;
    padding: 0 18px;
    border-radius: 22px;
    white-space: nowrap;
}

@media (max-width: 760px) {
    .period-filter-v02 {
        width: 100%;
        min-width: 0;
        flex-direction: column;
        align-items: stretch;
        border-radius: 24px;
    }

    .period-controls {
        width: 100%;
    }

    .period-select {
        width: 100%;
        min-width: 0;
    }

    .period-apply {
        flex-shrink: 0;
    }
}


/* v0.2 final salary-cycle period filter */
.period-filter-v02 {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 18px;
    min-width: 520px;
    padding: 12px 14px;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 30px;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 18px 48px rgba(15, 23, 42, 0.08);
    backdrop-filter: blur(16px);
}

.period-copy {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 3px;
    min-width: 155px;
    text-align: center;
}

.period-copy strong {
    font-size: 15px;
    line-height: 1.2;
    font-weight: 850;
    color: #111827;
    white-space: nowrap;
}

.period-copy small {
    font-size: 11px;
    line-height: 1.2;
    font-weight: 650;
    color: #7a8495;
    white-space: nowrap;
}

.period-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.period-select {
    appearance: none;
    -webkit-appearance: none;
    min-width: 140px;
    height: 42px;
    padding: 0 36px 0 14px;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 22px;
    background-color: #f8fafc;
    background-image:
        linear-gradient(45deg, transparent 50%, #64748b 50%),
        linear-gradient(135deg, #64748b 50%, transparent 50%);
    background-position:
        calc(100% - 18px) 18px,
        calc(100% - 13px) 18px;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    color: #111827;
    font-size: 13px;
    font-weight: 750;
    outline: none;
    cursor: pointer;
}

.period-select.compact {
    min-width: 94px;
}

.period-select:focus {
    border-color: rgba(15, 23, 42, 0.22);
    box-shadow: 0 0 0 4px rgba(15, 23, 42, 0.06);
}

.period-apply {
    height: 42px;
    padding: 0 18px;
    border-radius: 22px;
    white-space: nowrap;
}

@media (max-width: 760px) {
    .period-filter-v02 {
        width: 100%;
        min-width: 0;
        flex-direction: column;
        align-items: center;
        border-radius: 24px;
    }

    .period-controls {
        width: 100%;
    }

    .period-select {
        width: 100%;
        min-width: 0;
    }

    .period-apply {
        flex-shrink: 0;
    }
}


/* v0.2 premium planning workspace */
.planning-create-card {
    overflow: hidden;
}

.planning-create-form {
    display: grid;
    gap: 22px;
}

.planning-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 20px 22px;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 28px;
    background:
        radial-gradient(circle at top left, rgba(15, 23, 42, 0.08), transparent 34%),
        linear-gradient(135deg, rgba(248, 250, 252, 0.98), rgba(255, 255, 255, 0.92));
}

.planning-kicker {
    display: inline-flex;
    margin-bottom: 6px;
    font-size: 10px;
    font-weight: 850;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: #8a94a6;
}

.planning-hero h2 {
    margin: 0;
    font-size: 24px;
    letter-spacing: -0.04em;
}

.planning-hero p {
    margin: 4px 0 0;
    color: #7a8495;
    font-size: 13px;
    font-weight: 650;
}

.planning-workspace-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

.plan-section-card {
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 28px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 18px 52px rgba(15, 23, 42, 0.07);
    overflow: hidden;
}

.plan-section-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    padding: 18px 18px 14px;
    border-bottom: 1px solid rgba(15, 23, 42, 0.07);
    background: linear-gradient(180deg, rgba(248, 250, 252, 0.94), rgba(255, 255, 255, 0.98));
}

.plan-section-head span {
    display: inline-flex;
    margin-bottom: 5px;
    font-size: 10px;
    font-weight: 850;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #8a94a6;
}

.plan-section-head h3 {
    margin: 0;
    font-size: 17px;
    letter-spacing: -0.025em;
}

.plan-section-head p {
    max-width: 320px;
    margin: 5px 0 0;
    color: #7a8495;
    font-size: 12px;
    line-height: 1.45;
}

.plan-add-btn {
    white-space: nowrap;
}

.plan-lines-list {
    display: grid;
    gap: 12px;
    padding: 14px;
}

.plan-line-card-v02 {
    position: relative;
    padding: 14px;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 22px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.88));
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.05);
}

.plan-line-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.plan-line-label {
    display: block;
    font-size: 13px;
    font-weight: 850;
    color: #111827;
}

.plan-line-top small {
    display: block;
    margin-top: 2px;
    font-size: 11px;
    font-weight: 650;
    color: #8a94a6;
}

.plan-remove-btn {
    border: 0;
    background: transparent;
    color: #7a8495;
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
    padding: 7px 10px;
    border-radius: 999px;
}

.plan-remove-btn:hover {
    background: rgba(15, 23, 42, 0.06);
    color: #111827;
}

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

.plan-description-field {
    margin-top: 10px;
}

.planning-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 2px;
}

.badge.planned {
    background: rgba(15, 23, 42, 0.07);
    color: #334155;
}

.badge.received {
    background: rgba(22, 163, 74, 0.12);
    color: #15803d;
}

.badge.missed {
    background: rgba(220, 38, 38, 0.12);
    color: #b91c1c;
}

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

@media (max-width: 640px) {
    .planning-hero,
    .plan-section-head {
        flex-direction: column;
        align-items: stretch;
    }

    .plan-line-grid {
        grid-template-columns: 1fr;
    }

    .planning-actions {
        flex-direction: column;
    }

    .planning-actions .btn {
        width: 100%;
    }
}
/* end v0.2 premium planning workspace */


/* force money input polish */
.money-input {
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.01em;
    font-weight: 760;
}
/* end force money input polish */


/* v0.2 mark income received */
.inline-receive-form {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
}

.inline-receive-form input[type="date"] {
    min-width: 138px;
    max-width: 150px;
    height: 36px;
    padding: 7px 10px;
    border-radius: 12px;
    font-size: 12px;
}

.inline-receive-form .btn {
    white-space: nowrap;
}

@media (max-width: 720px) {
    .inline-receive-form {
        flex-direction: column;
        align-items: stretch;
    }

    .inline-receive-form input[type="date"],
    .inline-receive-form .btn {
        width: 100%;
        max-width: none;
    }
}
/* end v0.2 mark income received */


/* v0.2 budget scheduled payment fields */
.schedule-meta {
    display: block;
    margin-top: 3px;
    font-size: 11px;
    line-height: 1.35;
}

.plan-section-card.budget-section .plan-line-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (max-width: 640px) {
    .plan-section-card.budget-section .plan-line-grid {
        grid-template-columns: 1fr;
    }
}
/* end v0.2 budget scheduled payment fields */


/* v0.2 confirm scheduled payment */
.inline-pay-form {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
}

.inline-pay-form input[type="date"] {
    min-width: 138px;
    max-width: 150px;
    height: 36px;
    padding: 7px 10px;
    border-radius: 12px;
    font-size: 12px;
}

.inline-pay-form .btn {
    white-space: nowrap;
}

.scheduled-payment-card {
    overflow: hidden;
}

.badge.scheduled {
    background: rgba(245, 158, 11, 0.14);
    color: #b45309;
}

.badge.paid {
    background: rgba(22, 163, 74, 0.12);
    color: #15803d;
}

.badge.skipped,
.badge.cancelled {
    background: rgba(100, 116, 139, 0.14);
    color: #475569;
}

@media (max-width: 720px) {
    .inline-pay-form {
        flex-direction: column;
        align-items: stretch;
    }

    .inline-pay-form input[type="date"],
    .inline-pay-form .btn {
        width: 100%;
        max-width: none;
    }
}
/* end v0.2 confirm scheduled payment */
