/* ===== 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);
}

/* ===== Asset list header ===== */
.asset-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.asset-list-title {
    display: flex;
    align-items: baseline;
    gap: 16px;
    flex-wrap: wrap;
}

.asset-list-total {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    padding: 4px 12px;
    background: linear-gradient(135deg, #1e1b4b 0%, #4f46e5 100%);
    border-radius: var(--radius-full);
    color: white;
    box-shadow: var(--shadow-sm);
}

.asset-list-total .alt-label {
    font-size: 11px;
    color: rgba(255,255,255,0.75);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.asset-list-total .alt-value {
    font-size: 15px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
}

.asset-list-total .currency {
    font-size: 11px;
    font-weight: 500;
    margin-right: 2px;
    opacity: 0.8;
}

.asset-list-gross {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    padding: 4px 12px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, #64748b 0%, #334155 100%);
    color: white;
    box-shadow: var(--shadow-sm);
}

.asset-list-gross .alt-label {
    font-size: 11px;
    color: rgba(255,255,255,0.78);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.asset-list-gross .alt-value {
    font-size: 15px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
}

.asset-list-gross .currency {
    font-size: 11px;
    font-weight: 500;
    margin-right: 2px;
    opacity: 0.8;
}

.asset-list-pl {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    padding: 4px 12px;
    border-radius: var(--radius-full);
    color: white;
    box-shadow: var(--shadow-sm);
    background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
    transition: var(--transition);
}

.asset-list-pl.positive {
    background: linear-gradient(135deg, #10b981 0%, #047857 100%);
}

.asset-list-pl.negative {
    background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%);
}

.asset-list-pl .alt-label {
    font-size: 11px;
    color: rgba(255,255,255,0.78);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.asset-list-pl .alt-value {
    font-size: 15px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
}

.asset-list-pl .alt-value .pl-pct {
    font-size: 12px;
    font-weight: 500;
    opacity: 0.85;
    margin-left: 2px;
}

.asset-list-actions {
    display: inline-flex;
    gap: 8px;
    align-items: center;
}

.last-refresh {
    font-size: 12px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    margin-right: 4px;
    white-space: nowrap;
}

/* 市價 / 期望價格 切換按鈕 */
.price-mode-btn {
    min-width: 68px;
    justify-content: center;
}

.price-mode-btn.target-mode {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    border: none;
}

.price-mode-btn.target-mode:hover:not(:disabled) {
    background: linear-gradient(135deg, #f59e0b 0%, #b45309 100%);
}

.target-badge {
    display: inline-block;
    padding: 0 5px;
    margin-left: 4px;
    font-size: 9px;
    font-weight: 700;
    color: white;
    background: #d97706;
    border-radius: 3px;
    vertical-align: middle;
    line-height: 14px;
}

.btn.btn-icon-text {
    padding: 8px 14px;
    gap: 6px;
}

.btn.btn-icon-text .icon {
    width: 14px;
    height: 14px;
}

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

.list-tab {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 8px 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: 8px;
    white-space: nowrap;
    box-shadow: var(--shadow-sm);
}

.list-tab:hover:not(.active) {
    color: var(--text);
    border-color: var(--border-strong);
}

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

.list-tab .lt-name {
    font-weight: 600;
}

.list-tab .lt-total {
    font-size: 12px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.list-tab.active .lt-total {
    color: rgba(255,255,255,0.85);
}

.list-tab .count {
    font-size: 11px;
    background: var(--bg-subtle);
    color: var(--text-muted);
    padding: 1px 7px;
    min-width: 20px;
    text-align: center;
    border-radius: var(--radius-full);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    border: 1px solid var(--border);
}

.list-tab.active .count {
    background: rgba(255,255,255,0.22);
    color: white;
    border-color: transparent;
}

/* ===== 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;
}

/* ===== Group header / child rows ===== */
.group-header {
    transition: background 120ms ease;
}

.group-chevron {
    display: inline-block;
    width: 12px;
    margin-right: 6px;
    color: var(--text-muted);
    font-size: 10px;
    line-height: 1;
    vertical-align: middle;
    user-select: none;
    transition: color 180ms ease;
}

.group-header.expanded .group-chevron,
.group-header:hover .group-chevron {
    color: var(--primary);
}

.group-child td {
    background: var(--bg-subtle);
    font-size: 13px;
    color: var(--text-secondary);
}

.group-child td:nth-child(2) {
    padding-left: 32px;
    position: relative;
}

.group-child td:nth-child(2)::before {
    content: '';
    position: absolute;
    left: 16px;
    top: 50%;
    width: 8px;
    height: 1px;
    background: var(--border-strong);
}

.group-child .child-label {
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 500;
}

.group-child:hover td {
    background: var(--bg-hover);
}

/* ===== Totals (合計) row ===== */
.totals-row td {
    background: var(--bg-subtle) !important;
    border-top: 2px solid var(--border-strong);
    font-weight: 600;
    color: var(--text);
    padding-top: 14px;
    padding-bottom: 14px;
}

.totals-row td:first-child {
    color: var(--text-secondary);
    font-size: 12px;
    letter-spacing: 0.06em;
}

.totals-row:hover td {
    background: var(--bg-subtle) !important;
}

.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;
}

.settings-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    padding-top: 16px;
    margin-top: 20px;
    border-top: 1px solid var(--border);
}

/* ===== Retirement strategy ===== */
.strategy-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 4px;
    box-shadow: var(--shadow-sm);
}

.strategy-tab {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

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

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

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

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

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

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

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

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

.ret-tile-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.ret-tile.primary .ret-tile-value { color: white; }
.ret-tile-value.positive { color: #34d399; }
.ret-tile-value.negative { color: #fca5a5; }

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

.ret-tile.primary .ret-tile-sub { color: rgba(255,255,255,0.7); }

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

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

/* ===== Sentiment / Fear & Greed ===== */
.gauge-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.gauge-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.gauge-card-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 12px;
}

.gauge-card-head h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

.gauge-source {
    font-size: 11px;
    color: var(--text-muted);
    font-family: 'SF Mono', 'Menlo', monospace;
}

.gauge-wrap {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 16px;
}

.gauge-svg {
    width: 180px;
    height: 110px;
    flex-shrink: 0;
}

.gauge-svg svg {
    width: 100%;
    height: 100%;
}

.gauge-info {
    flex: 1;
    min-width: 0;
}

.gauge-score {
    font-size: 42px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.03em;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.gauge-score .max {
    font-size: 18px;
    color: var(--text-muted);
    font-weight: 500;
}

.gauge-rating {
    font-size: 14px;
    font-weight: 600;
    margin-top: 6px;
}

.gauge-rating[data-bucket="extreme-fear"] { color: #dc2626; }
.gauge-rating[data-bucket="fear"]         { color: #f97316; }
.gauge-rating[data-bucket="neutral"]      { color: #ca8a04; }
.gauge-rating[data-bucket="greed"]        { color: #65a30d; }
.gauge-rating[data-bucket="extreme-greed"]{ color: #16a34a; }

.gauge-history {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
    gap: 8px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.gauge-history-item {
    text-align: center;
}

.gauge-history-item .h-label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 4px;
}

.gauge-history-item .h-value {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.sentiment-legend {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    margin-top: 8px;
}

.sentiment-legend .seg {
    font-size: 11px;
    color: white;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-weight: 500;
    line-height: 1;
}

/* ===== Performance / Daily P/L ===== */
.perf-hero {
    text-align: center;
    padding: 28px 16px 20px;
}

.perf-hero-amount {
    font-size: 42px;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    color: var(--text);
}

.perf-hero-amount.positive { color: #16a34a; }
.perf-hero-amount.negative { color: #dc2626; }
.perf-hero-amount.muted    { color: var(--text-muted); font-size: 22px; font-weight: 500; }

.perf-hero-pct {
    font-size: 18px;
    font-weight: 600;
    margin-top: 8px;
    font-variant-numeric: tabular-nums;
    color: var(--text-secondary);
}

.perf-hero-pct.positive { color: #16a34a; }
.perf-hero-pct.negative { color: #dc2626; }

.perf-hero-sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 12px;
}

.perf-bytype-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

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

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

.perf-bytype-tile .pbt-label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
}

.perf-bytype-tile .pbt-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.perf-bytype-tile[data-type="stock_tw"] .pbt-dot { background: #2563eb; }
.perf-bytype-tile[data-type="stock_us"] .pbt-dot { background: #f97316; }
.perf-bytype-tile[data-type="crypto"]   .pbt-dot { background: #a855f7; }

.perf-bytype-tile .pbt-name {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.perf-bytype-tile .pbt-amount {
    font-size: 20px;
    font-weight: 600;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
}

.perf-bytype-tile .pbt-amount.positive { color: #16a34a; }
.perf-bytype-tile .pbt-amount.negative { color: #dc2626; }

.perf-bytype-tile .pbt-sub {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
    font-variant-numeric: tabular-nums;
}

.perf-empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-muted);
}

.perf-empty .pe-icon {
    font-size: 24px;
    margin-bottom: 8px;
}

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

.perf-empty .pe-desc {
    font-size: 12px;
}

/* ===== Exposure ===== */
.exposure-hero {
    text-align: center;
    padding: 28px 16px 24px;
}

.exp-ratio {
    font-size: 72px;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    color: var(--text);
    background: linear-gradient(135deg, #1e1b4b 0%, #4f46e5 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.exp-ratio.leveraged {
    background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.exp-ratio.defensive {
    background: linear-gradient(135deg, #10b981 0%, #047857 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.exp-label {
    font-size: 13px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 500;
    margin-top: 8px;
}

.exp-interpret {
    font-size: 15px;
    color: var(--text-secondary);
    margin-top: 16px;
    font-weight: 500;
}

.exp-nums {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 8px;
    font-variant-numeric: tabular-nums;
}

.exp-bytype-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

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

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

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

.exp-bytype-tile .ebt-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.exp-bytype-tile[data-type="stock_tw"] .ebt-dot { background: #2563eb; }
.exp-bytype-tile[data-type="stock_us"] .ebt-dot { background: #f97316; }
.exp-bytype-tile[data-type="crypto"]   .ebt-dot { background: #a855f7; }
.exp-bytype-tile[data-type="cash"]     .ebt-dot { background: #10b981; }
.exp-bytype-tile[data-type="loan"]     .ebt-dot { background: #ef4444; }

.exp-bytype-tile .ebt-book {
    font-size: 12px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.exp-bytype-tile .ebt-exposure {
    font-size: 20px;
    font-weight: 600;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
    margin-top: 4px;
}

.exp-bytype-tile .ebt-exposure.leveraged { color: #dc2626; }
.exp-bytype-tile .ebt-exposure.negative  { color: var(--text-muted); }

.exp-bytype-tile .ebt-avg-lev {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
    font-variant-numeric: tabular-nums;
}

.leverage-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.leverage-badge.lev-1 { background: var(--bg-subtle); color: var(--text-secondary); }
.leverage-badge.lev-0 { background: #ecfdf5; color: #047857; }
.leverage-badge.lev-pos { background: #fef3c7; color: #92400e; }
.leverage-badge.lev-neg { background: #fef2f2; color: #b91c1c; }

/* ===== Symbol picker (input + ▾ menu) ===== */
.symbol-picker {
    position: relative;
}

.symbol-picker input {
    padding-right: 32px;
    width: 100%;
}

.symbol-picker-btn {
    position: absolute;
    top: 50%;
    right: 6px;
    transform: translateY(-50%);
    width: 24px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 12px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    display: grid;
    place-items: center;
}

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

.symbol-picker-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 50;
    max-height: 280px;
    overflow-y: auto;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    display: none;
    padding: 4px;
}

.symbol-picker-menu.open {
    display: block;
}

.symbol-picker-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background 100ms ease;
}

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

.symbol-picker-item.active {
    background: var(--primary-soft);
    color: var(--primary-hover);
}

.symbol-picker-item .sp-sym {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.symbol-picker-item .sp-name {
    color: var(--text-muted);
    font-size: 12px;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.symbol-picker-item .sp-type {
    font-size: 10px;
    background: var(--bg-subtle);
    color: var(--text-muted);
    padding: 1px 6px;
    border-radius: var(--radius-full);
    font-weight: 500;
}

.symbol-picker-section {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 8px 10px 4px;
    font-weight: 600;
}

/* ===== Trend Signal ===== */
.trend-signal-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 28px 32px;
    text-align: center;
    margin: 16px 0 20px;
    box-shadow: var(--shadow-sm);
}

.ts-state {
    display: inline-block;
    font-size: 24px;
    font-weight: 700;
    padding: 8px 22px;
    border-radius: var(--radius-full);
    letter-spacing: 0.04em;
    background: var(--bg-subtle);
    color: var(--text-muted);
    transition: var(--transition);
}

.ts-state[data-state="buy"]  { background: linear-gradient(135deg, #10b981 0%, #047857 100%); color: white; box-shadow: 0 6px 16px -4px rgba(16,185,129,0.4); }
.ts-state[data-state="hold"] { background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%); color: white; }
.ts-state[data-state="sell"] { background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%); color: white; box-shadow: 0 6px 16px -4px rgba(239,68,68,0.4); }

.ts-symbol {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 10px;
    font-variant-numeric: tabular-nums;
}

.ts-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin: 24px 0;
    max-width: 460px;
    margin-left: auto;
    margin-right: auto;
}

.ts-stat-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 500;
    margin-bottom: 4px;
}

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

.ts-stat-value.positive { color: #16a34a; }
.ts-stat-value.negative { color: #dc2626; }

.ts-bar-wrap {
    margin: 32px auto 24px;
    max-width: 600px;
    padding: 0 12px;
}

.ts-bar {
    position: relative;
    height: 8px;
    background: linear-gradient(90deg, #fecaca 0%, #fde68a 35%, #d9f99d 65%, #bbf7d0 100%);
    border-radius: 4px;
}

.ts-bar-marker {
    position: absolute;
    top: -2px;
    width: 2px;
    height: 12px;
    background: var(--text-secondary);
    transform: translateX(-50%);
}

.ts-bar-marker span {
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.ts-bar-sma { background: var(--text); }
.ts-bar-sma span { color: var(--text); font-weight: 600; }
.ts-bar-sell { background: #dc2626; }
.ts-bar-buy  { background: #16a34a; }

.ts-bar-pointer {
    position: absolute;
    top: -8px;
    width: 0;
    height: 0;
    border-left: 7px solid transparent;
    border-right: 7px solid transparent;
    border-top: 10px solid #1f2937;
    transform: translateX(-50%);
    transition: left 400ms ease;
}

.ts-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 16px;
}

/* 區塊小標 */
.ts-section-title {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
    margin-bottom: 12px;
    text-align: center;
}

/* 短期時機 verdict */
.ts-verdict {
    display: inline-block;
    font-size: 26px;
    font-weight: 700;
    padding: 10px 26px;
    border-radius: var(--radius-full);
    letter-spacing: 0.06em;
    background: var(--bg-subtle);
    color: var(--text-muted);
    transition: var(--transition);
}

.ts-verdict[data-verdict="strong_buy"] { background: linear-gradient(135deg, #059669 0%, #047857 100%); color: white; box-shadow: 0 6px 18px -4px rgba(5,150,105,0.5); }
.ts-verdict[data-verdict="buy"]        { background: linear-gradient(135deg, #10b981 0%, #059669 100%); color: white; box-shadow: 0 6px 16px -4px rgba(16,185,129,0.45); }
.ts-verdict[data-verdict="consider"]   { background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%); color: white; box-shadow: 0 6px 16px -4px rgba(59,130,246,0.4); }
.ts-verdict[data-verdict="hold"]       { background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%); color: white; }
.ts-verdict[data-verdict="caution"]    { background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%); color: white; box-shadow: 0 6px 16px -4px rgba(245,158,11,0.4); }
.ts-verdict[data-verdict="exit"]       { background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%); color: white; box-shadow: 0 6px 16px -4px rgba(239,68,68,0.5); }

.ts-verdict-headline {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 12px;
    font-weight: 500;
}

.ts-stat-sub {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

.ts-stat-sub.positive { color: #16a34a; }
.ts-stat-sub.negative { color: #dc2626; }
.ts-stat-sub.warn     { color: #d97706; }

.ts-reasons {
    text-align: left;
    max-width: 520px;
    margin: 20px auto 0;
    padding: 14px 18px;
    background: var(--bg-subtle);
    border-radius: var(--radius-sm);
}

.ts-reasons-title {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
    margin-bottom: 6px;
}

.ts-reasons ul {
    margin: 0;
    padding-left: 18px;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.7;
}

.ts-reasons ul li strong { color: var(--text); }

/* ===== Explainer (details/summary) ===== */
.explainer {
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-top: 16px;
    overflow: hidden;
}

.explainer summary {
    padding: 12px 16px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    list-style: none;
    user-select: none;
    transition: var(--transition);
}

.explainer summary::-webkit-details-marker { display: none; }

.explainer summary::before {
    content: '▶';
    display: inline-block;
    margin-right: 8px;
    font-size: 10px;
    color: var(--text-muted);
    transition: transform 180ms ease;
}

.explainer[open] summary::before {
    transform: rotate(90deg);
}

.explainer summary:hover {
    background: var(--bg-hover);
    color: var(--text);
}

.explainer-body {
    padding: 0 18px 18px 36px;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.65;
}

.explainer-body p { margin-bottom: 10px; }
.explainer-body ul { margin: 8px 0 12px 18px; }
.explainer-body li { margin-bottom: 4px; }
.explainer-body strong { color: var(--text); }
.explainer-body em { color: var(--primary); font-style: normal; font-weight: 600; }

.tag-buy, .tag-sell, .tag-hold {
    display: inline-block;
    padding: 1px 8px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 600;
    color: white;
    margin-right: 4px;
}
.tag-buy  { background: #10b981; }
.tag-sell { background: #ef4444; }
.tag-hold { background: #6b7280; }

/* ===== 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(165, 180, 252, 0.45) 0px, transparent 55%),
        radial-gradient(at 70% 80%, rgba(167, 243, 208, 0.35) 0px, transparent 55%),
        linear-gradient(180deg, #f8fafc 0%, #e2e8f0 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    animation: fadeIn 220ms ease;
}

.lock-card {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: 20px;
    padding: 36px 40px 32px;
    width: 100%;
    max-width: 380px;
    text-align: center;
    box-shadow: 0 20px 50px -8px rgba(15, 23, 42, 0.18), 0 4px 12px -2px rgba(15, 23, 42, 0.08);
    color: var(--text);
    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.45), inset 0 1px 0 rgba(255,255,255,0.25);
}

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

.lock-title {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 4px;
    color: var(--text);
}

.lock-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    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: var(--text);
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    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: var(--bg-elevated);
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.18);
}

.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: var(--danger);
    font-size: 13px;
    min-height: 18px;
    margin-bottom: 18px;
}

.lock-hint {
    font-size: 12px;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    padding-top: 16px;
}

.lock-hint strong {
    color: var(--text);
    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; }
}
