:root {
    --bg-color: #0a0a0a;
    --surface-1: #121212;
    --surface-2: #181818;
    --surface-3: #202020;
    --text-color: #ededed;
    --muted-text: #8f8f8f;
    --border-color: rgba(255, 255, 255, 0.08);
    --focus-color: #f8fafc;
    --accent-color: #d4d4d4;
    --fail-color: #ff6b6b;
    --success-color: #7ddf96;
    --warning-color: #f0c674;
    --btn-bg: #1f1f1f;
    --btn-hover: #2a2a2a;
    --shadow-lg: 0 12px 30px rgba(2, 6, 23, 0.24);
    --shadow-md: 0 8px 20px rgba(2, 6, 23, 0.18);
    --radius-xl: 22px;
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --nav-width: 84px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
}

body {
    position: relative;
    display: flex;
    font-family: "Segoe UI Variable", "SF Pro Display", "Segoe UI", sans-serif;
    color: var(--text-color);
    background: linear-gradient(180deg, #050505 0%, #0a0a0a 100%);
    padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
}

body::before {
    content: "";
    position: fixed;
    inset: 14px;
    border-radius: 26px;
    border: 1px solid rgba(255, 255, 255, 0.03);
    pointer-events: none;
    opacity: 0.8;
}

.sidebar-nav {
    width: var(--nav-width);
    margin: 14px 0 14px 14px;
    padding: 12px 10px;
    border-radius: 22px;
    background: #0d0d0d;
    border: 1px solid rgba(255, 255, 255, 0.04);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    box-shadow: var(--shadow-md);
    z-index: 10;
}

.nav-item {
    width: 60px;
    min-height: 60px;
    padding: 8px 6px;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    color: var(--muted-text);
    transition: transform 0.2s ease, background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
}

.nav-item svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
}

.nav-item:hover,
.nav-item.active {
    background: #242424;
    color: var(--focus-color);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
    transform: translateY(-1px);
}

.nav-item-profile {
    margin-top: auto;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.01));
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.main-wrapper {
    flex: 1;
    height: 100dvh;
    min-height: 100dvh;
    padding: 14px;
    display: flex;
    justify-content: center;
    align-items: stretch;
    min-width: 0;
}

.view-section {
    display: none;
    width: 100%;
    max-width: 1480px;
    height: calc(100dvh - 28px - var(--safe-top) - var(--safe-bottom));
    padding: 14px 18px;
    border-radius: var(--radius-xl);
    background: var(--surface-1);
    border: 1px solid rgba(255, 255, 255, 0.04);
    box-shadow: var(--shadow-lg);
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

#finance-view {
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: #050505 #111111;
}

#finance-view::-webkit-scrollbar {
    width: 10px;
}

#finance-view::-webkit-scrollbar-track {
    background: #111111;
    border-radius: 999px;
}

#finance-view::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #050505 0%, #1b1b1b 100%);
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

#finance-view::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #0b0b0b 0%, #252525 100%);
}

.view-section.active {
    display: flex;
}

body.app-locked .nav-item:not(.nav-item-profile) {
    opacity: 0.35;
    filter: blur(1px);
}

body.app-locked .nav-item:not(.nav-item-profile):hover {
    transform: none;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding-bottom: 10px;
    margin-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.header-left {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.header-left h1 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--focus-color);
}

.header-actions,
.date-container {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted-text);
}

input[type="date"],
input[type="month"],
input[type="text"],
input[type="number"],
textarea,
select {
    width: 100%;
    min-width: 0;
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 10px;
    font-family: inherit;
    background: #141414;
    color: var(--text-color);
    outline: none;
    padding: 7px 10px;
    font-size: 12px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

input:focus,
textarea:focus,
select:focus {
    border-color: rgba(255, 255, 255, 0.18);
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.04);
    background: #191919;
}

::placeholder {
    color: #6f6f6f;
}

.btn {
    border: 1px solid rgba(255, 255, 255, 0.07);
    background: var(--btn-bg);
    color: var(--text-color);
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    cursor: pointer;
    transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
    font-family: inherit;
}

.btn:hover {
    background: var(--btn-hover);
    border-color: rgba(255, 255, 255, 0.12);
    color: var(--focus-color);
    transform: translateY(-1px);
}

.btn-danger:hover {
    background: rgba(251, 113, 133, 0.12);
    border-color: rgba(251, 113, 133, 0.36);
    color: #ffd3dc;
}

h2 {
    margin: 0 0 8px;
    padding-bottom: 6px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted-text);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

h3 {
    margin: 0;
}

.planner-shell {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.9fr);
    gap: 12px;
}

.planner-main-card,
.planner-side-card,
.fin-card,
.summary-box,
.score-box,
.progress-box {
    min-height: 0;
    padding: 14px;
    border-radius: var(--radius-lg);
    background: #141414;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.planner-main-card,
.planner-side-stack {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.planner-card-head {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.planner-card-head h2 {
    margin-bottom: 0;
}

.planner-card-head p {
    margin: 0;
    font-size: 12px;
    line-height: 1.5;
    color: var(--muted-text);
}

.planner-add-row {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(120px, 0.7fr) auto;
    gap: 10px;
    align-items: center;
}

.planner-items {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    padding-right: 2px;
}

.planner-items::-webkit-scrollbar,
.planner-summary-card textarea::-webkit-scrollbar {
    width: 8px;
}

.planner-items::-webkit-scrollbar-thumb,
.planner-summary-card textarea::-webkit-scrollbar-thumb {
    background: #232323;
    border-radius: 999px;
}

.planner-item-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    padding: 12px;
    border-radius: 14px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.01));
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.planner-item-main {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
}

.planner-item-name {
    font-size: 13px;
    font-weight: 600;
}

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

.planner-mini-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.planner-mini-field span {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted-text);
}

.planner-item-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
}

.planner-status-chip {
    min-width: 72px;
    padding: 7px 10px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.07);
}

.planner-status-chip.is-pending {
    color: var(--muted-text);
    background: rgba(255, 255, 255, 0.03);
}

.planner-status-chip.is-less {
    color: #ffd89a;
    background: rgba(240, 198, 116, 0.12);
    border-color: rgba(240, 198, 116, 0.22);
}

.planner-status-chip.is-exact {
    color: #121212;
    background: #d4d4d4;
    border-color: transparent;
}

.planner-status-chip.is-more {
    color: #c7f5d1;
    background: rgba(125, 223, 150, 0.15);
    border-color: rgba(125, 223, 150, 0.24);
}

.planner-item-delete {
    border: 0;
    background: transparent;
    color: #a8a8a8;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: pointer;
}

.planner-item-delete:hover {
    color: #ffffff;
}

.planner-empty-state {
    flex: 1;
    min-height: 180px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 16px;
    border: 1px dashed rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.015);
    color: var(--muted-text);
    text-align: center;
    padding: 20px;
}

.planner-empty-state strong {
    color: var(--focus-color);
    font-size: 13px;
}

.custom-checkbox {
    width: 18px;
    height: 18px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
    user-select: none;
    background: var(--surface-1);
    padding: 0;
}

.custom-checkbox[data-state="done"] {
    background: var(--accent-color);
    border-color: transparent;
}

.custom-checkbox[data-state="done"]::after {
    content: "✓";
    color: #111111;
    font-size: 11px;
    font-weight: 800;
}

.custom-checkbox[data-state="failed"] {
    border-color: rgba(251, 113, 133, 0.5);
    background: rgba(251, 113, 133, 0.08);
}

.custom-checkbox[data-state="failed"]::after {
    content: "✗";
    color: var(--fail-color);
    font-size: 11px;
    font-weight: 800;
}

.planner-reminders-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.planner-reminder-row {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
}

.planner-reminder-input {
    min-width: 0;
}

.planner-score-wrap {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.score-input {
    width: 78px;
    text-align: center;
    font-size: 30px;
    font-weight: 800;
    color: var(--focus-color);
}

.score-max {
    font-size: 13px;
    color: var(--muted-text);
}

.progress-ring {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: conic-gradient(var(--accent-color) 0%, rgba(255, 255, 255, 0.1) 0);
    position: relative;
    transition: background 0.3s ease;
}

.progress-ring::before {
    content: "";
    position: absolute;
    inset: 8px;
    background: #141414;
    border-radius: 50%;
}

.progress-text {
    position: relative;
    z-index: 1;
    font-weight: 800;
    font-size: 13px;
    color: var(--focus-color);
}

.planner-summary-card textarea {
    flex: 1;
    min-height: 160px;
    max-height: 100%;
    resize: none;
    overflow-y: auto;
}

.finance-grid {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: minmax(0, 280px) minmax(0, 1fr);
    gap: 10px;
}

.fin-workspace {
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(250px, 0.95fr) minmax(250px, 1fr) minmax(280px, 1.15fr);
    grid-template-rows: minmax(0, 1fr);
    gap: 12px;
}

.finance-entry-card,
.finance-search-card,
.finance-chart-card {
    min-height: 0;
    overflow: hidden;
}

.finance-panel-head {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-bottom: 4px;
}

.finance-panel-head p {
    margin: 0;
    font-size: 11px;
    line-height: 1.35;
    color: var(--muted-text);
}

.finance-chart-card {
    grid-column: auto;
    border-top: 0;
    padding-top: 12px;
}

.finance-adjustment-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.finance-search-card {
    border-left: 1px solid rgba(255, 255, 255, 0.08);
    padding-left: 12px;
}

.finance-entry-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 0;
}

.finance-entry-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 12px;
}

.fin-row-textarea {
    align-items: start;
}

.fin-row-textarea textarea {
    min-height: 70px;
    resize: none;
}

.finance-note-row {
    grid-column: 1 / -1;
}

.finance-entry-actions {
    display: flex;
    justify-content: flex-end;
}

.finance-entry-actions .btn,
.finance-search-controls .btn {
    min-height: 36px;
}

.finance-adjustment-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.finance-adjustment-amount-row {
    grid-column: 1 / -1;
}

.finance-adjustment-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-right: 4px;
}

.finance-adjustment-item {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    padding: 10px 12px;
    border-radius: 12px;
    background: var(--surface-1);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.finance-adjustment-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #f5f5f5;
}

.finance-adjustment-copy {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.finance-adjustment-copy strong {
    font-size: 12px;
    color: var(--focus-color);
}

.finance-adjustment-copy span {
    font-size: 10px;
    color: var(--muted-text);
    text-transform: capitalize;
}

.finance-adjustment-actions {
    display: flex;
    justify-content: flex-end;
}

.finance-save-transfer {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 4px;
    padding-top: 6px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

#finance-view .finance-grid > .fin-card:nth-child(2) {
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 8px;
}

.finance-search-controls {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.finance-search-controls input {
    flex: 1;
}

.finance-day-results {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding-right: 4px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.finance-day-item,
.finance-day-empty {
    padding: 10px 12px;
    border-radius: 12px;
    background: var(--surface-1);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.finance-day-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.finance-delete-btn {
    flex: 0 0 auto;
    min-width: 74px;
    padding: 7px 10px;
    border: 1px solid rgba(255, 107, 107, 0.16);
    border-radius: 10px;
    background: rgba(255, 107, 107, 0.08);
    color: #f3b0b0;
    font: inherit;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.finance-delete-btn:hover {
    background: rgba(255, 107, 107, 0.14);
    border-color: rgba(255, 107, 107, 0.28);
    transform: translateY(-1px);
}

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

.finance-day-item.expense {
    border-color: rgba(255, 107, 107, 0.18);
    background: linear-gradient(180deg, rgba(255, 107, 107, 0.06), rgba(255, 107, 107, 0.01));
}

.finance-day-item.income {
    border-color: rgba(125, 223, 150, 0.18);
    background: linear-gradient(180deg, rgba(125, 223, 150, 0.06), rgba(125, 223, 150, 0.01));
}

.finance-day-main,
.finance-day-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.finance-day-main strong,
.finance-day-meta strong {
    font-size: 11px;
    color: var(--focus-color);
}

.finance-day-main span,
.finance-day-meta span,
.finance-day-empty {
    font-size: 10px;
    color: var(--muted-text);
}

.finance-bottom-chart {
    flex: 1;
    min-height: 0;
    height: 100%;
}

#finance-view .fin-card {
    gap: 6px;
}

#finance-view .fin-card h2 {
    margin-bottom: 4px;
}

#finance-view .fin-row {
    grid-template-columns: minmax(0, 1fr) 132px;
    gap: 6px;
}

#finance-view .fin-row span {
    font-size: 11px;
}

#finance-view input[type="number"],
#finance-view input[type="date"],
#finance-view select,
#finance-view textarea {
    padding: 6px 9px;
    font-size: 11px;
}

#finance-view .category-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding-right: 4px;
    gap: 5px;
}

@media (min-width: 1101px) {
    #finance-view .finance-entry-card .fin-row {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 5px;
    }

    #finance-view .finance-entry-card .fin-row span {
        min-height: 0;
    }

    #finance-view .finance-entry-card .finance-entry-grid {
        grid-template-columns: 1fr 1fr;
    }

    #finance-view .finance-search-card,
    #finance-view .finance-chart-card {
        border-left: 1px solid rgba(255, 255, 255, 0.08);
        padding-left: 12px;
    }

    #finance-view .finance-day-results {
        max-height: 100%;
    }
}

.fin-row-highlight {
    grid-template-columns: minmax(0, 1fr) auto;
    padding: 8px 10px;
    border-radius: 10px;
    background: var(--surface-1);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.fin-row-highlight strong {
    font-size: 13px;
    color: var(--focus-color);
}

#fin-available-now,
#fin-saved-preview {
    color: #7ddf96;
}

#fin-net-month {
    color: #ff6b6b;
}

.finance-inline-value {
    cursor: pointer;
    min-width: 110px;
    text-align: right;
    transition: opacity 0.2s ease;
}

.finance-inline-value:hover {
    opacity: 0.82;
}

.finance-inline-value.is-editing {
    opacity: 1;
}

.finance-inline-input {
    width: 110px;
    margin-left: auto;
    text-align: right;
}

.finance-date-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.finance-date-display {
    font-size: 10px;
    color: var(--muted-text);
    line-height: 1.3;
}

.calendar-title {
    min-width: 180px;
    text-align: center;
    font-size: 13px;
    font-weight: 700;
    color: var(--focus-color);
}

.calendar-layout {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1.65fr) 280px;
    gap: 12px;
}

.calendar-board,
.calendar-note-card {
    min-height: 0;
    padding: 12px;
    border-radius: var(--radius-lg);
    background: var(--surface-2);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.calendar-board {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

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

.calendar-weekdays span {
    text-align: center;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted-text);
}

.calendar-grid {
    flex: 1;
    min-height: 0;
    grid-template-rows: none;
    grid-auto-rows: minmax(110px, 1fr);
}

.calendar-day {
    min-height: 0;
    padding: 8px;
    appearance: none;
    width: 100%;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    background: var(--surface-1);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 6px;
    cursor: pointer;
    font: inherit;
    color: inherit;
    text-align: left;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.calendar-day.is-muted {
    opacity: 0.4;
}

.calendar-day.is-selected {
    border-color: rgba(255, 255, 255, 0.18);
    background: #202020;
}

.calendar-day.is-today {
    border-color: rgba(248, 250, 252, 0.45);
    box-shadow: inset 0 0 0 1px rgba(248, 250, 252, 0.12);
    background: #252525;
}

.calendar-day-top {
    display: flex;
    justify-content: space-between;
    gap: 6px;
    align-items: flex-start;
}

.calendar-gregorian,
.calendar-jalali {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.calendar-gregorian strong,
.calendar-jalali strong {
    font-size: 14px;
    line-height: 1;
    color: var(--focus-color);
}

.calendar-gregorian span,
.calendar-jalali span {
    font-size: 10px;
    color: var(--muted-text);
}

.calendar-jalali {
    text-align: right;
}

.calendar-reminder-preview {
    min-height: 28px;
    font-size: 11px;
    line-height: 1.35;
    color: var(--text-color);
    overflow: hidden;
}

.calendar-note-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.calendar-selected-date {
    font-size: 13px;
    font-weight: 700;
    color: var(--focus-color);
    min-height: 18px;
}

#calendar-note {
    flex: 1;
    resize: none;
}

.calendar-note-meta {
    display: flex;
    justify-content: flex-end;
    font-size: 11px;
    color: var(--muted-text);
}

.overview-layout {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 12px;
}

.overview-top,
.overview-bottom {
    min-height: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.overview-bottom {
    grid-template-columns: 1.1fr 1.1fr 0.9fr;
}

.analytics-card {
    min-height: 0;
    padding: 12px;
    border-radius: var(--radius-lg);
    background: var(--surface-2);
    border: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.analytics-metrics {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.metric-box {
    padding: 10px;
    border-radius: 10px;
    background: var(--surface-1);
    border: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 6px;
}

.metric-box span {
    font-size: 10px;
    color: var(--muted-text);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.metric-box strong {
    font-size: 16px;
    color: var(--focus-color);
}

.metric-box strong.is-positive {
    color: var(--success-color);
}

.metric-box strong.is-negative {
    color: var(--fail-color);
}

.money-chart {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 12px;
}

.money-bar {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.money-bar-label {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    font-size: 11px;
    color: var(--muted-text);
}

.money-bar-label strong {
    color: var(--focus-color);
    font-size: 12px;
}

.money-bar-track {
    height: 10px;
    border-radius: 999px;
    background: var(--surface-1);
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.money-bar-fill {
    height: 100%;
    width: 0;
    border-radius: inherit;
    transition: width 0.25s ease;
}

.money-bar-fill.spent {
    background: #ff6b6b;
}

.money-bar-fill.remaining {
    background: #d4d4d4;
}

.money-bar-fill.debt {
    background: #f0c674;
}

.money-bar-fill.receivable {
    background: #60a5fa;
}

.money-bar-fill.income {
    background: #7ddf96;
}

.money-bar-fill.subscriptions {
    background: #f59e0b;
}

.money-bar-fill.saved {
    background: #7ddf96;
}

.chart-svg {
    width: 100%;
    height: 220px;
    min-height: 220px;
    display: block;
}

.chart-line {
    fill: none;
    stroke-width: 3;
}

.chart-line.spent {
    stroke: #ff6b6b;
}

.chart-line.remaining {
    stroke: #d4d4d4;
}

.chart-line.debt {
    stroke: #f0c674;
}

.chart-grid-line {
    stroke: rgba(255, 255, 255, 0.08);
    stroke-width: 1;
}

.chart-axis-text {
    fill: var(--muted-text);
    font-size: 10px;
}

.chart-bar {
    rx: 6;
    ry: 6;
}

.chart-bar.transport { fill: #c084fc; }
.chart-bar.bill { fill: #f87171; }
.chart-bar.buy { fill: #22c55e; }
.chart-bar.work { fill: #38bdf8; }
.chart-bar.food { fill: #7ddf96; }
.chart-bar.snack { fill: #f59e0b; }
.chart-bar.cafe { fill: #f0c674; }
.chart-bar.smoke { fill: #ff6b6b; }
.chart-bar.fun { fill: #60a5fa; }
.chart-bar.s { fill: #d4d4d4; }
.chart-bar.etc { fill: #94a3b8; }

.chart-empty {
    fill: var(--muted-text);
    font-size: 12px;
}

.profile-layout {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(280px, 0.9fr) minmax(0, 1.1fr);
    gap: 12px;
}

.profile-hero-card {
    background:
        radial-gradient(circle at top right, rgba(96, 165, 250, 0.12), transparent 36%),
        linear-gradient(180deg, #1a1a1a 0%, #141414 100%);
}

.profile-hero-top {
    display: flex;
    align-items: center;
    gap: 14px;
}

.profile-avatar {
    width: 58px;
    height: 58px;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, #2b2b2b, #171717);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--focus-color);
    font-size: 24px;
    font-weight: 800;
}

.profile-hero-copy h2 {
    margin-bottom: 4px;
}

.profile-hero-copy p {
    margin: 0;
    color: var(--muted-text);
    font-size: 12px;
    line-height: 1.5;
}

.profile-auth-card,
.profile-info-card {
    min-height: 0;
}

.profile-status {
    padding: 10px 12px;
    border-radius: 10px;
    background: var(--surface-1);
    border: 1px solid rgba(255, 255, 255, 0.06);
    color: var(--muted-text);
    font-size: 12px;
}

.profile-status.is-live {
    color: var(--success-color);
    border-color: rgba(125, 223, 150, 0.18);
}

.profile-status.is-error {
    color: #ffd1d1;
    border-color: rgba(255, 107, 107, 0.18);
    background: rgba(255, 107, 107, 0.08);
}

.profile-hint {
    color: var(--muted-text);
    font-size: 11px;
}

.profile-hint code {
    color: var(--focus-color);
}

.profile-info-list {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.notes-layout {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: 180px minmax(0, 1fr);
    gap: 12px;
}

.notes-tabs {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.note-tab {
    justify-content: flex-start;
    text-align: left;
}

.note-tab.active {
    background: #2a2a2a;
    border-color: rgba(255, 255, 255, 0.14);
}

.notes-card {
    min-height: 0;
    height: 100%;
}

.notes-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.notes-count {
    color: var(--muted-text);
    font-size: 11px;
}

.notes-textarea {
    flex: 1 1 auto;
    width: 100%;
    min-height: 0;
    height: 100%;
    max-height: 100%;
    line-height: 1.6;
    overflow-y: auto;
    overflow-x: hidden;
    resize: none;
}

.fin-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.fin-card-wide {
    grid-column: 1 / -1;
}

.fin-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 150px;
    align-items: center;
    gap: 8px;
}

.fin-row span {
    font-size: 12px;
    color: var(--text-color);
}

.fin-row .amount-input {
    text-align: right;
    color: var(--success-color);
}

.fin-row .debt-input {
    color: var(--warning-color);
}

.assets-list {
    flex: 1;
    display: grid;
    grid-template-rows: repeat(5, minmax(0, 1fr));
    gap: 6px;
}

.category-list {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.asset-item {
    display: grid;
    grid-template-columns: 1.15fr 0.9fr 0.9fr;
    gap: 6px;
    align-items: center;
}

.finance-select {
    background: #141414;
}

.context-menu {
    position: absolute;
    background: #151515;
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 10px;
    box-shadow: var(--shadow-md);
    padding: 6px;
    min-width: 160px;
    z-index: 1000;
    display: none;
}

.context-menu-item {
    padding: 9px 12px;
    font-size: 13px;
    cursor: pointer;
    border-radius: 10px;
    transition: background 0.2s ease, color 0.2s ease;
}

.context-menu-item:hover {
    background: #242424;
    color: var(--focus-color);
}

::-webkit-scrollbar {
    width: 0;
    height: 0;
}

@media print {
    body {
        overflow: visible;
        background: #fff;
        color: #000;
    }

    .sidebar-nav {
        display: none;
    }

    .main-wrapper {
        padding: 0;
    }

    #planner-view {
        display: flex !important;
        height: auto !important;
        box-shadow: none;
        border-radius: 0;
        background: #fff;
        border: 0;
    }

    #finance-view {
        display: none !important;
    }
}

@media (max-width: 1280px) {
    .planner-shell {
        grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.88fr);
    }

    .calendar-layout {
        grid-template-columns: minmax(0, 1.5fr) 240px;
    }

    .overview-bottom {
        grid-template-columns: 1fr 1fr 0.95fr;
    }

    .fin-workspace {
        grid-template-columns: minmax(220px, 0.95fr) minmax(220px, 1fr) minmax(240px, 1.15fr);
    }
}

@media (max-width: 1100px) {
    body::before {
        inset: 12px;
    }

    .main-wrapper {
        padding: 12px;
    }

    .view-section {
        height: calc(100dvh - 24px - var(--safe-top) - var(--safe-bottom));
        padding: 12px 14px;
    }

    .planner-shell {
        grid-template-columns: minmax(0, 1.1fr) minmax(260px, 0.9fr);
    }

    .header-left h1 {
        font-size: 18px;
    }

    .fin-row span,
    input[type="date"],
    input[type="month"],
    input[type="text"],
    input[type="number"],
    textarea,
    select {
        font-size: 12px;
    }
}

@media (min-width: 700px) and (max-width: 1100px) {
    html,
    body {
        height: auto;
        min-height: 100%;
        overflow-y: auto;
    }

    body {
        display: block;
        overflow-x: hidden;
    }

    .sidebar-nav {
        position: sticky;
        top: 8px;
        width: calc(100% - 16px);
        margin: 8px;
        padding: 10px;
        border-radius: 18px;
        flex-direction: row;
        justify-content: space-between;
        align-items: stretch;
        gap: 8px;
    }

    .nav-item {
        flex: 1;
        width: auto;
        min-height: 58px;
        padding: 8px 4px;
        font-size: 9px;
        line-height: 1.15;
        letter-spacing: 0.06em;
    }

    .nav-item svg {
        width: 18px;
        height: 18px;
    }

    .main-wrapper {
        height: auto;
        min-height: 0;
        padding: 0 8px 8px;
    }

    .view-section {
        height: auto;
        min-height: calc(100dvh - 96px - var(--safe-top) - var(--safe-bottom));
        overflow: visible;
        padding: 14px;
    }

    header {
        flex-direction: column;
        align-items: stretch;
    }

    .header-actions,
    .date-container {
        width: 100%;
        justify-content: flex-start;
    }

    .planner-shell,
    .finance-grid,
    .calendar-layout,
    .overview-top,
    .overview-bottom,
    .profile-layout,
    .notes-layout {
        grid-template-columns: 1fr;
    }

    .fin-workspace {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
    }

    .finance-entry-grid {
        grid-template-columns: 1fr 1fr;
    }

    .finance-search-card {
        border-left: 0;
        padding-left: 0;
    }

    .finance-chart-card {
        grid-column: auto;
    }

    .planner-add-row {
        grid-template-columns: 1fr 140px auto;
    }

    .calendar-board {
        overflow-x: auto;
        padding-bottom: 6px;
    }

    .calendar-weekdays,
    .calendar-grid {
        min-width: 700px;
    }

    .analytics-metrics {
        grid-template-columns: 1fr 1fr;
    }

    .notes-tabs {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .notes-card {
        min-height: 320px;
    }

    .chart-svg {
        height: 240px;
        min-height: 240px;
    }
}

@media (max-width: 1024px) {
    html,
    body {
        height: auto;
        min-height: 100%;
        overflow-y: auto;
    }

    body {
        display: block;
        overflow-x: hidden;
    }

    body::before {
        inset: 10px;
        border-radius: 20px;
    }

    .sidebar-nav {
        position: sticky;
        top: 10px;
        width: calc(100% - 20px);
        margin: 10px;
        padding: 10px;
        border-radius: 18px;
        flex-direction: row;
        justify-content: space-between;
        align-items: stretch;
        gap: 8px;
    }

    .nav-item {
        flex: 1;
        width: auto;
        min-height: 56px;
        font-size: 9px;
        letter-spacing: 0.08em;
    }

    .nav-item svg {
        width: 18px;
        height: 18px;
    }

    .main-wrapper {
        height: auto;
        min-height: 0;
        padding: 0 10px 10px;
    }

    .view-section {
        height: auto;
        min-height: calc(100dvh - 108px - var(--safe-top) - var(--safe-bottom));
        overflow: visible;
        padding: 14px;
    }

    header {
        align-items: flex-start;
    }

    .header-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .header-actions .btn,
    .header-actions input,
    .header-actions select {
        flex: 0 0 auto;
    }

    .planner-shell,
    .finance-grid,
    .calendar-layout,
    .overview-top,
    .overview-bottom,
    .notes-layout,
    .profile-layout {
        grid-template-columns: 1fr;
    }

    .fin-workspace {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
    }

    .finance-entry-grid {
        grid-template-columns: 1fr;
    }

    .overview-layout {
        grid-template-rows: auto;
    }

    .planner-item-card {
        grid-template-columns: 1fr;
    }

    .planner-item-actions {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }

    .calendar-board {
        overflow-x: auto;
    }

    .calendar-weekdays,
    .calendar-grid {
        min-width: 620px;
    }

    .analytics-metrics {
        grid-template-columns: 1fr 1fr;
    }

    .notes-tabs {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .notes-card {
        min-height: 320px;
    }

    .finance-day-item {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 768px) {
    body::before {
        inset: calc(6px + var(--safe-top)) calc(6px + var(--safe-right)) calc(6px + var(--safe-bottom)) calc(6px + var(--safe-left));
        border-radius: 16px;
    }

    .sidebar-nav {
        top: calc(6px + var(--safe-top));
        margin: calc(6px + var(--safe-top)) calc(6px + var(--safe-right)) 6px calc(6px + var(--safe-left));
        width: calc(100% - 12px - var(--safe-left) - var(--safe-right));
        padding: 8px;
        gap: 6px;
    }

    .nav-item {
        min-height: 52px;
        padding: 8px 4px;
        border-radius: 12px;
    }

    .nav-item-profile {
        margin-top: 0;
    }

    .main-wrapper {
        padding: 0 calc(6px + var(--safe-right)) calc(6px + var(--safe-bottom)) calc(6px + var(--safe-left));
    }

    .view-section {
        min-height: calc(100dvh - 86px - var(--safe-top) - var(--safe-bottom));
        padding: 12px;
        border-radius: 16px;
    }

    .planner-main-card,
    .planner-side-card {
        padding: 12px;
    }

    .planner-add-row,
    .planner-item-values {
        grid-template-columns: 1fr;
    }

    .planner-reminder-row {
        grid-template-columns: 18px minmax(0, 1fr);
    }

    .planner-summary-card textarea {
        min-height: 140px;
    }

    .fin-row {
        grid-template-columns: 1fr;
    }

    .fin-row-highlight {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .finance-entry-actions {
        justify-content: stretch;
    }

    .finance-entry-actions .btn,
    .finance-search-controls .btn {
        width: 100%;
    }

    .finance-search-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .analytics-metrics {
        grid-template-columns: 1fr;
    }

    .profile-info-list {
        grid-template-columns: 1fr;
    }

    .notes-tabs {
        flex-direction: column;
    }

    .notes-textarea {
        height: auto;
        min-height: calc(8 * 1.6em + 28px);
        max-height: calc(8 * 1.6em + 28px);
    }

    .chart-svg {
        height: 200px;
        min-height: 200px;
    }

}

@supports (-webkit-touch-callout: none) {
    html,
    body {
        min-height: -webkit-fill-available;
        background: #050505;
    }

    .main-wrapper {
        min-height: -webkit-fill-available;
    }
}

@media (max-width: 380px) {
    .header-left h1 {
        font-size: 16px;
    }

    .btn {
        padding: 7px 10px;
        font-size: 10px;
    }

    .calendar-weekdays,
    .calendar-grid {
        min-width: 560px;
    }

    .planner-item-card {
        padding: 10px;
    }

    .score-input {
        width: 68px;
        font-size: 26px;
    }
}
