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

:root {
    --bg: #f6f0e5;
    --bg-elevated: rgba(255, 251, 245, 0.78);
    --bg-panel: rgba(255, 250, 243, 0.9);
    --bg-panel-strong: rgba(255, 253, 249, 0.96);
    --bg-soft: rgba(255, 246, 232, 0.76);
    --line: rgba(97, 74, 44, 0.08);
    --line-strong: rgba(97, 74, 44, 0.14);
    --text: #1f1a15;
    --text-secondary: #695d4f;
    --text-muted: #918475;
    --brand: #183f8c;
    --brand-strong: #102a5f;
    --brand-soft: rgba(24, 63, 140, 0.1);
    --accent: #c56d53;
    --profit: #b95067;
    --profit-soft: rgba(185, 80, 103, 0.1);
    --loss: #1f6a60;
    --loss-soft: rgba(31, 106, 96, 0.1);
    --warning: #9f7044;
    --purple: #7252bf;
    --radius-sm: 16px;
    --radius-md: 24px;
    --radius-lg: 32px;
    --shadow-soft: 0 28px 64px rgba(76, 57, 31, 0.08);
    --shadow-lift: 0 18px 32px rgba(62, 45, 22, 0.12), 0 2px 8px rgba(62, 45, 22, 0.04);
    --shadow-press: 0 10px 18px rgba(62, 45, 22, 0.08);
    --blur: blur(24px);
    --ease-standard: cubic-bezier(0.22, 1, 0.36, 1);
    --ease-spring: cubic-bezier(0.175, 0.885, 0.32, 1.2);
    --content-width: 1240px;
}

html {
    scroll-behavior: smooth;
}

body {
    overflow-x: hidden;
}

body {
    min-height: 100vh;
    background:
        radial-gradient(circle at 12% 18%, rgba(24, 63, 140, 0.16), transparent 28%),
        radial-gradient(circle at 88% 16%, rgba(197, 109, 83, 0.14), transparent 24%),
        radial-gradient(circle at 50% 100%, rgba(31, 106, 96, 0.1), transparent 28%),
        linear-gradient(180deg, #f8f2e8 0%, #f4ecdf 48%, #f7efe5 100%);
    color: var(--text);
    font-family: "SF Pro Display", "Avenir Next", "PingFang SC", "Hiragino Sans GB", sans-serif;
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    font-variant-numeric: tabular-nums;
}

body::before,
body::after {
    content: "";
    position: fixed;
    inset: auto;
    width: 320px;
    height: 320px;
    border-radius: 50%;
    pointer-events: none;
    filter: blur(72px);
    opacity: 0.35;
    z-index: 0;
}

body::before {
    top: -60px;
    right: -40px;
    background: rgba(24, 63, 140, 0.14);
}

body::after {
    bottom: 12%;
    left: -80px;
    background: rgba(197, 109, 83, 0.12);
}

a {
    color: inherit;
    text-decoration: none;
}

.icon {
    flex: none;
    display: inline-block;
}

.icon-label {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.page-title {
    display: inline-flex;
    align-items: center;
    gap: 12px;
}

.page-title .icon {
    color: var(--brand);
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    appearance: none;
    border: 0;
    cursor: pointer;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    line-height: 1.08;
    letter-spacing: -0.04em;
    font-weight: 700;
}

.num {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1, "ss01" 1;
}

.positive {
    color: var(--profit);
}

.negative {
    color: var(--loss);
}

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

[data-ui-shell] {
    position: relative;
    z-index: 1;
}

nav {
    position: sticky;
    top: 0;
    z-index: 20;
    border-bottom: 1px solid rgba(255, 255, 255, 0.22);
    background: rgba(246, 240, 229, 0.58);
    backdrop-filter: blur(22px) saturate(140%);
}

.nav-inner,
main {
    width: min(calc(100% - 32px), var(--content-width));
    margin: 0 auto;
}

.nav-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 76px;
}

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

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 14px;
    background:
        linear-gradient(145deg, rgba(255, 255, 255, 0.68), rgba(255, 255, 255, 0.12)),
        linear-gradient(135deg, rgba(230, 239, 255, 0.98), rgba(197, 208, 255, 0.95) 56%, rgba(176, 206, 241, 0.94));
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.62),
        inset 0 -4px 10px rgba(113, 128, 210, 0.12),
        0 12px 24px rgba(103, 118, 205, 0.18);
    overflow: hidden;
}

.brand-mark-icon {
    width: 28px;
    height: 28px;
    display: block;
    filter: drop-shadow(0 3px 8px rgba(110, 117, 201, 0.18));
}

.brand-copy {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.logo {
    font-size: 18px;
    font-weight: 800;
    color: var(--brand-strong);
    letter-spacing: 0.02em;
}

.brand-subtitle {
    color: var(--text-muted);
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.nav-links a {
    position: relative;
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 0 16px;
    border-radius: 999px;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.26);
    border: 1px solid rgba(255, 255, 255, 0.3);
    transition:
        transform 180ms var(--ease-standard),
        box-shadow 180ms var(--ease-standard),
        background-color 180ms var(--ease-standard),
        color 180ms var(--ease-standard);
}

.nav-links a:hover {
    transform: translateY(-1px);
    background: rgba(255, 255, 255, 0.42);
    box-shadow: 0 8px 18px rgba(61, 44, 18, 0.08);
    color: var(--text);
}

.nav-links a.nav-danger {
    color: var(--profit);
    background: rgba(185, 80, 103, 0.08);
    border-color: rgba(185, 80, 103, 0.18);
}

.nav-links a.nav-danger:hover {
    color: var(--profit);
    background: rgba(185, 80, 103, 0.12);
}

main {
    padding: 28px 0 72px;
}

.page-frame {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.surface,
.card,
.hero-card,
.summary-item,
.stat-item,
.ledger-item,
.login-box,
.form-panel {
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.52);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.52), rgba(255, 251, 245, 0.82));
    backdrop-filter: var(--blur) saturate(140%);
    box-shadow: var(--shadow-soft);
}

.surface::before,
.card::before,
.hero-card::before,
.summary-item::before,
.stat-item::before,
.ledger-item::before,
.login-box::before,
.form-panel::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.6), transparent 38%, transparent 62%, rgba(255, 255, 255, 0.18));
    pointer-events: none;
    max-height: 320px;
}

.hero-card {
    min-height: 190px;
    padding: 28px 30px 26px;
    border-radius: var(--radius-lg);
}

.hero-card-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) minmax(260px, 0.7fr);
    gap: 18px;
    align-items: end;
}

.hero-eyebrow,
.summary-label,
.card-title,
.card-subtitle,
.group-sub,
.stock-sub,
.stock-code,
.stat-label,
.stat-sub,
.page-subtitle,
.ledger-label,
.brand-subtitle,
.hero-meta,
.summary-sub,
.empty-state,
.weak-meta,
.helper-text {
    color: var(--text-muted);
}

.hero-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.hero-eyebrow::before {
    content: "";
    width: 20px;
    height: 1px;
    background: rgba(24, 63, 140, 0.35);
}

.hero-value {
    margin-top: 14px;
    font-size: clamp(44px, 6vw, 68px);
    font-weight: 750;
    letter-spacing: -0.07em;
    line-height: 0.95;
}

.hero-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 18px;
    margin-top: 14px;
    font-size: 13px;
}

.hero-metrics {
    display: grid;
    gap: 12px;
}

.hero-metric {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding: 14px 16px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.32);
    background: rgba(255, 255, 255, 0.26);
}

.hero-metric strong {
    font-size: 24px;
    letter-spacing: -0.04em;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.55fr) minmax(320px, 0.85fr);
    gap: 18px;
    align-items: start;
}

.dashboard-main,
.dashboard-side,
.summary-stack {
    display: grid;
    gap: 18px;
}


.summary-row {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}

.summary-item,
.stat-item {
    min-height: 152px;
    padding: 22px 22px 20px;
    border-radius: 26px;
}

.summary-item-accent.profit {
    background:
        radial-gradient(circle at top right, rgba(185, 80, 103, 0.18), transparent 38%),
        linear-gradient(180deg, rgba(255, 243, 246, 0.92), rgba(255, 251, 245, 0.88));
}

.summary-item-accent.loss {
    background:
        radial-gradient(circle at top right, rgba(31, 106, 96, 0.16), transparent 38%),
        linear-gradient(180deg, rgba(240, 248, 247, 0.92), rgba(255, 251, 245, 0.88));
}

.summary-label,
.card-title,
.stat-label {
    font-size: 12px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.summary-value,
.stat-value {
    margin-top: 14px;
    font-size: clamp(28px, 3vw, 38px);
    font-weight: 760;
    line-height: 1;
    letter-spacing: -0.05em;
}

.summary-sub,
.stat-sub,
.page-subtitle,
.card-subtitle {
    margin-top: 10px;
    font-size: 12px;
}

.chart-sub-value {
    font-size: 18px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.card,
.form-panel {
    padding: 24px;
    border-radius: 28px;
}

.card-header,
.page-header,
.detail-hero,
.holdings-group-header,
.group-row,
.cash-row,
.ledger-top,
.page-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.chart-header {
    align-items: flex-start;
}

.card-title {
    color: var(--brand-strong);
}

.chart-row,
.holdings-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.chart-row-item,
.holdings-row > .card {
    min-width: 0;
}

.holdings-row {
    align-items: start;
}

.holdings-row-right .section-list {
    gap: 6px;
}

.holdings-row-right .stock-item {
    padding: 10px 14px;
    border-radius: 14px;
    box-shadow: 0 4px 12px rgba(62, 45, 22, 0.04);
}

.holdings-row-right .stock-name {
    font-size: 14px;
}

.holdings-row-right .stock-pnl {
    font-size: 12px;
}

.holdings-row-right .stock-code,
.holdings-row-right .stock-sub {
    font-size: 11px;
}

.chart-panel {
    height: 360px;
    margin-top: 18px;
}

.asset-group-chart {
    height: 300px;
    margin-top: 18px;
}

.asset-group-list {
    margin-top: 8px;
}

/* ── Freedom Progress Card ── */

.freedom-card {
}

.freedom-current {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-top: 16px;
}

.freedom-value {
    font-size: clamp(30px, 3.2vw, 42px);
    font-weight: 760;
    line-height: 1;
    letter-spacing: -0.04em;
    color: var(--profit);
}

.freedom-label {
    font-size: 15px;
    color: var(--text-muted);
}

.freedom-pct {
    margin-left: auto;
    font-size: 18px;
    font-weight: 700;
    color: var(--text-muted);
}

.freedom-bar-wrap {
    margin-top: 20px;
    padding: 0 2px;
}

.freedom-bar {
    position: relative;
    height: 10px;
    border-radius: 10px;
    background: rgba(97, 74, 44, 0.08);
    overflow: visible;
}

.freedom-bar-fill {
    height: 100%;
    border-radius: 10px;
    background: linear-gradient(90deg, #5D7CFF, #7A6CF5);
    transition: width 0.8s cubic-bezier(0.22, 1, 0.36, 1);
    min-width: 2px;
}


.freedom-status {
    margin-top: 16px;
    font-size: 13px;
    line-height: 1.7;
    color: var(--text-muted);
}

.freedom-status strong {
    color: var(--text-primary);
    font-weight: 650;
}

.freedom-status strong.num {
    color: #5D7CFF;
}

.freedom-highlight {
    display: inline-block;
    font-weight: 700;
    padding: 2px 10px;
    border-radius: 8px;
    font-size: 13px;
}

.freedom-highlight.achieved {
    background: rgba(93, 124, 255, 0.12);
    color: #4A6AE8;
}

.freedom-highlight.next {
    background: rgba(185, 80, 103, 0.10);
    color: #b95067;
}

.dividend-forecast-card {
    background:
        radial-gradient(circle at top right, rgba(197, 109, 83, 0.14), transparent 34%),
        linear-gradient(180deg, rgba(255, 252, 247, 0.9), rgba(255, 249, 241, 0.92));
}

.forecast-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-top: 18px;
}

.forecast-item {
    padding: 18px 18px 16px;
    border-radius: 22px;
    border: 1px solid rgba(255, 255, 255, 0.38);
    background: rgba(255, 255, 255, 0.34);
    box-shadow: 0 12px 24px rgba(62, 45, 22, 0.05);
}

.forecast-label {
    font-size: 12px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.forecast-value {
    margin-top: 12px;
    font-size: clamp(26px, 2.8vw, 34px);
    font-weight: 760;
    line-height: 1;
    letter-spacing: -0.05em;
}

.forecast-footnote {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 18px;
    margin-top: 16px;
    color: var(--text-muted);
    font-size: 12px;
}

.chart-empty {
    display: grid;
    place-items: center;
    min-height: 320px;
    text-align: center;
    color: var(--text-muted);
}

.section-list,
.summary-stack,
.ledger-list {
    display: grid;
    gap: 12px;
}

.group-row,
.cash-row {
    padding: 16px 0;
    border-bottom: 1px solid var(--line);
}

.group-row:last-child,
.cash-row:last-child {
    border-bottom: 0;
}

.group-label,
.stock-name,
.stock-value,
.group-value,
.detail-price,
.ledger-grid strong {
    font-weight: 700;
}

.holdings-group-header .group-label {
    color: var(--brand-strong);
    font-size: 16px;
}

.holdings-group-header .group-sub {
    color: var(--text-muted);
}

.group-value {
    font-size: 20px;
}

.range-buttons,
.txn-tabs {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.txn-tabs {
    margin-top: 4px;
    margin-bottom: 8px;
}

.range-btn,
.txn-tab,
.btn,
.btn-small,
.btn-danger {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    padding: 0 16px;
    border-radius: 999px;
    transition:
        transform 180ms var(--ease-standard),
        box-shadow 180ms var(--ease-standard),
        background-color 180ms var(--ease-standard),
        color 180ms var(--ease-standard),
        border-color 180ms var(--ease-standard);
}

.range-btn,
.txn-tab,
.btn-small {
    color: var(--text-secondary);
    border: 1px solid rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.4);
    box-shadow: 0 10px 22px rgba(62, 45, 22, 0.06);
}

.range-btn:hover,
.txn-tab:hover,
.btn-small:hover,
.btn:hover,
.btn-danger:hover,
.card[data-tilt]:hover,
.hero-card[data-tilt]:hover,
.summary-item[data-tilt]:hover,
.stat-item[data-tilt]:hover,
.ledger-item[data-tilt]:hover,
.stock-item[data-tilt]:hover {
    transform: translateY(-2px) scale(1.01);
    box-shadow: var(--shadow-lift);
}

.range-btn.active,
.txn-tab.active,
.btn {
    color: #fff;
    background: linear-gradient(135deg, rgba(24, 63, 140, 0.96), rgba(16, 42, 95, 0.96));
    box-shadow: 0 18px 28px rgba(24, 63, 140, 0.22);
}

.btn-small {
    padding-inline: 14px;
}

.btn-danger {
    color: var(--profit);
    background: rgba(185, 80, 103, 0.1);
    border: 1px solid rgba(185, 80, 103, 0.2);
}

.btn-danger-small {
    padding: 8px 12px;
    font-size: 12px;
    line-height: 1;
}

.btn:active,
.btn-small:active,
.btn-danger:active,
.range-btn:active,
.txn-tab:active {
    transform: translateY(1px) scale(0.985);
    box-shadow: var(--shadow-press);
}

.page-header h2 {
    font-size: clamp(30px, 4vw, 44px);
}

.page-header h2 .icon {
    width: 22px;
    height: 22px;
}

.stock-table {
    width: 100%;
    margin-top: 16px;
    table-layout: fixed;
    border-collapse: separate;
    border-spacing: 0 10px;
    display: table;
}

.stock-table-wrap {
    overflow-x: auto;
}

.stock-table thead {
    display: table-header-group;
}

.stock-table tbody {
    display: table-row-group;
}

.stock-table-head {
    color: var(--text-muted);
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    display: table-row;
}

.stock-table thead th {
    padding: 0 20px 8px;
    font-weight: 600;
    white-space: nowrap;
    display: table-cell;
}

.stock-item {
    position: relative;
    overflow: hidden;
    padding: 18px 20px;
    border-radius: 22px;
    border: 1px solid rgba(255, 255, 255, 0.45);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.46), rgba(255, 251, 245, 0.8));
    box-shadow: 0 12px 24px rgba(62, 45, 22, 0.06);
    transition:
        transform 180ms var(--ease-standard),
        box-shadow 180ms var(--ease-standard),
        border-color 180ms var(--ease-standard);
}

.stock-item:hover {
    border-color: rgba(24, 63, 140, 0.18);
}

.holding-row {
    display: table-row;
    cursor: pointer;
    transition:
        box-shadow 180ms var(--ease-standard),
        border-color 180ms var(--ease-standard),
        background-color 180ms var(--ease-standard);
}

.stock-table tbody td {
    display: table-cell;
    padding: 18px 20px;
    vertical-align: middle;
    border-top: 1px solid rgba(255, 255, 255, 0.45);
    border-bottom: 1px solid rgba(255, 255, 255, 0.45);
    border-left: 0;
    border-right: 0;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.46), rgba(255, 251, 245, 0.8));
    box-shadow: none;
}

.stock-table tbody td:first-child {
    border-left: 1px solid rgba(255, 255, 255, 0.45);
    border-top-left-radius: 22px;
    border-bottom-left-radius: 22px;
}

.stock-table tbody td:last-child {
    border-right: 1px solid rgba(255, 255, 255, 0.45);
    border-top-right-radius: 22px;
    border-bottom-right-radius: 22px;
}

.stock-table tbody td:not(:first-child) {
    padding-left: 16px;
}

.stock-table tbody td:not(:last-child) {
    padding-right: 16px;
}

.stock-table tbody tr:hover td {
    border-color: rgba(24, 63, 140, 0.18);
    background: #fffdf8;
}

.stock-left,
.stock-right,
.stock-mid,
.stock-price-col,
.stock-qty {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stock-right,
.stock-mid,
.stock-price-col,
.stock-qty {
    align-items: flex-end;
}

.stock-name {
    font-size: 16px;
}

.stock-name,
.stock-code,
.stock-sub,
.stock-value,
.stock-pnl,
.group-value {
    white-space: nowrap;
}

.stock-code,
.stock-sub,
.stock-cost,
.stock-date,
.helper-text {
    font-size: 12px;
}

.stock-pnl {
    font-size: 13px;
    font-weight: 700;
}

.cash-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
    margin-top: 6px;
    font-size: 12px;
}

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

.detail-shell {
    display: grid;
    gap: 18px;
}

.detail-hero {
    min-height: 188px;
    padding: 26px 28px;
    border-radius: 30px;
    background: linear-gradient(155deg, rgba(255, 255, 255, 0.52), rgba(255, 251, 245, 0.78));
    border: 1px solid rgba(255, 255, 255, 0.52);
    backdrop-filter: var(--blur);
    box-shadow: var(--shadow-soft);
}

.detail-quote {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.stock-name-lg {
    font-size: clamp(34px, 4vw, 48px);
}

.detail-price {
    font-size: clamp(44px, 5vw, 64px);
    letter-spacing: -0.06em;
    line-height: 0.95;
    white-space: nowrap;
}

.detail-change {
    margin-top: 8px;
    font-size: 14px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    height: 100%;
}

.stat-item {
    min-width: 0;
    min-height: 132px;
}

.summary-value,
.stat-value {
    white-space: nowrap;
}

.stat-value {
    font-size: clamp(22px, 2vw, 30px);
}

.stat-sub {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.form-panel-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
    gap: 18px;
}

.add-form,
.txn-entry-form {
    display: grid;
    gap: 12px;
    margin-bottom: 14px;
}

.card > .section-list,
.card > .empty-state {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--line);
}

.form-row,
.form-grid {
    display: grid;
    gap: 14px;
}

.form-row {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.cash-adjust-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-row-adjust {
    grid-template-columns: 1.1fr 0.8fr 0.8fr 1.2fr auto;
}

.form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-span-2 {
    grid-column: span 2;
}

.field {
    position: relative;
    min-width: 0;
}

.field input,
.field select,
.field textarea {
    width: 100%;
    min-height: 50px;
    padding: 20px 14px 10px;
    color: var(--text);
    border-radius: 16px;
    border: 1px solid rgba(97, 74, 44, 0.1);
    background: rgba(255, 255, 255, 0.62);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.48);
    transition:
        border-color 180ms var(--ease-standard),
        box-shadow 180ms var(--ease-standard),
        background-color 180ms var(--ease-standard),
        transform 180ms var(--ease-standard);
}

.field select {
    appearance: none;
    padding-right: 42px;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    background-image:
        linear-gradient(45deg, transparent 50%, rgba(105, 93, 79, 0.85) 50%),
        linear-gradient(135deg, rgba(105, 93, 79, 0.85) 50%, transparent 50%);
    background-position:
        calc(100% - 20px) calc(50% + 2px),
        calc(100% - 14px) calc(50% + 2px);
    background-size: 6px 6px, 6px 6px;
    background-repeat: no-repeat;
}

.field textarea {
    min-height: 92px;
    resize: vertical;
}

.field input::placeholder,
.field textarea::placeholder {
    color: transparent;
}

.field label {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    transition:
        transform 180ms var(--ease-standard),
        top 180ms var(--ease-standard),
        font-size 180ms var(--ease-standard),
        color 180ms var(--ease-standard);
}

.cash-adjust-row .field:last-child {
    grid-column: auto;
}

.cash-adjust-row .helper-text {
    margin-top: 8px;
}

.field.has-value label,
.field.is-focused label,
.field select + label,
.field input[type="date"] + label {
    top: 11px;
    transform: translateY(0);
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.field.is-focused input,
.field.is-focused select,
.field.is-focused textarea,
.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: rgba(24, 63, 140, 0.42);
    box-shadow: 0 0 0 4px rgba(24, 63, 140, 0.09), 0 16px 24px rgba(24, 63, 140, 0.08);
    background: rgba(255, 255, 255, 0.88);
    transform: translateY(-1px);
}

.inline-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.txn-entry-form .form-grid {
    gap: 10px 12px;
}

.txn-entry-form .field input,
.txn-entry-form .field select,
.txn-entry-form .field textarea {
    min-height: 46px;
    padding: 18px 13px 9px;
    border-radius: 14px;
}

.txn-entry-form .field label {
    left: 13px;
    font-size: 13px;
}

.txn-entry-form .field.has-value label,
.txn-entry-form .field.is-focused label,
.txn-entry-form .field select + label,
.txn-entry-form .field input[type="date"] + label {
    top: 10px;
    font-size: 10px;
}

.txn-entry-form .field textarea {
    min-height: 78px;
}

.txn-entry-form .inline-actions {
    gap: 10px;
    margin-top: 2px;
}

.txn-entry-form .btn {
    min-height: 42px;
    padding: 0 18px;
}

.txn-entry-form .switch-row {
    gap: 10px;
    font-size: 12px;
}

.txn-entry-form .switch-ui {
    width: 46px;
    height: 28px;
}

.txn-entry-form .switch-ui::after {
    top: 2px;
    left: 2px;
    width: 22px;
    height: 22px;
}

.txn-entry-form .switch-row input:checked + .switch-ui::after {
    transform: translateX(18px);
}

.txn-tabs {
    gap: 8px;
    margin-bottom: 12px;
}

.txn-tab {
    min-height: 38px;
    padding: 0 12px;
    font-size: 13px;
}

.switch-row {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: var(--text-secondary);
    font-size: 13px;
}

.switch-row input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.switch-ui {
    position: relative;
    width: 52px;
    height: 32px;
    border-radius: 999px;
    background: rgba(24, 63, 140, 0.14);
    border: 1px solid rgba(24, 63, 140, 0.12);
    transition: background-color 220ms var(--ease-standard);
}

.switch-ui::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 10px 16px rgba(53, 37, 14, 0.18);
    transition: transform 260ms var(--ease-spring), background-color 220ms var(--ease-standard);
}

.switch-row input:checked + .switch-ui {
    background: linear-gradient(135deg, rgba(24, 63, 140, 0.9), rgba(16, 42, 95, 0.96));
}

.switch-row input:checked + .switch-ui::after {
    transform: translateX(20px);
}

.ledger-list {
    gap: 14px;
}

.ledger-item {
    padding: 20px;
    border-radius: 24px;
}

.ledger-main {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.tag {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 0 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.buy-tag {
    color: var(--profit);
    background: rgba(185, 80, 103, 0.1);
}

.sell-tag {
    color: var(--loss);
    background: rgba(31, 106, 96, 0.1);
}

.dividend-tag {
    color: var(--purple);
    background: rgba(114, 82, 191, 0.1);
}

.ledger-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-top: 14px;
}

.ledger-grid > div {
    padding: 14px 16px;
    border-radius: 18px;
    border: 1px solid rgba(97, 74, 44, 0.08);
    background: rgba(255, 255, 255, 0.34);
}

.ledger-label {
    display: block;
    margin-bottom: 6px;
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.ledger-foot {
    display: flex;
    gap: 12px 16px;
    flex-wrap: wrap;
    margin-top: 14px;
    font-size: 12px;
}

.weak-meta {
    color: var(--text-muted);
}

.login-shell {
    width: min(100%, 980px);
    margin: 5vh auto 0;
}

.login-box {
    padding: 30px;
    border-radius: 34px;
    background:
        radial-gradient(circle at top left, rgba(24, 63, 140, 0.16), transparent 28%),
        radial-gradient(circle at 92% 18%, rgba(197, 109, 83, 0.18), transparent 24%),
        linear-gradient(180deg, rgba(255, 253, 249, 0.9), rgba(255, 249, 241, 0.92));
}

.login-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
    gap: 22px;
    align-items: stretch;
}

.login-intro,
.login-panel {
    min-width: 0;
}

.login-intro {
    display: grid;
    align-content: start;
    gap: 16px;
    padding: 10px 6px 6px;
}

.login-intro h1 {
    font-size: clamp(38px, 7vw, 52px);
    max-width: 11ch;
}

.login-subtitle {
    max-width: 36ch;
    color: var(--text-secondary);
    font-size: 15px;
}

.login-metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-top: 8px;
}

.login-metric {
    display: grid;
    gap: 10px;
    padding: 16px 16px 14px;
    border-radius: 22px;
    border: 1px solid rgba(255, 255, 255, 0.42);
    background: rgba(255, 255, 255, 0.34);
    box-shadow: 0 12px 24px rgba(62, 45, 22, 0.05);
}

.login-metric-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.login-metric strong {
    font-size: 18px;
    line-height: 1.15;
    letter-spacing: -0.03em;
    color: var(--brand-strong);
}

.login-panel {
    display: grid;
    align-content: start;
    gap: 18px;
    padding: 22px;
    border-radius: 30px;
    border: 1px solid rgba(255, 255, 255, 0.5);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.56), rgba(255, 251, 245, 0.86));
    box-shadow: 0 22px 34px rgba(62, 45, 22, 0.08);
}

.login-panel-head {
    display: grid;
    gap: 10px;
}

.login-panel-head p {
    color: var(--text-secondary);
}

.login-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    width: fit-content;
    min-height: 34px;
    padding: 0 14px;
    border-radius: 999px;
    color: var(--brand-strong);
    background: rgba(24, 63, 140, 0.08);
    border: 1px solid rgba(24, 63, 140, 0.12);
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.login-form {
    margin: 0;
}

.login-submit {
    width: 100%;
    justify-content: center;
}

.login-note {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-radius: 18px;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.32);
    border: 1px solid rgba(97, 74, 44, 0.08);
}

.empty-state {
    padding: 20px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.26);
    border: 1px dashed rgba(97, 74, 44, 0.14);
    text-align: center;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.back-link:hover {
    color: var(--text);
}

.back-link .icon {
    width: 16px;
    height: 16px;
}

.page-actions {
    justify-content: flex-end;
}

.flash-stack {
    display: grid;
    gap: 10px;
}

.flash {
    padding: 14px 16px;
    border-radius: 18px;
    backdrop-filter: blur(18px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 10px 24px rgba(62, 45, 22, 0.06);
}

.flash-success {
    color: var(--loss);
    background: rgba(241, 251, 248, 0.76);
}

.flash-error {
    color: var(--profit);
    background: rgba(253, 242, 245, 0.8);
}

[data-animate] {
    opacity: 0;
    transform: translate3d(0, 18px, 0) scale(0.985);
    transition:
        opacity 560ms var(--ease-standard),
        transform 720ms var(--ease-spring),
        box-shadow 220ms var(--ease-standard);
    transition-delay: var(--delay, 0ms);
}

[data-animate].is-visible {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1);
}

[data-tilt] {
    transform-style: preserve-3d;
    will-change: transform;
}

[data-tilt].is-tilting {
    transform:
        perspective(1200px)
        rotateX(var(--rx, 0deg))
        rotateY(var(--ry, 0deg))
        translateY(-2px)
        scale(1.01);
}

[data-tilt]::after {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at var(--mx, 50%) var(--my, 50%), rgba(255, 255, 255, 0.36), transparent 30%);
    opacity: 0;
    transition: opacity 180ms var(--ease-standard);
    pointer-events: none;
}

[data-tilt].is-tilting::after {
    opacity: 1;
}

.hidden {
    display: none !important;
}

/* ── Bottom Tab Bar (hidden on desktop) ── */
.bottom-tabs {
    display: none;
}

/* ── Tablet ── */
@media (max-width: 1100px) {
    .hero-card-grid,
    .dashboard-grid,
    .form-panel-grid {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* ── Mobile ── */
@media (max-width: 840px) {
    /* ── Compact top bar: brand only ── */
    .nav-inner {
        flex-direction: row;
        justify-content: center;
        align-items: center;
        gap: 10px;
        min-height: 52px;
        padding: 8px 0;
    }

    .nav-links {
        display: none;
    }

    .brand-subtitle {
        display: none;
    }

    /* ── Bottom tab bar ── */
    .bottom-tabs {
        display: flex;
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 100;
        height: calc(64px + env(safe-area-inset-bottom, 0px));
        padding-bottom: env(safe-area-inset-bottom, 0px);
        background: rgba(246, 240, 229, 0.82);
        backdrop-filter: blur(22px) saturate(140%);
        -webkit-backdrop-filter: blur(22px) saturate(140%);
        border-top: 1px solid rgba(255, 255, 255, 0.22);
        box-shadow: 0 -4px 24px rgba(76, 57, 31, 0.06);
        justify-content: space-around;
        align-items: center;
    }

    .bottom-tab {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2px;
        padding: 6px 16px;
        min-height: 44px;
        min-width: 64px;
        color: var(--text-muted);
        font-size: 11px;
        font-weight: 500;
        letter-spacing: 0.02em;
        text-decoration: none;
        transition: color 180ms ease, transform 180ms ease;
        -webkit-tap-highlight-color: transparent;
    }

    .bottom-tab .icon {
        transition: transform 180ms var(--ease-spring);
    }

    .bottom-tab.active {
        color: var(--brand);
    }

    .bottom-tab.active .icon {
        transform: scale(1.1);
    }

    .bottom-tab:active {
        transform: scale(0.92);
    }

    .page-header,
    .card-header,
    .detail-hero,
    .page-actions {
        flex-direction: column;
        align-items: flex-start;
    }

    main {
        padding: 18px 0 calc(64px + env(safe-area-inset-bottom, 0px) + 18px);
    }

    .nav-inner,
    main {
        width: calc(100% - 24px);
        padding-left: env(safe-area-inset-left, 0px);
        padding-right: env(safe-area-inset-right, 0px);
    }

    .page-frame {
        gap: 14px;
    }

    /* Hero */
    .hero-card {
        padding: 20px 18px;
    }

    .hero-value {
        font-size: clamp(32px, 8vw, 44px);
    }

    .hero-metric strong {
        font-size: 18px;
    }

    .hero-metric {
        padding: 10px 12px;
        border-radius: 16px;
    }

    /* Summary */
    .summary-row {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .summary-item,
    .stat-item {
        min-height: auto;
        padding: 16px 18px;
    }

    .summary-value {
        font-size: clamp(24px, 6vw, 32px);
    }

    /* Stats */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .stat-item {
        min-height: auto;
    }

    /* Charts & holdings row */
    .chart-row,
    .holdings-row {
        grid-template-columns: 1fr;
    }

    .chart-panel {
        height: 260px;
        margin-top: 14px;
    }

    .asset-group-chart {
        height: 240px;
        margin-top: 14px;
    }

    .freedom-value {
        font-size: clamp(26px, 7vw, 34px);
    }

    .forecast-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .forecast-item {
        padding: 16px 16px 14px;
        border-radius: 18px;
    }

    .forecast-value {
        font-size: clamp(24px, 6vw, 30px);
    }

    /* Forms */
    .form-row,
    .cash-adjust-row,
    .form-row-adjust,
    .form-grid,
    .ledger-grid,
    .txn-form-wide {
        grid-template-columns: 1fr;
    }

    .form-span-2 {
        grid-column: auto;
    }

    .cash-adjust-row .field:last-child {
        grid-column: auto;
    }

    .card,
    .form-panel {
        padding: 18px 16px;
    }

    .field input,
    .field select,
    .field textarea {
        min-height: 52px;
        padding: 22px 14px 10px;
        font-size: 14px;
    }

    .field select {
        padding-right: 40px;
        background-position:
            calc(100% - 18px) calc(50% + 2px),
            calc(100% - 12px) calc(50% + 2px);
    }

    .field label {
        font-size: 13px;
    }

    .field.has-value label,
    .field.is-focused label,
    .field select + label,
    .field input[type="date"] + label {
        top: 10px;
        font-size: 10px;
    }

    /* Stock table → card layout */
    .stock-table-wrap {
        overflow-x: visible;
    }

    .stock-table {
        display: block;
        border-spacing: 0;
        table-layout: auto;
    }

    .stock-table colgroup,
    .stock-table-head,
    .stock-table thead {
        display: none;
    }

    .stock-table tbody {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .holding-row {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 4px 12px;
        padding: 14px 16px;
        border-radius: 20px;
        border: 1px solid rgba(255, 255, 255, 0.45);
        background: linear-gradient(180deg, rgba(255, 255, 255, 0.46), rgba(255, 251, 245, 0.8));
        box-shadow: 0 12px 24px rgba(62, 45, 22, 0.06);
        cursor: pointer;
    }

    .stock-table tbody td,
    .stock-table tbody td:first-child,
    .stock-table tbody td:last-child,
    .stock-table tbody td:not(:first-child),
    .stock-table tbody td:not(:last-child) {
        display: block;
        width: auto;
        padding: 0;
        border: 0;
        border-radius: 0;
        box-shadow: none;
        background: transparent;
        vertical-align: baseline;
    }

    /* Row 1: name (full width) */
    .holding-row td:nth-child(1) {
        grid-column: 1 / -1;
        padding-bottom: 6px;
        border-bottom: 1px solid rgba(97, 74, 44, 0.06);
        margin-bottom: 4px;
    }

    /* Row 2: qty (left) + price/cost (right) */
    .holding-row td:nth-child(2) { grid-column: 1; }
    .holding-row td:nth-child(3) { grid-column: 2; }

    /* Row 3: market value (left) + pnl (right) */
    .holding-row td:nth-child(4) { grid-column: 1; }
    .holding-row td:nth-child(5) { grid-column: 2; }

    /* Reset alignment */
    .holding-row .stock-right,
    .holding-row .stock-mid,
    .holding-row .stock-price-col,
    .holding-row .stock-qty {
        align-items: flex-start;
        text-align: left;
    }

    .holding-row .align-right {
        text-align: left;
    }

    .stock-name {
        font-size: 15px;
    }

    .detail-quote {
        align-items: flex-start;
        text-align: left;
    }

    .hero-value,
    .summary-value,
    .stat-value,
    .detail-price,
    .stock-name,
    .stock-code,
    .stock-sub,
    .stock-value,
    .stock-pnl,
    .group-value,
    .stat-sub {
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .freedom-status {
        overflow-wrap: break-word;
    }

    /* Ledger */
    .ledger-item {
        padding: 16px;
    }

    .ledger-grid {
        gap: 8px;
    }

    .ledger-grid > div {
        padding: 10px 12px;
    }

    /* Detail page */
    .detail-hero {
        padding: 18px 16px;
    }

    .stock-name-lg {
        font-size: clamp(24px, 6vw, 34px);
    }

    .detail-price {
        font-size: clamp(32px, 8vw, 48px);
    }

    .page-header h2 {
        font-size: clamp(24px, 6vw, 34px);
    }

    /* Border radius */
    .hero-card,
    .card,
    .summary-item,
    .stat-item,
    .detail-hero,
    .ledger-item,
    .login-box,
    .form-panel {
        border-radius: 22px;
    }

    /* Group spacing */
    .holdings-group + .holdings-group {
        margin-top: 20px;
        padding-top: 20px;
        border-top: 1px solid rgba(97, 74, 44, 0.08);
    }

    .holdings-group-header {
        flex-wrap: wrap;
        gap: 4px 12px;
        margin-bottom: 10px;
    }

    .group-row,
    .cash-row {
        flex-wrap: wrap;
        gap: 6px 12px;
    }

    .group-label {
        font-size: 15px;
    }

    .group-value {
        font-size: 17px;
    }

    /* Buttons */
    .btn {
        width: 100%;
    }

    .page-actions {
        width: 100%;
    }

    /* Inline actions */
    .inline-actions {
        width: 100%;
    }

    .inline-actions .btn,
    .inline-actions .btn-small {
        flex: 1;
        min-width: 0;
    }

    /* Chart header: full-width children on mobile */
    .chart-header {
        align-items: stretch;
    }

    /* Range/tab buttons: fill row evenly */
    .range-buttons,
    .txn-tabs {
        width: 100%;
        flex-wrap: nowrap;
        gap: 6px;
    }

    .range-btn,
    .txn-tab {
        flex: 1 1 0;
        min-height: 36px;
        padding: 0 6px;
        font-size: 13px;
        text-align: center;
    }

    .card-header {
        gap: 10px;
    }

    .card-subtitle {
        display: none;
    }

    /* Closed positions */
    .stock-item {
        padding: 14px 16px;
    }

    /* Login */
    .login-shell {
        width: min(100%, 560px);
    }

    .login-box {
        padding: 22px 20px;
    }

    .login-layout {
        grid-template-columns: 1fr;
        gap: 18px;
    }

    .login-intro {
        padding: 0;
    }

    .login-intro h1 {
        max-width: none;
    }

    .login-metrics {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .login-panel {
        padding: 18px;
        border-radius: 24px;
    }

    /* Disable hover effects on touch */
    .range-btn:hover,
    .txn-tab:hover,
    .btn-small:hover,
    .btn:hover,
    .btn-danger:hover,
    .card[data-tilt]:hover,
    .hero-card[data-tilt]:hover,
    .summary-item[data-tilt]:hover,
    .stat-item[data-tilt]:hover,
    .ledger-item[data-tilt]:hover,
    .stock-item[data-tilt]:hover {
        transform: none;
    }

    /* Flash messages */
    .flash {
        font-size: 13px;
        padding: 12px 14px;
    }

    /* ── Touch targets ── */
    .btn,
    .btn-small,
    .btn-danger,
    .range-btn,
    .txn-tab {
        min-height: 44px;
    }

    [data-href] {
        -webkit-tap-highlight-color: transparent;
    }

    .btn-danger-small {
        min-height: 36px;
        padding: 8px 14px;
    }

    /* ── Active state feedback ── */
    .holding-row:active,
    .stock-item:active,
    [data-href]:active {
        transform: scale(0.98);
        transition: transform 80ms ease;
    }

    .btn:active,
    .btn-small:active,
    .btn-danger:active {
        transform: scale(0.96);
        opacity: 0.85;
    }

    /* ── Page transitions ── */
    .page-frame {
        animation: pageEnter 320ms var(--ease-standard) both;
    }

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

    body.page-exiting .page-frame {
        animation: pageExit 180ms ease-in both;
    }

    @keyframes pageExit {
        from { opacity: 1; transform: translateY(0); }
        to { opacity: 0; transform: translateY(-6px); }
    }

    /* ── Scroll behavior ── */
    html {
        -webkit-overflow-scrolling: touch;
    }

    body {
        overscroll-behavior-y: contain;
    }

    /* ── Pull-to-refresh indicator ── */
    .pull-indicator {
        position: fixed;
        top: 0;
        left: 50%;
        margin-left: -20px;
        width: 40px;
        height: 40px;
        border-radius: 50%;
        background: var(--bg-panel-strong);
        border: 1px solid var(--line);
        box-shadow: 0 4px 16px rgba(0,0,0,0.08);
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 200;
        transform: translateY(-40px);
        opacity: 0;
        transition: transform 300ms ease, opacity 200ms ease;
        color: var(--brand);
    }

    .pull-indicator.refreshing .pull-icon {
        animation: spin 0.6s linear infinite;
    }

    /* ── Summary row horizontal scroll ── */
    .summary-row {
        grid-template-columns: none;
        display: flex;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        gap: 10px;
        padding-bottom: 4px;
    }

    .summary-row::-webkit-scrollbar {
        display: none;
    }

    .summary-row > .summary-item {
        flex: 0 0 calc(75vw - 24px);
        scroll-snap-align: start;
    }

    /* ── Chart height responsive ── */
    .chart-panel {
        height: clamp(220px, 45vw, 300px);
    }

    .asset-group-chart {
        height: clamp(200px, 42vw, 280px);
    }

    /* ── Hide decorative blobs on mobile (GPU savings) ── */
    body::before,
    body::after {
        display: none;
    }

    /* ── Font/spacing refinements ── */
    .card-title {
        font-size: 13px;
    }

    .hero-eyebrow {
        font-size: 11px;
    }

    .summary-item {
        padding: 14px 16px;
    }

    /* ── Auth modal mobile ── */
    .auth-modal {
        width: calc(100% - 32px);
        border-radius: 24px;
    }

    .auth-modal-actions .btn {
        min-height: 44px;
    }
}

/* ── Small phones ── */
@media (max-width: 420px) {
    .nav-inner,
    main {
        width: calc(100% - 16px);
    }

    .hero-value {
        font-size: clamp(28px, 9vw, 36px);
    }

    .summary-value {
        font-size: clamp(22px, 6vw, 28px);
    }

    .holding-row {
        grid-template-columns: 1fr 1fr;
        gap: 4px 10px;
        padding: 12px;
    }

    .holding-row td:nth-child(1) {
        padding-bottom: 4px;
        margin-bottom: 2px;
    }

    .hero-card {
        padding: 16px 14px;
    }

    .card,
    .form-panel {
        padding: 14px 12px;
    }

    .ledger-grid > div {
        padding: 8px 10px;
    }

    .brand-copy .logo {
        font-size: 16px;
    }

    .range-btn,
    .txn-tab {
        font-size: 12px;
        min-height: 32px;
        padding: 0 4px;
    }
}

.btn-refresh {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    vertical-align: middle;
    margin-left: 4px;
    padding: 0;
}
.btn-refresh:hover { color: var(--accent); border-color: var(--accent); }
.btn-refresh:disabled { opacity: 0.5; cursor: wait; }
.btn-refresh .icon {
    width: 14px;
    height: 14px;
}
.btn-refresh.is-loading .refresh-icon {
    animation: spin 0.9s linear infinite;
}

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

[data-collapse] .collapsed-item { display: none; }
[data-collapse].expanded .collapsed-item { display: flex; }
.ledger-list[data-collapse] .collapsed-item { display: none; }
.ledger-list[data-collapse].expanded .collapsed-item { display: block; }

.btn-expand {
    display: block;
    width: 100%;
    padding: 10px;
    margin-top: 8px;
    border: 1px dashed var(--border);
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-expand:hover { color: var(--accent); border-color: var(--accent); }

.txn-form-wide {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}
.txn-form-wide .field.form-span-2 {
    grid-column: auto;
}

/* ── Auth Modal ── */
.auth-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(31, 26, 21, 0.45);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: authFadeIn 0.2s ease;
}
@keyframes authFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
.auth-modal {
    background: var(--bg-panel-strong);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    padding: 32px 28px 24px;
    width: 340px;
    max-width: 90vw;
    box-shadow: 0 20px 60px rgba(0,0,0,0.12);
    animation: authSlideUp 0.25s ease;
}
@keyframes authSlideUp {
    from { opacity: 0; transform: translateY(16px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.auth-modal-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}
.auth-modal-desc {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 18px;
}
.auth-modal .field input {
    width: 100%;
    padding: 10px 14px;
    font-size: 15px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    color: var(--text);
    outline: none;
    transition: border-color 0.2s;
}
.auth-modal .field input:focus {
    border-color: var(--brand);
}
.auth-modal-error {
    color: var(--accent);
    font-size: 13px;
    margin-top: 8px;
    margin-bottom: 4px;
}
.auth-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 18px;
}
.auth-modal-actions .btn {
    padding: 8px 20px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid var(--line);
    transition: all 0.2s;
}
.auth-modal-actions .btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}
.auth-modal-actions .btn-ghost:hover {
    background: var(--bg-soft);
}
.auth-modal-actions .btn-primary {
    background: var(--brand);
    color: #fff;
    border-color: var(--brand);
}
.auth-modal-actions .btn-primary:hover {
    background: var(--brand-strong);
}
.auth-modal-actions .btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
