/* ============================================================
   Zendexu 轻汇 统一设计系统 · Console
   方向：电子台账（ledger）— 纸白、墨色、发丝线、Tether 青绿
   原则：数字与哈希一律等宽 tabular；状态 = 圆点 + 文字；
        一种卡片、一种按钮体系、一种页头。
   ============================================================ */

:root {
    /* 基底 */
    --paper: #f6f7f5;          /* 页面底色：冷矿物白 */
    --surface: #ffffff;        /* 卡片 */
    --surface-2: #fafbfa;      /* 内嵌面板 */
    --ink: #15211c;            /* 主文字 */
    --ink-2: #5c6964;          /* 次要文字 */
    --ink-3: #93a09a;          /* 弱文字 */
    --line: #e3e8e5;           /* 发丝线 */
    --line-strong: #cbd3cf;

    /* 唯一品牌色：Tether 青绿（加深以保证白底对比度） */
    --teal: #0e9373;
    --teal-deep: #0a6e57;
    --teal-wash: #e9f5f0;
    --teal-line: #bfe2d6;

    /* 功能色（统一 wash + ink 双色制） */
    --ok: #0e9373;     --ok-wash: #e9f5f0;   --ok-line: #bfe2d6;
    --warn: #9a6700;   --warn-wash: #fdf3df; --warn-line: #efd9a8;
    --bad: #b3261e;    --bad-wash: #fceceb;  --bad-line: #f1c4c1;
    --info: #15618f;   --info-wash: #eaf2f8; --info-line: #c4dcec;
    --idle: #5c6964;   --idle-wash: #f0f2f1; --idle-line: #dbe0dd;

    --radius: 10px;
    --radius-sm: 7px;
    --shadow: 0 1px 2px rgba(21, 33, 28, 0.05);
    --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", Roboto, sans-serif;
    --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas,
                 "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { transition: none !important; animation: none !important; }
}

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-ui);
    font-size: 14px;
    line-height: 1.65;
    min-height: 100vh;
}

a { color: var(--teal-deep); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

:focus-visible {
    outline: 2px solid var(--teal);
    outline-offset: 2px;
    border-radius: 4px;
}

/* ---------- 顶栏 ---------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 0 24px;
    min-height: 56px;
    background: rgba(255, 255, 255, 0.92);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(8px);
}
.brand {
    display: inline-flex;
    align-items: center;
    font-weight: 750;
    font-size: 17px;
    letter-spacing: -0.3px;
    color: var(--ink);
    white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand span { color: var(--teal-deep); }
.brand::before {
    content: "";
    width: 10px;
    height: 10px;
    border-radius: 3px;
    background: var(--teal);
    margin-right: 9px;
}
nav {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 2px;
    flex-wrap: wrap;
    padding: 8px 0;
}
nav a {
    color: var(--ink-2);
    font-size: 13px;
    padding: 5px 10px;
    border-radius: 6px;
}
nav a:hover {
    color: var(--ink);
    background: var(--idle-wash);
    text-decoration: none;
}
.nav-sep {
    width: 1px;
    height: 16px;
    background: var(--line-strong);
    margin: 0 6px;
    flex: none;
}
.nav-user {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--teal-deep);
    background: var(--teal-wash);
    border: 1px solid var(--teal-line);
    border-radius: 999px;
    padding: 3px 10px;
    margin-left: 8px;
    white-space: nowrap;
}

/* ---------- 布局 ---------- */
.container {
    width: min(1180px, calc(100% - 40px));
    margin: 0 auto;
    padding: 28px 0 64px;
}
.footer {
    color: var(--ink-3);
    text-align: center;
    padding: 24px 20px 36px;
    border-top: 1px solid var(--line);
    font-size: 12px;
    background: var(--surface);
}
.narrow { max-width: 720px; margin-left: auto; margin-right: auto; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.actions, .report-filter-actions {
    display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 18px;
}

/* ---------- 文字 ---------- */
h1, h2, h3 { margin: 0 0 10px; line-height: 1.25; letter-spacing: -0.3px; font-weight: 700; }
h1 { font-size: 26px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p { margin: 0 0 10px; }
.muted { color: var(--ink-2); }
.small-muted, small { color: var(--ink-3); font-size: 12.5px; }
.success-text { color: var(--ok); font-weight: 650; }
.danger-text { color: var(--bad); font-weight: 650; }
.time-nowrap { white-space: nowrap; font-family: var(--font-mono); font-size: 12.5px; }

/* ---------- 页头（原 hero 大卡片统一收敛为页头条） ---------- */
.hero, .hero-card, .pay-hero {
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--line-strong);
    border-radius: 0;
    padding: 6px 0 22px;
    margin-bottom: 22px;
}
.hero h1, .hero-card h1 { margin-top: 6px; }
.hero .actions { margin-top: 16px; }
.hero p.muted, .hero-card p.muted { max-width: 64ch; }

/* ---------- 卡片 ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}
.card > h2:first-child, .card .actions:first-child h2 { margin-bottom: 14px; }
.inner-card, .credential-box, .choice-card, .energy-status-card,
.energy-payment-grid > div, .copy-grid > div, .summary-grid > div,
.metric, .check-item, .callback-url-box {
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
}
.inner-card { padding: 16px; margin-top: 14px; }
.choice-card { padding: 16px; }
.choice-card.accent-choice { border-color: var(--teal-line); background: var(--teal-wash); }

/* ---------- 按钮（.button/.btn/button 全部统一） ---------- */
.button, .btn, button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 9px 15px;
    border-radius: 8px;
    border: 1px solid var(--teal-deep);
    background: var(--teal);
    color: #fff;
    cursor: pointer;
    font-family: var(--font-ui);
    font-size: 13.5px;
    font-weight: 650;
    line-height: 1.2;
    transition: background .15s, border-color .15s, color .15s;
}
.button:hover, .btn:hover, button:hover {
    background: var(--teal-deep);
    color: #fff;
    text-decoration: none;
}
.button.secondary, .btn.secondary, button.secondary {
    background: var(--surface);
    border-color: var(--line-strong);
    color: var(--ink);
}
.button.secondary:hover, .btn.secondary:hover, button.secondary:hover {
    background: var(--idle-wash);
    border-color: var(--ink-3);
    color: var(--ink);
}
.button.danger, .btn.danger, button.danger {
    background: var(--surface);
    border-color: var(--bad-line);
    color: var(--bad);
}
.button.danger:hover, .btn.danger:hover, button.danger:hover {
    background: var(--bad);
    border-color: var(--bad);
    color: #fff;
}
.button.small, .btn.small, button.small { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
button:disabled, .button:disabled {
    opacity: .5; cursor: not-allowed;
    background: var(--idle-wash); color: var(--ink-3); border-color: var(--line);
}

/* ---------- 表单 ---------- */
.form, .stack-form { display: grid; gap: 14px; }
.form.inline { grid-template-columns: 1fr auto; align-items: end; }
label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink); }
input, select, textarea {
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--line-strong);
    background: var(--surface);
    color: var(--ink);
    font-family: var(--font-ui);
    font-size: 14px;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
input[name="txid"], input[name="amount_usdt"] { font-family: var(--font-mono); }
input:focus, select:focus, textarea:focus {
    border-color: var(--teal);
    box-shadow: 0 0 0 3px var(--teal-wash);
}
input::placeholder { color: var(--ink-3); }
hr { width: 100%; border: 0; border-top: 1px solid var(--line); margin: 4px 0; }

/* ---------- 通知条 ---------- */
.notice, .alert {
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    background: var(--surface-2);
    color: var(--ink-2);
}
.notice.success, .alert.success { border-color: var(--ok-line); background: var(--ok-wash); color: var(--teal-deep); }
.notice.warning, .warning-card { border-color: var(--warn-line); background: var(--warn-wash); color: var(--warn); }
.notice.danger, .error { border-color: var(--bad-line); background: var(--bad-wash); color: var(--bad); }
.error { padding: 20px; border-radius: var(--radius); }
.error h1 { color: var(--bad); }

/* ---------- 状态：统一“圆点 + 文字”语法 ---------- */
.tag, .badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    padding: 2px 9px 2px 7px;
    border-radius: 999px;
    border: 1px solid var(--idle-line);
    background: var(--idle-wash);
    color: var(--idle);
    font-family: var(--font-mono);
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: .01em;
    white-space: nowrap;
}
.tag::before, .badge::before {
    content: "";
    flex: none;
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: currentColor;
}

/* 成功族 */
.status-paid, .status-ok, .status-success, .status-succeeded, .status-completed,
.status-running, .status-matched, .status-leased, .status-real, .status-active,
.status-notified, .status-fee_paid, .status-leasing, .status-accepted, .success.tag {
    background: var(--ok-wash); color: var(--teal-deep); border-color: var(--ok-line);
}
/* 进行中族 */
.status-pending, .status-pending_fee, .status-energy_leased, .status-dry_run,
.status-created, .status-generic_energy_provider, .status-simulated {
    background: var(--info-wash); color: var(--info); border-color: var(--info-line);
}
/* 警告族 */
.status-expired, .status-warn, .status-warning, .status-mismatch, .status-partial_failed,
.status-skipped, .status-no_transfer, .status-no_candidate, .status-all_txid_used,
.status-txid_used, .status-duplicate_ignored {
    background: var(--warn-wash); color: var(--warn); border-color: var(--warn-line);
}
/* 失败族 */
.status-failed, .status-bad, .status-error, .status-address_error, .status-energy_failed,
.status-lease_failed, .status-order_status_invalid, .status-blocked {
    background: var(--bad-wash); color: var(--bad); border-color: var(--bad-line);
}
/* 中性族 */
.status-inactive, .status-not_configured, .status-unknown {
    background: var(--idle-wash); color: var(--idle); border-color: var(--idle-line);
}

/* ---------- 指标格 ---------- */
.metric-grid, .metrics, .summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(158px, 1fr));
    gap: 10px;
    margin-top: 16px;
}
.metric, .summary-grid > div { padding: 13px 14px; }
.metric span, .summary-grid strong {
    display: block; color: var(--ink-3); font-size: 12px; font-weight: 500; margin-bottom: 4px;
}
.metric strong, .summary-grid span {
    display: block;
    color: var(--ink);
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-size: 19px;
    font-weight: 650;
    letter-spacing: -0.3px;
    word-break: break-word;
}
.metric small { display: block; margin-top: 3px; color: var(--ink-3); font-family: var(--font-mono); }

/* ---------- 表格：台账风 ---------- */
.table-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
th, td {
    padding: 9px 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
}
th {
    color: var(--ink-3);
    font-size: 11px;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: .06em;
    white-space: nowrap;
    border-bottom-color: var(--line-strong);
}
td { color: var(--ink); font-size: 13px; font-variant-numeric: tabular-nums; }
tbody tr:hover td { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
.wide-table, .report-table, .callback-table, .risk-events-table { min-width: 1040px; }

/* ---------- 代码与哈希 ---------- */
code, pre { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
code {
    display: inline-block;
    max-width: 100%;
    padding: 1px 6px;
    border-radius: 5px;
    background: var(--idle-wash);
    border: 1px solid var(--line);
    color: var(--ink);
    font-size: 12.5px;
    word-break: break-all;
}
pre, .code-block {
    overflow-x: auto;
    padding: 16px;
    border-radius: var(--radius-sm);
    background: #112520;            /* 全站唯一深色面：代码块 */
    border: 1px solid #1d3a32;
    color: #d7e7e0;
    font-size: 12.5px;
    line-height: 1.7;
}
.code-block pre { margin: 0; padding: 0; border: 0; background: transparent; }
.code-block code, pre code { background: transparent; border: 0; padding: 0; color: inherit; font-size: inherit; }
.token, .mono-ellipsis {
    display: inline-block;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
}

/* ---------- 收银台（pay.html） ---------- */
.pay-hero { text-align: center; border-bottom: 1px solid var(--line-strong); }
.pay-amount {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-size: clamp(38px, 7vw, 56px);
    font-weight: 700;
    letter-spacing: -1.5px;
    color: var(--ink);
    margin: 8px 0 4px;
    line-height: 1.1;
}
.pay-amount span:last-child { font-size: 16px; color: var(--ink-3); letter-spacing: 0; font-weight: 600; }
.expiry-box {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 5px 13px;
    border-radius: 999px;
    border: 1px solid var(--warn-line);
    background: var(--warn-wash);
    color: var(--warn);
    font-size: 13px;
}
.expiry-box strong { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.auto-refresh {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 7px 13px;
    margin-bottom: 14px;
    border-radius: 999px;
    border: 1px solid var(--info-line);
    background: var(--info-wash);
    color: var(--info);
    font-size: 12.5px;
}
.auto-refresh::before {
    content: "";
    width: 7px; height: 7px; border-radius: 999px;
    background: currentColor;
    animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .35; } }

.status-steps, .flow-steps, .energy-checklist {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 8px;
    margin-top: 18px;
    text-align: left;
}
.step, .flow-steps div, .energy-checklist > div {
    padding: 10px 13px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink-3);
    font-size: 13px;
}
.step.active {
    color: var(--teal-deep);
    border-color: var(--teal-line);
    background: var(--teal-wash);
    font-weight: 650;
}
.pay-address-row, .secret-line {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    align-items: center;
}
.secret-line { grid-template-columns: 110px 1fr auto; }
.secret-line span { font-size: 12.5px; color: var(--ink-2); font-weight: 600; }
.qr-card {
    display: grid;
    justify-items: center;
    gap: 8px;
    padding: 18px;
    margin-top: 14px;
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius);
    background: var(--surface);
    text-align: center;
}
.qr-img {
    width: 208px; height: 208px; max-width: 100%;
    padding: 8px;
    border-radius: var(--radius-sm);
    background: #fff;
    border: 1px solid var(--line);
}
.qr-card.compact .qr-img { width: 168px; height: 168px; }
.copy-grid, .energy-payment-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin: 14px 0;
}
.copy-grid > div, .energy-payment-grid > div { padding: 12px 14px; }
.energy-buy-box, .detect-panel {
    padding: 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    background: var(--surface-2);
    margin-top: 14px;
}
.detect-title { font-weight: 700; color: var(--ink); margin-bottom: 6px; font-size: 13.5px; }
.detect-status { color: var(--ink-2); }
.detect-status.detect-ok { color: var(--teal-deep); font-weight: 650; }
.detect-status.detect-warn { color: var(--warn); }
.detect-status.detect-loading { color: var(--info); }
.txid-form { margin-top: 14px; }

.toast {
    position: fixed;
    left: 50%;
    bottom: 26px;
    transform: translateX(-50%);
    background: var(--ink);
    color: #fff;
    padding: 9px 18px;
    border-radius: 999px;
    font-size: 13px;
    box-shadow: 0 8px 24px rgba(21, 33, 28, .25);
    z-index: 200;
}

/* ---------- 凭证管理 ---------- */
.credential-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 12px; }
.credential-box, .credential-current, .credential-action { padding: 15px; }
.credential-card-head, .one-time-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.credential-current {
    margin: 12px 0;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
}
.credential-current code, .secret-line code { width: 100%; padding: 8px 10px; overflow-x: auto; white-space: nowrap; }
.credential-action {
    margin-top: 10px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
}
.credential-action summary { cursor: pointer; color: var(--ink); font-weight: 650; font-size: 13px; }
.credential-action summary:hover { color: var(--teal-deep); }
.credential-action form { margin-top: 12px; }
.saved-check, .checkbox-line {
    display: flex; gap: 10px; align-items: flex-start;
    margin: 12px 0; padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    background: var(--surface);
    font-weight: 500;
}
.saved-check input, .checkbox-line input { width: auto; margin-top: 3px; accent-color: var(--teal); }
.one-time-secret-box { border-color: var(--ok-line); background: var(--ok-wash); }
.one-time-secret-box .secret-line { margin-bottom: 10px; }
.secret-hidden code { color: var(--ink-3); }

/* ---------- 其他 ---------- */
.callback-url-box { display: flex; justify-content: space-between; gap: 14px; align-items: center; padding: 13px 15px; }
.plain-list, .doc-list { line-height: 2; padding-left: 20px; margin: 0 0 10px; }
.checklist { display: grid; gap: 10px; }
.check-item { display: grid; grid-template-columns: 88px 1fr; gap: 12px; padding: 13px 14px; }
.check-level { font-size: 12px; font-weight: 700; color: var(--ink); }
.report-filter { grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: end; gap: 12px; margin-top: 14px; }
.report-filter .report-filter-actions { margin-top: 0; }
.inline-form { display: inline; }
.auth-card { margin-top: 40px; }

/* ---------- 响应式 ---------- */
@media (max-width: 920px) {
    .topbar { align-items: flex-start; flex-direction: column; gap: 0; padding: 12px 16px 6px; }
    .nav-sep { display: none; }
    nav { justify-content: flex-start; padding: 6px 0 4px; }
    .container { width: calc(100% - 28px); padding-top: 20px; }
    .grid.two, .grid.three, .credential-grid, .copy-grid,
    .energy-payment-grid, .report-filter { grid-template-columns: 1fr; }
    .form.inline, .pay-address-row { grid-template-columns: 1fr; }
    .secret-line { grid-template-columns: 1fr; gap: 6px; }
    .card { padding: 16px; }
    h1 { font-size: 22px; }
}
