/* ============================================================
   Kanso Design System — Web Dashboard
   Mirrors the mobile app's 3-theme palette and aesthetic
   ============================================================ */

/* ── Theme Variables ─────────────────────────────────────── */

/* Warm Ink (default dark — Japanese aesthetic) */
:root,
[data-theme="warm-ink"] {
    --bg:              #141210;
    --surface:         #201D18;
    --surface-raised:  #2A2520;
    --surface-hover:   #322C26;
    --border:          #332E28;
    --border-subtle:   #26221D;

    --primary:         #C49A5E;
    --primary-dim:     rgba(196, 154, 94, 0.14);
    --primary-hover:   #D4AA6E;

    --text:            #F0EBE3;
    --text-muted:      #8A8278;
    --text-faint:      #4E4A46;

    --needs:           #7BAF8E;
    --wants:           #D4956A;
    --business:        #6A8FBF;
    --savings:         #A67FB5;
    --unexpected:      #E8761F;
    --danger:          #C96060;
    --danger-dim:      rgba(201, 96, 96, 0.12);
    --success:         #7BAF8E;
    --success-dim:     rgba(123, 175, 142, 0.12);
    --warning:         #E8761F;
    --warning-dim:     rgba(232, 118, 31, 0.12);

    --nav-bg:          #0E0C0A;
    --nav-border:      #1C1814;
    --scrollbar-thumb: #332E28;
}

/* Japanese Indigo */
[data-theme="indigo"] {
    --bg:              #0F1117;
    --surface:         #1A1F2C;
    --surface-raised:  #222840;
    --surface-hover:   #2A3250;
    --border:          #252B3B;
    --border-subtle:   #1E2333;

    --primary:         #7B9ED9;
    --primary-dim:     rgba(123, 158, 217, 0.14);
    --primary-hover:   #8BAEE9;

    --text:            #E8EDF7;
    --text-muted:      #6B7894;
    --text-faint:      #3A4260;

    --needs:           #7BAF8E;
    --wants:           #D4956A;
    --business:        #6A8FBF;
    --savings:         #A67FB5;
    --unexpected:      #E8761F;
    --danger:          #C96060;
    --danger-dim:      rgba(201, 96, 96, 0.12);
    --success:         #7BAF8E;
    --success-dim:     rgba(123, 175, 142, 0.12);
    --warning:         #E8761F;
    --warning-dim:     rgba(232, 118, 31, 0.12);

    --nav-bg:          #0A0D13;
    --nav-border:      #151A26;
    --scrollbar-thumb: #252B3B;
}

/* Washi Paper (light) */
[data-theme="washi"] {
    --bg:              #F7F4EF;
    --surface:         #FFFFFF;
    --surface-raised:  #F0EDE8;
    --surface-hover:   #EAE7E2;
    --border:          #DDD9D2;
    --border-subtle:   #EBE8E3;

    --primary:         #8C6A3F;
    --primary-dim:     rgba(140, 106, 63, 0.10);
    --primary-hover:   #7A5A32;

    --text:            #2C2622;
    --text-muted:      #7A6F65;
    --text-faint:      #B8B0A8;

    --needs:           #4A8B60;
    --wants:           #B86A3A;
    --business:        #3A6A9F;
    --savings:         #7A5A9F;
    --unexpected:      #C86010;
    --danger:          #B04040;
    --danger-dim:      rgba(176, 64, 64, 0.08);
    --success:         #4A8B60;
    --success-dim:     rgba(74, 139, 96, 0.10);
    --warning:         #C86010;
    --warning-dim:     rgba(200, 96, 16, 0.10);

    --nav-bg:          #EEEAE4;
    --nav-border:      #DDD9D2;
    --scrollbar-thumb: #C8C3BC;
}

/* ── Base ────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI',
                 system-ui, sans-serif;
    font-size: 15px;
    line-height: 1.6;
    min-height: 100vh;
    transition: background-color 0.25s ease, color 0.25s ease;
}

::selection {
    background: var(--primary-dim);
    color: var(--primary);
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 3px;
}

/* ── Navigation ──────────────────────────────────────────── */

.kanso-nav {
    background: var(--nav-bg);
    border-bottom: 1px solid var(--nav-border);
    padding: 0 1.5rem;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    transition: background-color 0.25s ease, border-color 0.25s ease;
}

.kanso-nav-brand {
    display: flex;
    align-items: center;
    gap: 9px;
    text-decoration: none;
    flex-shrink: 0;
}

.kanso-nav-brand:hover { text-decoration: none; }

.kanso-nav-icon {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
}

.kanso-nav-wordmark {
    display: flex;
    flex-direction: column;
    line-height: 1;
}

.kanso-nav-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: -0.3px;
}

.kanso-nav-sub {
    font-size: 9px;
    color: var(--text-faint);
    letter-spacing: 0.4px;
    text-transform: uppercase;
    margin-top: 1px;
    white-space: nowrap;
}

/* Nav links */
.kanso-nav-links {
    display: flex;
    align-items: center;
    gap: 2px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.kanso-nav-links a {
    display: block;
    padding: 6px 11px;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 7px;
    transition: color 0.15s ease, background 0.15s ease;
    white-space: nowrap;
}

.kanso-nav-links a:hover {
    color: var(--text);
    background: var(--surface-hover);
}

.kanso-nav-links a.active {
    color: var(--primary);
    background: var(--primary-dim);
}

/* Nav right cluster */
.kanso-nav-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* ── Theme Toggle ────────────────────────────────────────── */

.theme-toggle {
    display: flex;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 3px;
    gap: 2px;
}

.theme-btn {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    transition: background 0.15s ease, transform 0.15s ease;
    padding: 0;
}

.theme-btn:hover { transform: scale(1.1); }

.theme-btn.active {
    background: var(--primary-dim);
    box-shadow: 0 0 0 1.5px var(--primary);
}

.theme-btn svg {
    width: 14px;
    height: 14px;
}

/* Sign out link */
.kanso-signout {
    font-size: 13px;
    color: var(--text-faint);
    text-decoration: none;
    padding: 6px 10px;
    border-radius: 7px;
    transition: color 0.15s ease, background 0.15s ease;
    white-space: nowrap;
}

.kanso-signout:hover {
    color: var(--danger);
    background: var(--danger-dim);
}

/* ── Page Layout ─────────────────────────────────────────── */

.kanso-page {
    max-width: 860px;
    margin: 0 auto;
    padding: 2rem 1.5rem 4rem;
}

.kanso-page-wide {
    max-width: 1120px;
    margin: 0 auto;
    padding: 2rem 1.5rem 4rem;
}

/* Page header */
.kanso-page-header {
    margin-bottom: 2rem;
}

.kanso-page-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.4px;
    margin: 0 0 3px;
}

.kanso-page-subtitle {
    font-size: 14px;
    color: var(--text-muted);
    margin: 0;
}

/* ── Section ─────────────────────────────────────────────── */

.kanso-section {
    margin-bottom: 1.5rem;
}

.kanso-section-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-faint);
    letter-spacing: 0.8px;
    text-transform: uppercase;
    margin-bottom: 8px;
    padding: 0 2px;
}

/* ── Card ────────────────────────────────────────────────── */

.kanso-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
    transition: background-color 0.25s ease, border-color 0.25s ease;
}

.kanso-card + .kanso-card { margin-top: 1px; }

/* Card row — icon | label+description | action */
.kanso-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-subtle);
    transition: background 0.15s ease;
}

.kanso-row:last-child { border-bottom: none; }
.kanso-row:hover { background: var(--surface-raised); }

.kanso-row-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--primary-dim);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--primary);
}

.kanso-row-icon.danger { background: var(--danger-dim); color: var(--danger); }
.kanso-row-icon.success { background: var(--success-dim); color: var(--success); }
.kanso-row-icon.warning { background: var(--warning-dim); color: var(--warning); }
.kanso-row-icon.muted {
    background: var(--surface-raised);
    color: var(--text-muted);
}

.kanso-row-icon svg {
    width: 18px;
    height: 18px;
}

.kanso-row-body {
    flex: 1;
    min-width: 0;
}

.kanso-row-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kanso-row-desc {
    font-size: 12.5px;
    color: var(--text-muted);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kanso-row-action {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ── Password strength requirements list ────────────────── */

.pwd-req-list {
    list-style: none;
    margin: 6px 0 0;
    padding: 0;
    font-size: 11.5px;
    line-height: 1.8;
}
.pwd-req-list li { color: var(--text-faint); }
.pwd-req-list li::before { content: '○  '; }
.pwd-req-list li.met { color: var(--success); }
.pwd-req-list li.met::before { content: '✓  '; }

/* ── Table (used inside kanso-card) ─────────────────────── */

.kanso-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
    color: var(--text);
}

.kanso-table thead th {
    padding: 12px 16px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-faint);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.kanso-table tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-subtle);
    vertical-align: middle;
}

.kanso-table tbody tr:last-child td { border-bottom: none; }
.kanso-table tbody tr:hover td { background: var(--surface-raised); }

/* ── Info strip (top status bar) ─────────────────────────── */

.kanso-info-strip {
    display: flex;
    align-items: center;
    gap: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.kanso-info-item {
    flex: 1;
    padding: 14px 18px;
    border-right: 1px solid var(--border-subtle);
}

.kanso-info-item:last-child { border-right: none; }

.kanso-info-label {
    font-size: 11px;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 4px;
}

.kanso-info-value {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

.kanso-info-value.primary { color: var(--primary); }
.kanso-info-value.muted { color: var(--text-muted); font-weight: 400; font-size: 13.5px; }

/* ── Status dot ──────────────────────────────────────────── */

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
}

.status-dot.green { background: var(--success); }
.status-dot.red   { background: var(--danger); }
.status-dot.amber { background: var(--warning); }

/* ── Buttons ─────────────────────────────────────────────── */

.btn-kanso {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 16px;
    border-radius: 9px;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    border: 1px solid transparent;
    transition: all 0.15s ease;
    white-space: nowrap;
    line-height: 1;
}

.btn-kanso svg { width: 15px; height: 15px; }

.btn-kanso-primary {
    background: var(--primary);
    color: var(--bg);
    border-color: var(--primary);
}

.btn-kanso-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    color: var(--bg);
    text-decoration: none;
}

.btn-kanso-ghost {
    background: var(--surface-raised);
    color: var(--text);
    border-color: var(--border);
}

.btn-kanso-ghost:hover {
    background: var(--surface-hover);
    color: var(--text);
    text-decoration: none;
}

.btn-kanso-danger {
    background: var(--danger-dim);
    color: var(--danger);
    border-color: transparent;
}

.btn-kanso-danger:hover {
    background: var(--danger);
    color: white;
    text-decoration: none;
}

.btn-kanso-danger-solid {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}

.btn-kanso-danger-solid:hover {
    opacity: 0.85;
    color: white;
    text-decoration: none;
}

.btn-kanso:disabled,
.btn-kanso[disabled] {
    opacity: 0.38;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-kanso-sm {
    padding: 5px 11px;
    font-size: 12.5px;
    border-radius: 7px;
}

/* ── Forms ───────────────────────────────────────────────── */

.kanso-input {
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: 9px;
    color: var(--text);
    font-size: 14px;
    padding: 8px 12px;
    width: 100%;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    font-family: inherit;
}

.kanso-input::placeholder { color: var(--text-faint); }

.kanso-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-dim);
}

/* Select */
.kanso-select {
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: 9px;
    color: var(--text);
    font-size: 14px;
    padding: 8px 32px 8px 12px;
    width: 100%;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    font-family: inherit;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%238A8278' d='M4.5 6.5 8 10 11.5 6.5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px;
    cursor: pointer;
}
.kanso-select option { background: var(--surface); color: var(--text); }
.kanso-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-dim);
}

/* Input group (prefix/suffix) */
.kanso-input-group {
    display: flex;
    align-items: stretch;
    width: 100%;
}
.kanso-input-affix {
    display: flex;
    align-items: center;
    padding: 0 10px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--surface);
    border: 1px solid var(--border);
    white-space: nowrap;
}
.kanso-input-affix.prefix {
    border-right: none;
    border-radius: 9px 0 0 9px;
}
.kanso-input-affix.suffix {
    border-left: none;
    border-radius: 0 9px 9px 0;
}
.kanso-input-group .kanso-input.has-prefix {
    border-radius: 0 9px 9px 0;
    border-left: none;
}
.kanso-input-group .kanso-input.has-suffix {
    border-radius: 9px 0 0 9px;
    border-right: none;
}

/* Form label + hint */
.kanso-form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 5px;
}
.kanso-form-hint {
    font-size: 11.5px;
    color: var(--text-faint);
    margin-top: 4px;
}

/* Form grid */
.kanso-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px 20px;
}
.kanso-form-grid .span-2 { grid-column: 1 / -1; }

/* Form section label (inside card) */
.kanso-form-section {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--primary);
    margin: 0 0 12px;
}

/* Tip / note boxes */
.kanso-tip-box {
    background: var(--primary-dim);
    border: 1px solid var(--border);
    border-left: 3px solid var(--primary);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 12.5px;
    color: var(--text-muted);
    line-height: 1.5;
}
.kanso-note-box {
    background: color-mix(in srgb, var(--wants) 10%, transparent);
    border: 1px solid var(--border);
    border-left: 3px solid var(--wants);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 12.5px;
    color: var(--text-muted);
    line-height: 1.5;
}

/* File input */
.kanso-file-label {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 14px;
    border-radius: 9px;
    font-size: 13.5px;
    font-weight: 500;
    background: var(--surface-raised);
    border: 1px dashed var(--border);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
}

.kanso-file-label:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-dim);
}

.kanso-file-name {
    font-size: 12.5px;
    color: var(--text-muted);
    margin-left: 4px;
}

/* ── Theme picker (Settings) ─────────────────────────────── */

.theme-picker {
    display: flex;
    gap: 10px;
    padding: 16px 18px;
}

.theme-option {
    flex: 1;
    border-radius: 12px;
    border: 2px solid var(--border);
    padding: 12px;
    cursor: pointer;
    transition: border-color 0.15s ease, transform 0.15s ease;
    background: none;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.theme-option:hover { transform: translateY(-1px); }
.theme-option.active { border-color: var(--primary); }

.theme-swatch {
    display: flex;
    gap: 4px;
    height: 24px;
    border-radius: 6px;
    overflow: hidden;
}

.theme-swatch span {
    flex: 1;
    border-radius: 0;
}

.theme-option-name {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text);
}

.theme-option-desc {
    font-size: 11.5px;
    color: var(--text-muted);
}

/* ── Danger section ──────────────────────────────────────── */

.kanso-danger-card {
    background: var(--surface);
    border: 1px solid var(--danger);
    border-radius: 14px;
    overflow: hidden;
    opacity: 0.85;
    transition: opacity 0.2s ease;
}

.kanso-danger-card:hover { opacity: 1; }

.kanso-danger-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 18px;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--danger);
    font-size: 13.5px;
    font-weight: 600;
}

.kanso-danger-body {
    padding: 16px 18px;
}

/* ── Backup history list ─────────────────────────────────── */

.backup-list { list-style: none; margin: 0; padding: 0; }

.backup-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 18px;
    border-bottom: 1px solid var(--border-subtle);
    transition: background 0.15s ease;
}

.backup-item:last-child { border-bottom: none; }
.backup-item:hover { background: var(--surface-raised); }

.backup-item-icon {
    color: var(--text-faint);
    flex-shrink: 0;
}

.backup-item-name {
    flex: 1;
    font-size: 13px;
    color: var(--text);
    font-family: 'SF Mono', 'Fira Code', monospace;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.backup-item-meta {
    font-size: 12px;
    color: var(--text-faint);
    white-space: nowrap;
    flex-shrink: 0;
}

.backup-item-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

/* ── Progress bar ────────────────────────────────────────── */

.kanso-progress-wrap {
    background: var(--surface-raised);
    border-radius: 6px;
    height: 8px;
    overflow: hidden;
}

.kanso-progress-bar {
    height: 100%;
    background: var(--primary);
    border-radius: 6px;
    transition: width 0.4s ease;
}

/* ── Inline feedback ─────────────────────────────────────── */

.kanso-feedback {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    padding: 10px 14px;
    border-radius: 9px;
    margin-top: 10px;
}

.kanso-feedback.success {
    background: var(--success-dim);
    color: var(--success);
}

.kanso-feedback.error {
    background: var(--danger-dim);
    color: var(--danger);
}

.kanso-feedback.info {
    background: var(--primary-dim);
    color: var(--primary);
}

/* ── Footer ──────────────────────────────────────────────── */

.kanso-footer {
    border-top: 1px solid var(--border-subtle);
    padding: 20px 0;
    text-align: center;
    font-size: 12px;
    color: var(--text-faint);
    margin-top: 3rem;
}

/* ── Flash messages ──────────────────────────────────────── */

.kanso-flash {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 13.5px;
    margin-bottom: 12px;
}

.kanso-flash.success {
    background: var(--success-dim);
    color: var(--success);
    border: 1px solid var(--success);
}

.kanso-flash.error,
.kanso-flash.danger {
    background: var(--danger-dim);
    color: var(--danger);
    border: 1px solid var(--danger);
}

.kanso-flash.info {
    background: var(--primary-dim);
    color: var(--primary);
    border: 1px solid var(--primary);
}

.kanso-flash-close {
    margin-left: auto;
    background: none;
    border: none;
    cursor: pointer;
    color: inherit;
    opacity: 0.6;
    padding: 0;
    line-height: 1;
    font-size: 16px;
}

/* ── Code ────────────────────────────────────────────────── */

code {
    font-family: 'SF Mono', 'Fira Code', 'Fira Mono', monospace;
    font-size: 12.5px;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    padding: 1px 6px;
    border-radius: 5px;
    color: var(--primary);
}

/* ── Utilities ───────────────────────────────────────────── */

.text-primary-k { color: var(--primary); }
.text-muted-k   { color: var(--text-muted); }
.text-faint-k   { color: var(--text-faint); }
.text-danger-k  { color: var(--danger); }
.text-success-k { color: var(--success); }

.mt-section { margin-top: 2rem; }

/* ── Debt Page ──────────────────────────────────────────── */

/* Summary strip: use kanso-info-strip already defined */

/* Debt list card */
.debt-list { list-style: none; margin: 0; padding: 0; }

.debt-item {
    border-bottom: 1px solid var(--border-subtle);
    transition: background 0.15s ease;
}
.debt-item:last-child { border-bottom: none; }

.debt-item-main {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 15px 18px;
    transition: background 0.15s ease;
}
.debt-item:hover .debt-item-main { background: var(--surface-raised); }

.debt-item-identity { flex: 0 0 170px; min-width: 0; }
.debt-item-name-text {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    display: inline;
}
.debt-item-last4 {
    font-size: 11px;
    color: var(--text-faint);
    font-family: 'SF Mono', monospace;
    margin-top: 1px;
}
.debt-type-badge {
    display: inline-block;
    font-size: 10.5px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 5px;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    color: var(--text-muted);
    margin-top: 5px;
    letter-spacing: 0.2px;
}

.debt-paid-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    padding: 1px 7px;
    border-radius: 4px;
    background: var(--success-dim);
    color: var(--success);
    margin-left: 6px;
    vertical-align: middle;
}

.debt-item-owner {
    flex: 0 0 80px;
    font-size: 13px;
    color: var(--text-muted);
    white-space: nowrap;
}

.debt-item-balance { flex: 0 0 140px; }
.debt-balance-value {
    font-size: 17px;
    font-weight: 700;
    color: var(--danger);
    font-variant-numeric: tabular-nums;
}
.debt-balance-value.paid-off { color: var(--success); }
.debt-balance-label {
    font-size: 11px;
    color: var(--text-faint);
    margin-top: 1px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.debt-item-progress { flex: 1; min-width: 70px; }
.debt-progress-mini-track {
    height: 4px;
    background: var(--surface-hover);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 4px;
}
.debt-progress-mini-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 2px;
    transition: width 0.4s ease;
}
.debt-progress-mini-label {
    font-size: 11px;
    color: var(--text-faint);
}

.debt-item-payment { flex: 0 0 110px; }
.debt-min-payment {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}
.debt-min-label {
    font-size: 11px;
    color: var(--text-faint);
    margin-top: 1px;
}

.debt-item-actions {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-left: auto;
}

.debt-action-btn {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface-raised);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    padding: 0;
    flex-shrink: 0;
}
.debt-action-btn svg { width: 14px; height: 14px; }
.debt-action-btn:hover { transform: scale(1.06); }
.debt-action-btn.payment:hover {
    background: var(--success-dim);
    color: var(--success);
    border-color: var(--success);
}
.debt-action-btn.edit:hover {
    background: var(--primary-dim);
    color: var(--primary);
    border-color: var(--primary);
}
.debt-action-btn.history:hover {
    background: rgba(106, 143, 191, 0.15);
    color: var(--business);
    border-color: var(--business);
}
.debt-action-btn.delete:hover {
    background: var(--danger-dim);
    color: var(--danger);
    border-color: var(--danger);
}

.debt-expand-btn {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    border: 1px solid var(--border-subtle);
    background: transparent;
    color: var(--text-faint);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    padding: 0;
    flex-shrink: 0;
}
.debt-expand-btn:hover {
    color: var(--text);
    border-color: var(--border);
}
.debt-expand-btn.expanded svg { transform: rotate(180deg); }
.debt-expand-btn svg {
    width: 12px;
    height: 12px;
    transition: transform 0.2s ease;
}

/* Detail expand section */
.debt-item-details {
    padding: 14px 18px 16px;
    border-top: 1px solid var(--border-subtle);
    background: var(--surface-raised);
}

.debt-details-grid {
    display: flex;
    gap: 28px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.debt-detail-label {
    font-size: 10.5px;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 3px;
}
.debt-detail-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}
.debt-detail-value.positive { color: var(--success); }

.debt-progress-full-track {
    height: 18px;
    background: var(--surface-hover);
    border-radius: 5px;
    overflow: hidden;
    margin-bottom: 5px;
}
.debt-progress-full-fill {
    height: 100%;
    background: var(--danger);
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: white;
    transition: width 0.4s ease;
    min-width: 30px;
}
.debt-progress-full-fill.mid { background: var(--wants); }
.debt-progress-full-fill.high { background: var(--success); }

.debt-progress-end-labels {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-faint);
}

/* Paid-off debt row */
.debt-paid-off .debt-item-main { opacity: 0.6; }

/* Show paid-off toggle */
.debt-header-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
}
.debt-header-toggle input[type="checkbox"] {
    accent-color: var(--primary);
    width: 14px;
    height: 14px;
    cursor: pointer;
}

/* Charts section */
.debt-charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 16px;
}

/* Insights */
.debt-insights-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}
.debt-insight-card {
    padding: 14px 16px;
    border-radius: 10px;
    background: var(--surface-raised);
    border: 1px solid var(--border-subtle);
}
.debt-insight-label {
    font-size: 11px;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}
.debt-insight-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 2px;
}
.debt-insight-value {
    font-size: 13px;
    color: var(--text-muted);
}

/* ── Kanso Modal ─────────────────────────────────────────── */
.kanso-modal .modal-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.4);
    color: var(--text);
}
.kanso-modal .modal-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border-subtle);
    border-radius: 16px 16px 0 0;
    padding: 16px 20px;
}
.kanso-modal .modal-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
}
.kanso-modal .btn-close {
    filter: var(--btn-close-filter, invert(0.5));
    opacity: 0.6;
}
[data-theme="warm-ink"] .kanso-modal .btn-close,
[data-theme="indigo"] .kanso-modal .btn-close {
    filter: invert(1) opacity(0.5);
}
.kanso-modal .modal-body {
    background: var(--surface);
    padding: 20px;
    color: var(--text);
}
.kanso-modal .modal-footer {
    background: var(--surface);
    border-top: 1px solid var(--border-subtle);
    border-radius: 0 0 16px 16px;
    padding: 14px 20px;
    gap: 8px;
}
/* Modal backdrop darker for dark themes */
[data-theme="warm-ink"] .modal-backdrop,
[data-theme="indigo"] .modal-backdrop {
    background: rgba(0,0,0,0.7);
}

/* Modal form elements */
.kanso-modal label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 5px;
    display: block;
}
.kanso-modal .form-control,
.kanso-modal .form-select {
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: 9px;
    color: var(--text);
    font-size: 14px;
    padding: 8px 12px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.kanso-modal .form-control::placeholder { color: var(--text-faint); }
.kanso-modal .form-control:focus,
.kanso-modal .form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-dim);
    background: var(--surface-raised);
    color: var(--text);
}
.kanso-modal .form-select option {
    background: var(--surface-raised);
    color: var(--text);
}
.kanso-modal .input-group-text {
    background: var(--surface-hover);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 13px;
}
.kanso-modal .form-text {
    font-size: 11.5px;
    color: var(--text-faint);
    margin-top: 4px;
}
.kanso-modal .form-control.is-invalid {
    border-color: var(--danger);
}
.kanso-modal .form-control.is-valid {
    border-color: var(--success);
}
.kanso-modal .btn-link {
    color: var(--primary);
    font-size: 12.5px;
    text-decoration: none;
    padding: 0;
    background: none;
    border: none;
    cursor: pointer;
}
.kanso-modal .btn-link:hover { text-decoration: underline; }

/* Modal section headers */
.modal-section-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-subtle);
}

/* Modal balance strip */
.modal-balance-strip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--primary-dim);
    border: 1px solid var(--primary);
    border-radius: 10px;
    padding: 12px 16px;
    margin-bottom: 18px;
}
.modal-balance-main {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}
.modal-balance-main span { color: var(--danger); }
.modal-balance-min {
    font-size: 13px;
    color: var(--text-muted);
}

/* Modal note block */
.modal-note {
    background: var(--warning-dim);
    border: 1px solid var(--warning);
    border-radius: 9px;
    padding: 12px 14px;
    font-size: 12.5px;
    color: var(--text-muted);
    margin-top: 14px;
}
.modal-note strong { color: var(--text); }
.modal-note ul { margin: 6px 0 0 0; padding-left: 16px; }

/* History modal summary strip */
.history-summary-strip {
    display: flex;
    gap: 0;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 16px;
}
.history-summary-item {
    flex: 1;
    padding: 12px 14px;
    border-right: 1px solid var(--border-subtle);
    text-align: center;
}
.history-summary-item:last-child { border-right: none; }
.history-summary-label {
    font-size: 10.5px;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 4px;
}
.history-summary-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

/* History view toggle */
.history-view-toggle {
    display: flex;
    gap: 4px;
    margin-bottom: 14px;
}
.history-toggle-btn {
    flex: 1;
    padding: 7px 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface-raised);
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}
.history-toggle-btn:hover {
    background: var(--surface-hover);
    color: var(--text);
}
.history-toggle-btn.active {
    background: var(--primary-dim);
    color: var(--primary);
    border-color: var(--primary);
}

/* History table in modal */
.kanso-modal .table {
    color: var(--text);
    font-size: 13.5px;
}
.kanso-modal .table thead th {
    color: var(--text-faint);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
    padding: 8px 10px;
    background: transparent;
}
.kanso-modal .table tbody td {
    border-bottom: 1px solid var(--border-subtle);
    padding: 10px;
    color: var(--text);
    vertical-align: middle;
    background: transparent;
}
.kanso-modal .table tbody tr:last-child td { border-bottom: none; }
.kanso-modal .table tbody tr:hover td { background: var(--surface-raised); }

/* Badge variants inside modals */
.kanso-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 9px;
    border-radius: 5px;
}
.kanso-badge-payment {
    background: var(--success-dim);
    color: var(--success);
}
.kanso-badge-charge {
    background: var(--danger-dim);
    color: var(--danger);
}
.kanso-badge-type {
    background: var(--surface-hover);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

/* Empty state in modal */
.modal-empty-state {
    text-align: center;
    padding: 32px 20px;
    color: var(--text-faint);
    font-size: 14px;
}

/* Spinner for dark themes */
[data-theme="warm-ink"] .spinner-border,
[data-theme="indigo"] .spinner-border {
    border-color: var(--primary);
    border-right-color: transparent;
}

/* ── Transaction List ────────────────────────────────────── */

.txn-list { list-style: none; margin: 0; padding: 0; }

.txn-item {
    border-bottom: 1px solid var(--border-subtle);
    transition: background 0.15s ease;
}
.txn-item:last-child { border-bottom: none; }

.txn-item-main {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 18px;
    transition: background 0.15s ease;
}
.txn-item:hover .txn-item-main { background: var(--surface-raised); }

.txn-date {
    flex: 0 0 56px;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    line-height: 1.3;
    text-align: center;
}
.txn-date-day {
    font-weight: 600;
    color: var(--text);
}
.txn-date-year {
    font-size: 11px;
    color: var(--text-faint);
}

.txn-desc {
    flex: 1;
    min-width: 0;
}
.txn-desc-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.txn-desc-sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.txn-amount {
    flex: 0 0 110px;
    text-align: right;
    font-size: 14px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.txn-amount.income { color: var(--success); }
.txn-amount.expense { color: var(--danger); }

.txn-type {
    flex: 0 0 90px;
    text-align: center;
}
.txn-type-badge {
    display: inline-block;
    font-size: 10.5px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 5px;
    letter-spacing: 0.2px;
    border: 1px solid;
}
.txn-type-needs {
    background: color-mix(in srgb, var(--needs) 15%, transparent);
    border-color: var(--needs);
    color: var(--needs);
}
.txn-type-wants {
    background: color-mix(in srgb, var(--wants) 15%, transparent);
    border-color: var(--wants);
    color: var(--wants);
}
.txn-type-savings {
    background: color-mix(in srgb, var(--savings) 15%, transparent);
    border-color: var(--savings);
    color: var(--savings);
}
.txn-type-business {
    background: color-mix(in srgb, var(--business) 15%, transparent);
    border-color: var(--business);
    color: var(--business);
}

.txn-actions {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 4px;
}

.txn-expand-btn {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    border: 1px solid var(--border-subtle);
    background: transparent;
    color: var(--text-faint);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    padding: 0;
    flex-shrink: 0;
}
.txn-expand-btn:hover {
    color: var(--text);
    border-color: var(--border);
}
.txn-expand-btn.open svg { transform: rotate(180deg); }
.txn-expand-btn svg {
    width: 12px;
    height: 12px;
    transition: transform 0.2s ease;
}

.txn-item-details {
    padding: 12px 18px 14px;
    border-top: 1px solid var(--border-subtle);
    background: var(--surface-raised);
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px 20px;
}

.txn-detail-label {
    font-size: 10px;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 3px;
}
.txn-detail-value {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
}

.txn-income-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 4px;
    background: var(--success-dim);
    color: var(--success);
    margin-left: 5px;
    vertical-align: middle;
}
.txn-expense-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 4px;
    background: var(--surface-hover);
    color: var(--text-faint);
    border: 1px solid var(--border-subtle);
    margin-left: 5px;
    vertical-align: middle;
}

/* ── Pagination ───────────────────────────────────────────── */

.kanso-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-top: 20px;
    flex-wrap: wrap;
}
.kanso-pagination a,
.kanso-pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    border-radius: 7px;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    border: 1px solid var(--border);
    background: var(--surface-raised);
    color: var(--text-muted);
    transition: all 0.15s ease;
}
.kanso-pagination a:hover {
    background: var(--surface-hover);
    color: var(--text);
    text-decoration: none;
}
.kanso-pagination .active {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--bg);
    font-weight: 700;
}
.kanso-pagination .disabled {
    opacity: 0.35;
    cursor: default;
    pointer-events: none;
}

/* ── Bulk row ─────────────────────────────────────────────── */

.bulk-item-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-subtle);
}
.bulk-item-row:last-child { border-bottom: none; }
.bulk-item-row .kanso-input { font-size: 13.5px; }

/* is-invalid support for kanso inputs */
.kanso-input.is-invalid { border-color: var(--danger); }
