/* ===== Design Tokens ===== */
:root {
    --bg: #f7f8fb;
    --bg-elevated: #ffffff;
    --bg-subtle: #f1f3f8;
    --bg-hover: #f8fafc;

    --border: #e4e7ec;
    --border-strong: #d0d5dd;

    --text: #101828;
    --text-secondary: #475467;
    --text-muted: #98a2b3;

    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-soft: #eef2ff;

    --success: #10b981;
    --success-soft: #ecfdf5;
    --danger: #ef4444;
    --danger-soft: #fef2f2;
    --warning: #f59e0b;
    --warning-soft: #fffbeb;

    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
    --shadow: 0 1px 3px rgba(16, 24, 40, 0.06), 0 1px 2px rgba(16, 24, 40, 0.04);
    --shadow-md: 0 4px 8px -2px rgba(16, 24, 40, 0.08), 0 2px 4px -2px rgba(16, 24, 40, 0.04);
    --shadow-lg: 0 12px 16px -4px rgba(16, 24, 40, 0.08), 0 4px 6px -2px rgba(16, 24, 40, 0.03);
    --shadow-xl: 0 20px 24px -4px rgba(16, 24, 40, 0.08), 0 8px 8px -4px rgba(16, 24, 40, 0.03);

    --radius-sm: 6px;
    --radius: 10px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 999px;

    --transition: 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang TC', 'Microsoft JhengHei', sans-serif;
    background: var(--bg);
    background-image:
        radial-gradient(at 0% 0%, rgba(79, 70, 229, 0.05) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(16, 185, 129, 0.04) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text);
    line-height: 1.5;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 32px 24px 80px;
}

/* ===== Header ===== */
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 4px;
    margin-bottom: 28px;
    flex-wrap: wrap;
    gap: 16px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

/* ===== FX Badge ===== */
.fx-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    padding: 6px 12px;
    box-shadow: var(--shadow-sm);
    font-size: 12px;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.fx-badge .fx-pair {
    font-weight: 500;
    color: var(--text-muted);
    font-size: 11px;
    letter-spacing: 0.04em;
}

.fx-badge .fx-rate {
    font-weight: 600;
    color: var(--text);
    font-size: 13px;
}

.fx-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.18);
}

/* ===== Field hints ===== */
.optional {
    color: var(--text-muted);
    font-weight: 400;
    font-size: 12px;
    margin-left: 2px;
}

.field-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
    min-height: 16px;
    display: block;
    transition: color 120ms ease;
}

.field-hint.loading { color: var(--primary); }
.field-hint.success { color: var(--success); }
.field-hint.error   { color: var(--danger); }

/* ===== Tabs ===== */
.tabs {
    display: inline-flex;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 4px;
    box-shadow: var(--shadow-sm);
    gap: 2px;
}

.tab {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.tab:hover:not(.active) {
    color: var(--text);
    background: var(--bg-subtle);
}

.tab.active {
    background: var(--primary);
    color: white;
    box-shadow: var(--shadow-sm);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; animation: panelIn 220ms cubic-bezier(0.16, 1, 0.3, 1); }

@keyframes panelIn {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ===== Analysis ===== */
.analysis-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.stat-tile {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.stat-tile:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow);
}

.stat-tile.primary {
    background: linear-gradient(135deg, #1e1b4b 0%, #4f46e5 100%);
    color: white;
    border: none;
    box-shadow: var(--shadow-md);
}

.stat-tile .stat-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.stat-tile.primary .stat-label { color: rgba(255,255,255,0.75); }

.stat-tile .stat-value {
    font-size: 22px;
    font-weight: 600;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
    line-height: 1.2;
}

.stat-tile.primary .stat-value { color: white; }
.stat-tile .stat-value.negative { color: var(--danger); }

.stat-tile .stat-sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.stat-tile.primary .stat-sub { color: rgba(255,255,255,0.65); }

.analysis-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

.donut-card {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 28px;
    align-items: center;
}

.donut-card.compact {
    gap: 20px;
}

.donut-wrap {
    width: 220px;
    height: 220px;
    flex-shrink: 0;
    position: relative;
}

.donut-wrap.small {
    width: 170px;
    height: 170px;
}

.donut-wrap svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

.donut-wrap .donut-center {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    text-align: center;
}

.donut-wrap .donut-center .label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 500;
}

.donut-wrap .donut-center .value {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    margin-top: 2px;
    letter-spacing: -0.01em;
}

.donut-wrap.small .donut-center .value {
    font-size: 15px;
}

.donut-slice {
    fill: none;
    stroke-width: 22;
    transition: stroke-width 180ms ease;
    cursor: pointer;
}

.donut-wrap.small .donut-slice {
    stroke-width: 18;
}

.donut-slice:hover {
    stroke-width: 28;
}

.donut-wrap.small .donut-slice:hover {
    stroke-width: 22;
}

.legend-wrap {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.legend-item {
    display: grid;
    grid-template-columns: 10px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    transition: background 120ms ease;
}

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

.legend-item .swatch {
    width: 10px;
    height: 10px;
    border-radius: 3px;
}

.legend-item .legend-name {
    min-width: 0;
    line-height: 1.3;
}

.legend-item .name {
    color: var(--text);
    font-weight: 500;
    font-size: 13px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}

.legend-item .sub {
    color: var(--text-muted);
    font-weight: 400;
    font-size: 11px;
    font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
    margin-top: 1px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.legend-item .legend-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    line-height: 1.3;
}

.legend-item .pct {
    color: var(--text);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    font-size: 13px;
}

.legend-item .amt {
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    font-size: 11px;
}

.empty-chart {
    grid-column: 1 / -1;
    padding: 32px 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

@media (max-width: 640px) {
    .donut-card { grid-template-columns: 1fr; justify-items: center; }
    .donut-card.compact .legend-wrap { width: 100%; }
    .analysis-grid { grid-template-columns: 1fr; }
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-mark {
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    display: grid;
    place-items: center;
    color: white;
    font-weight: 700;
    font-size: 20px;
    box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255,255,255,0.15);
}

header h1 {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text);
}

header .subtitle {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ===== Summary Panel ===== */
.summary-panel {
    display: grid;
    grid-template-columns: 1.2fr 2fr auto;
    gap: 16px;
    align-items: stretch;
    margin-bottom: 24px;
}

.summary-hero {
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, #1e1b4b 0%, #4f46e5 60%, #7c3aed 100%);
    color: white;
    padding: 24px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
}

.summary-hero::after {
    content: '';
    position: absolute;
    top: -40%;
    right: -20%;
    width: 280px;
    height: 280px;
    background: radial-gradient(circle, rgba(255,255,255,0.15) 0%, transparent 70%);
    pointer-events: none;
}

.summary-hero .label {
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255,255,255,0.75);
    margin-bottom: 12px;
}

.total-value {
    font-size: 36px;
    font-weight: 700;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}

.total-value .currency {
    font-size: 18px;
    font-weight: 500;
    margin-right: 4px;
    opacity: 0.75;
}

.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
}

.type-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    padding: 14px 16px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.type-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
    border-color: var(--border-strong);
}

.type-card .type-card-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
}

.type-card .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.type-card[data-type="stock_tw"] .dot    { background: #2563eb; }
.type-card[data-type="stock_us"] .dot    { background: #f97316; }
.type-card[data-type="crypto"] .dot      { background: #a855f7; }
.type-card[data-type="real_estate"] .dot { background: #d97706; }
.type-card[data-type="cash"] .dot        { background: #10b981; }
.type-card[data-type="loan"] .dot        { background: #ef4444; }

.type-card .type-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
}

.type-card .type-value {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
}

.type-card .type-count {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

.summary-actions {
    display: flex;
    align-items: stretch;
}

/* ===== Section ===== */
section.card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
    overflow: hidden;
}

.card-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.card-header h2 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.005em;
}

.card-header .hint {
    font-size: 12px;
    color: var(--text-muted);
}

.card-body {
    padding: 24px;
}

/* ===== Form ===== */
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-group label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.form-group label .required {
    color: var(--danger);
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    background: var(--bg-elevated);
    transition: var(--transition);
    width: 100%;
    font-variant-numeric: tabular-nums;
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-muted);
}

.form-group textarea {
    resize: vertical;
    min-height: 70px;
    font-variant-numeric: normal;
}

.form-group input:hover,
.form-group select:hover,
.form-group textarea:hover {
    border-color: var(--border-strong);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.form-group select {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

.form-actions {
    display: flex;
    gap: 8px;
    padding-top: 8px;
}

/* ===== Button ===== */
.btn {
    padding: 9px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    line-height: 1;
    white-space: nowrap;
    user-select: none;
}

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

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255,255,255,0.15);
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255,255,255,0.15);
}

.btn-secondary {
    background: var(--bg-elevated);
    color: var(--text-secondary);
    border-color: var(--border);
    box-shadow: var(--shadow-sm);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--bg-hover);
    color: var(--text);
    border-color: var(--border-strong);
}

.btn-refresh {
    background: var(--bg-elevated);
    color: var(--text);
    border-color: var(--border);
    box-shadow: var(--shadow-sm);
    font-weight: 500;
    padding: 0 18px;
    height: 100%;
    min-height: 48px;
}

.btn-refresh:hover:not(:disabled) {
    background: var(--bg-hover);
    border-color: var(--border-strong);
    box-shadow: var(--shadow);
}

.btn-refresh .icon {
    width: 14px;
    height: 14px;
    transition: transform 400ms ease;
}

.btn-refresh.loading .icon {
    animation: spin 1s linear infinite;
}

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

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    padding: 6px 10px;
    font-size: 12px;
}

.btn-ghost:hover:not(:disabled) {
    background: var(--bg-subtle);
    color: var(--text);
}

.btn-ghost.danger:hover:not(:disabled) {
    background: var(--danger-soft);
    color: var(--danger);
}

/* ===== List filter tabs ===== */
.list-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-subtle);
}

.list-tab {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary);
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.list-tab:hover:not(.active) {
    background: var(--bg-elevated);
    color: var(--text);
}

.list-tab.active {
    background: var(--bg-elevated);
    color: var(--text);
    border-color: var(--border);
    box-shadow: var(--shadow-sm);
}

.list-tab .count {
    font-size: 11px;
    background: rgba(0, 0, 0, 0.06);
    color: var(--text-muted);
    padding: 1px 6px;
    min-width: 18px;
    text-align: center;
    border-radius: var(--radius-full);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.list-tab.active .count {
    background: var(--primary);
    color: white;
}

/* ===== Table ===== */
.table-wrap {
    overflow-x: auto;
    margin: -1px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

table thead {
    background: var(--bg-subtle);
}

table th {
    padding: 11px 16px;
    text-align: left;
    font-weight: 500;
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

table th.text-right { text-align: right; }
table td.text-right { text-align: right; font-variant-numeric: tabular-nums; }

table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    font-size: 14px;
    color: var(--text);
}

table tbody tr {
    transition: background 100ms ease;
}

table tbody tr:hover {
    background: var(--bg-hover);
}

table tbody tr:last-child td {
    border-bottom: none;
}

.asset-name {
    font-weight: 500;
    color: var(--text);
}

.asset-symbol {
    font-size: 12px;
    color: var(--text-muted);
    font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
}

.row-actions {
    display: flex;
    gap: 4px;
    justify-content: flex-end;
}

.empty-state {
    padding: 64px 24px;
    text-align: center;
    color: var(--text-muted);
}

.empty-state .empty-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 16px;
    border-radius: 50%;
    background: var(--bg-subtle);
    display: grid;
    place-items: center;
    color: var(--text-muted);
}

.empty-state .empty-title {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.empty-state .empty-desc {
    font-size: 13px;
    color: var(--text-muted);
}

/* ===== Badges ===== */
.type-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 500;
    line-height: 1.4;
    white-space: nowrap;
}

.type-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.badge-stock_tw    { background: #eff6ff; color: #1d4ed8; }
.badge-stock_us    { background: #fff7ed; color: #c2410c; }
.badge-crypto      { background: #faf5ff; color: #7e22ce; }
.badge-real_estate { background: #fef3c7; color: #92400e; }
.badge-cash        { background: #ecfdf5; color: #047857; }
.badge-loan        { background: #fef2f2; color: #b91c1c; }

/* ===== P/L indicator ===== */
.pl {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-variant-numeric: tabular-nums;
    font-weight: 500;
}

.pl-positive { color: var(--success); }
.pl-negative { color: var(--danger); }
.pl-neutral  { color: var(--text-muted); }

.pl .arrow {
    font-size: 10px;
    line-height: 1;
}

.pl-pct {
    font-size: 12px;
    opacity: 0.8;
    margin-left: 2px;
}

/* ===== Forecast ===== */
.forecast-target {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.forecast-target .ft-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
}

.forecast-target .ft-suffix {
    font-size: 14px;
    color: var(--text-secondary);
}

.forecast-year {
    width: 100px;
    height: 40px;
    padding: 0 12px;
    font-size: 18px;
    font-weight: 600;
    text-align: center;
    color: var(--text);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    font-variant-numeric: tabular-nums;
    font-family: inherit;
    transition: var(--transition);
}

.forecast-year:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.forecast-period {
    color: var(--text-muted);
    font-size: 13px;
    margin-left: auto;
}

.rate-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
    margin-bottom: 24px;
}

.rate-item {
    display: grid;
    grid-template-columns: 10px auto 1fr;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.rate-item:hover {
    border-color: var(--border-strong);
}

.rate-item .dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.rate-item[data-type="stock_tw"] .dot    { background: #2563eb; }
.rate-item[data-type="stock_us"] .dot    { background: #f97316; }
.rate-item[data-type="crypto"] .dot      { background: #a855f7; }
.rate-item[data-type="real_estate"] .dot { background: #d97706; }
.rate-item[data-type="cash"] .dot        { background: #10b981; }
.rate-item[data-type="loan"] .dot        { background: #ef4444; }

.rate-item .rate-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
}

.rate-item .rate-control {
    display: flex;
    align-items: center;
    gap: 4px;
    justify-self: end;
}

.rate-item .rate-control input {
    width: 64px;
    height: 30px;
    padding: 0 8px;
    text-align: right;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    outline: none;
    font-variant-numeric: tabular-nums;
    font-family: inherit;
    transition: var(--transition);
}

.rate-item .rate-control input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.rate-item .rate-control .suffix {
    font-size: 12px;
    color: var(--text-muted);
}

.forecast-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.forecast-tile {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    transition: var(--transition);
}

.forecast-tile.primary {
    background: linear-gradient(135deg, #1e1b4b 0%, #4f46e5 100%);
    color: white;
    border: none;
    box-shadow: var(--shadow-md);
}

.forecast-tile .ft-tile-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 500;
}

.forecast-tile.primary .ft-tile-label { color: rgba(255,255,255,0.75); }

.forecast-tile .ft-tile-value {
    font-size: 22px;
    font-weight: 600;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
    line-height: 1.2;
}

.forecast-tile.primary .ft-tile-value { color: white; }

.forecast-tile .ft-tile-value.positive { color: var(--success); }
.forecast-tile .ft-tile-value.negative { color: var(--danger); }

.forecast-tile .ft-tile-sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
    font-variant-numeric: tabular-nums;
}

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

.forecast-table th {
    background: var(--bg-subtle);
}

.forecast-table tbody tr:last-child td {
    border-bottom: none;
}

/* ===== Modal ===== */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(16, 24, 40, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
    padding: 24px;
    animation: fadeIn 180ms ease;
}

.modal.show {
    display: flex;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-content {
    background: var(--bg-elevated);
    border-radius: var(--radius-md);
    width: 100%;
    max-width: 560px;
    box-shadow: var(--shadow-xl);
    animation: slideUp 220ms cubic-bezier(0.16, 1, 0.3, 1);
    overflow: hidden;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h2 {
    font-size: 15px;
    font-weight: 600;
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
}

.modal-footer {
    padding: 14px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    background: var(--bg-subtle);
}

.close-btn {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: var(--transition);
    font-size: 18px;
}

.close-btn:hover {
    background: var(--bg-subtle);
    color: var(--text);
}

/* ===== Lock Screen ===== */
.lock-screen {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background:
        radial-gradient(at 30% 20%, rgba(124, 58, 237, 0.18) 0px, transparent 50%),
        radial-gradient(at 70% 80%, rgba(79, 70, 229, 0.15) 0px, transparent 50%),
        linear-gradient(180deg, #0f0d1e 0%, #1e1b4b 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    animation: fadeIn 220ms ease;
}

.lock-card {
    background: rgba(255, 255, 255, 0.04);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 20px;
    padding: 36px 40px 32px;
    width: 100%;
    max-width: 380px;
    text-align: center;
    box-shadow: 0 20px 50px -8px rgba(0, 0, 0, 0.6);
    color: white;
    animation: slideUp 320ms cubic-bezier(0.16, 1, 0.3, 1);
}

.lock-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 18px;
    border-radius: 16px;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    color: white;
    display: grid;
    place-items: center;
    box-shadow: 0 8px 24px -4px rgba(124, 58, 237, 0.6), inset 0 1px 0 rgba(255,255,255,0.2);
}

.lock-icon svg {
    width: 26px;
    height: 26px;
}

.lock-title {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.01em;
    margin-bottom: 4px;
    color: white;
}

.lock-subtitle {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 24px;
}

.pin-form {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 12px;
}

#pinInput {
    width: 220px;
    height: 60px;
    padding: 0 16px;
    text-align: center;
    font-size: 26px;
    font-weight: 600;
    letter-spacing: 0.32em;
    text-indent: 0.32em;
    color: white;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    outline: none;
    transition: all 150ms ease;
    -webkit-text-security: disc;
    font-variant-numeric: tabular-nums;
    font-family: inherit;
}

#pinInput::-webkit-outer-spin-button,
#pinInput::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

#pinInput:focus {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(124, 58, 237, 0.8);
    box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.2);
}

.pin-submit {
    width: 60px;
    height: 60px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    color: white;
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: all 150ms ease;
    box-shadow: 0 4px 12px -2px rgba(124, 58, 237, 0.45), inset 0 1px 0 rgba(255,255,255,0.2);
}

.pin-submit:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px -2px rgba(124, 58, 237, 0.6), inset 0 1px 0 rgba(255,255,255,0.2);
}

.pin-submit:active:not(:disabled) {
    transform: translateY(0);
}

.pin-submit:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.pin-submit svg {
    width: 22px;
    height: 22px;
}

.pin-form.shake {
    animation: shake 380ms cubic-bezier(.36,.07,.19,.97);
}

@keyframes shake {
    10%, 90% { transform: translateX(-2px); }
    20%, 80% { transform: translateX(4px); }
    30%, 50%, 70% { transform: translateX(-6px); }
    40%, 60% { transform: translateX(6px); }
}

.pin-error {
    color: #fca5a5;
    font-size: 13px;
    min-height: 18px;
    margin-bottom: 18px;
}

.lock-hint {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.45);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: 16px;
}

.lock-hint strong {
    color: rgba(255, 255, 255, 0.75);
    font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
    letter-spacing: 0.06em;
}

/* ===== Icon button (header) ===== */
.icon-btn-group {
    display: inline-flex;
    gap: 2px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 4px;
    box-shadow: var(--shadow-sm);
}

.icon-btn {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: var(--transition);
}

.icon-btn:hover {
    background: var(--bg-subtle);
    color: var(--text);
}

.icon-btn svg {
    width: 16px;
    height: 16px;
}

/* ===== Toast ===== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px 12px 14px;
    box-shadow: var(--shadow-lg);
    min-width: 280px;
    max-width: 380px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    pointer-events: auto;
    animation: toastIn 200ms cubic-bezier(0.16, 1, 0.3, 1);
}

.toast.leaving {
    animation: toastOut 180ms ease forwards;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
    to { opacity: 0; transform: translateX(20px); }
}

.toast .toast-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    margin-top: 1px;
}

.toast.success .toast-icon { color: var(--success); }
.toast.error   .toast-icon { color: var(--danger); }
.toast.info    .toast-icon { color: var(--primary); }

.toast .toast-body {
    flex: 1;
    font-size: 13px;
    color: var(--text);
    line-height: 1.45;
}

.toast .toast-title {
    font-weight: 600;
    margin-bottom: 2px;
}

.toast .toast-msg {
    color: var(--text-secondary);
    font-size: 12.5px;
}

/* ===== Responsive ===== */
@media (max-width: 960px) {
    .summary-panel {
        grid-template-columns: 1fr;
    }
    .summary-actions { justify-content: flex-end; }
    .btn-refresh { min-height: 40px; }
}

@media (max-width: 640px) {
    .container { padding: 20px 14px 60px; }
    header h1 { font-size: 16px; }
    .total-value { font-size: 28px; }
    .card-body { padding: 18px; }
    table th, table td { padding: 10px 12px; }
    .modal { padding: 12px; }
    .modal-header, .modal-body, .modal-footer { padding-left: 18px; padding-right: 18px; }
}

@media (max-width: 480px) {
    .form-row { grid-template-columns: 1fr; }
}
