/* =============================================================================
   XTTB — application stylesheet
   Dark-navy exchange UI with a purple brand accent, implemented from the XTTB
   design comps (Wallet / Trade / Market screens, 1536px reference width).

   1. Fonts & tokens      6. Buttons            11. Dashboard
   2. Base                7. Forms              12. Charts
   3. Layout: topbar      8. Cards & tiles      13. Auth pages
   4. Layout: sidebar     9. Tables & tabs      14. Error page
   5. Layout: main       10. Feedback          15. Utilities & motion
   ========================================================================== */

/* 1. Fonts & tokens --------------------------------------------------------- */

/* Inter (SIL Open Font License) — self-hosted latin subset, variable 400–700. */
@font-face {
    font-family: "Inter";
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url("../fonts/inter-latin-var.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
        U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Metric-adjusted fallback so the swap to Inter does not shift layout. */
@font-face {
    font-family: "Inter Fallback";
    src: local("Arial"), local("Helvetica Neue"), local("Helvetica");
    ascent-override: 96.88%;
    descent-override: 24.15%;
    line-gap-override: 0%;
    size-adjust: 107.12%;
}

:root {
    color-scheme: dark;

    /* Surfaces */
    --bg: #090a21;
    --bg-bar: #0a0b25;
    --surface: #0f1031;
    --surface-raised: #14153a;
    --surface-hover: #1a1b46;
    --surface-input: #10112f;
    --surface-popover: #121336;
    --border: #1c1d47;
    --border-strong: #292a5c;
    --border-hover: #35367a;

    /* Text */
    --text: #f5f5ff;
    --text-secondary: #c2c4e0;
    --text-muted: #9092b8;
    --text-subtle: #6e7099;

    /* Brand */
    --primary: #6e34f0;
    --primary-hover: #7d48f6;
    --primary-active: #5f28db;
    --primary-soft: rgba(123, 63, 242, 0.16);
    --primary-border: rgba(139, 103, 247, 0.45);
    --primary-text: #9d74ff;
    --primary-line: #7b3ff2;
    --link-hover: #b596ff;
    --accent-soft-text: #c2a8ff;
    --sidebar-active: linear-gradient(90deg, #5a2ad6 0%, #6c36ef 100%);

    /* Market & status */
    --up: #2ed47a;
    --up-soft: rgba(46, 212, 122, 0.14);
    --down: #f6465d;
    --down-soft: rgba(246, 70, 93, 0.14);
    --warning: #f5b041;
    --warning-soft: rgba(245, 176, 65, 0.14);
    --info: #5aa9ff;
    --info-soft: rgba(90, 169, 255, 0.14);
    --neutral-soft: rgba(144, 146, 184, 0.14);
    --danger-text: #ff7d8f;
    --alert-success-text: #8ff0bb;
    --alert-error-text: #ffa3af;
    --alert-warning-text: #ffd28a;
    --alert-info-text: #a9d0ff;

    /* Chart series — validated (dataviz validate_palette.js, dark, surface #0f1031):
       slots 1–3 pass all-pairs; "Others" is a labelled neutral by convention. */
    --series-1: #8b67f7;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-other: #6b6c94;
    --chart-track: #1b1c47;

    /* Shape & depth */
    --radius-xs: 4px;
    --radius-sm: 6px;
    --radius: 8px;
    --radius-lg: 12px;
    --radius-pill: 999px;
    --shadow-pop: 0 18px 40px rgba(3, 3, 18, 0.55);
    --ring: 0 0 0 3px rgba(123, 63, 242, 0.32);

    /* Layout */
    --topbar-h: 64px;
    --sidebar-w: 218px;
    --gutter: 20px;

    --font: "Inter", "Inter Fallback", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

/* Light appearance — same tokens, stepped for light surfaces (contrast-checked).
   Applied when a user chooses Light, or System on a light-mode device. */
:root[data-theme="light"] {
    color-scheme: light;
    --bg: #f4f5fb;
    --bg-bar: #ffffff;
    --surface: #ffffff;
    --surface-raised: #f1f1f9;
    --surface-hover: #e8e8f4;
    --surface-input: #ffffff;
    --surface-popover: #ffffff;
    --border: #e3e4f0;
    --border-strong: #d3d4e6;
    --border-hover: #b9bad6;
    --text: #14152e;
    --text-secondary: #3f4166;
    --text-muted: #62648a;
    --text-subtle: #7a7c99;
    --primary-soft: rgba(110, 52, 240, 0.1);
    --primary-border: rgba(91, 43, 217, 0.45);
    --primary-text: #5b2bd9;
    --link-hover: #4520b0;
    --accent-soft-text: #5b2bd9;
    --up: #087f47;
    --up-soft: rgba(8, 127, 71, 0.1);
    --down: #d92d45;
    --down-soft: rgba(217, 45, 69, 0.1);
    --warning: #a65f00;
    --warning-soft: rgba(166, 95, 0, 0.12);
    --info: #1f6fd1;
    --info-soft: rgba(31, 111, 209, 0.1);
    --neutral-soft: rgba(98, 100, 138, 0.12);
    --danger-text: #b81f36;
    --alert-success-text: #0b6b3d;
    --alert-error-text: #a61b30;
    --alert-warning-text: #7f4a00;
    --alert-info-text: #1a5aa8;
    /* validate_palette.js, light, surface #ffffff: slots 1–3 pass all-pairs incl. contrast */
    --series-1: #7048ea;
    --series-2: #e2632f;
    --series-3: #159f6f;
    --series-other: #8b8da8;
    --chart-track: #ececf6;
    --shadow-pop: 0 18px 40px rgba(20, 21, 46, 0.14);
}

@media (prefers-color-scheme: light) {
    :root[data-theme="system"] {
        color-scheme: light;
        --bg: #f4f5fb;
        --bg-bar: #ffffff;
        --surface: #ffffff;
        --surface-raised: #f1f1f9;
        --surface-hover: #e8e8f4;
        --surface-input: #ffffff;
        --surface-popover: #ffffff;
        --border: #e3e4f0;
        --border-strong: #d3d4e6;
        --border-hover: #b9bad6;
        --text: #14152e;
        --text-secondary: #3f4166;
        --text-muted: #62648a;
        --text-subtle: #7a7c99;
        --primary-soft: rgba(110, 52, 240, 0.1);
        --primary-border: rgba(91, 43, 217, 0.45);
        --primary-text: #5b2bd9;
        --link-hover: #4520b0;
        --accent-soft-text: #5b2bd9;
        --up: #087f47;
        --up-soft: rgba(8, 127, 71, 0.1);
        --down: #d92d45;
        --down-soft: rgba(217, 45, 69, 0.1);
        --warning: #a65f00;
        --warning-soft: rgba(166, 95, 0, 0.12);
        --info: #1f6fd1;
        --info-soft: rgba(31, 111, 209, 0.1);
        --neutral-soft: rgba(98, 100, 138, 0.12);
        --danger-text: #b81f36;
        --alert-success-text: #0b6b3d;
        --alert-error-text: #a61b30;
        --alert-warning-text: #7f4a00;
        --alert-info-text: #1a5aa8;
        --series-1: #7048ea;
        --series-2: #e2632f;
        --series-3: #159f6f;
        --series-other: #8b8da8;
        --chart-track: #ececf6;
        --shadow-pop: 0 18px 40px rgba(20, 21, 46, 0.14);
    }
}

/* 2. Base ------------------------------------------------------------------- */

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

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

/* Components set their own display; the hidden attribute must always win. */
[hidden] {
    display: none !important;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: "cv11", "ss01";
}

h1, h2, h3, h4, p {
    margin: 0;
}

h1, h2, h3, h4 {
    font-weight: 600;
    line-height: 1.25;
    letter-spacing: -0.01em;
}

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

a:hover {
    color: var(--link-hover);
}

img,
svg {
    display: block;
    max-width: 100%;
}

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

button {
    cursor: pointer;
}

:focus-visible {
    outline: 2px solid var(--primary-text);
    outline-offset: 2px;
}

::selection {
    background: color-mix(in srgb, var(--primary) 45%, transparent);
}

.icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.skip-link {
    position: absolute;
    left: 12px;
    top: -60px;
    z-index: 100;
    padding: 10px 16px;
    border-radius: var(--radius);
    background: var(--primary);
    color: #fff;
}

.skip-link:focus {
    top: 12px;
}

.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Brand lockup */
.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
}

/*
 * XTTB logo: one silhouette (CSS mask), filled per theme so it always fits the palette.
 * Light mode fills with the brand purple; dark mode fills white on the navy.
 */
.brand-logo {
    display: block;
    height: 38px;
    aspect-ratio: 480 / 174;
    -webkit-mask: url("../images/brand/xttb-white.png") left center / contain no-repeat;
    mask: url("../images/brand/xttb-white.png") left center / contain no-repeat;
    /* Light is the default. */
    background: linear-gradient(122deg, var(--primary-line) 0%, var(--primary) 55%, var(--primary-active) 100%);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .brand-logo { background: #ffffff; }
}

:root[data-theme="dark"] .brand-logo { background: #ffffff; }
:root[data-theme="light"] .brand-logo { background: linear-gradient(122deg, var(--primary-line) 0%, var(--primary) 55%, var(--primary-active) 100%); }

/* Legacy inline-SVG wordmark (kept so any stray reference degrades gracefully). */
.brand-mark {
    width: 36px;
    height: 36px;
}

.brand-name {
    font-size: 26px;
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1;
}

.brand-accent {
    color: var(--primary-text);
}

.brand-suffix {
    margin-left: 2px;
    padding: 3px 8px;
    border-radius: var(--radius-xs);
    background: var(--primary-soft);
    color: var(--accent-soft-text);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

/* 3. Layout: topbar ---------------------------------------------------------- */

.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    height: var(--topbar-h);
    padding: 0 26px 0 24px;
    background: var(--bg-bar);
    border-bottom: 1px solid var(--border);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    width: calc(var(--sidebar-w) + 32px);
    flex-shrink: 0;
}

.topbar-brand {
    display: inline-flex;
}

.topnav {
    display: flex;
    align-items: stretch;
    align-self: stretch;
    gap: 2px;
}

.topnav-link {
    position: relative;
    display: inline-flex;
    align-items: center;
    padding: 0 24px;
    color: var(--text-secondary);
    font-size: 16px;
    font-weight: 500;
    white-space: nowrap;
}

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

.topnav-link.is-active {
    color: var(--text);
    font-weight: 600;
}

.topnav-link.is-active::after {
    content: "";
    position: absolute;
    left: 14px;
    right: 14px;
    bottom: -1px;
    height: 4px;
    border-radius: 3px 3px 0 0;
    background: var(--primary-line);
}

.topnav-link.is-disabled {
    color: var(--text-subtle);
    cursor: default;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 18px;
    margin-left: auto;
}

.topbar-search {
    position: relative;
    width: 294px;
}

.topbar-search input {
    width: 100%;
    height: 36px;
    padding: 0 14px 0 40px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface-input);
    font-size: 13px;
    color: var(--text);
}

.topbar-search input::placeholder {
    color: var(--text-muted);
}

.topbar-search input:focus {
    outline: none;
    border-color: var(--primary-border);
    box-shadow: var(--ring);
}

.topbar-search input:disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

.topbar-search-icon {
    position: absolute;
    left: 13px;
    top: 50%;
    width: 18px;
    height: 18px;
    color: var(--text-secondary);
    transform: translateY(-50%);
    pointer-events: none;
}

.icon-btn {
    position: relative;
    display: inline-grid;
    place-items: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 0;
    border-radius: var(--radius);
    background: transparent;
    color: var(--text-secondary);
}

.icon-btn:hover {
    background: var(--surface-raised);
    color: var(--text);
}

.icon-btn .icon {
    width: 24px;
    height: 24px;
}

.dot-indicator {
    position: absolute;
    top: 8px;
    right: 9px;
    width: 8px;
    height: 8px;
    border: 2px solid var(--bg-bar);
    border-radius: 50%;
    background: var(--primary-line);
    box-sizing: content-box;
}

.sidebar-toggle {
    display: none;
}

.user-menu-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--text-secondary);
}

.user-menu-toggle:hover {
    color: var(--text);
}

.user-menu-caret {
    width: 18px;
    height: 18px;
}

.avatar {
    display: inline-grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    object-fit: cover;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.01em;
}

/* Dropdowns */
.dropdown {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    z-index: 50;
    display: none;
    min-width: 248px;
    padding: 6px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    background: var(--surface-popover);
    box-shadow: var(--shadow-pop);
}

.dropdown.is-open > .dropdown-menu {
    display: block;
}

.dropdown-menu-wide {
    width: 340px;
}

.dropdown-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px 8px;
}

.dropdown-header-stacked {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 12px;
    border: 0;
    border-radius: var(--radius);
    background: transparent;
    color: var(--text-secondary);
    font-size: 14px;
    text-align: left;
}

.dropdown-item .icon {
    width: 18px;
    height: 18px;
    color: var(--text-muted);
}

.dropdown-item:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.dropdown-item.is-disabled {
    color: var(--text-subtle);
    cursor: default;
}

.dropdown-item.is-disabled:hover {
    background: transparent;
}

.dropdown-item .chip {
    margin-left: auto;
}

.dropdown-item-danger:hover,
.dropdown-item-danger:hover .icon {
    color: var(--danger-text);
}

.dropdown-divider {
    height: 1px;
    margin: 6px 4px;
    background: var(--border);
}

.dropdown-empty {
    padding: 16px 12px 18px;
    color: var(--text-muted);
}

.notification-list {
    max-height: 360px;
    margin: 0;
    padding: 0;
    overflow-y: auto;
    list-style: none;
}

.notification-link {
    position: relative;
    display: grid;
    gap: 2px;
    padding: 10px 12px 10px 24px;
    border-radius: var(--radius);
    color: var(--text-secondary);
}

a.notification-link:hover {
    background: var(--surface-hover);
    color: var(--text-secondary);
}

.notification-item.is-unread .notification-link::before {
    content: "";
    position: absolute;
    left: 10px;
    top: 17px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--primary-line);
}

.notification-title {
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
}

.notification-body {
    font-size: 12px;
    color: var(--text-muted);
}

.notification-time {
    font-size: 11px;
    color: var(--text-subtle);
}

/* 4. Layout: sidebar --------------------------------------------------------- */

.app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    min-height: calc(100vh - var(--topbar-h));
}

.sidebar {
    position: sticky;
    top: var(--topbar-h);
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--topbar-h));
    padding: 22px 12px 22px;
    overflow-y: auto;
    background: var(--bg-bar);
    border-right: 1px solid var(--border);
}

.sidebar-mobile-header {
    display: none;
}

.sidebar-nav {
    display: grid;
    gap: 14px;
}

.sidebar-group {
    display: grid;
    gap: 8px;
}

.sidebar-group + .sidebar-group {
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.sidebar-group-label {
    padding: 0 16px 2px;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 16px;
    height: 43px;
    padding: 0 14px;
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 15px;
    font-weight: 500;
}

.sidebar-link .icon {
    width: 24px;
    height: 24px;
    color: var(--text-secondary);
}

.sidebar-link:hover {
    background: var(--surface-raised);
    color: var(--text);
}

.sidebar-link.is-active {
    background: var(--sidebar-active);
    box-shadow: 0 8px 22px color-mix(in srgb, var(--primary) 32%, transparent);
    color: #fff;
    font-weight: 600;
}

.sidebar-link.is-active .icon {
    color: #fff;
}

.sidebar-link.is-disabled {
    color: var(--text-subtle);
    cursor: default;
}

.sidebar-link.is-disabled .icon {
    color: var(--text-subtle);
}

.sidebar-link.is-disabled:hover {
    background: transparent;
}

.sidebar-link .chip {
    margin-left: auto;
}

.sidebar-backdrop {
    display: none;
}

.promo-card {
    position: relative;
    flex-shrink: 0;
    margin: auto 0 0;
    padding: 22px 15px 22px 16px;
    overflow: hidden;
    border: 1px solid color-mix(in srgb, var(--primary) 35%, var(--border));
    border-radius: var(--radius-lg);
    background:
        radial-gradient(120% 80% at 100% 0%, color-mix(in srgb, var(--primary) 28%, transparent) 0%, transparent 60%),
        linear-gradient(165deg, color-mix(in srgb, var(--primary) 34%, var(--surface)) 0%, color-mix(in srgb, var(--primary) 17%, var(--surface)) 52%, color-mix(in srgb, var(--primary) 8%, var(--surface)) 100%);
}

.promo-icon {
    display: inline-grid;
    place-items: center;
    width: 48px;
    height: 48px;
    margin-bottom: 18px;
    border-radius: 50%;
    background: linear-gradient(145deg, var(--primary-hover), var(--primary-active));
    box-shadow: 0 8px 20px color-mix(in srgb, var(--primary) 45%, transparent);
    color: #fff;
}

.promo-icon .icon {
    width: 24px;
    height: 24px;
}

.promo-title {
    margin-bottom: 6px;
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.015em;
    white-space: nowrap;
}

.promo-card .btn {
    max-width: 100%;
    padding: 0 16px;
}

.promo-text {
    margin-bottom: 18px;
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.55;
}

/* 5. Layout: main ------------------------------------------------------------ */

.app-main {
    min-width: 0;
    padding: 24px 22px 28px var(--gutter);
    outline: none;
}

.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.page-title {
    font-size: 24px;
}

.page-subtitle {
    margin-top: 4px;
    color: var(--text-muted);
}

.app-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 16px;
    margin-top: 28px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
    color: var(--text-subtle);
    font-size: 12px;
}

/* 6. Buttons ----------------------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 44px;
    padding: 0 26px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
    text-decoration: none;
    user-select: none;
}

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

.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 6px 18px color-mix(in srgb, var(--primary) 28%, transparent);
}

.btn-primary:hover {
    background: var(--primary-hover);
    color: #fff;
}

.btn-primary:active {
    background: var(--primary-active);
}

.btn-secondary {
    border-color: var(--border-strong);
    background: var(--surface-raised);
    color: var(--text);
}

.btn-secondary:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover {
    background: var(--surface-raised);
    color: var(--text);
}

.btn-danger {
    background: var(--down);
    color: #fff;
}

.btn-sm {
    height: 34px;
    padding: 0 18px;
    border-radius: 5px;
    font-size: 13px;
}

.btn-lg {
    height: 50px;
    font-size: 16px;
}

.btn-block {
    width: 100%;
}

.btn:disabled,
.btn.is-disabled,
.btn[aria-disabled="true"] {
    box-shadow: none;
    cursor: not-allowed;
    opacity: 0.72;
}

.btn.is-loading {
    pointer-events: none;
    opacity: 0.8;
}

.btn.is-loading::after {
    content: "";
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.link-arrow {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
}

.link-arrow .icon {
    width: 14px;
    height: 14px;
}

.link-arrow.is-disabled {
    color: var(--text-subtle);
    cursor: default;
}

/* 7. Forms ------------------------------------------------------------------- */

.form {
    display: grid;
    gap: 18px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.form-group {
    display: grid;
    align-content: start;
    gap: 7px;
}

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

.form-label-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}

.form-control,
.form-select {
    width: 100%;
    height: 48px;
    padding: 0 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface-input);
    color: var(--text);
    font-size: 15px;
}

.form-control::placeholder {
    color: var(--text-subtle);
}

.form-control:hover,
.form-select:hover {
    border-color: var(--border-hover);
}

.form-control:focus,
.form-select:focus {
    outline: none;
    border-color: var(--primary-border);
    box-shadow: var(--ring);
}

.form-select {
    padding-right: 40px;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239092b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-position: right 14px center;
    background-repeat: no-repeat;
    background-size: 18px;
}

.form-select option {
    background: var(--surface-popover);
    color: var(--text);
}

.form-control.is-invalid,
.form-select.is-invalid {
    border-color: color-mix(in srgb, var(--down) 75%, transparent);
}

.form-control.is-invalid:focus,
.form-select.is-invalid:focus {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--down) 22%, transparent);
}

.input-icon {
    position: relative;
}

.input-icon > .icon {
    position: absolute;
    left: 14px;
    top: 50%;
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    transform: translateY(-50%);
    pointer-events: none;
}

.input-icon > .form-control {
    padding-left: 44px;
}

.input-icon.has-action > .form-control {
    padding-right: 48px;
}

.input-action {
    position: absolute;
    right: 6px;
    top: 50%;
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    transform: translateY(-50%);
}

.input-action:hover {
    color: var(--text);
}

.input-action .icon {
    width: 18px;
    height: 18px;
}

.input-action .icon-shown {
    display: none;
}

.input-action[aria-pressed="true"] .icon-hidden {
    display: none;
}

.input-action[aria-pressed="true"] .icon-shown {
    display: block;
}

.form-error {
    color: var(--danger-text);
    font-size: 12.5px;
}

.form-hint {
    color: var(--text-subtle);
    font-size: 12.5px;
}

.form-check {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    color: var(--text-secondary);
    font-size: 13.5px;
    line-height: 1.5;
}

.form-check input {
    display: grid;
    place-items: center;
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    margin: 1px 0 0;
    border: 1px solid var(--border-hover);
    border-radius: var(--radius-xs);
    background: var(--surface-input);
    appearance: none;
    cursor: pointer;
}

.form-check input::after {
    content: "";
    width: 10px;
    height: 10px;
    background: #fff;
    clip-path: polygon(14% 52%, 0 67%, 38% 100%, 100% 22%, 86% 8%, 38% 72%);
    opacity: 0;
}

.form-check input:checked {
    border-color: var(--primary);
    background: var(--primary);
}

.form-check input:checked::after {
    opacity: 1;
}

.form-check input:focus-visible {
    box-shadow: var(--ring);
}

.form-check input.is-invalid {
    border-color: color-mix(in srgb, var(--down) 75%, transparent);
}

.password-meter {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    margin-top: 2px;
}

.password-meter span {
    height: 4px;
    border-radius: 2px;
    background: var(--border-strong);
}

.password-meter[data-score="1"] span:nth-child(-n + 1) { background: var(--down); }
.password-meter[data-score="2"] span:nth-child(-n + 2) { background: var(--warning); }
.password-meter[data-score="3"] span:nth-child(-n + 3) { background: #a3d65c; }
.password-meter[data-score="4"] span { background: var(--up); }

/* 8. Cards & tiles ----------------------------------------------------------- */

.card {
    min-width: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
}

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

.card-title {
    font-size: 18px;
    font-weight: 600;
}

.card-body {
    padding: 20px;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--gutter);
}

.stat-card {
    display: grid;
    gap: 6px;
    padding: 18px 20px;
}

.stat-label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 14px;
}

.stat-label .icon {
    width: 18px;
    height: 18px;
    color: var(--primary-text);
}

.stat-value {
    font-size: 26px;
    font-weight: 600;
    letter-spacing: -0.01em;
    font-variant-numeric: tabular-nums;
}

.stat-meta {
    color: var(--text-muted);
    font-size: 12.5px;
}

.icon-badge {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--primary) 62%, var(--surface));
    color: #fff;
}

.icon-badge .icon {
    width: 18px;
    height: 18px;
}

.coin {
    display: inline-grid;
    place-items: center;
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--coin-color, #7b3ff2);
    box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.18), inset 0 2px 0 rgba(255, 255, 255, 0.18);
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    object-fit: cover;
}

.coin-sm {
    width: 28px;
    height: 28px;
    font-size: 12px;
}

.empty-state {
    display: grid;
    justify-items: center;
    gap: 6px;
    padding: 36px 20px;
    color: var(--text-muted);
    text-align: center;
}

.empty-state .icon {
    width: 32px;
    height: 32px;
    margin-bottom: 4px;
    color: var(--text-subtle);
}

/* 9. Tables & tabs ----------------------------------------------------------- */

.table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-variant-numeric: tabular-nums;
}

.table th {
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 500;
    text-align: left;
    white-space: nowrap;
}

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

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

.table tbody tr:hover td {
    background: color-mix(in srgb, var(--text) 2%, transparent);
}

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

.cell-stack {
    display: grid;
    gap: 1px;
}

.cell-sub {
    color: var(--text-muted);
    font-size: 12px;
}

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

.table-actions {
    display: flex;
    justify-content: flex-end;
    gap: 16px;
}

.table-actions .btn {
    min-width: 84px;
}

.table-actions .btn-secondary {
    min-width: 98px;
}

.pill-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.pill-tab {
    display: inline-flex;
    align-items: center;
    height: 28px;
    padding: 0 16px;
    border: 0;
    border-radius: var(--radius-sm);
    background: var(--surface-raised);
    color: var(--text-secondary);
    font-size: 12.5px;
    font-weight: 500;
}

.pill-tab:hover {
    color: var(--text);
}

.pill-tab.is-active {
    background: var(--primary);
    color: #fff;
}

.table-search {
    position: relative;
    width: 214px;
}

.table-search .icon {
    position: absolute;
    left: 12px;
    top: 50%;
    width: 16px;
    height: 16px;
    color: var(--text-secondary);
    transform: translateY(-50%);
    pointer-events: none;
}

.table-search input {
    width: 100%;
    height: 34px;
    padding: 0 12px 0 36px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface-input);
    font-size: 13px;
}

.table-search input::placeholder {
    color: var(--text-muted);
}

.table-search input:focus {
    outline: none;
    border-color: var(--primary-border);
    box-shadow: var(--ring);
}

/* 10. Feedback: badges, chips, alerts, tooltip ------------------------------- */

.badge {
    display: inline-flex;
    align-items: center;
    height: 22px;
    padding: 0 9px;
    border-radius: var(--radius-pill);
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.badge-success { background: var(--up-soft); color: var(--up); }
.badge-danger { background: var(--down-soft); color: var(--danger-text); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-neutral { background: var(--neutral-soft); color: var(--text-secondary); }
.badge-primary { background: var(--primary-soft); color: var(--accent-soft-text); }

.chip {
    display: inline-flex;
    align-items: center;
    padding: 2px 6px;
    border-radius: var(--radius-xs);
    background: var(--primary-soft);
    color: var(--accent-soft-text);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.05em;
    line-height: 1.4;
    text-transform: uppercase;
}

.chip-warning {
    background: var(--warning-soft);
    color: var(--warning);
}

.chip-success {
    background: var(--up-soft);
    color: var(--up);
}

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

.alert {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 12px 12px 14px;
    border: 1px solid;
    border-radius: var(--radius);
    font-size: 14px;
}

.alert-icon {
    margin-top: 1px;
}

.alert-body {
    flex: 1;
    min-width: 0;
    padding-top: 1px;
}

.alert-close {
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    padding: 0;
    border: 0;
    border-radius: var(--radius-xs);
    background: transparent;
    color: inherit;
    opacity: 0.7;
}

.alert-close:hover {
    opacity: 1;
}

.alert-close .icon {
    width: 16px;
    height: 16px;
}

.alert-success { border-color: color-mix(in srgb, var(--up) 35%, transparent); background: color-mix(in srgb, var(--up) 8%, transparent); color: var(--alert-success-text); }
.alert-error { border-color: color-mix(in srgb, var(--down) 40%, transparent); background: color-mix(in srgb, var(--down) 8%, transparent); color: var(--alert-error-text); }
.alert-warning { border-color: color-mix(in srgb, var(--warning) 40%, transparent); background: color-mix(in srgb, var(--warning) 8%, transparent); color: var(--alert-warning-text); }
.alert-info { border-color: color-mix(in srgb, var(--info) 35%, transparent); background: color-mix(in srgb, var(--info) 8%, transparent); color: var(--alert-info-text); }

.tooltip {
    position: fixed;
    z-index: 90;
    display: grid;
    gap: 2px;
    padding: 8px 10px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface-popover);
    box-shadow: var(--shadow-pop);
    pointer-events: none;
}

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

.tooltip-label {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    font-size: 12px;
}

.tooltip-key {
    width: 12px;
    height: 2px;
    border-radius: 1px;
    background: var(--tooltip-key, var(--series-1));
}

/* 11. Dashboard -------------------------------------------------------------- */

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 398px;
    gap: var(--gutter);
    align-items: start;
}

.dashboard-main,
.dashboard-side {
    display: grid;
    gap: var(--gutter);
    min-width: 0;
}

.balance-card {
    position: relative;
    display: flex;
    min-height: 218px;
    overflow: hidden;
    background:
        radial-gradient(60% 120% at 82% 50%, color-mix(in srgb, var(--primary) 34%, transparent) 0%, color-mix(in srgb, var(--primary) 8%, transparent) 45%, transparent 70%),
        linear-gradient(90deg, var(--surface) 0%, color-mix(in srgb, var(--primary) 9%, var(--surface)) 100%);
}

.balance-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    padding: 24px 26px 24px;
}

.balance-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 17px;
    font-weight: 500;
}

.balance-toggle {
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    padding: 0;
    border: 0;
    border-radius: var(--radius-xs);
    background: transparent;
    color: var(--primary-text);
}

.balance-toggle .icon {
    width: 18px;
    height: 18px;
}

.balance-toggle .icon-shown {
    display: none;
}

.balance-card.is-masked .balance-toggle .icon-hidden {
    display: none;
}

.balance-card.is-masked .balance-toggle .icon-shown {
    display: block;
}

.balance-value {
    margin-top: 12px;
    font-size: 36px;
    font-weight: 700;
    letter-spacing: -0.015em;
    line-height: 1.15;
    font-variant-numeric: tabular-nums;
}

.balance-change {
    margin-top: 8px;
    font-size: 17px;
    font-variant-numeric: tabular-nums;
}

.balance-card.is-masked [data-maskable] {
    filter: blur(9px);
    user-select: none;
}

.balance-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-top: auto;
    padding-top: 22px;
}

.balance-actions .btn-primary {
    min-width: 110px;
}

.balance-actions .btn-secondary {
    min-width: 107px;
    border-color: var(--border-strong);
    background: color-mix(in srgb, var(--surface-raised) 85%, transparent);
}

.balance-art {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 44%;
    max-width: 380px;
    pointer-events: none;
}

.balance-art img,
.balance-art svg {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: right center;
}

.quick-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    padding: 18px;
}

.quick-actions-title {
    grid-column: 1 / -1;
    margin: 6px 0 4px;
    font-size: 18px;
}

.action-tile {
    display: grid;
    align-content: start;
    gap: 2px;
    min-height: 107px;
    padding: 15px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-raised);
    color: var(--text);
}

a.action-tile:hover {
    border-color: var(--primary-border);
    background: var(--surface-hover);
    color: var(--text);
}

.action-tile .icon-badge {
    margin-bottom: 10px;
}

.action-tile-title {
    font-size: 15px;
    font-weight: 500;
}

.action-tile-text {
    color: var(--text-muted);
    font-size: 11.5px;
}

.action-tile.is-disabled {
    cursor: default;
    opacity: 0.78;
}

.assets-card .card-header {
    padding: 22px 20px 0;
}

.assets-toolbar {
    padding: 14px 20px 14px;
}

.assets-card .table th:first-child,
.assets-card .table td:first-child {
    padding-left: 20px;
}

.activity-list {
    display: grid;
    margin: 0;
    padding: 6px 20px 12px;
    list-style: none;
}

.activity-item {
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr) auto;
    align-items: center;
    gap: 16px;
    padding: 12px 0;
}

.activity-item + .activity-item {
    border-top: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
}

.activity-icon {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    color: #fff;
}

.activity-icon .icon {
    width: 16px;
    height: 16px;
}

.activity-icon-credit { background: #1faa63; }
.activity-icon-debit { background: #e8761f; }
.activity-icon-neutral { background: var(--primary); }

.activity-title {
    font-size: 13.5px;
    font-weight: 500;
}

.activity-time {
    color: var(--text-muted);
    font-size: 12px;
}

.activity-amount {
    display: grid;
    justify-items: end;
    gap: 2px;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

/* 12. Charts ----------------------------------------------------------------- */

.overview-body {
    display: grid;
    grid-template-columns: 150px minmax(0, 1fr);
    align-items: center;
    gap: 30px;
    padding: 14px 20px 22px;
}

.donut {
    position: relative;
    width: 150px;
    height: 150px;
}

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

.donut-segment {
    outline: none;
}

.donut-track {
    fill: none;
    stroke: var(--chart-track);
    stroke-width: 14;
}

.donut-arc {
    fill: none;
    stroke-width: 14;
}

.donut-arc.series-1 { stroke: var(--series-1); }
.donut-arc.series-2 { stroke: var(--series-2); }
.donut-arc.series-3 { stroke: var(--series-3); }
.donut-arc.series-other { stroke: var(--series-other); }
.legend-swatch.series-1 { background: var(--series-1); }
.legend-swatch.series-2 { background: var(--series-2); }
.legend-swatch.series-3 { background: var(--series-3); }
.legend-swatch.series-other { background: var(--series-other); }

.donut-hit {
    fill: none;
    stroke: transparent;
    stroke-width: 30;
}

.donut-segment:hover .donut-arc,
.donut-segment:focus-visible .donut-arc {
    filter: brightness(1.2);
}

.donut-segment:focus-visible .donut-arc {
    stroke-width: 17;
}

.donut-center {
    position: absolute;
    inset: 0;
    display: grid;
    place-content: center;
    gap: 2px;
    text-align: center;
    pointer-events: none;
}

.donut-total {
    font-size: 16px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.donut-caption {
    color: var(--text-muted);
    font-size: 11.5px;
}

.legend {
    display: grid;
    gap: 14px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.legend-item {
    display: grid;
    grid-template-columns: 10px minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    color: var(--text-secondary);
    font-size: 13px;
}

.legend-swatch {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--swatch, var(--series-other));
}

.legend-value {
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

/* 13. Auth pages ------------------------------------------------------------- */

.layout-auth {
    background:
        radial-gradient(50% 60% at 15% 20%, color-mix(in srgb, var(--primary) 12%, transparent) 0%, transparent 70%),
        var(--bg);
}

.auth {
    display: grid;
    grid-template-columns: minmax(420px, 44%) minmax(0, 1fr);
    min-height: 100vh;
}

.auth-aside {
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 36px 48px 40px;
    overflow: hidden;
    border-right: 1px solid var(--border);
    background:
        radial-gradient(70% 55% at 80% 75%, color-mix(in srgb, var(--primary) 32%, transparent) 0%, transparent 70%),
        linear-gradient(160deg, color-mix(in srgb, var(--primary) 12%, var(--bg-bar)) 0%, var(--bg-bar) 55%, var(--bg) 100%);
}

.auth-brand {
    display: inline-flex;
    align-self: flex-start;
}

.auth-hero {
    position: relative;
    z-index: 1;
    max-width: 440px;
    margin-top: clamp(40px, 12vh, 120px);
}

.eyebrow {
    margin-bottom: 12px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.auth-hero-title {
    font-size: clamp(32px, 3.2vw, 44px);
    font-weight: 700;
    letter-spacing: -0.025em;
    line-height: 1.12;
}

.text-gradient {
    color: var(--primary-text);
    background: linear-gradient(90deg, color-mix(in srgb, var(--primary-text) 80%, var(--text)) 0%, var(--primary-line) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.auth-hero-text {
    margin-top: 16px;
    color: var(--text-secondary);
    font-size: 15.5px;
    line-height: 1.6;
}

.auth-features {
    display: grid;
    gap: 14px;
    margin: 30px 0 0;
    padding: 0;
    list-style: none;
}

.auth-features li {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-secondary);
    font-size: 14.5px;
}

.auth-features .icon {
    width: 34px;
    height: 34px;
    padding: 8px;
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--primary-text);
}

.auth-illustration {
    width: 100%;
    max-width: 480px;
    margin-top: auto;
    align-self: flex-end;
}

.auth-main {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px 32px;
}

.auth-mobile-brand {
    display: none;
    margin-bottom: 28px;
}

.auth-card {
    width: 100%;
    max-width: 440px;
}

.auth-card-wide {
    max-width: 600px;
}

.layout-auth .auth-card:has(.register-form) {
    max-width: 600px;
}

.auth-title {
    font-size: 30px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.auth-subtitle {
    margin: 8px 0 28px;
    color: var(--text-muted);
    font-size: 15px;
}

.auth-switch {
    margin-top: 24px;
    color: var(--text-muted);
    text-align: center;
}

.auth-switch a {
    font-weight: 600;
}

.auth-legal {
    max-width: 520px;
    margin-top: 36px;
    color: var(--text-subtle);
    font-size: 12px;
    text-align: center;
}

.auth-notice {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    padding: 12px 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface-raised);
    color: var(--text-secondary);
    font-size: 13px;
}

.auth-notice .icon {
    width: 18px;
    height: 18px;
    margin-top: 1px;
    color: var(--primary-text);
}

/* 14. Error page ------------------------------------------------------------- */

.error-page {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 32px 16px;
    background: radial-gradient(50% 50% at 50% 30%, color-mix(in srgb, var(--primary) 16%, transparent) 0%, transparent 70%), var(--bg);
}

.error-card {
    width: 100%;
    max-width: 560px;
    padding: 36px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    text-align: center;
}

.error-card .brand {
    justify-content: center;
}

.error-code {
    margin-top: 28px;
    color: var(--primary-text);
    font-size: 56px;
    font-weight: 700;
    line-height: 1;
}

.error-title {
    margin-top: 12px;
    font-size: 24px;
}

.error-message {
    margin-top: 10px;
    color: var(--text-secondary);
}

.error-actions {
    margin-top: 26px;
}

.error-debug {
    margin-top: 28px;
    padding: 16px;
    border: 1px solid rgba(246, 70, 93, 0.35);
    border-radius: var(--radius);
    background: rgba(246, 70, 93, 0.06);
    text-align: left;
}

.error-debug summary {
    color: #ffa3af;
    cursor: pointer;
    font-weight: 600;
}

.error-debug pre {
    max-height: 320px;
    overflow: auto;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 12px;
    white-space: pre-wrap;
}

/* 15. Utilities & motion ---------------------------------------------------- */

.text-up { color: var(--up); }
.text-down { color: var(--down); }
.text-warning { color: var(--warning); }
.text-info { color: var(--info); }
.text-muted { color: var(--text-muted); }
.text-subtle { color: var(--text-subtle); }
.text-secondary { color: var(--text-secondary); }
.text-primary { color: var(--primary-text); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.text-end { text-align: right; }
.fw-semibold { font-weight: 600; }
.tabular { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); }
.mt-0 { margin-top: 0; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.d-flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }

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

/* Transitions are opt-in for people who have not asked for reduced motion.
   Only the transition is guarded; resting states are identical for everyone. */
@media (prefers-reduced-motion: no-preference) {
    .btn,
    .icon-btn,
    .sidebar-link,
    .topnav-link,
    .dropdown-item,
    .pill-tab,
    .action-tile,
    .form-control,
    .form-select,
    .donut-arc,
    .balance-card [data-maskable] {
        transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease,
            box-shadow 0.15s ease, filter 0.15s ease, opacity 0.15s ease;
    }

    .sidebar {
        transition: transform 0.22s ease;
    }
}

@media (prefers-reduced-motion: reduce) {
    .btn.is-loading::after {
        animation-duration: 2s;
    }
}

/* Responsive ----------------------------------------------------------------- */

@media (max-width: 1360px) {
    .dashboard-grid {
        grid-template-columns: minmax(0, 1fr) 360px;
    }

    .topnav-link {
        padding: 0 16px;
    }

    .topnav-link.is-active::after {
        left: 8px;
        right: 8px;
    }

    .topbar-search {
        width: 240px;
    }
}

@media (max-width: 1180px) {
    .topbar-left {
        width: auto;
        margin-right: 20px;
    }

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

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

    .dashboard-side > .activity-card {
        grid-column: 1 / -1;
    }

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

@media (max-width: 991.98px) {
    :root {
        --gutter: 16px;
    }

    .topbar {
        padding: 0 16px 0 10px;
    }

    .topnav {
        display: none;
    }

    .sidebar-toggle {
        display: inline-grid;
    }

    .app-shell {
        grid-template-columns: minmax(0, 1fr);
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 60;
        width: min(290px, 86vw);
        height: 100vh;
        padding-top: 14px;
        transform: translateX(-102%);
        box-shadow: var(--shadow-pop);
    }

    .sidebar-mobile-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin: 0 4px 18px 10px;
    }

    .sidebar-mobile-header .brand-logo {
        height: 32px;
    }

    body.sidebar-open .sidebar {
        transform: none;
    }

    body.sidebar-open .sidebar-backdrop {
        position: fixed;
        inset: 0;
        z-index: 55;
        display: block;
        background: rgba(4, 4, 18, 0.66);
    }

    body.sidebar-open {
        overflow: hidden;
    }

    .promo-card {
        margin-top: 28px;
    }

    .app-main {
        padding: 18px var(--gutter) 24px;
    }

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

    .auth-aside {
        display: none;
    }

    .auth-mobile-brand {
        display: block;
    }
}

@media (max-width: 760px) {
    .topbar-search {
        display: none;
    }

    .topbar-right {
        gap: 8px;
    }

    .topbar-brand .brand-logo {
        height: 32px;
    }

    .user-menu-caret {
        display: none;
    }

    .dropdown-menu-wide {
        position: fixed;
        top: calc(var(--topbar-h) + 6px);
        left: 12px;
        right: 12px;
        width: auto;
    }

    .dashboard-side {
        grid-template-columns: minmax(0, 1fr);
    }

    .balance-art {
        opacity: 0.35;
        width: 60%;
    }

    .balance-value {
        font-size: 30px;
    }

    .balance-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .balance-actions .btn {
        min-width: 0;
    }

    .assets-card .card-header {
        flex-wrap: wrap;
    }

    .table-search {
        width: 100%;
    }

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

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

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 420px) {
    .overview-body {
        grid-template-columns: minmax(0, 1fr);
        justify-items: center;
    }

    .legend {
        width: 100%;
    }

    .quick-actions {
        grid-template-columns: minmax(0, 1fr);
    }

    .auth-title {
        font-size: 26px;
    }
}

/* 16. Account, settings & security ----------------------------------------- */

.icon-flip {
    transform: rotate(180deg);
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 8px;
    color: var(--text-muted);
    font-size: 13px;
}

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

.link-button {
    padding: 0;
    border: 0;
    background: none;
    color: var(--primary-text);
    font-size: inherit;
}

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

.mt-section {
    margin-top: var(--gutter);
}

.card-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
}

.card-muted {
    background: color-mix(in srgb, var(--surface) 70%, var(--bg));
}

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

.fieldset {
    display: grid;
    gap: 10px;
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

/* Underline tabs (Market comp style) */
.page-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: var(--gutter);
    overflow-x: auto;
    border-bottom: 1px solid var(--border);
    scrollbar-width: none;
}

.page-tab {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px 14px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
}

.page-tab .icon {
    width: 18px;
    height: 18px;
}

.page-tab:hover {
    color: var(--text);
}

.page-tab.is-active {
    color: var(--text);
    font-weight: 600;
}

.page-tab.is-active::after {
    content: "";
    position: absolute;
    left: 10px;
    right: 10px;
    bottom: -1px;
    height: 3px;
    border-radius: 3px 3px 0 0;
    background: var(--primary-line);
}

.settings-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: var(--gutter);
    align-items: start;
}

.settings-main {
    display: grid;
    gap: var(--gutter);
    min-width: 0;
}

.settings-aside {
    position: sticky;
    top: calc(var(--topbar-h) + 20px);
}

.settings-narrow {
    max-width: 820px;
}

.inline-notice {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 12px;
    margin-bottom: 18px;
    padding: 12px 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface-raised);
    color: var(--text-secondary);
    font-size: 13px;
}

.inline-notice > .icon {
    width: 18px;
    height: 18px;
    color: var(--primary-text);
}

.inline-notice > span {
    flex: 1;
    min-width: 200px;
}

.inline-notice-warning {
    border-color: color-mix(in srgb, var(--warning) 40%, transparent);
    background: color-mix(in srgb, var(--warning) 8%, transparent);
}

.inline-notice-warning > .icon {
    color: var(--warning);
}

.inline-notice form {
    margin-left: auto;
}

.readonly-field {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 48px;
    padding: 0 6px 0 14px;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 15px;
}

.copy-button {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
}

.copy-button:hover {
    background: var(--surface-raised);
    color: var(--text);
}

.copy-button .icon {
    width: 18px;
    height: 18px;
}

.copy-button.is-copied,
[data-copy].is-copied {
    color: var(--up);
}

/* Avatar sizes & editor */
img.avatar {
    display: block;
    object-fit: cover;
}

.avatar-lg {
    width: 72px;
    height: 72px;
    font-size: 24px;
}

.avatar-xl {
    width: 88px;
    height: 88px;
    font-size: 28px;
}

.avatar-editor {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 20px 24px;
}

.avatar-editor-body {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 240px;
}

.avatar-editor-body .form-hint,
.avatar-editor-body .form-error {
    flex-basis: 100%;
    margin: 0;
}

.file-button {
    position: relative;
    cursor: pointer;
}

.file-button:focus-within {
    box-shadow: var(--ring);
}

/* Setting rows */
.setting-row {
    display: flex;
    align-items: center;
    gap: 14px;
}

.setting-row + .setting-row,
.setting-row + .disclosure {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.setting-row-icon {
    display: grid;
    place-items: center;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--primary-text);
}

.setting-row-icon .icon {
    width: 20px;
    height: 20px;
}

.setting-row-body {
    display: grid;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.setting-row-title {
    color: var(--text);
    font-size: 14.5px;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.setting-row-text {
    margin: 0;
    color: var(--text-muted);
    font-size: 13px;
}

/* Profile summary */
.profile-summary {
    display: grid;
    justify-items: center;
    padding: 26px 20px 12px;
    text-align: center;
}

.profile-summary-name {
    margin-top: 14px;
    font-size: 18px;
}

.profile-summary-handle {
    color: var(--text-muted);
    font-size: 13px;
}

.detail-list {
    display: grid;
    width: 100%;
    margin: 18px 0 0;
    text-align: left;
}

.detail-list > div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 11px 0;
    border-top: 1px solid var(--border);
    font-size: 13px;
}

.detail-list dt {
    color: var(--text-muted);
}

.detail-list dd {
    margin: 0;
    color: var(--text);
    text-align: right;
}

.detail-list-compact > div {
    padding: 8px 0;
}

/* Appearance picker */
.theme-options {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.theme-option {
    position: relative;
    display: grid;
    gap: 10px;
    padding: 10px 10px 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface-raised);
    cursor: pointer;
}

.theme-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.theme-option:has(input:checked) {
    border-color: var(--primary);
    box-shadow: var(--ring);
}

.theme-option:has(input:focus-visible) {
    outline: 2px solid var(--primary-text);
    outline-offset: 2px;
}

.theme-option-label {
    color: var(--text);
    font-size: 13.5px;
    font-weight: 500;
    text-align: center;
}

.theme-swatch {
    display: grid;
    grid-template-columns: 26% 1fr;
    grid-template-rows: 20% 1fr;
    height: 76px;
    overflow: hidden;
    border-radius: var(--radius-sm);
}

.theme-swatch span:nth-child(1) { grid-column: 1 / -1; }
.theme-swatch span:nth-child(3) { margin: 8px; border-radius: 4px; }

.theme-swatch-dark { background: #090a21; }
.theme-swatch-dark span:nth-child(1) { background: #0a0b25; border-bottom: 1px solid #1c1d47; }
.theme-swatch-dark span:nth-child(2) { background: #0a0b25; border-right: 1px solid #1c1d47; }
.theme-swatch-dark span:nth-child(3) { background: #0f1031; border: 1px solid #1c1d47; }

.theme-swatch-light { background: #f4f5fb; }
.theme-swatch-light span:nth-child(1) { background: #ffffff; border-bottom: 1px solid #e3e4f0; }
.theme-swatch-light span:nth-child(2) { background: #ffffff; border-right: 1px solid #e3e4f0; }
.theme-swatch-light span:nth-child(3) { background: #ffffff; border: 1px solid #e3e4f0; }

.theme-swatch-system { background: linear-gradient(90deg, #f4f5fb 0 50%, #090a21 50% 100%); }
.theme-swatch-system span:nth-child(1) { background: linear-gradient(90deg, #ffffff 0 50%, #0a0b25 50% 100%); border-bottom: 1px solid #3a3c63; }
.theme-swatch-system span:nth-child(2) { background: #ffffff; border-right: 1px solid #e3e4f0; }
.theme-swatch-system span:nth-child(3) { background: linear-gradient(90deg, #ffffff 0 50%, #0f1031 50% 100%); border: 1px solid #6e7099; }

/* Toggle switch */
.toggle-list {
    display: grid;
    margin: 0 0 18px;
    padding: 0;
    list-style: none;
}

.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 16px 0;
}

.toggle-row + .toggle-row {
    border-top: 1px solid var(--border);
}

.switch {
    position: relative;
    flex-shrink: 0;
    width: 44px;
    height: 24px;
}

.switch input {
    position: absolute;
    inset: 0;
    z-index: 1;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: pointer;
}

.switch-track {
    position: absolute;
    inset: 0;
    border-radius: var(--radius-pill);
    background: var(--border-strong);
}

.switch-track::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.switch input:checked + .switch-track {
    background: var(--primary);
}

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

.switch input:focus-visible + .switch-track {
    box-shadow: var(--ring);
}

/* Security overview */
.security-overview {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 20px 40px;
    margin-bottom: var(--gutter);
    padding: 20px;
}

.security-level {
    display: flex;
    align-items: center;
    gap: 16px;
}

.security-meter {
    display: flex;
    gap: 5px;
}

.security-meter span {
    width: 12px;
    height: 36px;
    border-radius: 3px;
    background: var(--border-strong);
}

.security-meter[data-level="1"] span:nth-child(-n + 1) { background: var(--down); }
.security-meter[data-level="2"] span:nth-child(-n + 2) { background: var(--warning); }
.security-meter[data-level="3"] span { background: var(--up); }

.security-checks {
    display: flex;
    flex-wrap: wrap;
    gap: 16px 32px;
    margin: 0 0 0 auto;
    padding: 0;
    list-style: none;
}

.security-check {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13.5px;
}

.security-check-icon {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
}

.security-check-icon .icon {
    width: 15px;
    height: 15px;
}

.security-check-icon.is-ok {
    background: var(--up-soft);
    color: var(--up);
}

.security-check-icon.is-missing {
    background: var(--warning-soft);
    color: var(--warning);
}

.security-alert {
    align-items: center;
    margin-bottom: var(--gutter);
}

.security-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--gutter);
    align-items: start;
}

.session-icon {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--surface-raised);
    color: var(--text-secondary);
}

.session-icon .icon {
    width: 18px;
    height: 18px;
}

/* Disclosure (details/summary) */
.disclosure {
    margin-top: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-raised);
}

.disclosure > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    color: var(--text);
    font-size: 13.5px;
    font-weight: 500;
    list-style: none;
    cursor: pointer;
}

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

.disclosure > summary::after {
    content: "";
    width: 8px;
    height: 8px;
    border-right: 2px solid var(--text-muted);
    border-bottom: 2px solid var(--text-muted);
    transform: rotate(45deg);
}

.disclosure[open] > summary::after {
    transform: rotate(-135deg);
}

.disclosure-body {
    padding: 0 14px 14px;
}

.disclosure-danger > summary {
    color: var(--danger-text);
}

.btn-danger:hover {
    background: color-mix(in srgb, var(--down) 88%, #000);
    color: #fff;
}

/* Pagination */
.pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.pagination-summary {
    color: var(--text-muted);
    font-size: 13px;
}

.pagination-list {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.page-link {
    display: inline-grid;
    place-items: center;
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface-raised);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
}

.page-link .icon {
    width: 15px;
    height: 15px;
}

a.page-link:hover {
    border-color: var(--primary-border);
    color: var(--text);
}

.page-link.is-active {
    border-color: var(--primary);
    background: var(--primary);
    color: #fff;
}

.page-link.is-disabled {
    opacity: 0.45;
}

.page-gap {
    color: var(--text-muted);
}

/* Notifications (dropdown & page) */
button.notification-link {
    width: 100%;
    border: 0;
    background: transparent;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

button.notification-link:hover {
    background: var(--surface-hover);
}

.dropdown-footer {
    padding: 8px 12px 6px;
    border-top: 1px solid var(--border);
}

.notification-feed {
    margin: 12px 0 0;
    padding: 0;
    list-style: none;
}

.notification-feed-item {
    position: relative;
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr) auto;
    align-items: start;
    gap: 14px;
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}

.notification-feed-item.is-unread {
    background: color-mix(in srgb, var(--primary) 5%, transparent);
}

.notification-feed-item.is-unread::before {
    content: "";
    position: absolute;
    left: 0;
    top: 16px;
    bottom: 16px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--primary-line);
}

.notification-feed-icon {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.notification-feed-icon .icon {
    width: 18px;
    height: 18px;
}

.notification-tone-up { background: var(--up-soft); color: var(--up); }
.notification-tone-down { background: var(--down-soft); color: var(--down); }
.notification-tone-warning { background: var(--warning-soft); color: var(--warning); }
.notification-tone-primary { background: var(--primary-soft); color: var(--primary-text); }

.notification-feed-title {
    color: var(--text);
    font-size: 14.5px;
    font-weight: 600;
}

.notification-feed-text {
    margin-top: 2px;
    color: var(--text-secondary);
    font-size: 13.5px;
}

.notification-feed-time {
    display: block;
    margin-top: 6px;
    color: var(--text-subtle);
    font-size: 12px;
}

/* Two-factor setup */
.setup-card {
    max-width: 880px;
    padding: 8px 24px;
}

.setup-steps {
    margin: 0;
    padding: 0;
    list-style: none;
}

.setup-step {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr);
    gap: 16px;
    padding: 22px 0;
}

.setup-step + .setup-step {
    border-top: 1px solid var(--border);
}

.setup-step-number {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--primary-text);
    font-weight: 700;
}

.setup-step-title {
    margin: 4px 0 6px;
    font-size: 16px;
}

.qr-block {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 24px;
    margin-top: 16px;
}

.qr-tile {
    flex-shrink: 0;
    width: 200px;
    height: 200px;
    padding: 8px;
    border-radius: var(--radius-lg);
    background: #ffffff;
    box-shadow: 0 0 0 1px var(--border);
}

.qr-tile svg {
    width: 100%;
    height: 100%;
}

.qr-manual {
    display: grid;
    gap: 8px;
    flex: 1;
    min-width: 240px;
}

.secret-field .mono {
    font-size: 15px;
    letter-spacing: 0.04em;
    word-break: break-all;
}

.otp-form {
    max-width: 360px;
    margin-top: 12px;
}

.otp-input {
    font-family: var(--font-mono);
    font-size: 22px;
    letter-spacing: 0.3em;
    text-align: center;
}

/* Recovery codes */
.recovery-card {
    max-width: 640px;
    margin: 20px auto 0;
    text-align: center;
}

.recovery-card .card-body {
    padding: 32px;
}

.recovery-icon,
.auth-icon {
    display: inline-grid;
    place-items: center;
    width: 52px;
    height: 52px;
    margin-bottom: 16px;
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--primary-text);
}

.recovery-icon .icon,
.auth-icon .icon {
    width: 24px;
    height: 24px;
}

.recovery-intro {
    max-width: 480px;
    margin: 8px auto 24px;
}

.recovery-codes {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin: 0 0 24px;
    padding: 18px;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface-raised);
    list-style: none;
}

.recovery-codes li {
    padding: 6px;
    color: var(--text);
    font-size: 17px;
    letter-spacing: 0.06em;
}

.recovery-actions {
    justify-content: center;
}

@media (max-width: 1180px) {
    .settings-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .settings-aside {
        position: static;
        order: -1;
    }

    .security-checks {
        margin-left: 0;
    }
}

@media (max-width: 991.98px) {
    .security-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 760px) {
    .theme-options {
        grid-template-columns: minmax(0, 1fr);
    }

    .notification-feed-item {
        grid-template-columns: 40px minmax(0, 1fr);
    }

    .notification-feed-actions {
        grid-column: 2;
    }

    .recovery-codes {
        grid-template-columns: minmax(0, 1fr);
    }

    .setup-card {
        padding: 4px 16px;
    }

    .qr-tile {
        width: 180px;
        height: 180px;
    }
}

@media print {
    .topbar,
    .sidebar,
    .app-footer,
    .recovery-actions,
    .flash-stack {
        display: none !important;
    }

    .app-shell {
        display: block;
    }

    .recovery-card {
        border: 0;
        color: #000;
    }
}

@media (prefers-reduced-motion: no-preference) {
    .switch-track,
    .switch-track::after,
    .theme-option,
    .page-link,
    .disclosure > summary::after {
        transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
    }
}

.dashboard-notice {
    align-items: center;
    margin-bottom: var(--gutter);
}

/* 17. Deposit ------------------------------------------------------------------- */

.coin-xs {
    width: 18px;
    height: 18px;
    font-size: 9px;
    box-shadow: none;
}

.icon-inline {
    display: inline-block;
    width: 13px;
    height: 13px;
    vertical-align: -2px;
}

.deposit-demo-notice {
    margin-bottom: var(--gutter);
}

.deposit-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 380px;
    gap: var(--gutter);
    align-items: start;
}

.deposit-card {
    padding: 4px 24px;
}

.deposit-steps {
    margin: 0;
    padding: 0;
    list-style: none;
}

.deposit-step {
    position: relative;
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr);
    gap: 18px;
    padding: 22px 0;
}

.deposit-step:not(:last-child)::before {
    content: "";
    position: absolute;
    left: 15px;
    top: 62px;
    bottom: -14px;
    width: 2px;
    border-radius: 1px;
    background: var(--border-strong);
}

.deposit-step.is-complete:not(:last-child)::before {
    background: color-mix(in srgb, var(--primary) 60%, var(--border-strong));
}

.deposit-step-marker {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border: 1px solid var(--border-strong);
    border-radius: 50%;
    background: var(--surface-raised);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 700;
}

.deposit-step.is-complete .deposit-step-marker {
    border-color: var(--primary);
    background: var(--primary);
    color: #fff;
}

.deposit-step-body {
    min-width: 0;
}

.deposit-step-title {
    margin: 5px 0 14px;
    font-size: 16px;
}

/* Coin picker */
.coin-picker {
    position: relative;
    max-width: 520px;
}

.coin-picker-trigger {
    display: flex;
    align-items: center;
    gap: 12px;
    height: 60px;
    padding: 0 16px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface-input);
    list-style: none;
    cursor: pointer;
}

.coin-picker-trigger::-webkit-details-marker {
    display: none;
}

.coin-picker-trigger:hover {
    border-color: var(--border-hover);
}

.coin-picker[open] .coin-picker-trigger {
    border-color: var(--primary-border);
    box-shadow: var(--ring);
}

.coin-picker-value {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.coin-picker-symbol {
    color: var(--text);
    font-size: 17px;
    font-weight: 600;
}

.coin-picker-name {
    overflow: hidden;
    color: var(--text-muted);
    font-size: 14px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.coin-picker-caret {
    color: var(--text-muted);
}

.coin-picker[open] .coin-picker-caret {
    transform: rotate(180deg);
}

.coin-picker-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    z-index: 30;
    padding: 8px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    background: var(--surface-popover);
    box-shadow: var(--shadow-pop);
}

.coin-picker-search {
    position: relative;
    display: block;
    margin-bottom: 6px;
}

.coin-picker-search .icon {
    position: absolute;
    left: 12px;
    top: 50%;
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    transform: translateY(-50%);
}

.coin-picker-search input {
    width: 100%;
    height: 40px;
    padding: 0 12px 0 36px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface-input);
    font-size: 14px;
}

.coin-picker-search input:focus {
    outline: none;
    border-color: var(--primary-border);
}

.coin-picker-list {
    max-height: 300px;
    margin: 0;
    padding: 0;
    overflow-y: auto;
    list-style: none;
}

.coin-picker-option {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    padding: 9px 10px;
    border-radius: var(--radius);
    color: var(--text);
}

.coin-picker-option:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.coin-picker-option.is-selected {
    background: var(--primary-soft);
}

.coin-picker-balance {
    color: var(--text-secondary);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

.coin-picker-empty {
    padding: 14px 10px;
    color: var(--text-muted);
    font-size: 13px;
}

.coin-shortcuts {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.coin-shortcut {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 32px;
    padding: 0 12px 0 8px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-pill);
    background: var(--surface-raised);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
}

.coin-shortcut:hover {
    border-color: var(--border-hover);
    color: var(--text);
}

.coin-shortcut.is-active {
    border-color: var(--primary);
    background: var(--primary-soft);
    color: var(--text);
}

/* Network options */
.network-options {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
}

.network-option {
    display: grid;
    gap: 8px;
    padding: 14px 16px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface-raised);
    color: var(--text);
}

.network-option:hover {
    border-color: var(--border-hover);
    color: var(--text);
}

.network-option.is-selected {
    border-color: var(--primary);
    background: var(--primary-soft);
    box-shadow: var(--ring);
}

.network-option.is-suspended {
    opacity: 0.62;
}

.network-option-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.network-option-name {
    font-size: 14.5px;
    font-weight: 600;
}

.network-option-check {
    display: grid;
    place-items: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
}

.network-option-check .icon {
    width: 12px;
    height: 12px;
    stroke-width: 3;
}

.network-option-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 2px 0;
    color: var(--text-muted);
    font-size: 12.5px;
}

.network-option-meta span:not(:last-child)::after {
    content: "·";
    margin: 0 7px;
    color: var(--text-subtle);
}

.deposit-hint {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-top: 12px;
    color: var(--text-muted);
    font-size: 13px;
}

.deposit-hint .icon {
    width: 16px;
    height: 16px;
    margin-top: 2px;
    color: var(--primary-text);
}

/* Address */
.address-panel {
    display: grid;
    grid-template-columns: 190px minmax(0, 1fr);
    gap: 24px;
    padding: 20px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    background: color-mix(in srgb, var(--surface-raised) 70%, var(--surface));
}

.address-qr {
    display: grid;
    align-content: start;
    justify-items: center;
    gap: 10px;
}

.address-qr .qr-tile {
    width: 190px;
    height: 190px;
}

.address-details {
    display: grid;
    align-content: start;
    gap: 16px;
    min-width: 0;
}

.address-field {
    display: grid;
    gap: 8px;
}

.address-field .form-label {
    display: flex;
    align-items: center;
    gap: 8px;
}

.address-value {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 10px 10px 16px;
    border: 1px dashed var(--border-hover);
    border-radius: var(--radius);
    background: var(--surface);
}

.address-value .mono {
    flex: 1;
    min-width: 0;
    color: var(--text);
    font-size: 15px;
    line-height: 1.45;
    word-break: break-all;
}

.address-value .btn {
    flex-shrink: 0;
}

.address-field-memo .address-value {
    border-color: color-mix(in srgb, var(--warning) 55%, transparent);
}

.address-field-memo .form-hint strong {
    color: var(--text);
}

.address-facts {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 20px;
    margin: 0;
}

.address-facts > div {
    display: grid;
    gap: 2px;
    padding: 10px 0;
    border-top: 1px solid var(--border);
}

.address-facts dt {
    color: var(--text-muted);
    font-size: 12.5px;
}

.address-facts dd {
    margin: 0;
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
}

.deposit-warning {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-top: 16px;
    padding: 12px 14px;
    border: 1px solid color-mix(in srgb, var(--warning) 35%, transparent);
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--warning) 8%, transparent);
    color: var(--alert-warning-text);
    font-size: 13.5px;
}

.deposit-warning .icon {
    width: 18px;
    height: 18px;
    margin-top: 1px;
    color: var(--warning);
}

.deposit-unavailable {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface-raised);
    color: var(--text-secondary);
}

.deposit-unavailable .icon {
    color: var(--text-muted);
}

/* Side column */
.deposit-side {
    display: grid;
    gap: var(--gutter);
    min-width: 0;
}

.deposit-balance-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.deposit-balance-total {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.01em;
    font-variant-numeric: tabular-nums;
}

.deposit-balance-total span {
    color: var(--text-muted);
    font-size: 16px;
    font-weight: 500;
}

.deposit-tips {
    display: grid;
    gap: 12px;
    margin: 0;
    padding: 14px 20px 20px;
    list-style: none;
}

.deposit-tips li {
    display: grid;
    grid-template-columns: 24px minmax(0, 1fr);
    gap: 12px;
    color: var(--text-secondary);
    font-size: 13.5px;
}

.deposit-tips li > .deposit-tip-number {
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--primary-text);
    font-size: 12px;
    font-weight: 700;
}

.deposit-tips li > .deposit-tip-text {
    min-width: 0;
}

/* History */
.deposit-history-header {
    flex-wrap: wrap;
}

.confirmations {
    display: flex;
    align-items: center;
    gap: 8px;
}

.confirmations-bar {
    position: relative;
    width: 64px;
    height: 6px;
    overflow: hidden;
    border-radius: var(--radius-pill);
    background: var(--border-strong);
}

.confirmations-bar > span {
    position: absolute;
    inset: 0 auto 0 0;
    border-radius: inherit;
    background: var(--up);
}

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

@media (max-width: 1180px) {
    .deposit-layout {
        grid-template-columns: minmax(0, 1fr);
    }

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

    .deposit-side > :last-child {
        grid-column: 1 / -1;
    }
}

@media (max-width: 760px) {
    .deposit-card {
        padding: 0 16px;
    }

    .deposit-step {
        grid-template-columns: 28px minmax(0, 1fr);
        gap: 12px;
    }

    .deposit-step-marker {
        width: 28px;
        height: 28px;
    }

    .deposit-step:not(:last-child)::before {
        left: 13px;
    }

    .address-panel {
        grid-template-columns: minmax(0, 1fr);
        padding: 16px;
    }

    .address-facts {
        grid-template-columns: minmax(0, 1fr);
    }

    .deposit-side {
        grid-template-columns: minmax(0, 1fr);
    }

    .network-options {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* 18. Wallet, withdraw, transfer, history --------------------------------------- */

.page-header-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.wallet-totals {
    margin-bottom: var(--gutter);
}

.wallet-totals .stat-label {
    justify-content: flex-start;
}

.wallet-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 380px;
    gap: var(--gutter);
    align-items: start;
}

.wallet-side {
    display: grid;
    gap: var(--gutter);
    min-width: 0;
}

.wallet-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.wallet-hide-zero {
    font-size: 13px;
    white-space: nowrap;
}

.wallet-actions .btn {
    min-width: 0;
}

/* Amount field with suffix and Max */
.amount-input {
    position: relative;
    display: flex;
    align-items: center;
}

.amount-input .form-control {
    padding-right: 118px;
    font-size: 17px;
    font-variant-numeric: tabular-nums;
}

.amount-suffix {
    position: absolute;
    right: 64px;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 600;
    pointer-events: none;
}

.amount-max {
    position: absolute;
    right: 8px;
    height: 30px;
    padding: 0 12px;
    border: 1px solid var(--primary-border);
    border-radius: var(--radius-sm);
    background: var(--primary-soft);
    color: var(--primary-text);
    font-size: 12px;
    font-weight: 600;
}

.amount-max:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

/* Fee / total quote */
.quote-box {
    display: grid;
    gap: 2px;
    margin: 0;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-raised);
}

.quote-box > div {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    padding: 5px 0;
    font-size: 13.5px;
}

.quote-box dt {
    color: var(--text-muted);
}

.quote-box dd {
    margin: 0;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.quote-box .quote-total {
    margin-top: 4px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

.quote-box .quote-total dt,
.quote-box .quote-total dd {
    color: var(--text);
    font-size: 15px;
    font-weight: 600;
}

.withdraw-blocked {
    max-width: 640px;
}

.withdraw-blocked .card-body {
    display: grid;
    justify-items: start;
    gap: 12px;
    padding: 28px;
}

.transfer-card {
    min-width: 0;
}

.recipient-result {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.recipient-result.is-found {
    color: var(--up);
}

.recipient-result.is-missing {
    color: var(--danger-text);
}

/* History filters */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px 16px;
    margin-bottom: var(--gutter);
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
}

.filter-field {
    display: grid;
    gap: 6px;
    min-width: 170px;
}

.filter-field .form-select {
    height: 40px;
    font-size: 14px;
}

.filter-actions {
    display: flex;
    gap: 8px;
    margin-left: auto;
}

.table-note {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 20px 0;
    color: var(--text-muted);
    font-size: 13px;
}

.table-note .icon {
    width: 16px;
    height: 16px;
}

.page-tab.is-disabled {
    color: var(--text-subtle);
    cursor: default;
}

.page-tab.is-disabled .chip {
    margin-left: 6px;
}

@media (max-width: 1180px) {
    .wallet-layout {
        grid-template-columns: minmax(0, 1fr);
    }

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

@media (max-width: 760px) {
    .wallet-side {
        grid-template-columns: minmax(0, 1fr);
    }

    .filter-actions {
        margin-left: 0;
        width: 100%;
    }

    .filter-field {
        flex: 1;
    }
}

/* 19. Market ------------------------------------------------------------------ */

.market-top {
    display: grid;
    grid-template-columns: minmax(0, 1.55fr) repeat(3, minmax(148px, 0.5fr));
    gap: var(--gutter);
    margin-bottom: var(--gutter);
    align-items: stretch;
}

.market-hero {
    position: relative;
    display: flex;
    min-height: 196px;
    overflow: hidden;
    background:
        radial-gradient(70% 130% at 88% 45%, color-mix(in srgb, var(--primary) 32%, transparent) 0%, transparent 70%),
        linear-gradient(90deg, var(--surface) 0%, color-mix(in srgb, var(--primary) 10%, var(--surface)) 100%);
}

.market-hero-body {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    max-width: 62%;
    padding: 24px 26px;
}

.market-hero-title {
    margin: 6px 0 10px;
    font-size: clamp(24px, 2.4vw, 34px);
    font-weight: 700;
    letter-spacing: -0.02em;
}

.market-hero-text {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
}

.market-hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: auto;
    padding-top: 18px;
}

.market-hero-art {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 46%;
    pointer-events: none;
}

.market-hero-art img,
.market-hero-art svg {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: right center;
}

.market-stat {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
    padding: 18px;
}

.market-stat-label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 13px;
}

.market-stat-label .icon {
    width: 18px;
    height: 18px;
    color: var(--primary-text);
}

.market-stat-value {
    font-size: 21px;
    font-weight: 700;
    letter-spacing: -0.01em;
    font-variant-numeric: tabular-nums;
}

.market-stat-change {
    font-size: 12.5px;
    font-variant-numeric: tabular-nums;
}

/*
 * Pinned to the foot of the card at a fixed sparkline height. Letting it grow with the
 * row (the hero sets that height) stretched a few-percent drift into what read as a crash.
 */
.market-stat-chart {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    justify-content: flex-end;
    margin-top: 12px;
}

.market-stat-chart .sparkline {
    width: 100%;
    height: 64px;
}

.market-stat-range {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 2px 8px;
    margin-top: 6px;
    color: var(--text-muted);
    font-size: 11px;
    font-variant-numeric: tabular-nums;
}

.market-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 380px;
    gap: var(--gutter);
    align-items: start;
}

.market-side {
    display: grid;
    gap: var(--gutter);
    min-width: 0;
}

.market-table-header {
    flex-wrap: wrap;
    gap: 12px;
}

.market-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.market-currency .form-select {
    width: 92px;
    height: 34px;
    padding: 0 30px 0 12px;
    font-size: 13px;
    background-position: right 8px center;
}

.market-table-card {
    container: market-table / inline-size;
}

.market-table th,
.market-table td {
    padding-inline: 12px;
    white-space: nowrap;
}

.market-table th:first-child,
.market-table td:first-child {
    padding-left: 14px;
}

.market-table th:last-child,
.market-table td:last-child {
    padding-right: 20px;
}

.market-rank {
    width: 1%;
}

.market-rank-inner {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-width: 52px;
}

/* Holds the star's width in the header so "#" lines up with the numbers. */
.market-rank-star {
    width: 30px;
}

.market-table .col-action {
    width: 1%;
}

.market-price-stack {
    display: inline-grid;
    justify-items: end;
    gap: 2px;
}

.market-price-change {
    display: none;
    font-size: 12.5px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/*
 * Columns drop by priority as the card narrows — volume, then the sparkline, then
 * market cap, then the action — so the table never scrolls sideways. Thresholds are
 * the measured natural table width with those columns present (plus the card border).
 */
@container market-table (max-width: 860px) {
    .market-table .col-volume {
        display: none;
    }
}

@container market-table (max-width: 768px) {
    .market-table .col-spark {
        display: none;
    }
}

@container market-table (max-width: 658px) {
    .market-table .col-cap {
        display: none;
    }
}

@container market-table (max-width: 567px) {
    .market-table .col-action,
    .market-table .market-ticker {
        display: none;
    }
}

/* Phones: the 24h move moves under the price, where it is still read with it. */
@container market-table (max-width: 440px) {
    .market-table .col-change {
        display: none;
    }

    .market-table .market-price-change {
        display: block;
    }
}

.market-name-link {
    color: var(--text);
}

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

.market-name-link:hover .fw-semibold {
    color: var(--primary-text);
}

.market-ticker {
    margin-left: 4px;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 500;
}

.change-pill {
    display: inline-flex;
    align-items: center;
    height: 24px;
    padding: 0 10px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.change-pill.is-up {
    background: var(--up-soft);
    color: var(--up);
}

.change-pill.is-down {
    background: var(--down-soft);
    color: var(--down);
}

.market-spark {
    width: 110px;
}

.sparkline {
    width: 96px;
    height: 30px;
    overflow: visible;
}

.sparkline .sparkline-line {
    stroke: var(--up);
    stroke-linecap: round;
    stroke-linejoin: round;
}

.sparkline.is-down .sparkline-line {
    stroke: var(--down);
}

/* Volume and dominance have no good/bad direction, so they wear the brand colour, not green/red. */
.sparkline.is-neutral .sparkline-line {
    stroke: var(--primary-text);
}

.sparkline-empty {
    color: var(--text-subtle);
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 28px;
    padding: 0 10px;
    border: 1px solid var(--primary-border);
    border-radius: var(--radius-pill);
    background: var(--primary-soft);
    color: var(--text);
    font-size: 12.5px;
}

.filter-chip .icon {
    width: 13px;
    height: 13px;
}

/* Favourite star */
.favourite-form {
    display: inline-flex;
}

.favourite-button {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-subtle);
}

.favourite-button:hover {
    background: var(--surface-raised);
    color: var(--warning);
}

.favourite-button .icon {
    width: 17px;
    height: 17px;
}

.favourite-button.is-active {
    color: var(--warning);
}

.favourite-button.is-active .icon {
    fill: color-mix(in srgb, var(--warning) 28%, transparent);
}

/* Trend card */
.trend-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.trend-price {
    margin-left: auto;
    display: grid;
    justify-items: end;
    gap: 2px;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

.pill-tabs-sm .pill-tab {
    height: 26px;
    padding: 0 10px;
    font-size: 12px;
}

/* Candlestick chart — assets/js/candle-chart.js draws into .candle-chart-plot. */
.candle-chart {
    margin: 0;
}

.candle-chart-legend {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 18px;
    margin-bottom: 8px;
    color: var(--text-muted);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.candle-chart-ohlc {
    display: flex;
    flex-wrap: wrap;
    gap: 2px 10px;
    color: var(--up);
}

.candle-chart-ohlc.is-down {
    color: var(--down);
}

.candle-chart-key {
    margin-right: 3px;
    color: var(--text-muted);
}

.candle-chart-live {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.candle-chart-live-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--up);
    box-shadow: 0 0 0 3px var(--up-soft);
}

@media (prefers-reduced-motion: no-preference) {
    .candle-chart-live-dot {
        animation: candle-live-pulse 2s ease-in-out infinite;
    }
}

@keyframes candle-live-pulse {
    50% { opacity: 0.4; }
}

.candle-chart-plot {
    position: relative;
    height: 220px;
}

.candle-chart-credit {
    margin-top: 6px;
    font-size: 11px;
    text-align: right;
}

.candle-chart-credit a {
    color: var(--text-subtle);
}

.candle-chart-credit a:hover {
    color: var(--text-muted);
}

.chart-empty {
    display: grid;
    justify-items: center;
    gap: 8px;
    padding: 36px 20px;
    color: var(--text-muted);
    text-align: center;
}

.chart-empty .icon {
    width: 28px;
    height: 28px;
    color: var(--text-subtle);
}

.chart-range-note {
    margin-bottom: 10px;
    color: var(--text-muted);
    font-size: 13px;
}

/* Trending & categories */
.trending-list {
    display: grid;
    margin: 0;
    padding: 6px 20px 14px;
    list-style: none;
}

.trending-item {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
}

.trending-item + .trending-item {
    border-top: 1px solid var(--border);
}

.trending-list-unranked .trending-item {
    grid-template-columns: minmax(0, 1fr) auto;
}

.trending-rank {
    color: var(--text-muted);
    font-size: 12px;
    text-align: center;
}

.trending-link {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    color: var(--text);
}

.trending-link:hover .fw-semibold {
    color: var(--primary-text);
}

.trending-figures {
    display: grid;
    justify-items: end;
    gap: 2px;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

.category-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding: 14px 20px 20px;
}

.category-tile {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) 16px;
    align-items: center;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-raised);
    color: var(--text);
}

.category-tile:hover {
    border-color: var(--primary-border);
    color: var(--text);
}

.category-tile.is-active {
    border-color: var(--primary);
    background: var(--primary-soft);
}

.category-icon {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    background: var(--primary-soft);
    color: var(--primary-text);
}

.category-icon .icon {
    width: 18px;
    height: 18px;
}

.category-tile > .icon {
    color: var(--text-subtle);
}

/* Market detail */
.market-detail-title {
    display: flex;
    align-items: center;
    gap: 14px;
}

.market-detail-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: var(--gutter);
    align-items: start;
}

.market-detail-main,
.market-detail-side {
    display: grid;
    align-content: start;
    gap: var(--gutter);
    min-width: 0;
}

/* The price and the range tabs share a row while they fit, then the tabs take their own. */
.chart-card-header {
    flex-wrap: wrap;
    row-gap: 12px;
}

.chart-card-header .pill-tabs {
    flex-wrap: nowrap;
}

.market-detail-side .card-body > .detail-list:first-child {
    margin-top: 0;
}

.market-detail-side .card-body > .detail-list:first-child > div:first-child {
    padding-top: 0;
    border-top: 0;
}

/* Beside bordered buttons the star gets the same frame and height. */
.page-header-actions .favourite-button {
    width: 34px;
    height: 34px;
    border: 1px solid var(--border-strong);
    background: var(--surface-raised);
}

.market-performance-card .card-header {
    flex-wrap: wrap;
    row-gap: 4px;
}

.performance-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
    gap: 10px;
    margin: 0;
    padding: 16px 20px 20px;
    list-style: none;
}

.performance-tile {
    display: grid;
    align-content: start;
    gap: 4px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-raised);
}

.performance-tile.is-current {
    border-color: var(--primary-border);
}

.performance-range {
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
}

.performance-change {
    font-size: 18px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.performance-extremes {
    display: grid;
    gap: 1px;
    color: var(--text-muted);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.performance-since {
    color: var(--text-muted);
    font-size: 11.5px;
    font-style: italic;
}

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

.detail-price-value {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.01em;
    font-variant-numeric: tabular-nums;
}

.market-detail-layout .candle-chart-plot,
.trade-chart-card .candle-chart-plot {
    height: 340px;
}

@media (max-width: 760px) {
    .market-detail-layout .candle-chart-plot,
    .trade-chart-card .candle-chart-plot {
        height: 260px;
    }
}

/*
 * Below 1440px the hero takes its own row, and the market list takes the full width with
 * the side cards in a row beneath — a laptop sees every table column, as a tablet does.
 */
@media (max-width: 1440px) {
    .market-top {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .market-hero {
        grid-column: 1 / -1;
    }

    .market-layout {
        grid-template-columns: minmax(0, 1fr);
    }

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

    /* An odd card out spans the row instead of leaving half of it empty. */
    .market-side > :last-child:nth-child(odd) {
        grid-column: 1 / -1;
    }
}

@media (max-width: 1180px) {
    .market-detail-layout {
        grid-template-columns: minmax(0, 1fr);
    }

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

    .market-detail-side > :last-child:nth-child(odd) {
        grid-column: 1 / -1;
    }
}

@media (max-width: 760px) {
    .market-top {
        grid-template-columns: minmax(0, 1fr);
    }

    .market-hero-body {
        max-width: 100%;
    }

    .market-hero-art {
        opacity: 0.32;
        width: 62%;
    }

    .market-side,
    .market-detail-side {
        grid-template-columns: minmax(0, 1fr);
    }

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

    .market-tools {
        width: 100%;
    }

    .market-tools .table-search {
        flex: 1;
    }

    .chart-card-header .pill-tabs {
        width: 100%;
    }

    .chart-card-header .pill-tab {
        flex: 1;
        justify-content: center;
    }
}

/* On a phone the artwork would run through the paragraph; the copy carries the card. */
@media (max-width: 480px) {
    .market-hero-art {
        display: none;
    }
}

/* Touch: stars and range tabs grow toward the 44px guideline without changing the desktop look. */
@media (pointer: coarse) {
    .favourite-button,
    .page-header-actions .favourite-button {
        width: 40px;
        height: 40px;
    }

    .market-rank-star {
        width: 40px;
    }

    .pill-tab {
        height: 36px;
    }

    .pill-tabs-sm .pill-tab {
        height: 34px;
    }
}

/* 20. Trade ------------------------------------------------------------------- */
.trade-page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px 28px;
}

.trade-pair-head {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.trade-pair-form {
    display: flex;
    align-items: center;
    gap: 8px;
}

.trade-pair-select {
    width: auto;
    min-width: 150px;
    height: 38px;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.trade-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 26px;
    margin: 0;
}

.trade-stats > div {
    display: grid;
    gap: 2px;
}

.trade-stats dt {
    color: var(--text-muted);
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.trade-stats dd {
    margin: 0;
    font-size: 15px;
    font-variant-numeric: tabular-nums;
}

.trade-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.7fr) minmax(240px, 0.9fr) minmax(310px, 1.1fr);
    grid-template-areas:
        "chart  book form"
        "orders book tape";
    gap: var(--gutter);
    align-items: start;
}

.trade-chart-card  { grid-area: chart; }
.trade-book-card   { grid-area: book; align-self: stretch; }
.trade-form-card   { grid-area: form; padding: 16px; }
.trade-orders-card { grid-area: orders; }
.trade-tape-card   { grid-area: tape; }

/* Order book */
.order-book {
    display: flex;
    flex-direction: column;
    padding: 4px 4px 10px;
}

.order-book-head,
.trade-tape-head {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
    padding: 6px 16px;
    color: var(--text-subtle);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.order-book-head span:not(:first-child),
.trade-tape-head span:not(:first-child) { text-align: right; }

.order-book-side {
    display: flex;
    flex-direction: column;
}

.order-book-side.is-asks { justify-content: flex-end; }

.order-book-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
    width: 100%;
    padding: 4px 16px;
    border: 0;
    background: transparent;
    font-size: 12.5px;
    font-variant-numeric: tabular-nums;
    text-align: right;
    cursor: pointer;
}

.order-book-row span:first-child { text-align: left; }
.order-book-row:hover { background: color-mix(in srgb, var(--text) 4%, transparent); }

.order-book-spread {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 16px;
    margin: 4px 0;
    border-block: 1px solid var(--border);
    font-size: 15px;
    font-variant-numeric: tabular-nums;
}

.order-book-empty {
    padding: 14px 16px;
    color: var(--text-subtle);
    font-size: 12.5px;
}

/* Order form */
.trade-type-tabs {
    display: inline-flex;
    gap: 4px;
    padding: 3px;
    margin-bottom: 14px;
    border-radius: var(--radius-sm);
    background: var(--surface-raised);
}

.trade-type-tab {
    padding: 6px 16px;
    border: 0;
    border-radius: var(--radius-xs);
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.trade-type-tab.is-active {
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-pop);
}

.trade-sides {
    display: grid;
    gap: 14px;
}

.trade-form {
    display: grid;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-raised);
}

.trade-form-buy  { border-top: 2px solid var(--up); }
.trade-form-sell { border-top: 2px solid var(--down); }

.trade-avail {
    margin: 0;
    color: var(--text-muted);
    font-size: 12.5px;
}

.input-suffix {
    position: relative;
    display: flex;
    align-items: center;
}

.input-suffix .form-control {
    padding-right: 58px;
    font-variant-numeric: tabular-nums;
}

.input-suffix-label {
    position: absolute;
    right: 12px;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
    pointer-events: none;
}

.trade-percents {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}

.trade-percent {
    padding: 6px 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.trade-percent:hover { border-color: var(--primary-border); color: var(--primary-text); }

.trade-summary {
    display: grid;
    gap: 3px;
    margin: 0;
    padding-top: 4px;
    border-top: 1px solid var(--border);
    font-size: 12.5px;
}

.trade-summary > div {
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.trade-summary dt { color: var(--text-muted); }
.trade-summary dd { margin: 0; font-variant-numeric: tabular-nums; }

.btn-buy {
    background: var(--up);
    border-color: var(--up);
    color: #04150c;
}

.btn-buy:hover { background: color-mix(in srgb, var(--up) 88%, #000); }

.btn-sell {
    background: var(--down);
    border-color: var(--down);
    color: #fff;
}

.btn-sell:hover { background: color-mix(in srgb, var(--down) 88%, #000); }

.trade-blocked {
    display: grid;
    justify-items: center;
    gap: 10px;
    padding: 26px 18px;
    color: var(--text-muted);
    text-align: center;
}

.trade-blocked .icon { width: 26px; height: 26px; color: var(--warning); }

/* Recent trades tape */
.trade-tape {
    display: flex;
    flex-direction: column;
    max-height: 320px;
    padding-bottom: 8px;
    overflow-y: auto;
}

.trade-tape-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
    padding: 3px 16px;
    font-size: 12.5px;
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.trade-tape-row span:first-child { text-align: left; }

@media (max-width: 1200px) {
    .trade-layout {
        grid-template-columns: minmax(0, 1.4fr) minmax(280px, 1fr);
        grid-template-areas:
            "chart  form"
            "book   form"
            "orders tape";
    }
}

@media (max-width: 820px) {
    .trade-layout {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas:
            "chart"
            "form"
            "book"
            "orders"
            "tape";
    }
}

/* 21. KYC (identity verification) --------------------------------------------- */
.form-divider {
    height: 1px;
    margin: 22px 0 18px;
    border: 0;
    background: var(--border);
}

.kyc-status-card .card-body {
    display: grid;
    justify-items: start;
    gap: 8px;
}

.kyc-status-card h2 {
    margin: 4px 0 0;
    font-size: 20px;
}

.kyc-status-icon {
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    border-radius: var(--radius);
    background: var(--primary-soft);
    color: var(--primary-text);
}

.kyc-status-icon .icon { width: 24px; height: 24px; }
.kyc-status-icon.is-verified { background: var(--up-soft); color: var(--up); }
.kyc-status-icon.is-pending { background: var(--warning-soft); color: var(--warning); }

.kyc-status-card .detail-list { max-width: 460px; }

.kyc-uploads {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px 18px;
    margin: 12px 0 4px;
}

.kyc-upload .form-control[type="file"] {
    padding: 8px 10px;
    font-size: 13px;
}

/* 22. Convert ----------------------------------------------------------------- */
.convert-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: var(--gutter);
    align-items: start;
}

.convert-field {
    display: flex;
    gap: 10px;
}

.convert-field .form-control {
    flex: 1 1 auto;
    font-size: 18px;
    font-variant-numeric: tabular-nums;
}

.convert-field .form-select {
    width: auto;
    min-width: 104px;
    font-weight: 600;
}

.convert-percents {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    margin-top: 10px;
}

.convert-swap {
    display: flex;
    justify-content: center;
    margin: 4px 0;
}

.convert-swap-btn {
    width: 40px;
    height: 40px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--surface-raised);
    color: var(--primary-text);
}

.convert-swap-btn:hover { border-color: var(--primary-border); }

.convert-summary {
    display: grid;
    gap: 6px;
    margin: 16px 0 0;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    font-size: 13px;
}

.convert-summary > div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.convert-summary dt { color: var(--text-muted); }
.convert-summary dd { margin: 0; font-variant-numeric: tabular-nums; }
.convert-summary-total dd { font-weight: 700; color: var(--text); }

@media (max-width: 860px) {
    .convert-layout { grid-template-columns: minmax(0, 1fr); }
}

/* =============================================================================
   Section 23 — Responsive collapsible tables
   On small screens, columns that do not fit are hidden behind a per-row (+)
   toggle that expands to reveal them as label/value pairs. Progressive
   enhancement added by initResponsiveTables() in app.js; opt out with
   data-no-collapse on the <table>.
   ========================================================================== */
.table-control-col {
    display: none;
    width: 44px;
    text-align: center;
    vertical-align: middle;
    padding-left: 10px !important;
    padding-right: 4px !important;
}

.table-toggle {
    position: relative;
    width: 26px;
    height: 26px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: color-mix(in srgb, var(--primary) 8%, transparent);
    color: var(--primary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
    transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.table-toggle:hover { border-color: var(--primary); background: var(--primary-soft); }
.table-toggle:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Plus mark drawn from a bar + a crossbar; the crossbar hides when expanded. */
.table-toggle > span { position: relative; display: block; width: 12px; height: 2px; background: currentColor; border-radius: 2px; }
.table-toggle > span::before { content: ""; position: absolute; left: 5px; top: -5px; width: 2px; height: 12px; background: currentColor; border-radius: 2px; transition: opacity .15s ease; }
tr.is-expanded .table-toggle { background: var(--primary); border-color: var(--primary); color: #fff; }
tr.is-expanded .table-toggle > span::before { opacity: 0; }

/* The expanded detail row. */
.table-detail-row > .table-detail-cell {
    padding: 0 14px 12px;
    background: color-mix(in srgb, var(--primary) 4%, transparent);
    border-top: 0;
}
.table tbody tr.table-detail-row:hover td { background: color-mix(in srgb, var(--primary) 4%, transparent); }
.table-detail-list { margin: 0; padding: 10px 0 2px; display: grid; gap: 0; }
.table-detail-list > div {
    display: grid;
    grid-template-columns: minmax(84px, 38%) 1fr;
    gap: 10px;
    align-items: baseline;
    padding: 9px 0;
    border-bottom: 1px solid var(--border);
}
.table-detail-list > div:last-child { border-bottom: 0; }
.table-detail-list dt { margin: 0; color: var(--text-muted); font-size: 13px; font-weight: 500; }
.table-detail-list dd { margin: 0; font-size: 14px; text-align: right; word-break: break-word; overflow-wrap: anywhere; }

@media (max-width: 767.98px) {
    .table.is-collapsible-active .table-control-col { display: table-cell; }
    .table th.table-col-hidden,
    .table td.table-col-hidden { display: none; }
}
@media (min-width: 768px) {
    .table-detail-row { display: none; }
}

/* =============================================================================
   Section 24 — Modal dialogs
   In-app modals replacing native alert()/confirm(). Built by the Modal module in
   app.js; styled with the shared design tokens and .btn classes.
   ========================================================================== */
.modal-root {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-root[hidden] { display: none; }

body.modal-open { overflow: hidden; }

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(4, 5, 20, 0.62);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
    animation: modal-fade 0.16s ease;
}

.modal-dialog {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 430px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
    animation: modal-pop 0.18s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

.modal-title {
    margin: 0 0 10px;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text);
}
.modal-dialog.is-danger .modal-title { color: var(--danger-text); }

.modal-body { margin: 0 0 22px; }
.modal-message {
    margin: 0;
    font-size: 15px;
    line-height: 1.6;
    color: var(--text-secondary);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}
.modal-actions .btn { min-width: 104px; }

@keyframes modal-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-pop { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
    .modal-overlay, .modal-dialog { animation: none; }
}

@media (max-width: 520px) {
    .modal-root { padding: 0; align-items: flex-end; }
    .modal-dialog {
        max-width: none;
        border-radius: 18px 18px 0 0;
        padding: 20px 18px calc(20px + env(safe-area-inset-bottom, 0px));
        animation: modal-sheet 0.2s ease;
    }
    .modal-actions { flex-direction: column-reverse; }
    .modal-actions .btn { width: 100%; }
    @keyframes modal-sheet { from { transform: translateY(100%); } to { transform: none; } }
}

/* =============================================================================
   Section 25 — Timed trades (fixed-time Buy/Sell)
   ========================================================================== */
.timed-layout { display: grid; grid-template-columns: 1fr; gap: 16px; }

/* Mobile / single column: put the trade panel first and the chart last. */
@media (max-width: 979.98px) {
    .timed-layout { display: flex; flex-direction: column; }
    .timed-layout .timed-panel        { order: 1; }
    .timed-layout .timed-active-card  { order: 2; }
    .timed-layout .timed-history-card { order: 3; }
    .timed-layout .trade-chart-card   { order: 4; }
}

@media (min-width: 980px) {
    .timed-layout {
        grid-template-columns: minmax(0, 1fr) 372px;
        grid-template-areas: "chart panel" "active panel" "history panel";
        align-items: start;
    }
    .timed-layout .trade-chart-card   { grid-area: chart; }
    .timed-layout .timed-panel        { grid-area: panel; position: sticky; top: 84px; }
    .timed-layout .timed-active-card  { grid-area: active; }
    .timed-layout .timed-history-card { grid-area: history; }
}

/* Panel */
.trade-blocked { text-align: center; padding: 26px 10px; color: var(--text-muted); }
.trade-blocked svg { width: 30px; height: 30px; opacity: 0.6; margin-bottom: 8px; }
.trade-blocked p { margin: 0 0 12px; }

.timed-durations { display: grid; grid-template-columns: repeat(auto-fit, minmax(72px, 1fr)); gap: 8px; }
.timed-duration { position: relative; }
.timed-duration input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.timed-duration span {
    display: flex; flex-direction: column; gap: 2px; align-items: center; text-align: center; padding: 8px 6px;
    border: 1px solid var(--border); border-radius: 10px; color: var(--text-secondary);
    transition: border-color .15s ease, background .15s ease, color .15s ease;
}
.timed-duration-time { font-weight: 700; font-size: 14px; }
.timed-duration-payout { font-size: 11px; font-weight: 600; color: var(--up); }
.timed-duration input:checked + span { border-color: var(--primary); background: var(--primary-soft); color: var(--text); }
.timed-duration input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }

.timed-summary { margin: 18px 0 16px; display: grid; gap: 8px; }
.timed-summary > div { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.timed-summary dt { color: var(--text-muted); }
.timed-summary dd { margin: 0; font-variant-numeric: tabular-nums; }
.timed-summary-win dd { font-weight: 700; color: var(--up); }

.timed-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 600px) {
    .timed-actions { grid-template-columns: 1fr; }
    .timed-btn { flex-direction: row; gap: 8px; padding: 14px; }
}
.timed-btn { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 12px 8px; border: 0; color: #fff; line-height: 1.25; }
.timed-btn-main { display: inline-flex; align-items: center; gap: 7px; font-size: 16px; font-weight: 700; }
.timed-btn-main svg { width: 18px; height: 18px; }
.timed-btn-sub { font-size: 11px; font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; opacity: 0.82; }
.timed-btn-up   { background: var(--up); }
.timed-btn-up:hover   { background: color-mix(in srgb, var(--up) 88%, #000); }
.timed-btn-down { background: var(--down, #ef4444); }
.timed-btn-down:hover { background: color-mix(in srgb, var(--down, #ef4444) 88%, #000); }
.timed-btn.is-loading { opacity: 0.7; }
.timed-disclaimer { margin: 14px 0 0; font-size: 12px; line-height: 1.5; color: var(--text-muted); display: flex; gap: 6px; }
.timed-disclaimer svg { width: 14px; height: 14px; flex-shrink: 0; margin-top: 2px; }

/* Active trades list */
.timed-active-list { list-style: none; margin: 0; padding: 0; }
.timed-active { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--border); }
.timed-active:first-child { border-top: 0; }
.timed-active-dir { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; font-size: 13px; padding: 3px 8px; border-radius: 6px; }
.timed-active-dir svg { width: 13px; height: 13px; }
.timed-active-up   { color: var(--up); background: var(--up-soft); }
.timed-active-down { color: var(--down, #ef4444); background: color-mix(in srgb, var(--down, #ef4444) 12%, transparent); }
.timed-active .cell-stack { flex: 1; min-width: 0; }
.timed-countdown { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 15px; color: var(--primary); }

/* Loader / result overlay */
.timed-loader-root { position: fixed; inset: 0; z-index: 1300; display: flex; align-items: center; justify-content: center; padding: 20px; }
.timed-loader-root[hidden] { display: none; }
.timed-loader-backdrop { position: absolute; inset: 0; background: rgba(4, 5, 20, 0.7); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.timed-loader-dialog { position: relative; width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 28px 24px; box-shadow: 0 24px 60px rgba(0,0,0,.5); text-align: center; }
.timed-loader-title { margin: 0 0 18px; font-size: 17px; font-weight: 700; color: var(--text); }
.timed-loader-sub { margin: 14px 0 0; font-size: 13px; color: var(--text-muted); }
.timed-loader-wait { margin: 10px 0 0; font-size: 12px; color: var(--text-subtle); }

.timed-ring { width: 148px; height: 148px; margin: 0 auto; border-radius: 50%; position: relative; display: flex; align-items: center; justify-content: center; background: conic-gradient(var(--ring, var(--primary)) calc(var(--pct, 100) * 1%), var(--border) 0); transition: background .95s linear; }
.timed-ring::before { content: ""; position: absolute; inset: 12px; border-radius: 50%; background: var(--surface); }
.timed-ring-up { --ring: var(--up); }
.timed-ring-down { --ring: var(--down, #ef4444); }
.timed-ring-time { position: relative; font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); }

.timed-result-icon { width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 26px; }
.timed-result-won  { color: var(--up); background: var(--up-soft); }
.timed-result-lost { color: var(--down, #ef4444); background: color-mix(in srgb, var(--down, #ef4444) 14%, transparent); }
.timed-result-void { color: var(--text-muted); background: var(--primary-soft); }
.timed-result-amount { margin: 0 0 8px; font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }
.timed-result-amount.timed-result-won  { color: var(--up); }
.timed-result-amount.timed-result-lost { color: var(--down, #ef4444); }
.timed-result-amount.timed-result-void { color: var(--text); }
.timed-loader-dialog .btn-block { margin-top: 20px; }

@media (prefers-reduced-motion: reduce) { .timed-ring { transition: none; } }

/* Account-level toggle ------------------------------------------------------
   Each choice keeps its colour whether or not it is selected: unselected is an
   outline, selected is filled and carries a tick, so the state is not carried
   by colour alone. */

.level-toggle {
    display: inline-flex;
    gap: 6px;
    align-items: center;
}

.btn-level {
    background: transparent;
    border: 1px solid currentColor;
    font-weight: 600;
}

.btn-level .icon {
    margin-right: 4px;
}

.btn-level-inherit { color: var(--text-secondary); border-color: var(--border-strong); }
.btn-level-l       { color: var(--down); }
.btn-level-p       { color: var(--up); }

.btn-level:hover:not(:disabled) {
    background: color-mix(in srgb, currentColor 14%, transparent);
}

.btn-level.is-selected {
    box-shadow: 0 0 0 2px color-mix(in srgb, currentColor 35%, transparent);
}

.btn-level-inherit.is-selected {
    background: var(--surface-raised);
    color: var(--text);
    border-color: var(--border-strong);
}

.btn-level-l.is-selected {
    background: var(--down);
    border-color: var(--down);
    color: #fff;
}

.btn-level-p.is-selected {
    background: var(--up);
    border-color: var(--up);
    color: #04150c;
}

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