/* === Reset & Base === */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #f8f9fa;
    --bg-secondary: #f0f1f3;
    --bg-card: #ffffff;
    --bg-input: #ffffff;
    --border: #e2e4e9;
    --border-focus: #0caa41;
    --text-primary: #1a1d23;
    --text-secondary: #5b616e;
    --text-muted: #9ca3af;
    --accent: #0caa41;
    --accent-hover: #099236;
    --accent-dim: rgba(12, 170, 65, 0.07);
    --green: #0caa41;
    --green-dim: rgba(12, 170, 65, 0.07);
    --red: #dc2626;
    --red-dim: rgba(220, 38, 38, 0.06);
    --blue: #2563eb;
    --blue-dim: rgba(37, 99, 235, 0.06);
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 1px 3px rgba(0, 0, 0, 0.03);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.08);
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    line-height: 1.5;
}

/* === Screens === */
.screen {
    display: none;
    min-height: 100vh;
}

.screen.active {
    display: flex;
    flex-direction: column;
}

/* === Login === */
.login-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 24px;
    max-width: 400px;
    margin: 0 auto;
    width: 100%;
}

.login-logo {
    text-align: center;
    margin-bottom: 48px;
}

.logo-icon {
    width: 68px;
    height: 68px;
    background: var(--accent);
    color: #ffffff;
    font-family: 'DM Mono', monospace;
    font-size: 30px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
    margin: 0 auto 16px;
    box-shadow: 0 2px 8px rgba(12, 170, 65, 0.25);
}

.login-logo h1 {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.login-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 4px;
    font-weight: 400;
}

.login-form {
    width: 100%;
}

/* === Forms === */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
select {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
}

input:focus, select:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

input::placeholder {
    color: var(--text-muted);
}

input[type="number"],
.money-input {
    font-family: 'DM Mono', monospace;
    font-size: 14px;
}

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 22px;
    border-radius: var(--radius-sm);
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    border: none;
    outline: none;
    text-decoration: none;
    gap: 8px;
}

.btn-primary {
    background: var(--accent);
    color: #ffffff;
    box-shadow: var(--shadow);
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-outline {
    background: transparent;
    border: 1px dashed var(--border);
    color: var(--text-secondary);
}

.btn-outline:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-dim);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover {
    color: var(--text-primary);
    background: var(--bg-secondary);
}

.btn-danger {
    background: var(--red-dim);
    color: var(--red);
    padding: 8px 12px;
    font-size: 13px;
}

.btn-danger:hover {
    background: rgba(220, 38, 38, 0.12);
}

.btn-full {
    width: 100%;
}

/* === Onboarding === */
.onboarding-header {
    padding: 24px 24px 8px;
    display: flex;
    justify-content: center;
}

.step-indicators {
    display: flex;
    gap: 8px;
}

.step-dot {
    width: 32px;
    height: 4px;
    border-radius: 2px;
    background: var(--border);
    transition: background 0.3s;
}

.step-dot.active {
    background: var(--accent);
}

.step-dot.completed {
    background: var(--green);
}

.onboarding-step {
    display: none;
    padding: 0 24px 32px;
    max-width: 500px;
    margin: 0 auto;
    width: 100%;
}

.onboarding-step.active {
    display: block;
}

.step-content h2 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 8px;
    letter-spacing: -0.4px;
    color: var(--text-primary);
}

.step-content > p {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 24px;
}

.step-detail {
    color: var(--text-muted) !important;
    font-size: 13px !important;
    margin-top: -16px !important;
}

.centered {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 70vh;
}

.welcome-icon {
    width: 76px;
    height: 76px;
    background: var(--accent-dim);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    margin-bottom: 24px;
}

.step-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 32px;
    gap: 12px;
}

/* === Snapshot Date === */
.snapshot-date-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-card);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    gap: 12px;
    border: 1px solid var(--border);
}

.snapshot-date-row label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
}

.snapshot-date-row .input-date {
    width: auto;
    max-width: 180px;
    padding: 8px 12px;
    font-size: 14px;
}

/* === Item Rows (accounts, cards, investments) === */
.items-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.item-row {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.item-row-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.item-row-header span {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.item-fields {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.item-field-row {
    display: flex;
    gap: 10px;
}

.item-field-row .form-group {
    flex: 1;
    margin-bottom: 0;
}

.item-field-row .form-group.small {
    flex: 0 0 80px;
}

.name-with-color {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.name-with-color input {
    width: 100%;
}

.color-picker {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.color-swatch {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.15s, border-color 0.15s;
    outline: none;
    padding: 0;
}

.color-swatch:hover {
    transform: scale(1.2);
}

.color-swatch.selected {
    border-color: var(--text-primary);
    box-shadow: 0 0 0 1.5px var(--bg-card), 0 0 0 3px var(--text-primary);
}

/* === Review === */
.review-section {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.review-section h3 {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.review-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
}

.review-item-name {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-primary);
}

.review-item-value {
    font-family: 'DM Mono', monospace;
    font-size: 14px;
    color: var(--text-primary);
}

.review-highlight {
    border-color: var(--accent);
    background: var(--accent-dim);
}

.review-highlight .review-item-value {
    color: var(--accent);
    font-weight: 500;
}

.color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

/* === Error === */
.error-message {
    background: var(--red-dim);
    color: var(--red);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 16px;
}

.hidden {
    display: none !important;
}

/* === Loading === */
.btn.loading {
    opacity: 0.7;
    pointer-events: none;
}

.btn.loading::after {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-left: 8px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* === Responsive === */
@media (max-width: 400px) {
    .item-field-row {
        flex-direction: column;
    }

    .item-field-row .form-group.small {
        flex: 1;
    }
}

/* === Dashboard === */
.dash-container {
    max-width: 500px;
    margin: 0 auto;
    padding: 20px 20px 40px;
    width: 100%;
}

.dash-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 24px;
}

.logo-icon-sm {
    width: 36px;
    height: 36px;
    background: var(--accent);
    color: #ffffff;
    font-family: 'DM Mono', monospace;
    font-size: 16px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    flex-shrink: 0;
}

.dash-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.3px;
    flex: 1;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
}

.summary-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 24px;
}

.summary-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 14px 16px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.summary-card:last-child {
    grid-column: 1 / -1;
}

.summary-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.summary-value {
    font-family: 'DM Mono', monospace;
    font-size: 18px;
    font-weight: 500;
    color: var(--text-primary);
}

.summary-card--green .summary-value {
    color: var(--green);
}

.summary-card--red .summary-value {
    color: var(--red);
}

.summary-card--accent {
    background: var(--accent-dim);
    border-color: var(--accent);
}

.summary-card--accent .summary-value {
    color: var(--accent);
    font-size: 22px;
}

.dash-section {
    margin-bottom: 16px;
}

.dash-section-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    padding-left: 4px;
}

.review-item-sub {
    font-size: 12px;
    color: var(--text-muted);
    font-family: 'DM Mono', monospace;
}

.dash-loading {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
    font-size: 14px;
}

/* === FAB === */
.fab {
    position: fixed;
    bottom: 28px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--accent);
    color: #ffffff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(12, 170, 65, 0.35);
    transition: transform 0.15s, box-shadow 0.15s;
    z-index: 50;
}

.fab:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(12, 170, 65, 0.4);
}

.fab:active {
    transform: scale(0.95);
}

/* === Modal Overlay === */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0);
    z-index: 100;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    transition: background 0.3s;
}

.modal-overlay.open {
    background: rgba(0, 0, 0, 0.4);
    touch-action: none;
    overscroll-behavior: none;
}

.modal-sheet {
    background: var(--bg-primary);
    width: 100%;
    max-width: 500px;
    height: 92vh;
    border-radius: 20px 20px 0 0;
    padding: 12px 24px 32px;
    overflow-y: hidden;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    display: flex;
    flex-direction: column;
}

.modal-sheet .btn-full:last-child {
    margin-top: auto;
}

.modal-overlay.open .modal-sheet {
    transform: translateY(0);
}

.modal-handle {
    width: 36px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 0 auto 16px;
}

.modal-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.3px;
    margin-bottom: 20px;
}

/* === Type Toggle === */
.txn-type-toggle {
    display: flex;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    padding: 3px;
    margin-bottom: 20px;
    gap: 3px;
}

.txn-type-btn {
    flex: 1;
    padding: 9px 0;
    border: none;
    border-radius: 6px;
    background: transparent;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.txn-type-btn.active[data-type="expense"] {
    background: var(--bg-card);
    color: var(--red);
    box-shadow: var(--shadow);
}

.txn-type-btn.active[data-type="income"] {
    background: var(--bg-card);
    color: var(--green);
    box-shadow: var(--shadow);
}

.txn-type-btn.active[data-type="cc_payment"] {
    background: var(--bg-card);
    color: var(--blue);
    box-shadow: var(--shadow);
}

.txn-type-btn.active[data-type="transfer"] {
    background: var(--bg-card);
    color: #7c3aed;
    box-shadow: var(--shadow);
}

/* === Amount Input === */
.txn-amount-input {
    font-size: 24px !important;
    padding: 14px !important;
    text-align: center;
    font-weight: 500;
}

/* === History === */
.history-month-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding: 8px 0;
}

.history-month-label-nav {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.nav-disabled {
    opacity: 0.2;
    pointer-events: none;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    margin-bottom: 6px;
    box-shadow: var(--shadow);
}

.history-item-left {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
    margin-right: 12px;
}

.history-item-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.history-item-detail {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-item-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.history-item-amount {
    font-family: 'DM Mono', monospace;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
}

.history-item-date {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
}

.amount-green { color: var(--green); }
.amount-red { color: var(--red); }
.amount-blue { color: var(--blue); }
.amount-purple { color: #7c3aed; }

/* === Settings === */
.settings-menu {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.settings-menu-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 14px 16px;
    background: none;
    border: none;
    border-bottom: 1px solid var(--border);
    font-family: 'Inter', sans-serif;
    font-size: 15px;
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.15s;
    text-align: left;
}

.settings-menu-item:last-child {
    border-bottom: none;
}

.settings-menu-item:hover {
    background: var(--bg-secondary);
}

.settings-menu-item svg {
    color: var(--text-muted);
    flex-shrink: 0;
}

.settings-menu-item--danger span {
    color: var(--red);
}

.settings-menu-divider {
    height: 1px;
    background: var(--border);
}

.settings-desc {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 16px;
}

.success-message {
    background: var(--green-dim);
    color: var(--green);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 16px;
}

/* === Responsive FAB centering === */
@media (min-width: 501px) {
    .fab {
        right: calc(50% - 250px + 24px);
        right: calc(50% - 226px);
    }
}
