:root {
    --bg: #0e1116;
    --bg-raised: #171b22;
    --bg-raised-2: #1f242d;
    --border: #2a3039;
    --text: #eef1f5;
    --text-dim: #98a2b3;
    --text-faint: #6b7480;
    --accent: #ff4f40;
    --accent-soft: rgba(255, 79, 64, 0.14);
    --positive: #3ddc84;
    --warning: #ffb020;
    --danger: #ff5f56;
    --radius: 14px;
    --radius-sm: 10px;
}

* {
    box-sizing: border-box;
}

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

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
    margin: 0;
    font-weight: 650;
    letter-spacing: -0.01em;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ---------------------------------------------------------------- page header */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.topbar h1 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-dim);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg-raised);
    color: var(--text-dim);
    font-size: 1.05rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.icon-button:hover:not(:disabled) {
    color: var(--text);
    border-color: var(--text-faint);
}

.icon-button:disabled {
    opacity: 0.5;
    cursor: default;
}

/* ---------------------------------------------------------------- balance */

.balance-card {
    background: linear-gradient(160deg, var(--bg-raised) 0%, var(--bg-raised-2) 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem 1.25rem 1.25rem;
    text-align: center;
    margin-bottom: 1.25rem;
}

.balance-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--text-faint);
    margin-bottom: 0.4rem;
}

.balance-amount {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 0.1rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.balance-whole {
    font-size: clamp(2.75rem, 15vw, 4rem);
}

.balance-fraction {
    font-size: clamp(1.25rem, 6vw, 1.75rem);
    color: var(--text-dim);
}

.balance-sub {
    margin-top: 0.6rem;
    font-size: 0.9rem;
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
}

.balance-meta {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-faint);
}

.stale {
    color: var(--warning);
}

/* ---------------------------------------------------------------- transactions */

.section-heading {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--text-faint);
    margin: 1.5rem 0 0.5rem;
}

.day-heading {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem;
    padding: 0.9rem 0.25rem 0.4rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-faint);
    font-variant-numeric: tabular-nums;
}

.tx-list {
    list-style: none;
    margin: 0;
    padding: 0;
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.tx {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 0.85rem;
    border-bottom: 1px solid var(--border);
}

.tx:last-child {
    border-bottom: none;
}

.tx-avatar {
    flex: 0 0 auto;
    width: 2.4rem;
    height: 2.4rem;
    border-radius: 50%;
    background: var(--bg-raised-2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    overflow: hidden;
    color: var(--text-dim);
}

.tx-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.tx-body {
    flex: 1 1 auto;
    min-width: 0;
}

.tx-title {
    font-weight: 550;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tx-sub {
    font-size: 0.78rem;
    color: var(--text-faint);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tx-amounts {
    flex: 0 0 auto;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.tx-amount {
    font-weight: 600;
    white-space: nowrap;
}

.tx-amount.incoming {
    color: var(--positive);
}

.tx-amount.estimated::after {
    content: "≈";
    margin-left: 0.15rem;
    font-size: 0.7em;
    color: var(--text-faint);
    vertical-align: 0.15em;
}

.tx-gbp {
    font-size: 0.75rem;
    color: var(--text-faint);
    white-space: nowrap;
}

.tx.declined {
    opacity: 0.55;
}

.tx.declined .tx-amount {
    text-decoration: line-through;
}

/* ---------------------------------------------------------------- forms & cards */

.card {
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.1rem;
    margin-bottom: 1rem;
}

.card h2 {
    font-size: 0.95rem;
    margin-bottom: 0.15rem;
}

.card-hint {
    font-size: 0.82rem;
    color: var(--text-faint);
    margin: 0 0 0.9rem;
}

.field {
    display: block;
    margin-bottom: 0.9rem;
}

.field > span {
    display: block;
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-bottom: 0.3rem;
}

input[type="text"],
input[type="password"],
input[type="number"],
select {
    width: 100%;
    padding: 0.65rem 0.75rem;
    font-size: 1rem;
    font-family: inherit;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    appearance: none;
}

input:focus,
select:focus,
button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
    border-color: transparent;
}

input.code-input {
    font-size: 1.5rem;
    letter-spacing: 0.4em;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.checkbox {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    margin-bottom: 0.8rem;
    cursor: pointer;
}

.checkbox input {
    margin: 0.2rem 0 0;
    width: 1.1rem;
    height: 1.1rem;
    accent-color: var(--accent);
}

.checkbox span {
    font-size: 0.9rem;
}

.checkbox small {
    display: block;
    color: var(--text-faint);
    font-size: 0.78rem;
}

button,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.7rem 1.1rem;
    font-size: 0.95rem;
    font-family: inherit;
    font-weight: 600;
    color: #fff;
    background: var(--accent);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-decoration: none;
}

button:hover:not(:disabled),
.button:hover {
    filter: brightness(1.08);
    text-decoration: none;
}

button:disabled {
    opacity: 0.55;
    cursor: default;
}

button.secondary,
.button.secondary {
    background: var(--bg-raised-2);
    color: var(--text);
    border-color: var(--border);
}

button.danger {
    background: transparent;
    color: var(--danger);
    border-color: var(--danger);
}

button.block,
.button.block {
    width: 100%;
}

.button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* ---------------------------------------------------------------- messages */

.alert {
    border-radius: var(--radius-sm);
    padding: 0.7rem 0.85rem;
    font-size: 0.88rem;
    margin-bottom: 1rem;
    border: 1px solid;
}

.alert.error {
    background: rgba(255, 95, 86, 0.1);
    border-color: rgba(255, 95, 86, 0.4);
    color: #ffb3ae;
}

.alert.success {
    background: rgba(61, 220, 132, 0.1);
    border-color: rgba(61, 220, 132, 0.35);
    color: #9ff0c1;
}

.alert.info {
    background: var(--accent-soft);
    border-color: rgba(255, 79, 64, 0.3);
    color: #ffc4bd;
}

.empty {
    text-align: center;
    color: var(--text-faint);
    padding: 2rem 1rem;
    font-size: 0.9rem;
}

/* ---------------------------------------------------------------- auth pages */

.auth-page {
    max-width: 22rem;
    margin: 0 auto;
    padding-top: 8vh;
}

.auth-brand {
    text-align: center;
    margin-bottom: 1.5rem;
}

.auth-brand .mark {
    font-size: 2.25rem;
}

.auth-brand h1 {
    font-size: 1.25rem;
    margin-top: 0.35rem;
}

.auth-brand p {
    color: var(--text-faint);
    font-size: 0.85rem;
    margin: 0.25rem 0 0;
}

.qr {
    display: block;
    width: 190px;
    height: 190px;
    margin: 0 auto 0.9rem;
    background: #fff;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    image-rendering: pixelated;
}

.secret {
    display: block;
    text-align: center;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.95rem;
    letter-spacing: 0.08em;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.6rem;
    word-break: break-all;
    margin-bottom: 0.9rem;
}

/* ---------------------------------------------------------------- misc */

.status-dot {
    display: inline-block;
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    margin-right: 0.4rem;
    vertical-align: 0.05rem;
}

.status-dot.on { background: var(--positive); }
.status-dot.off { background: var(--text-faint); }

/* Collapsed diagnostic readout on the settings page. */

.config-readout {
    margin-top: 1rem;
    border-top: 1px solid var(--border);
    padding-top: 0.75rem;
}

.config-readout summary {
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--text-faint);
    list-style: none;
}

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

.config-readout summary::before {
    content: "▸ ";
}

.config-readout[open] summary::before {
    content: "▾ ";
}

.config-readout dl {
    margin: 0.75rem 0 0;
    font-size: 0.8rem;
}

.config-readout dt {
    color: var(--text-faint);
    margin-top: 0.6rem;
}

.config-readout dd {
    margin: 0.1rem 0 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    color: var(--text);
    word-break: break-all;
}

.config-readout .card-hint {
    margin-top: 0.9rem;
    margin-bottom: 0;
}

.spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

.footer-nav {
    margin-top: 1.5rem;
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-faint);
}

#blazor-error-ui {
    color-scheme: dark;
    background: var(--bg-raised-2);
    color: var(--text);
    bottom: 0;
    box-shadow: 0 -1px 6px rgba(0, 0, 0, 0.5);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.8rem 1.2rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.7rem;
}
