:root {
    --brand-bg: #ffffff;
    --brand-panel: #f5f7fb;
    --brand-panel-alt: #eef2f8;
    --brand-dark: #112f5b;
    --brand-gray: #5f6360;
    --brand-amber: #f9740a;
    --brand-amber-soft: #ff8762;
    --brand-blue: #116dff;
    --brand-light: #106f9a;
    --brand-card: #ffffff;
    --border: #e1e7ef;
    --danger: #ed1c24;
    --success: #4bd1a0;
    --font: 'Poppins', 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    --font-heading: 'Playfair Display', 'Georgia', serif;
    --shadow-soft: 0 12px 40px rgba(17, 47, 91, 0.12);
    --table-sticky-offset: 0px;
}

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

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font);
    background: linear-gradient(168deg, #f8fafd 0%, #ffffff 40%, #fdf8f4 100%);
    color: var(--brand-dark);
    line-height: 1.6;
}

.hidden {
    display: none !important;
}

.glass {
    background: var(--brand-card);
    border: 1px solid var(--border);
    border-radius: 22px;
    box-shadow: 0 4px 24px rgba(17, 47, 91, 0.06), 0 12px 40px rgba(17, 47, 91, 0.04);
    backdrop-filter: blur(22px);
    transition: box-shadow 0.25s ease;
}

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(17, 47, 91, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
}

.loading-card {
    text-align: center;
}

.spinner-border {
    width: 54px;
    height: 54px;
    border: 4px solid rgba(17, 47, 91, 0.08);
    border-top-color: var(--brand-amber);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
    margin: 0 auto 12px;
}

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

.auth-shell {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 80px 24px;
}

.auth-card {
    max-width: 480px;
    width: 100%;
    padding: 48px;
    background: var(--brand-panel);
    position: relative;
    overflow: hidden;
}

.auth-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--brand-amber), var(--brand-amber-soft), var(--brand-blue));
}

.auth-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.auth-brand h1 {
    margin: 0 0 6px;
    font-size: 2rem;
    font-family: var(--font-heading);
    letter-spacing: 0.02em;
}

.auth-brand .eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.2em;
    font-size: 0.75rem;
    color: var(--brand-amber-soft);
}

.auth-brand .subheading {
    color: var(--brand-gray);
    margin-top: 0;
    line-height: 1.4;
}

.auth-logo {
    width: 150px;
    height: 150px;
    object-fit: contain;
    display: block;
    margin-bottom: 12px;
}

.auth-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
}

.btn.full-width {
    width: 100%;
}

.btn.microsoft {
    background: linear-gradient(120deg, #2f6ad9, #1b4ca1);
    color: #f7fbff;
    border: 1px solid rgba(27, 76, 161, 0.35);
    box-shadow: 0 10px 25px rgba(27, 76, 161, 0.25);
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 20px 0 8px;
    color: var(--brand-gray);
    font-weight: 600;
}

.auth-divider::before,
.auth-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 24px;
}

.link-btn {
    border: none;
    background: none;
    color: var(--brand-amber);
    font-weight: 600;
    padding: 0;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.link-btn.loading {
    opacity: 0.7;
    pointer-events: none;
}

.link-btn .spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(17, 47, 91, 0.12);
    border-top-color: rgba(17, 47, 91, 0.6);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.link-btn:hover {
    color: #c65c08;
    text-decoration: underline;
}

.form-label {
    display: flex;
    flex-direction: column;
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--brand-gray);
    gap: 6px;
}

.form-label input,
input,
select {
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 12px 16px;
    font-family: inherit;
    font-size: 0.95rem;
    background: #f5f7fb;
    color: var(--brand-dark);
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
select:focus {
    border-color: rgba(249, 116, 10, 0.6);
    box-shadow: 0 0 0 3px rgba(249, 116, 10, 0.10), 0 2px 8px rgba(249, 116, 10, 0.08);
}

select.role-select {
    padding: 6px 10px;
    font-size: 0.85rem;
    border-radius: 8px;
}

select.role-select:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    border-radius: 999px;
    font-size: 0.95rem;
    font-weight: 600;
    padding: 12px 20px;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn.primary {
    background: linear-gradient(120deg, #f9740a, #f6b01c);
    color: #1b1106;
    box-shadow: 0 10px 25px rgba(249, 116, 10, 0.45);
}
.btn.loading {
    opacity: 0.6;
    pointer-events: none;
}

.btn.secondary {
    background: rgba(17, 47, 91, 0.08);
    color: var(--brand-dark);
    border: 1px solid rgba(17, 47, 91, 0.2);
}

.btn.ghost {
    background: transparent;
    border: 1px solid rgba(17, 47, 91, 0.2);
    color: var(--brand-dark);
}

.btn.danger {
    color: var(--danger);
    border-color: rgba(255, 95, 95, 0.3);
}

.btn.small {
    padding: 8px 16px;
    font-size: 0.85rem;
}

.btn.tiny {
    padding: 6px 12px;
    font-size: 0.82rem;
}

.btn.is-on {
    background: rgba(249, 116, 10, 0.12);
    color: #b35406;
    border-color: rgba(249, 116, 10, 0.6);
    box-shadow: none;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(17, 47, 91, 0.14);
}

.btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(17, 47, 91, 0.10);
}

.btn.primary:hover {
    box-shadow: 0 12px 28px rgba(249, 116, 10, 0.35);
}
.btn.loading .spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(17, 47, 91, 0.15);
    border-top-color: rgba(17, 47, 91, 0.6);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.app-shell {
    max-width: 1440px;
    margin: 0 auto;
    padding: 40px 32px 80px;
}

.app-header {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 32px;
    align-items: center;
    padding: 24px 32px;
    border: 1px solid var(--border);
    border-radius: 24px;
    background: var(--brand-panel);
}

.brand-cluster {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

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

.user-greeting {
    font-weight: 600;
    color: var(--brand-dark);
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: rgba(17, 47, 91, 0.05);
}

.brand-logo {
    width: 130px;
    height: 130px;
    padding: 10px;
    object-fit: contain;
    background: #fff;
    border-radius: 12px;
    border: 1px solid rgba(17, 47, 91, 0.15);
    box-shadow: 0 10px 30px rgba(17, 47, 91, 0.2);
}

.brand h1 {
    margin: 2px 0 0;
    font-size: 2rem;
    font-family: var(--font-heading);
    letter-spacing: 0.03em;
    color: var(--brand-dark);
}

.brand .eyebrow {
    letter-spacing: 0.25em;
    font-size: 0.9rem;
    color: var(--brand-amber-soft);
    text-transform: uppercase;
}

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

.filename {
    font-size: 0.9rem;
    color: var(--brand-gray);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: nowrap;
    justify-content: flex-end;
}

.glass-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 999px;
    border: 1px solid rgba(17, 47, 91, 0.14);
    background: rgba(17, 47, 91, 0.06);
    font-size: 0.85rem;
    color: var(--brand-gray);
}

.api-key-indicator i {
    color: var(--brand-amber);
}

.api-key-status {
    font-size: 0.85rem;
    color: var(--brand-gray);
    white-space: nowrap;
}

.api-key-status.error {
    color: var(--danger);
}

.api-key-status.hidden {
    display: none;
}

.refresh-meta {
    text-align: right;
    font-size: 0.85rem;
    color: var(--brand-gray);
}

.refresh-meta strong {
    display: block;
    color: var(--brand-amber-soft);
    font-size: 1.15rem;
}

.app-body {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
}

.sticky-kpis {
    position: sticky;
    top: 0;
    z-index: 12;
    background: var(--brand-bg);
    padding: 8px 0;
}

.kpi-card {
    padding: 24px;
    background: var(--brand-panel);
    border-radius: 24px;
    border: 1px solid var(--border);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(17, 47, 91, 0.12);
}

.kpi-card p {
    margin: 0;
    font-size: 0.85rem;
    color: var(--brand-gray);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.kpi-card h2 {
    margin: 12px 0 4px;
    font-size: 2rem;
    color: var(--brand-dark);
}

.kpi-card .muted {
    color: var(--brand-gray);
    font-size: 0.9rem;
}

.panel {
    padding: 0 0 24px;
    border-radius: 24px;
    border: 1px solid var(--border);
    background: var(--brand-panel-alt);
}

.tx-kpi-grid {
    margin: 12px 0;
    padding: 8px 12px;
    position: sticky;
    top: 0;
    z-index: 12;
    background: var(--brand-bg);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px 0;
    gap: 12px;
}

.sticky-panel-header {
    position: sticky;
    top: var(--kpi-sticky-height, 0px);
    background: var(--brand-panel-alt);
    z-index: 11;
    border-bottom: 1px solid var(--border);
}

.tabs {
    display: flex;
    gap: 8px;
}

.tab {
    border: none;
    background: transparent;
    padding: 10px 18px;
    border-radius: 24px;
    font-weight: 600;
    cursor: pointer;
    color: var(--brand-gray);
    position: relative;
    transition: background 0.2s ease, color 0.2s ease;
}

.tab:hover {
    background: rgba(249, 116, 10, 0.08);
}

.tab.active {
    background: rgba(249, 116, 10, 0.10);
    color: var(--brand-dark);
}

.tab.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 20%;
    right: 20%;
    height: 3px;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--brand-amber), var(--brand-amber-soft));
}

.tab-panel {
    display: none;
    padding: 12px 24px 0;
}

.tab-panel.active {
    display: block;
}

/* Historical portfolio chart */
.history-chart-card {
    margin: 0 0 20px;
    padding: 18px 22px 14px;
    border-radius: 18px;
}

.history-chart-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.history-chart-header h3 {
    margin: 0 0 2px;
    font-size: 1.05rem;
    color: var(--brand-dark);
}

.history-chart-header .muted {
    margin: 0;
    font-size: 0.85rem;
}

.history-chart-range {
    display: inline-flex;
    background: rgba(17, 47, 91, 0.05);
    border-radius: 999px;
    padding: 3px;
}

.history-chart-range .range-btn {
    border: 0;
    background: transparent;
    color: var(--brand-gray);
    padding: 5px 12px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.history-chart-range .range-btn.active {
    background: #fff;
    color: var(--brand-dark);
    box-shadow: 0 1px 3px rgba(17, 47, 91, 0.10);
}

.history-chart-range .range-btn:not(.active):hover {
    color: var(--brand-dark);
}

.history-chart-canvas-wrap {
    position: relative;
    height: 260px;
    width: 100%;
}

.panel-actions {
   display: flex;
   align-items: center;
   gap: 12px;
   font-size: 0.9rem;
   color: var(--brand-gray);
   flex-wrap: wrap;
}

.actions-group.hidden {
    display: none;
}

.actions-group {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.toggle-switch {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

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

.toggle-track {
    width: 52px;
    height: 26px;
    background: #d6deea;
    border-radius: 20px;
    position: relative;
    transition: background 0.2s ease;
    box-shadow: inset 0 2px 4px rgba(17, 47, 91, 0.12);
}

.toggle-thumb {
    position: absolute;
    top: 2px;
    left: 3px;
    width: 22px;
    height: 22px;
    background: #ffffff;
    border-radius: 50%;
    box-shadow: 0 3px 10px rgba(17, 47, 91, 0.18);
    transition: transform 0.2s ease, background 0.2s ease;
}

.toggle-switch input:checked + .toggle-track {
    background: rgba(17, 109, 255, 0.25);
}

.toggle-switch input:checked + .toggle-track .toggle-thumb {
    transform: translateX(22px);
    background: var(--brand-blue);
}

.toggle-label {
    font-weight: 600;
    color: var(--brand-dark);
}

.toggle-label.left {
    min-width: 108px;
    text-align: right;
}

.toggle-label.right {
    min-width: 40px;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--brand-gray);
    display: inline-flex;
}

.summary-controls {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
    margin-bottom: 16px;
}

.summary-actions {
    display: flex;
    gap: 8px;
}

.transactions-actions-bar {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    align-items: center;
    padding: 8px 0 4px;
}

.callout {
    display: flex;
    gap: 14px;
    align-items: center;
    padding: 14px 18px;
    border-radius: 16px;
    background: rgba(249, 116, 10, 0.15);
    color: var(--brand-dark);
}

.callout p {
    margin: 2px 0 0;
    color: var(--brand-gray);
    font-size: 0.9rem;
}

.table-scroll {
    width: 100%;
    overflow: auto;
    border-radius: 18px;
    position: relative;
    max-height: 70vh;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1100px;
}

.sticky-table thead th {
    position: sticky;
    top: 0;
    background: var(--brand-card);
    z-index: 3;
    box-shadow: inset 0 -1px 0 rgba(17, 47, 91, 0.08);
}

th,
td {
    padding: 14px 16px;
    border-bottom: 1px solid rgba(17, 47, 91, 0.08);
    text-align: left;
    font-size: 0.92rem;
}

th {
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.08em;
    color: var(--brand-gray);
    background: #f5f7fb;
}

.data-table tbody tr {
    transition: background 0.15s ease;
}

.data-table tbody tr:hover {
    background: rgba(249, 116, 10, 0.05);
    box-shadow: inset 3px 0 0 var(--brand-amber);
}

.data-table .net-row {
    background: #fff3e8;
    font-weight: 700;
}

.data-table .net-row td {
    border-top: 2px solid rgba(249, 116, 10, 0.35);
}

.empty-state {
    text-align: center;
    color: var(--brand-gray);
    padding: 48px 16px;
}

.ticker-input {
    width: 180px;
}

.ticker-input.alert {
    border-color: rgba(198, 40, 40, 0.6);
    background: rgba(198, 40, 40, 0.04);
}

.symbol-results {
    margin: 0 0 12px;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: rgba(249, 116, 10, 0.08);
    font-size: 0.9rem;
}

.symbol-results.hidden {
    display: none;
}

.symbol-results ul {
    padding-left: 18px;
    margin: 8px 0 0;
}

.transaction-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 20px;
    border-radius: 16px;
    border: 1px dashed rgba(249, 116, 10, 0.35);
    background: #fff9f3;
    margin: 10px 0 16px;
}

.transaction-form h3 {
    margin: 0 0 6px;
}

.transaction-form input.static {
    background: transparent;
    border: 1px dashed rgba(17, 47, 91, 0.15);
    color: var(--brand-dark);
    cursor: default;
}

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

.fx-field {
    grid-column: span 1;
}

.note-field {
    grid-column: span 2;
}

.note-field input {
    width: 100%;
    min-width: 220px;
}

.transaction-form input[readonly] {
    background: #f5f5f5;
    cursor: not-allowed;
}

.fx-field span {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.transaction-form input[type="number"]::-webkit-inner-spin-button,
.transaction-form input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.transaction-form input[type="number"] {
    -moz-appearance: textfield;
}

.tx-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 4px;
}

.tx-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px 16px;
    padding: 8px 12px;
    border-radius: 12px;
    border: 1px solid rgba(17, 47, 91, 0.1);
    background: #fff;
}

.tx-summary span {
    display: block;
    font-size: 0.82rem;
    color: var(--brand-gray);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.tx-summary strong {
    font-size: 1rem;
    color: var(--brand-dark);
}

.tx-summary .tx-hint {
    grid-column: 1 / -1;
    background: rgba(17, 109, 255, 0.06);
    border: 1px dashed rgba(17, 109, 255, 0.3);
    padding: 10px 12px;
    border-radius: 10px;
}

.tx-summary .tx-hint small {
    display: block;
    color: var(--brand-gray);
    font-size: 0.85rem;
    line-height: 1.4;
}

#transactionFormShell.inline .transaction-form {
    margin-top: 0;
}

.inline-tx-row td {
    padding: 0;
}

.range-filter {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: var(--brand-gray);
}

.range-filter select {
    min-width: 120px;
    padding: 8px 12px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: #fff;
}

.edit-btn {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 6px 10px;
    cursor: pointer;
    color: var(--brand-dark);
}

.edit-btn[disabled] {
    opacity: 0.4;
    cursor: not-allowed;
}

.sheet-browser {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sheet-pills {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.sheet-pill {
    padding: 6px 16px;
    border-radius: 999px;
    border: 1px solid rgba(17, 47, 91, 0.14);
    background: transparent;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--brand-gray);
}

.sheet-pill.active {
    background: var(--brand-blue);
    color: #ffffff;
    border-color: var(--brand-blue);
}

.security-cell strong {
    font-size: 1rem;
}

.muted {
    color: var(--brand-gray);
    font-size: 0.85rem;
}

.text-up {
    color: var(--success);
}

.text-down {
    color: var(--danger);
}

.cost-override-badge {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--brand-amber-deep, #f9740a);
    background: rgba(246, 176, 28, 0.14);
    border: 1px solid rgba(246, 176, 28, 0.4);
    border-radius: 4px;
    cursor: help;
    vertical-align: middle;
}

.toast {
    position: fixed;
    bottom: 32px;
    right: 32px;
    padding: 16px 22px;
    border-radius: 16px;
    background: var(--brand-blue);
    color: #ffffff;
    box-shadow: var(--shadow-soft);
    z-index: 1000;
    animation: toast-slide-in 0.3s ease-out;
}

@keyframes toast-slide-in {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

.toast.error {
    background: var(--danger);
    color: #ffffff;
}

.toast.success {
    background: var(--success);
    color: #0e4828;
}

/* ── Tablet ───────────────────────────────────────────── */
@media (max-width: 900px) {
    .app-shell {
        padding: 20px 16px 60px;
    }

    .app-header {
        flex-direction: column;
        align-items: flex-start;
        padding: 16px 20px;
        gap: 16px;
    }

    .header-actions {
        flex-wrap: wrap;
        width: 100%;
    }

    .brand-logo {
        width: 80px;
        height: 80px;
    }

    .brand h1 {
        font-size: 1.5rem;
    }

    .kpi-grid {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
        gap: 10px;
    }

    .kpi-card {
        padding: 16px;
    }

    .kpi-card h2 {
        font-size: 1.4rem;
    }

    table {
        min-width: 800px;
    }
}

/* ── Mobile ──────────────────────────────────────────── */
@media (max-width: 640px) {
    .app-shell {
        padding: 12px 8px 48px;
    }

    .app-header {
        padding: 12px 14px;
        border-radius: 16px;
        margin-bottom: 16px;
        gap: 12px;
    }

    .brand-lockup {
        gap: 10px;
    }

    .brand-logo {
        width: 56px;
        height: 56px;
        padding: 6px;
        border-radius: 10px;
    }

    .brand h1 {
        font-size: 1.2rem;
        margin: 0;
    }

    .brand .eyebrow {
        font-size: 0.7rem;
        letter-spacing: 0.15em;
    }

    .header-actions {
        gap: 8px;
    }

    .header-actions .btn {
        padding: 8px 12px;
        font-size: 0.8rem;
    }

    .user-greeting {
        font-size: 0.82rem;
        padding: 6px 10px;
    }

    /* KPI cards: 2-column on mobile */
    .kpi-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        padding: 6px 0;
    }

    .kpi-card {
        padding: 12px;
        border-radius: 16px;
    }

    .kpi-card p {
        font-size: 0.72rem;
        letter-spacing: 0.06em;
    }

    .kpi-card h2 {
        font-size: 1.15rem;
        margin: 6px 0 2px;
    }

    .kpi-card .muted {
        font-size: 0.75rem;
    }

    /* Panel & tabs */
    .panel {
        border-radius: 16px;
    }

    .panel-header {
        flex-direction: column;
        align-items: flex-start;
        padding: 12px 12px 0;
        gap: 10px;
    }

    .tabs {
        width: 100%;
        gap: 4px;
    }

    .tab {
        padding: 8px 12px;
        font-size: 0.85rem;
        flex: 1;
        text-align: center;
    }

    .panel-actions {
        width: 100%;
        justify-content: flex-start;
        gap: 8px;
        flex-wrap: wrap;
    }

    .actions-group {
        flex-wrap: wrap;
        gap: 6px;
    }

    .toggle-switch {
        gap: 6px;
    }

    .toggle-label {
        font-size: 0.82rem;
    }

    .toggle-label.left {
        min-width: auto;
        text-align: left;
    }

    .toggle-track {
        width: 42px;
        height: 22px;
    }

    .toggle-thumb {
        width: 18px;
        height: 18px;
    }

    .toggle-switch input:checked + .toggle-track .toggle-thumb {
        transform: translateX(18px);
    }

    .btn.small, .btn.tiny {
        padding: 6px 10px;
        font-size: 0.78rem;
    }

    /* Tab content */
    .tab-panel {
        padding: 10px 10px 0;
    }

    /* Table */
    .table-scroll {
        border-radius: 12px;
        max-height: 60vh;
    }

    table {
        min-width: 600px;
    }

    th, td {
        padding: 10px 8px;
        font-size: 0.82rem;
    }

    th {
        font-size: 0.7rem;
    }

    .empty-state {
        padding: 32px 12px;
    }

    /* Transaction form */
    .transaction-form {
        padding: 14px;
        margin: 8px 0 12px;
        border-radius: 12px;
    }

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

    .note-field {
        grid-column: span 1;
    }

    .tx-summary {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        padding: 8px;
    }

    .tx-actions {
        flex-direction: column;
        gap: 8px;
    }

    .tx-actions .btn {
        width: 100%;
    }

    /* Range filter */
    .range-filter {
        width: 100%;
    }

    .range-filter select {
        flex: 1;
        min-width: 0;
    }

    /* Admin */
    .admin-panel {
        padding: 12px;
        border-radius: 10px;
    }

    .admin-form {
        grid-template-columns: 1fr;
    }

    /* Auth card */
    .auth-shell {
        padding: 40px 12px;
    }

    .auth-card {
        padding: 28px 20px;
        border-radius: 18px;
    }

    .auth-logo {
        width: 100px;
        height: 100px;
    }

    .auth-brand h1 {
        font-size: 1.5rem;
    }

    /* Toast */
    .toast {
        bottom: 16px;
        right: 12px;
        left: 12px;
        text-align: center;
        font-size: 0.88rem;
        padding: 12px 16px;
    }

    /* Transaction KPIs */
    .tx-kpi-grid {
        padding: 6px 8px;
    }

    /* Status text inline */
    #priceStatusText {
        display: block;
        width: 100%;
        font-size: 0.78rem;
        margin-top: 4px;
    }

    /* Sticky offsets tighter */
    .sticky-kpis {
        padding: 4px 0;
    }
}

/* ── Small phones ────────────────────────────────────── */
@media (max-width: 380px) {
    .kpi-grid {
        grid-template-columns: 1fr;
    }

    .brand-logo {
        width: 44px;
        height: 44px;
    }

    .brand h1 {
        font-size: 1rem;
    }

    .tab {
        padding: 6px 8px;
        font-size: 0.78rem;
    }
}


.admin-panel {
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
    margin-top: 12px;
}

.admin-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

.admin-actions {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 12px;
}

.data-table .status-pill {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(17, 109, 255, 0.1);
    color: var(--brand-dark);
    font-weight: 600;
}

/* Custom scrollbars */
.table-scroll::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.table-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.table-scroll::-webkit-scrollbar-thumb {
    background: rgba(17, 47, 91, 0.15);
    border-radius: 3px;
}

.table-scroll::-webkit-scrollbar-thumb:hover {
    background: rgba(17, 47, 91, 0.3);
}
