/* ─── VERSO — institutional Swiss palette ─────────────────
           Warm paper background, near-black text, UBS-adjacent deep-red
           accent, three typefaces (Inter / Source Serif 4 / JetBrains Mono).
           Legacy variables (--bg-primary, --accent-green, etc.) remap onto
           the new tokens so existing templates (token list, chain list,
           NFT list, etc.) get the paper aesthetic without per-page edits.
         */
        :root {
            /* Paper palette */
            --bg:        #F7F4EE;
            --surface:   #FFFFFF;
            --surface-2: #F2EEE6;
            --surface-3: #ECE7DC;
            --surface-4: #1B1816;

            /* Lines */
            --line:      #E2DBCB;
            --line-2:    #D4CBB6;
            --line-3:    #312A23;

            /* Text */
            --text:      #1B1816;
            --text-2:    #4B453C;
            --text-3:    #807866;
            --text-4:    #ADA38B;

            /* Accent — institutional red */
            --accent:        #C8102E;
            --accent-2:      #8E0E22;
            --accent-soft:   rgba(200, 16, 46, 0.08);
            --accent-text:   #8E0E22;

            /* Status */
            --pos:       #15663E;
            --pos-soft:  rgba(21, 102, 62, 0.10);
            --neg:       #A82A1A;
            --neg-soft:  rgba(168, 42, 26, 0.10);
            --warn:      #8A5A0F;
            --warn-soft: rgba(138, 90, 15, 0.10);

            /* Chain colors */
            --chain-eth:  #5A6B8C;
            --chain-poly: #7A4FAE;
            --chain-arb:  #2C7BB6;
            --chain-base: #1F4FCF;
            --chain-op:   #C8102E;
            --chain-bsc:  #C0962E;
            --chain-sol:  #6E54B5;
            --chain-btc:  #B8761A;

            /* Effects */
            --shadow-1: 0 1px 0 rgba(27, 24, 22, 0.04), 0 1px 3px rgba(27, 24, 22, 0.04);
            --shadow-2: 0 2px 6px rgba(27, 24, 22, 0.06), 0 8px 24px rgba(27, 24, 22, 0.04);

            /* Type */
            --font-sans:  'Inter', system-ui, -apple-system, 'Helvetica Neue', sans-serif;
            --font-serif: 'Source Serif 4', 'Source Serif Pro', Georgia, 'Times New Roman', serif;
            --font-mono:  'JetBrains Mono', 'SF Mono', ui-monospace, Menlo, monospace;

            /* Legacy aliases — remap so existing pages adopt the paper look */
            --bg-primary: var(--bg);
            --bg-secondary: var(--surface-2);
            --bg-tertiary: var(--surface-3);
            --bg-card: var(--surface);
            --bg-hover: var(--surface-2);
            --border-color: var(--line-2);
            --border-subtle: var(--line);
            --text-primary: var(--text);
            --text-secondary: var(--text-2);
            --text-muted: var(--text-3);
            --accent-green: var(--pos);
            --accent-green-dim: var(--pos-soft);
            --accent-blue: var(--chain-base);
            --accent-purple: var(--chain-poly);
            --accent-orange: var(--warn);
            --accent-red: var(--neg);
            --error: var(--neg);
            --gradient-primary: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
            --gradient-card: linear-gradient(180deg, rgba(0,0,0,0.01) 0%, rgba(0,0,0,0) 100%);
            --shadow-sm: var(--shadow-1);
            --shadow-md: var(--shadow-2);
            --shadow-glow: 0 0 0 transparent;
            --radius-sm: 5px;
            --radius-md: 6px;
            --radius-lg: 8px;
        }

        html.dark {
            --bg:        #0E0D0B;
            --surface:   #15140F;
            --surface-2: #1B1915;
            --surface-3: #221F19;
            --surface-4: #FAF7EF;
            --line:      #2A2620;
            --line-2:    #3A342B;
            --line-3:    #E2DBCB;
            --text:      #F1ECE0;
            --text-2:    #B6AE9A;
            --text-3:    #807866;
            --text-4:    #5A5345;
            --accent:        #E63A52;
            --accent-2:      #E63A52;
            --accent-soft:   rgba(230, 58, 82, 0.14);
            --accent-text:   #F18A99;
            --pos:       #5DBC85;
            --pos-soft:  rgba(93, 188, 133, 0.14);
            --neg:       #E47363;
            --neg-soft:  rgba(228, 115, 99, 0.14);
            --warn:      #D4A24E;
            --warn-soft: rgba(212, 162, 78, 0.14);
            --shadow-1: 0 1px 0 rgba(0,0,0,0.5), 0 1px 3px rgba(0,0,0,0.4);
            --shadow-2: 0 2px 6px rgba(0,0,0,0.5), 0 8px 24px rgba(0,0,0,0.4);
        }

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

        body {
            font-family: var(--font-sans);
            background: var(--bg);
            color: var(--text);
            line-height: 1.5;
            min-height: 100vh;
            -webkit-font-smoothing: antialiased;
            -moz-osx-font-smoothing: grayscale;
            font-feature-settings: 'cv11', 'ss01', 'ss03';
        }

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

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

        ::selection { background: var(--accent-soft); color: var(--text); }

        /* Navigation */
        .navbar {
            background: var(--bg-secondary);
            border-bottom: 1px solid var(--border-color);
            padding: 0 2rem;
            position: sticky;
            top: 0;
            z-index: 100;
            backdrop-filter: blur(10px);
        }

        .navbar-inner {
            max-width: 1800px;
            margin: 0 auto;
            display: flex;
            align-items: center;
            justify-content: space-between;
            height: 64px;
        }

        .navbar-brand {
            display: flex;
            align-items: center;
            gap: 0.75rem;
            font-weight: 600;
            font-size: 1.25rem;
            color: var(--text-primary);
        }

        .navbar-brand svg {
            width: 28px;
            height: 28px;
        }

        .navbar-nav {
            display: flex;
            gap: 0.5rem;
        }

        .nav-link {
            padding: 0.5rem 1rem;
            border-radius: var(--radius-sm);
            color: var(--text-secondary);
            font-weight: 500;
            font-size: 0.9rem;
            transition: all 0.2s;
        }

        .nav-link:hover, .nav-link.active {
            background: var(--bg-hover);
            color: var(--text-primary);
        }

        .nav-link.active {
            color: var(--accent-green);
        }

        /* Settings Dropdown */
        .nav-dropdown {
            position: relative;
        }

        .nav-dropdown-toggle {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            background: none;
            border: none;
            cursor: pointer;
        }

        .nav-icon-btn {
            width: 40px;
            height: 40px;
            padding: 0;
            justify-content: center;
        }

        .nav-dropdown-toggle svg {
            transition: transform 0.3s ease;
        }

        .nav-dropdown.open .nav-dropdown-toggle svg {
            transform: rotate(90deg);
        }

        .nav-dropdown-menu {
            position: absolute;
            top: calc(100% + 0.5rem);
            right: 0;
            background: var(--bg-card);
            border: 1px solid var(--border-color);
            border-radius: var(--radius-md);
            min-width: 180px;
            padding: 0.5rem;
            box-shadow: var(--shadow-md);
            opacity: 0;
            visibility: hidden;
            transform: translateY(-10px);
            transition: all 0.2s ease;
            z-index: 200;
        }

        .nav-dropdown.open .nav-dropdown-menu {
            opacity: 1;
            visibility: visible;
            transform: translateY(0);
        }

        .nav-dropdown-item {
            display: flex;
            align-items: center;
            gap: 0.75rem;
            padding: 0.625rem 0.875rem;
            border-radius: var(--radius-sm);
            color: var(--text-secondary);
            font-size: 0.875rem;
            font-weight: 500;
            transition: all 0.15s;
        }

        .nav-dropdown-item:hover {
            background: var(--bg-hover);
            color: var(--text-primary);
        }

        .nav-dropdown-item.active {
            color: var(--accent-green);
            background: var(--accent-green-dim);
        }

        .nav-dropdown-item svg {
            opacity: 0.7;
        }

        .nav-dropdown-item:hover svg,
        .nav-dropdown-item.active svg {
            opacity: 1;
        }
        
        .nav-dropdown-header {
            padding: 0.75rem 0.875rem;
            border-bottom: 1px solid var(--border-color);
            margin-bottom: 0.25rem;
            display: flex;
            flex-direction: column;
            gap: 0.15rem;
        }
        
        .nav-dropdown-item-danger {
            color: var(--error) !important;
        }
        
        .nav-dropdown-item-danger:hover {
            background: rgba(239, 68, 68, 0.1) !important;
        }

        /* Main content */
        .main-content {
            max-width: 1800px;
            margin: 0 auto;
            padding: 2rem;
        }

        /* Page header */
        .page-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            margin-bottom: 2rem;
        }

        .page-title {
            font-size: 1.75rem;
            font-weight: 600;
            display: flex;
            align-items: center;
            gap: 0.75rem;
        }

        .page-title-icon {
            width: 32px;
            height: 32px;
            display: flex;
            align-items: center;
            justify-content: center;
            background: var(--accent-green-dim);
            border-radius: var(--radius-sm);
            color: var(--accent-green);
        }

        /* Cards */
        .card {
            background: var(--bg-card);
            border: 1px solid var(--border-color);
            border-radius: var(--radius-lg);
            padding: 1.5rem;
            position: relative;
            overflow: hidden;
        }

        .card::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            height: 1px;
            background: var(--gradient-primary);
            opacity: 0.3;
        }

        .card-title {
            font-size: 1rem;
            font-weight: 500;
            color: var(--text-secondary);
            margin-bottom: 1rem;
        }

        /* Stats grid */
        .stats-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 1.5rem;
            margin-bottom: 2rem;
        }

        .stat-card {
            background: var(--bg-card);
            border: 1px solid var(--border-color);
            border-radius: var(--radius-lg);
            padding: 1.25rem 1.5rem;
            display: flex;
            align-items: center;
            gap: 1rem;
        }

        .stat-icon {
            width: 48px;
            height: 48px;
            border-radius: var(--radius-md);
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 1.25rem;
        }

        .stat-icon.green { background: rgba(0, 217, 154, 0.15); color: var(--accent-green); }
        .stat-icon.blue { background: rgba(59, 130, 246, 0.15); color: var(--accent-blue); }
        .stat-icon.purple { background: rgba(139, 92, 246, 0.15); color: var(--accent-purple); }
        .stat-icon.orange { background: rgba(245, 158, 11, 0.15); color: var(--accent-orange); }

        .stat-content {
            flex: 1;
        }

        .stat-label {
            font-size: 0.85rem;
            color: var(--text-muted);
            margin-bottom: 0.25rem;
        }

        .stat-value {
            font-size: 1.5rem;
            font-weight: 600;
            font-family: var(--font-mono);
        }

        .stat-value.large {
            font-size: 1.75rem;
            background: var(--gradient-primary);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }

        /* Tables */
        .table-container {
            overflow-x: auto;
        }

        table {
            width: 100%;
            border-collapse: collapse;
        }

        th {
            text-align: left;
            padding: 0.875rem 1rem;
            font-size: 0.75rem;
            font-weight: 600;
            text-transform: uppercase;
            letter-spacing: 0.05em;
            color: var(--text-muted);
            border-bottom: 1px solid var(--border-color);
        }

        td {
            padding: 1rem;
            border-bottom: 1px solid var(--border-subtle);
            vertical-align: middle;
        }

        tr:hover td {
            background: var(--bg-hover);
        }

        .address-cell {
            font-family: var(--font-mono);
            font-size: 0.9rem;
        }

        .amount-cell {
            font-family: var(--font-mono);
            font-weight: 500;
        }

        .value-cell {
            font-family: var(--font-mono);
            color: var(--accent-green);
        }

        /* Badges */
        .badge {
            display: inline-flex;
            align-items: center;
            padding: 0.25rem 0.625rem;
            border-radius: 9999px;
            font-size: 0.75rem;
            font-weight: 500;
        }

        .badge-evm { background: rgba(59, 130, 246, 0.15); color: var(--accent-blue); }
        .badge-solana { background: rgba(139, 92, 246, 0.15); color: var(--accent-purple); }
        .badge-btc { background: rgba(245, 158, 11, 0.15); color: var(--accent-orange); }
        .badge-native { background: rgba(0, 217, 154, 0.15); color: var(--accent-green); }
        .badge-erc20 { background: rgba(59, 130, 246, 0.15); color: var(--accent-blue); }
        .badge-spl { background: rgba(139, 92, 246, 0.15); color: var(--accent-purple); }

        /* Buttons */
        .btn {
            display: inline-flex;
            align-items: center;
            gap: 0.5rem;
            padding: 0.625rem 1.25rem;
            border-radius: var(--radius-sm);
            font-family: var(--font-sans);
            font-size: 0.9rem;
            font-weight: 500;
            cursor: pointer;
            border: none;
            transition: all 0.2s;
        }

        .btn-primary {
            background: var(--gradient-primary);
            color: var(--bg-primary);
        }

        .btn-primary:hover {
            opacity: 0.9;
            transform: translateY(-1px);
            box-shadow: var(--shadow-glow);
        }

        .btn-secondary {
            background: var(--bg-tertiary);
            color: var(--text-primary);
            border: 1px solid var(--border-color);
        }

        .btn-secondary:hover {
            background: var(--bg-hover);
            border-color: var(--text-muted);
        }

        .btn-danger {
            background: rgba(239, 68, 68, 0.15);
            color: var(--accent-red);
            border: 1px solid rgba(239, 68, 68, 0.3);
        }

        .btn-danger:hover {
            background: rgba(239, 68, 68, 0.25);
        }

        .btn-sm {
            padding: 0.375rem 0.75rem;
            font-size: 0.8rem;
        }

        .btn-icon {
            width: 36px;
            height: 36px;
            padding: 0;
            justify-content: center;
        }

        /* Forms */
        .form-group {
            margin-bottom: 1.5rem;
        }

        .form-label {
            display: block;
            margin-bottom: 0.5rem;
            font-size: 0.9rem;
            font-weight: 500;
            color: var(--text-secondary);
        }

        .form-input, .form-select {
            width: 100%;
            padding: 0.75rem 1rem;
            background: var(--bg-tertiary);
            border: 1px solid var(--border-color);
            border-radius: var(--radius-sm);
            font-family: var(--font-sans);
            font-size: 0.95rem;
            color: var(--text-primary);
            transition: border-color 0.2s, box-shadow 0.2s;
        }

        .form-input:focus, .form-select:focus {
            outline: none;
            border-color: var(--accent-green);
            box-shadow: 0 0 0 3px var(--accent-green-dim);
        }

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

        .form-select {
            cursor: pointer;
        }

        /* Explicit dark styling for the native dropdown popup. Without
           these the browser uses OS defaults (white-on-white on light
           OS themes, even when the parent <select> says dark). Affects
           every <select> on the site, including the token chip-picker. */
        select option,
        .form-select option {
            background: var(--bg-card);
            color: var(--text-primary);
        }
        select option:checked,
        select option:hover,
        .form-select option:checked,
        .form-select option:hover {
            background: var(--bg-hover);
            color: var(--text-primary);
        }
        select optgroup,
        .form-select optgroup {
            background: var(--bg-secondary);
            color: var(--text-secondary);
            font-weight: 600;
            font-style: normal;
        }

        .form-help {
            margin-top: 0.375rem;
            font-size: 0.8rem;
            color: var(--text-muted);
        }

        /* Messages */
        .messages {
            position: fixed;
            top: 80px;
            right: 2rem;
            z-index: 1000;
            display: flex;
            flex-direction: column;
            gap: 0.5rem;
            max-width: 400px;
        }

        .message {
            padding: 1rem 1.25rem;
            border-radius: var(--radius-md);
            font-size: 0.9rem;
            display: flex;
            align-items: center;
            gap: 0.75rem;
            animation: slideIn 0.3s ease;
            box-shadow: var(--shadow-md);
        }

        @keyframes slideIn {
            from { transform: translateX(100%); opacity: 0; }
            to { transform: translateX(0); opacity: 1; }
        }

        .message-success {
            background: rgba(0, 217, 154, 0.15);
            border: 1px solid rgba(0, 217, 154, 0.3);
            color: var(--accent-green);
        }

        .message-error {
            background: rgba(239, 68, 68, 0.15);
            border: 1px solid rgba(239, 68, 68, 0.3);
            color: var(--accent-red);
        }

        .message-warning {
            background: rgba(245, 158, 11, 0.15);
            border: 1px solid rgba(245, 158, 11, 0.3);
            color: var(--accent-orange);
        }

        /* Empty state */
        .empty-state {
            text-align: center;
            padding: 4rem 2rem;
            color: var(--text-muted);
        }

        .empty-state-icon {
            font-size: 3rem;
            margin-bottom: 1rem;
            opacity: 0.5;
        }

        .empty-state-title {
            font-size: 1.25rem;
            font-weight: 500;
            color: var(--text-secondary);
            margin-bottom: 0.5rem;
        }

        .empty-state-description {
            margin-bottom: 1.5rem;
        }

        /* Chain icon */
        .chain-dot {
            width: 8px;
            height: 8px;
            border-radius: 50%;
            display: inline-block;
            margin-right: 0.5rem;
        }

        .chain-dot.ethereum { background: #627eea; }
        .chain-dot.polygon { background: #8247e5; }
        .chain-dot.arbitrum { background: #28a0f0; }
        .chain-dot.optimism { background: #ff0420; }
        .chain-dot.base { background: #0052ff; }
        .chain-dot.bsc { background: #f0b90b; }
        .chain-dot.solana { background: #9945ff; }
        .chain-dot.bitcoin { background: #f7931a; }

        /* Token row */
        .token-row {
            display: flex;
            align-items: center;
            gap: 0.75rem;
        }

        .token-icon {
            width: 32px;
            height: 32px;
            border-radius: 50%;
            background: var(--bg-tertiary);
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 0.8rem;
            font-weight: 600;
            color: var(--text-secondary);
        }

        .token-info {
            flex: 1;
        }

        .token-symbol {
            font-weight: 500;
        }

        .token-name {
            font-size: 0.8rem;
            color: var(--text-muted);
        }

        /* Actions */
        .actions {
            display: flex;
            gap: 0.5rem;
        }

        /* Wallet address display */
        .wallet-address {
            font-family: var(--font-mono);
            font-size: 0.85rem;
            background: var(--bg-tertiary);
            padding: 0.25rem 0.5rem;
            border-radius: var(--radius-sm);
        }

        /* Grid layouts */
        .grid-2 {
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 1.5rem;
        }

        @media (max-width: 768px) {
            .grid-2 {
                grid-template-columns: 1fr;
            }
            
            .navbar-nav {
                display: none;
            }
            
            .page-header {
                flex-direction: column;
                align-items: flex-start;
                gap: 1rem;
            }
        }

        /* Section divider */
        .section-title {
            font-size: 1.125rem;
            font-weight: 600;
            margin-bottom: 1rem;
            display: flex;
            align-items: center;
            gap: 0.5rem;
        }

        .section-title::after {
            content: '';
            flex: 1;
            height: 1px;
            background: var(--border-color);
            margin-left: 1rem;
        }

        /* Loading spinner */
        .spinner {
            width: 20px;
            height: 20px;
            border: 2px solid var(--border-color);
            border-top-color: var(--accent-green);
            border-radius: 50%;
            animation: spin 0.8s linear infinite;
        }

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

        /* Utility classes */
        .text-muted { color: var(--text-muted); }
        .text-success { color: var(--accent-green); }
        .text-right { text-align: right; }
        .mt-1 { margin-top: 0.5rem; }
        .mt-2 { margin-top: 1rem; }
        .mb-1 { margin-bottom: 0.5rem; }
        .mb-2 { margin-bottom: 1rem; }
        .flex { display: flex; }
        .items-center { align-items: center; }
        .justify-between { justify-content: space-between; }
        .gap-1 { gap: 0.5rem; }
        .gap-2 { gap: 1rem; }

        /* ─── VERSO design system (.ct-*) ─────────────────────── */
        .ct-mark {
            width: 32px; height: 32px;
            background: var(--text); color: var(--bg);
            display: inline-flex; align-items: center; justify-content: center;
            font-family: var(--font-serif); font-weight: 800;
            font-size: 13px; letter-spacing: -0.02em;
            border-radius: 4px; position: relative;
        }
        .ct-mark::after {
            content: ''; position: absolute;
            right: -3px; bottom: -3px;
            width: 8px; height: 8px;
            background: var(--accent); border-radius: 1px;
        }

        .ct-eyebrow {
            font-family: var(--font-mono);
            font-size: 10px; font-weight: 700;
            letter-spacing: 0.16em; text-transform: uppercase;
            color: var(--text-3);
        }
        .ct-h-serif {
            font-family: var(--font-serif);
            font-weight: 600;
            letter-spacing: -0.01em;
            line-height: 1.15;
            color: var(--text);
        }
        .ct-mono { font-family: var(--font-mono); font-feature-settings: 'tnum' on; }
        .ct-num  { font-family: var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }

        .ct-card {
            background: var(--surface);
            border: 1px solid var(--line);
            border-radius: 6px;
            box-shadow: var(--shadow-1);
        }
        .ct-card-flat {
            background: var(--surface);
            border: 1px solid var(--line);
            border-radius: 6px;
        }
        .ct-dotted {
            background-image: radial-gradient(circle, var(--line-2) 1px, transparent 1px);
            background-size: 24px 24px;
            background-position: -2px -2px;
        }
        html.dark .ct-dotted { background-image: radial-gradient(circle, var(--line) 1px, transparent 1px); }

        .ct-btn {
            display: inline-flex; align-items: center; gap: 6px;
            background: var(--surface); color: var(--text);
            border: 1px solid var(--line-2);
            border-radius: 5px;
            padding: 7px 12px;
            font-size: 12.5px; font-weight: 600;
            cursor: pointer;
            transition: all .12s ease;
            white-space: nowrap;
            font-family: var(--font-sans);
            text-decoration: none;
        }
        .ct-btn:hover { background: var(--surface-2); border-color: var(--text-3); color: var(--text); }
        .ct-btn--primary {
            background: var(--text); color: var(--surface);
            border-color: var(--text);
        }
        .ct-btn--primary:hover { background: var(--accent-2); border-color: var(--accent-2); color: #FFF; }
        .ct-btn--ghost { background: transparent; border-color: transparent; color: var(--text-2); }
        .ct-btn--ghost:hover { background: var(--surface-2); color: var(--text); }
        .ct-btn--sm { padding: 4px 8px; font-size: 11.5px; gap: 4px; }
        .ct-btn--icon { padding: 6px; }
        .ct-btn--icon.ct-btn--sm { padding: 4px; }
        .ct-btn--danger { background: var(--neg); color: #FFF; border-color: var(--neg); }
        .ct-btn--danger:hover { background: #8C1F11; border-color: #8C1F11; color: #FFF; }
        .ct-btn--accent { background: var(--accent); color: #FFF; border-color: var(--accent); }
        .ct-btn--accent:hover { background: var(--accent-2); border-color: var(--accent-2); color: #FFF; }

        .ct-input {
            background: var(--surface);
            border: 1px solid var(--line-2);
            border-radius: 5px;
            padding: 7px 10px;
            font-size: 13px;
            color: var(--text);
            outline: none;
            font-family: var(--font-sans);
            transition: border-color .12s, box-shadow .12s;
        }
        .ct-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
        .ct-input--full { width: 100%; box-sizing: border-box; }
        textarea.ct-input { resize: vertical; min-height: 64px; line-height: 1.5; }
        select.ct-input {
            appearance: none;
            background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%),
                              linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
            background-position: calc(100% - 14px) 50%, calc(100% - 9px) 50%;
            background-size: 5px 5px, 5px 5px;
            background-repeat: no-repeat;
            padding-right: 28px;
        }

        .ct-pill {
            display: inline-flex; align-items: center; gap: 5px;
            font-family: var(--font-mono);
            font-size: 10.5px; font-weight: 700;
            letter-spacing: 0.04em; text-transform: uppercase;
            padding: 2px 7px;
            border: 1px solid var(--line-2);
            border-radius: 3px;
            color: var(--text-2);
            background: var(--surface);
            white-space: nowrap;
        }
        .ct-pill--solid { background: var(--text); color: var(--surface); border-color: var(--text); }
        .ct-pill--accent { color: var(--accent-text); border-color: var(--accent-soft); background: var(--accent-soft); }
        .ct-pill--pos    { color: var(--pos);  border-color: var(--pos-soft);  background: var(--pos-soft); }
        .ct-pill--neg    { color: var(--neg);  border-color: var(--neg-soft);  background: var(--neg-soft); }
        .ct-pill--warn   { color: var(--warn); border-color: var(--warn-soft); background: var(--warn-soft); }

        .ct-chip {
            display: inline-flex; align-items: center; gap: 5px;
            background: var(--surface);
            color: var(--text-2);
            border: 1px solid var(--line);
            border-radius: 999px;
            padding: 4px 10px;
            font-size: 11.5px; font-weight: 600;
            cursor: pointer;
            font-family: var(--font-sans);
            transition: all .12s;
        }
        .ct-chip:hover { border-color: var(--text-3); color: var(--text); }
        .ct-chip--active { background: var(--text); color: var(--surface); border-color: var(--text); }

        .ct-chain-dot { display: inline-block; border-radius: 50%; flex-shrink: 0; }

        .ct-table {
            width: 100%;
            border-collapse: collapse;
            font-size: 12.5px;
        }
        .ct-table thead th {
            text-align: left;
            padding: 10px 14px;
            font-family: var(--font-mono);
            font-size: 10px; font-weight: 700;
            letter-spacing: 0.14em; text-transform: uppercase;
            color: var(--text-3);
            background: var(--surface-2);
            border-bottom: 1px solid var(--line);
            white-space: nowrap;
        }
        .ct-table thead th.right { text-align: right; }
        .ct-table tbody td {
            padding: 12px 14px;
            border-bottom: 1px solid var(--line);
            color: var(--text);
            vertical-align: middle;
        }
        .ct-table tbody td.right { text-align: right; }
        .ct-table tbody tr:last-child td { border-bottom: 0; }
        .ct-table tbody tr.clickable { cursor: pointer; transition: background .1s; }
        .ct-table tbody tr.clickable:hover { background: var(--surface-2); }
        .ct-table tbody tr.ct-row-selected { background: var(--accent-soft); }

        .ct-glyph {
            display: inline-flex; align-items: center; justify-content: center;
            border-radius: 50%;
            background: var(--surface-3);
            color: var(--text);
            font-family: var(--font-mono);
            font-size: 10px; font-weight: 800;
            border: 1px solid var(--line);
            letter-spacing: -0.02em;
        }
        .ct-glyph--sq { border-radius: 4px; }

        .ct-spark.up   { color: var(--pos); }
        .ct-spark.down { color: var(--neg); }

        .ct-seg {
            display: inline-flex;
            background: var(--surface-2);
            border: 1px solid var(--line);
            border-radius: 6px;
            padding: 2px;
        }
        .ct-seg__btn {
            background: transparent; border: 0;
            padding: 5px 12px;
            font-size: 11.5px; font-weight: 600;
            letter-spacing: 0.02em;
            color: var(--text-2);
            border-radius: 4px;
            cursor: pointer;
            transition: all .12s;
            white-space: nowrap;
            font-family: var(--font-sans);
        }
        .ct-seg__btn:hover { color: var(--text); }
        .ct-seg__btn.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,0.06); }
        html.dark .ct-seg__btn.active { background: var(--surface-3); }

        .ct-toggle {
            position: relative;
            width: 32px; height: 18px;
            background: var(--line-2);
            border-radius: 999px;
            cursor: pointer;
            transition: background .15s;
            flex: 0 0 auto;
        }
        .ct-toggle::after {
            content: '';
            position: absolute;
            left: 2px; top: 2px;
            width: 14px; height: 14px;
            border-radius: 50%;
            background: var(--surface);
            transition: transform .15s;
            box-shadow: 0 1px 2px rgba(0,0,0,0.18);
        }
        .ct-toggle.on { background: var(--text); }
        .ct-toggle.on::after { transform: translateX(14px); }

        .ct-spinner {
            width: 22px; height: 22px;
            border-radius: 50%;
            border: 2px solid var(--line-2);
            border-top-color: var(--accent);
            animation: ct-spin 0.8s linear infinite;
        }
        @keyframes ct-spin { to { transform: rotate(360deg); } }
        @keyframes ct-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

        .ct-divider { height: 1px; background: var(--line); margin: 16px 0; }
        .ct-link {
            color: var(--accent-text);
            text-decoration: none;
            border-bottom: 1px dashed currentColor;
            cursor: pointer;
        }
        .ct-link:hover { color: var(--accent); }

        .ct-avatar {
            width: 28px; height: 28px;
            border-radius: 50%;
            background: var(--surface-3);
            color: var(--text);
            display: inline-flex; align-items: center; justify-content: center;
            font-size: 11px; font-weight: 700;
            letter-spacing: 0.02em;
            flex: 0 0 auto;
            border: 1px solid var(--line);
        }

        /* Modal — used by sync/justify modals via partial template */
        .ct-modal-overlay {
            position: fixed; inset: 0;
            background: rgba(20, 18, 14, 0.45);
            backdrop-filter: blur(2px);
            display: flex; align-items: center; justify-content: center;
            z-index: 100;
            padding: 32px 24px;
            animation: ct-fade-in .12s ease-out;
        }
        html.dark .ct-modal-overlay { background: rgba(0, 0, 0, 0.65); }
        .ct-modal {
            background: var(--surface);
            border: 1px solid var(--line);
            border-radius: 8px;
            box-shadow: 0 24px 60px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(0, 0, 0, 0.08);
            display: flex; flex-direction: column;
            max-height: calc(100vh - 64px);
            animation: ct-modal-in .14s ease-out;
        }
        @keyframes ct-fade-in { from { opacity: 0; } to { opacity: 1; } }
        @keyframes ct-modal-in { from { opacity: 0; transform: translateY(8px) scale(0.985); } to { opacity: 1; transform: none; } }
        .ct-modal__header {
            display: flex; align-items: flex-start; gap: 12px;
            padding: 18px 20px 14px;
            border-bottom: 1px solid var(--line);
        }
        .ct-modal__body { padding: 18px 20px; overflow-y: auto; flex: 1; }
        .ct-modal__footer {
            display: flex; justify-content: flex-end; gap: 8px;
            padding: 12px 20px;
            border-top: 1px solid var(--line);
            background: var(--surface-2);
        }

        /* Hero band responsive — used by Dashboard & Wallet detail */
        .ct-hero-row { grid-template-columns: 1.5fr 1fr 1fr 1fr; }
        .ct-hero-value-num { font-size: 44px; }
        @media (max-width: 1180px) {
            .ct-hero-row { grid-template-columns: 1fr 1fr 1fr; }
            .ct-hero-value-num { font-size: 40px; }
        }
        @media (max-width: 720px) {
            .ct-hero-row { grid-template-columns: 1fr; }
            .ct-hero-value-num { font-size: 32px; }
        }

        /* Make legacy .card softer to match the paper aesthetic */
        .card::before { display: none; }
        .stat-value.large { background: none; -webkit-text-fill-color: var(--text); color: var(--text); }

        /* ─── Application shell — top bar + sidebar ─────────────────── */
        .ct-topbar {
            position: sticky; top: 0; z-index: 30;
            background: var(--surface);
            border-bottom: 1px solid var(--line);
            height: 60px;
            display: flex; align-items: center;
            padding: 0 24px; gap: 24px;
        }
        .ct-topbar__brand {
            display: flex; align-items: center; gap: 10px;
            text-decoration: none; color: var(--text);
            white-space: nowrap;
        }
        .ct-topbar__brand-name {
            font-weight: 800; font-size: 14px; letter-spacing: -0.01em;
        }
        .ct-topbar__brand-tag {
            font-family: var(--font-mono);
            font-size: 9px; font-weight: 700;
            letter-spacing: 0.16em; text-transform: uppercase;
            color: var(--text-3); margin-top: 3px;
        }
        .ct-topbar__search {
            flex: 1; max-width: 420px; min-width: 0;
            position: relative;
        }
        .ct-topbar__search-icon {
            position: absolute; left: 12px; top: 50%;
            transform: translateY(-50%);
            color: var(--text-3); display: flex;
            pointer-events: none;
        }
        .ct-topbar__search input {
            width: 100%;
            padding: 7px 10px 7px 36px;
            background: var(--surface-2);
            border: 1px solid var(--line-2);
            border-radius: 5px;
            font-size: 13px;
            color: var(--text);
            outline: none;
            font-family: var(--font-sans);
            transition: border-color .12s, box-shadow .12s;
        }
        .ct-topbar__search input:focus {
            border-color: var(--accent);
            box-shadow: 0 0 0 3px var(--accent-soft);
        }
        .ct-topbar__kbd {
            position: absolute; right: 8px; top: 50%;
            transform: translateY(-50%);
            font-family: var(--font-mono);
            font-size: 10px;
            padding: 2px 6px;
            border: 1px solid var(--line-2); border-radius: 4px;
            color: var(--text-3); background: var(--surface);
            pointer-events: none;
        }
        .ct-topbar__right {
            display: flex; align-items: center; gap: 8px;
            margin-left: auto;
        }
        .ct-topbar__user {
            display: flex; align-items: center; gap: 10px;
            padding: 2px 4px 2px 2px;
        }
        .ct-topbar__user-avatar {
            width: 30px; height: 30px;
            border-radius: 6px;
            background: var(--surface-3);
            border: 1px solid var(--line);
            display: flex; align-items: center; justify-content: center;
            font-weight: 800; font-size: 11px;
        }
        .ct-topbar__user-meta {
            display: flex; flex-direction: column; line-height: 1.1;
            white-space: nowrap;
        }
        .ct-topbar__user-name { font-size: 12px; font-weight: 700; color: var(--text); }
        .ct-topbar__user-role {
            font-size: 10px; color: var(--text-3);
            text-transform: uppercase; letter-spacing: 0.1em; font-weight: 700;
        }

        .ct-shell {
            display: flex; align-items: stretch;
            min-height: calc(100vh - 60px);
        }
        .ct-sidebar {
            width: 224px; flex: 0 0 224px;
            border-right: 1px solid var(--line);
            background: var(--bg);
            padding: 20px 14px;
            display: flex; flex-direction: column; gap: 18px;
            position: sticky; top: 60px;
            height: calc(100vh - 60px);
            overflow-y: auto;
        }
        .ct-sidebar__group { display: flex; flex-direction: column; gap: 2px; }
        .ct-sidebar__group-title {
            font-family: var(--font-mono);
            font-size: 10px; font-weight: 700;
            letter-spacing: 0.16em; text-transform: uppercase;
            color: var(--text-3);
            padding: 0 12px; margin-bottom: 6px;
        }
        .ct-side-link {
            display: flex; align-items: center; gap: 10px;
            padding: 8px 12px;
            border-radius: 5px;
            font-size: 13px; font-weight: 600;
            color: var(--text-2);
            cursor: pointer;
            text-decoration: none;
            transition: all .12s;
            user-select: none;
        }
        .ct-side-link:hover { background: var(--surface-2); color: var(--text); }
        .ct-side-link.active {
            background: var(--text);
            color: var(--surface);
        }
        .ct-side-link.active svg { color: var(--accent); }

        .ct-sidebar__footer {
            margin-top: auto;
        }

        .ct-main {
            flex: 1;
            min-width: 0;
            padding: 28px 32px 80px;
            background: var(--bg);
        }

        /* Hide legacy navbar styles — superseded by .ct-topbar */
        .navbar { display: none !important; }
        .main-content { display: contents; }

        /* Mobile / narrow: collapse sidebar */
        @media (max-width: 880px) {
            .ct-sidebar { display: none; }
            .ct-main { padding: 20px 16px 60px; }
        }

        /* Theme toggle pulse for live indicator */
        .ct-live-dot {
            width: 6px; height: 6px; border-radius: 50%;
            background: var(--pos);
            box-shadow: 0 0 0 3px rgba(21,102,62,0.18);
        }

/* page loader */
#page-loader {
            position: fixed;
            inset: 0;
            background: var(--surface, #FFFFFF);
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 99999;
            transition: opacity 180ms ease;
        }
        #page-loader.is-hidden { opacity: 0; pointer-events: none; }
        .page-loader__inner {
            width: 280px;
            max-width: 60%;
            text-align: center;
        }
        .page-loader__mark {
            display: flex;
            justify-content: center;
            margin-bottom: 14px;
        }
        .page-loader__brand {
            font-family: var(--font-serif, Georgia, serif);
            font-size: 22px;
            font-weight: 700;
            letter-spacing: 0.10em;
            margin-bottom: 18px;
            color: var(--text, #1B1816);
        }
        .page-loader__bar {
            height: 4px;
            background: var(--line, #E2DBCB);
            border-radius: 2px;
            overflow: hidden;
        }
        .page-loader__fill {
            height: 100%;
            width: 0%;
            background: var(--accent, #C8102E);
            transition: width 120ms linear;
        }
        .page-loader__pct {
            margin-top: 10px;
            font-size: 11px;
            font-family: var(--font-mono, monospace);
            color: var(--text-3, #807866);
            letter-spacing: 0.04em;
        }
