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

html,
body {
    margin: 0;
    min-height: 100%;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: #0f1218;
    color: #e8eaed;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1.25rem;
    background: #1a1f28;
    border-bottom: 1px solid #2d3544;
}

.topbar h1 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 600;
}

.topbar nav {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.commission-banner {
    padding: 0.85rem 1.25rem;
    background: linear-gradient(90deg, rgba(255, 180, 50, 0.12), rgba(255, 180, 50, 0.04));
    border-bottom: 1px solid rgba(255, 180, 50, 0.25);
}

.commission-banner p {
    margin: 0;
    max-width: 960px;
    font-size: 0.9rem;
    line-height: 1.5;
    color: #c8cdd6;
}

.commission-banner strong {
    color: #f0b429;
}

.announcement-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
}

.announcement-overlay[hidden] {
    display: none;
}

.announcement {
    width: min(520px, 100%);
    max-height: min(90vh, 640px);
    overflow-y: auto;
    background: #171c24;
    border: 1px solid #3d4f6f;
    border-radius: 14px;
    padding: 1.35rem 1.5rem 1.5rem;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

.announcement-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.announcement-head h2 {
    margin: 0;
    font-size: 1.15rem;
    line-height: 1.35;
}

.btn-close {
    flex-shrink: 0;
    width: 2rem;
    height: 2rem;
    border: none;
    border-radius: 8px;
    background: #2d3544;
    color: #e8eaed;
    font-size: 1.35rem;
    line-height: 1;
    cursor: pointer;
}

.btn-close:hover {
    background: #3d4656;
}

.how-steps {
    margin: 0 0 1rem;
    padding-left: 1.25rem;
    line-height: 1.55;
    font-size: 0.92rem;
    color: #c9cdd3;
}

.how-steps li {
    margin-bottom: 0.65rem;
}

.how-steps strong {
    color: #e8eaed;
}

.announcement-note {
    margin: 0 0 1.15rem;
    padding: 0.75rem 0.85rem;
    background: rgba(37, 99, 235, 0.12);
    border-left: 3px solid #2563eb;
    border-radius: 0 8px 8px 0;
    font-size: 0.85rem;
    color: #9aa0a6;
}

.announcement .btn.primary {
    width: 100%;
}

.topbar a {
    color: #8ab4ff;
    text-decoration: none;
    font-size: 0.9rem;
}

.topbar a:hover {
    text-decoration: underline;
}

.layout {
    max-width: 960px;
    margin: 0 auto;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.status-stack {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
    min-width: 0;
}

.status-stack .status-box {
    width: 100%;
    min-height: 100px;
}

.status-stack .card-head {
    margin-bottom: 0.65rem;
}

.status-stack .card-head h2 {
    font-size: 0.95rem;
}

.send-footer {
    display: grid;
    grid-template-columns: minmax(180px, auto) minmax(0, 1fr);
    gap: 1.25rem;
    align-items: start;
    margin-top: 0.5rem;
    padding-top: 1rem;
    border-top: 1px solid #2d3544;
}

.send-footer-main {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    align-items: stretch;
}

.send-footer-main .btn.primary {
    width: 100%;
    white-space: nowrap;
}

.send-footer .tx-status {
    margin: 0;
}

@media (max-width: 720px) {
    .send-footer {
        grid-template-columns: 1fr;
    }

    .send-footer-main {
        order: 1;
    }

    .status-stack {
        order: 2;
    }
}

.status-box.status-success {
    border-color: #238636;
    box-shadow: 0 0 0 1px rgba(35, 134, 54, 0.25);
}

.status-box.status-error {
    border-color: #da3633;
    box-shadow: 0 0 0 1px rgba(218, 54, 51, 0.25);
}

.status-box.status-processing {
    border-color: #2563eb;
}

.status-body {
    font-size: 0.9rem;
    color: #c9d1d9;
}

.status-placeholder {
    margin: 0;
    color: #9aa0a6;
}

.status-message {
    margin: 0 0 0.75rem;
}

.tx-id-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.tx-id-list li {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding: 0.55rem 0.65rem;
    background: #0f1218;
    border-radius: 8px;
    border: 1px solid #2d3544;
}

.tx-id-list code {
    font-size: 0.78rem;
    word-break: break-all;
    color: #8ab4ff;
}

.tx-id-list a {
    color: #58a6ff;
    font-size: 0.8rem;
    text-decoration: none;
}

.tx-id-list a:hover {
    text-decoration: underline;
}

.support-link {
    display: inline-block;
    margin-top: 0.75rem;
    color: #8ab4ff;
    font-weight: 600;
    text-decoration: none;
}

.support-link:hover {
    text-decoration: underline;
}

.relay-retry-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.85rem;
    padding: 0.45rem 1rem;
    background: #92400e;
    border: 1px solid #d97706;
    color: #fde68a;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
}

.relay-retry-btn:hover:not(:disabled) {
    background: #b45309;
}

.relay-retry-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.relay-retry-btn .spin {
    display: inline-block;
    animation: spin 1s linear infinite;
}

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

.orders-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.orders-list li {
    padding: 0.55rem 0.65rem;
    background: #0f1218;
    border-radius: 8px;
    border: 1px solid #2d3544;
}

.order-row-top {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    font-size: 0.85rem;
}

.order-status {
    font-size: 0.75rem;
    padding: 0.15rem 0.45rem;
    border-radius: 999px;
    background: #2d3544;
    color: #fbbf24;
}

.order-status.done {
    background: rgba(35, 134, 54, 0.2);
    color: #7ee787;
}

.order-status.failed {
    background: rgba(218, 54, 51, 0.2);
    color: #ff8b8b;
}

.order-status.running {
    background: rgba(59, 130, 246, 0.2);
    color: #93c5fd;
    animation: pulse-badge 1.4s ease-in-out infinite;
}

@keyframes pulse-badge {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.5; }
}

.relay-spinner {
    color: #93c5fd;
    font-size: 0.75rem;
}

.order-error {
    color: #ff8b8b;
    font-size: 0.78rem;
}

.order-meta {
    margin: 0.35rem 0 0;
    font-size: 0.78rem;
    color: #9aa0a6;
    word-break: break-all;
}

.card {
    background: #171c24;
    border: 1px solid #2d3544;
    border-radius: 12px;
    padding: 1.25rem;
}

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.card-head h2 {
    margin: 0;
    font-size: 1.05rem;
}

.badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.55rem;
    border-radius: 999px;
    background: #2d3544;
    color: #9aa0a6;
}

.badge.connected {
    background: #1e3a2f;
    color: #6dd58c;
}

.hint {
    color: #9aa0a6;
    font-size: 0.85rem;
    margin: 0;
}

.wallet-connect p:first-child {
    margin-top: 0;
}

.btn {
    border: 1px solid #4a5568;
    background: #2d3544;
    color: #e8eaed;
    border-radius: 8px;
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
    cursor: pointer;
}

.btn:hover:not(:disabled) {
    background: #3d4656;
}

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.btn.primary {
    background: #2563eb;
    border-color: #2563eb;
}

.btn.primary:hover:not(:disabled) {
    background: #1d4ed8;
}

.btn.ghost {
    background: transparent;
}

.btn.sm {
    padding: 0.35rem 0.65rem;
    font-size: 0.8rem;
}

#wallet-error {
    color: #f87171;
    margin-top: 0.75rem;
}

.address-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.address-row .label {
    color: #9aa0a6;
    font-size: 0.85rem;
}

.address-row code {
    font-size: 0.85rem;
    background: #0f1218;
    padding: 0.35rem 0.5rem;
    border-radius: 6px;
    word-break: break-all;
}

.balances {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.wallet-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

#btn-connect-btc.connected {
    opacity: 0.85;
}

.balance-tile {
    background: #0f1218;
    border: 1px solid #2d3544;
    border-radius: 10px;
    padding: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.balance-tile .coin {
    font-size: 0.8rem;
    color: #9aa0a6;
}

.balance-tile .coin small {
    font-size: 0.7rem;
}

.balance-tile strong {
    font-size: 1.1rem;
}

.balance-tile .usd {
    font-size: 0.8rem;
    color: #6dd58c;
}

.disabled-block {
    opacity: 0.55;
    pointer-events: none;
    user-select: none;
}

.disabled-block.enabled {
    opacity: 1;
    pointer-events: auto;
    user-select: auto;
}

fieldset {
    border: 1px solid #2d3544;
    border-radius: 10px;
    padding: 1rem;
    margin: 0 0 1rem;
}

legend {
    padding: 0 0.35rem;
    font-size: 0.85rem;
    color: #9aa0a6;
}

.row-3 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.75rem;
}

label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.8rem;
    color: #9aa0a6;
}

input,
select {
    padding: 0.55rem 0.65rem;
    border: 1px solid #4a5568;
    border-radius: 8px;
    background: #0f1218;
    color: #e8eaed;
    font-size: 0.9rem;
}

input:focus,
select:focus {
    outline: 2px solid #2563eb;
    outline-offset: 1px;
}

.pct-summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
}

.pct-ok {
    color: #6dd58c;
    font-size: 0.8rem;
}

.pct-warn {
    color: #fbbf24;
    margin-left: 0.5rem;
}

.recipient-grid {
    display: grid;
    grid-template-columns: 2rem 1fr 7rem 4.5rem 6rem 6rem;
    gap: 0.5rem;
    align-items: center;
    font-size: 0.85rem;
}

.recipient-grid.head {
    color: #9aa0a6;
    font-size: 0.75rem;
    margin-bottom: 0.35rem;
    padding: 0 0.15rem;
}

.recipient-grid.row {
    margin-bottom: 0.5rem;
}

.recipient-grid.row.row-active {
    background: rgba(37, 99, 235, 0.06);
    border-radius: 8px;
    padding: 0.15rem 0;
}

.recipient-grid.row.row-incomplete {
    outline: 1px dashed #fbbf24;
    border-radius: 8px;
}

.row-num {
    color: #6b7280;
    text-align: center;
}

.send-amt,
.recv-amt {
    font-size: 0.8rem;
    color: #8ab4ff;
    word-break: break-all;
}

.rates-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.8rem;
    color: #9aa0a6;
    margin-bottom: 1rem;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
}

.preview-panel {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #2d3544;
}

.preview-panel h3 {
    margin: 0 0 0.5rem;
    font-size: 0.95rem;
}

.preview-panel pre {
    margin: 0;
    padding: 0.75rem;
    background: #0f1218;
    border-radius: 8px;
    font-size: 0.75rem;
    overflow-x: auto;
    white-space: pre-wrap;
}

.split-pool-note,
.btc-treasury-note {
    margin: 0.75rem 0 0;
    font-size: 0.85rem;
    color: #9aa3b2;
}

.split-pool-note strong {
    color: #d4dce8;
}

.btc-treasury-note code {
    font-size: 0.75rem;
    word-break: break-all;
}

.tx-status {
    margin: 0.75rem 0 0;
    font-size: 0.9rem;
    color: #7ee787;
}

.tx-status.error {
    color: #ff8b8b;
}

#btc-account-hint {
    display: block;
    margin-top: 0.35rem;
    font-size: 0.72rem;
    word-break: break-all;
    color: #9aa3b2;
}

.btc-address-field {
    display: block;
    margin-top: 0.65rem;
}

.btc-address-field .field-label {
    display: block;
    font-size: 0.72rem;
    color: #9aa3b2;
    margin-bottom: 0.35rem;
}

.btc-address-row {
    display: flex;
    gap: 0.35rem;
}

.btc-address-row input {
    flex: 1;
    min-width: 0;
    padding: 0.4rem 0.5rem;
    border-radius: 6px;
    border: 1px solid #2d3544;
    background: #0f1218;
    color: #e8eaed;
    font-size: 0.75rem;
}

/* ── Session history card ──────────────────────────────────────────────── */
.history-card {
    margin: 0 auto 2.5rem;
    max-width: 960px;
    width: calc(100% - 2.5rem);
}

.history-card .card-head {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.history-card .card-head h2 { flex: 1; }

/* Individual order row (collapsible) */
.history-order {
    border: 1px solid #2d3544;
    border-radius: 8px;
    margin-bottom: 0.55rem;
    background: #151a23;
    overflow: hidden;
}

.history-order-head {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 0.85rem;
    cursor: pointer;
    list-style: none;
    user-select: none;
    flex-wrap: wrap;
}

.history-order-head::-webkit-details-marker { display: none; }

.history-order-head::before {
    content: "▶";
    font-size: 0.6rem;
    color: #6b7280;
    transition: transform 0.15s;
    flex-shrink: 0;
}
.history-order[open] > .history-order-head::before { transform: rotate(90deg); }

.history-date {
    font-size: 0.8rem;
    color: #9ca3af;
    min-width: 7rem;
}

.history-amount {
    font-weight: 600;
    font-size: 0.9rem;
    color: #e8eaed;
    min-width: 6rem;
}

.history-uuid {
    font-size: 0.72rem;
    color: #6b7280;
    margin-left: auto;
    font-family: monospace;
}

.history-order-body {
    padding: 0.6rem 0.85rem 0.75rem;
    border-top: 1px solid #2d3544;
}

.history-meta {
    margin: 0.2rem 0;
    font-size: 0.82rem;
    color: #9ca3af;
}

.history-meta .lbl {
    color: #6b7280;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-right: 0.25rem;
}

.history-recipients {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0 0;
}

.history-recipients li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0;
    border-top: 1px solid #1f2635;
    font-size: 0.82rem;
    flex-wrap: wrap;
}

.hist-addr {
    font-size: 0.75rem;
    color: #60a5fa;
    min-width: 8rem;
}

.hist-pct {
    color: #9ca3af;
    min-width: 2.5rem;
    text-align: right;
}

.hist-amt {
    color: #d1d5db;
    flex: 1;
}

/* Nested step details */
.history-substeps {
    margin-top: 0.5rem;
    border: 1px solid #2d3544;
    border-radius: 6px;
    overflow: hidden;
}

.history-substeps > summary {
    padding: 0.35rem 0.65rem;
    cursor: pointer;
    font-size: 0.8rem;
    color: #9ca3af;
    background: #0f1218;
    list-style: none;
}
.history-substeps > summary::-webkit-details-marker { display: none; }
.history-substeps[open] > summary { border-bottom: 1px solid #2d3544; }

.history-substeps .orders-list {
    margin: 0;
    padding: 0.25rem 0;
}

/* ── End session history ───────────────────────────────────────────────── */

@media (max-width: 720px) {
    .recipient-grid {
        grid-template-columns: 1fr;
        gap: 0.35rem;
        padding: 0.75rem;
        background: #0f1218;
        border-radius: 8px;
        margin-bottom: 0.75rem;
    }

    .recipient-grid.head {
        display: none;
    }

    .row-num::before {
        content: "Recipient ";
    }
}
