:root {
  --bg: #f3f5f7;
  --surface: #ffffff;
  --surface-muted: #f8f9fa;
  --ink: #16191d;
  --muted: #687078;
  --line: #dde1e5;
  --line-strong: #c9ced4;
  --accent: #e93679;
  --accent-dark: #bd1d5a;
  --green: #16845b;
  --green-soft: #e8f5ef;
  --red: #b93632;
  --red-soft: #fbeceb;
  --sidebar: #202428;
  --sidebar-muted: #aab1b7;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { min-width: 320px; min-height: 100vh; margin: 0; background: var(--bg); }
button, input, select { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .48; }
code { font-family: "SFMono-Regular", Consolas, monospace; letter-spacing: 0; }
svg { width: 18px; height: 18px; stroke-width: 1.8; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 224px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 22px 16px; display: flex; flex-direction: column; color: #fff; background: var(--sidebar); }
.brand-block { min-height: 46px; padding: 0 7px; display: flex; align-items: center; gap: 11px; }
.brand-mark { width: 38px; height: 38px; border-radius: 6px; object-fit: cover; background: #fff; }
.brand-block div { min-width: 0; display: grid; gap: 2px; }
.brand-block strong { font-size: 15px; }
.brand-block span { color: var(--sidebar-muted); font-size: 11px; }
.side-nav { margin-top: 34px; }
.nav-item { width: 100%; height: 40px; padding: 0 11px; display: flex; align-items: center; gap: 10px; border: 0; border-radius: 6px; color: #fff; background: #34393e; text-align: left; }
.nav-item svg { color: #ff6da4; }
.side-footer { margin-top: auto; padding: 14px 9px 3px; display: grid; gap: 8px; border-top: 1px solid #3a3f44; color: var(--sidebar-muted); font-size: 11px; }
.network-row { display: flex; align-items: center; gap: 8px; }
.network-dot { width: 7px; height: 7px; border-radius: 50%; background: #51ca91; box-shadow: 0 0 0 3px rgb(81 202 145 / 12%); }

.main-content { min-width: 0; padding: 28px clamp(20px, 3vw, 46px) 24px; }
.topbar { min-height: 55px; display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.topbar h1 { margin: 0; font-size: 24px; line-height: 1.2; }
.topbar p { margin: 6px 0 0; color: var(--muted); font-size: 12px; }
.status-chip { height: 32px; padding: 0 11px; display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); font-size: 12px; }
.status-chip > span { width: 7px; height: 7px; border-radius: 50%; background: #8c939a; }
.status-chip.is-running { color: var(--green); border-color: #b9ddcc; background: var(--green-soft); }
.status-chip.is-running > span { background: var(--green); box-shadow: 0 0 0 3px rgb(22 132 91 / 13%); }

.auth-band { max-width: 520px; margin: 52px auto 0; padding: 24px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); }
.auth-copy { display: flex; align-items: center; gap: 12px; }
.auth-copy > svg { width: 28px; height: 28px; color: var(--green); }
.auth-copy div { display: grid; gap: 3px; }
.auth-copy strong { font-size: 15px; }
.auth-copy span { color: var(--muted); font-size: 11px; }
.auth-tabs { height: 36px; margin-top: 18px; display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); border-radius: 5px; overflow: hidden; }
.auth-tab { border: 0; color: var(--muted); background: var(--surface-muted); font-size: 11px; font-weight: 600; }
.auth-tab + .auth-tab { border-left: 1px solid var(--line); }
.auth-tab.is-active { color: var(--ink); background: #fff; }
.auth-form { margin-top: 14px; display: grid; gap: 12px; }
.auth-form label { min-width: 0; display: grid; gap: 6px; color: var(--muted); font-size: 11px; }
.auth-form input { min-width: 0; height: 40px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 5px; font-family: "SFMono-Regular", Consolas, monospace; }
.auth-form .primary-button { width: 100%; margin-top: 2px; padding-inline: 18px; }

.balance-band { margin-top: 24px; display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); border: 1px solid var(--line); border-radius: 7px; background: var(--surface); overflow: hidden; }
.wallet-balance-group { min-width: 0; padding-top: 10px; border-right: 1px solid var(--line); }
.wallet-label { min-width: 0; padding: 0 14px 6px; display: grid; gap: 4px; color: var(--muted); font-size: 10px; }
.wallet-label > span { font-family: "SFMono-Regular", Consolas, monospace; }
.balance-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.balance-item { min-width: 0; min-height: 68px; padding: 10px 14px; display: flex; align-items: center; gap: 9px; border-right: 1px solid var(--line); }
.balance-item:last-child { border-right: 0; }
.balance-item img, .metric-icon { width: 28px; height: 28px; flex: 0 0 28px; border-radius: 50%; object-fit: cover; background: #f1f3f4; }
.metric-icon { display: grid; place-items: center; color: #43617a; }
.balance-item div:not(.metric-icon) { min-width: 0; display: grid; gap: 4px; }
.balance-item span { color: var(--muted); font-size: 10px; }
.balance-item strong { overflow: hidden; font-size: 13px; font-variant-numeric: tabular-nums; text-overflow: ellipsis; }
.gas-item { min-height: 88px; }
.balance-unavailable { min-height: 84px; display: grid; place-items: center; color: var(--muted); font-size: 11px; }

.workspace-grid { margin-top: 20px; display: grid; grid-template-columns: minmax(320px, .9fr) minmax(380px, 1.1fr); gap: 20px; align-items: stretch; }
.control-panel, .live-panel { min-width: 0; padding: 20px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); }
.panel-heading, .section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.panel-heading h2, .section-heading h2 { margin: 3px 0 0; font-size: 16px; line-height: 1.3; }
.panel-heading > svg { color: var(--muted); }
.eyebrow { color: var(--muted); font-size: 10px; font-weight: 600; text-transform: uppercase; }

.server-wallet-section { margin-top: 18px; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.server-wallet-heading { padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--surface-muted); }
.server-wallet-heading h3 { margin: 2px 0 0; font-size: 14px; }
.readiness-badge, .signer-state { display: inline-flex; align-items: center; gap: 5px; color: #9a6811; font-size: 10px; font-weight: 600; }
.readiness-badge.is-ready, .signer-state.is-ready { color: var(--green); }
.readiness-badge.is-error, .signer-state.is-error { color: var(--red); }
.signer-state svg { width: 14px; height: 14px; }
.server-wallet-item { min-height: 66px; padding: 10px 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-top: 1px solid var(--line); }
.server-wallet-list { max-height: 270px; overflow-y: auto; }
.wallet-item-details { min-width: 0; display: grid; gap: 4px; }
.server-wallet-item strong { font-size: 11px; }
.wallet-address-row { min-width: 0; display: flex; align-items: center; gap: 5px; }
.wallet-address-row code { min-width: 0; color: var(--muted); font-size: 10px; line-height: 1.45; overflow-wrap: anywhere; }
.wallet-address-row .icon-button { width: 25px; height: 25px; flex: 0 0 25px; }
.wallet-address-row .icon-button svg { width: 12px; height: 12px; }
.wallet-address-row .icon-button.is-copied { color: var(--green); border-color: #b9ddcc; background: var(--green-soft); }
.wallet-empty { min-height: 54px; display: grid; place-items: center; border-top: 1px solid var(--line); color: var(--muted); font-size: 10px; }
.wallet-item-actions { display: flex; align-items: center; gap: 8px; }
.wallet-item-actions .icon-button { width: 28px; height: 28px; color: var(--red); }
.wallet-item-actions .icon-button svg { width: 13px; height: 13px; }
.wallet-import { padding: 10px 14px; display: grid; grid-template-columns: minmax(0, 1fr) 86px auto; gap: 8px; border-top: 1px solid var(--line); background: #fff; }
.wallet-import.is-metamask { grid-template-columns: minmax(0, 1fr) auto; }
.wallet-type-selector { grid-column: 1 / -1; height: 36px; display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); border-radius: 5px; overflow: hidden; }
.wallet-type { display: flex; align-items: center; justify-content: center; gap: 7px; border: 0; color: var(--muted); background: var(--surface-muted); font-size: 11px; font-weight: 600; }
.wallet-type + .wallet-type { border-left: 1px solid var(--line); }
.wallet-type.is-active { color: var(--ink); background: #fff; }
.wallet-type img, .wallet-type svg { width: 16px; height: 16px; border-radius: 3px; object-fit: cover; }
.wallet-import > label { min-width: 0; display: grid; gap: 5px; color: var(--muted); font-size: 10px; }
.wallet-import input { min-width: 0; height: 38px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 5px; font-family: "SFMono-Regular", Consolas, monospace; font-size: 11px; }
#account-count { text-align: center; }
.wallet-import .secondary-button { height: 38px; align-self: end; padding-inline: 12px; }
.security-note { padding: 9px 14px; display: flex; align-items: center; gap: 7px; border-top: 1px solid var(--line); color: #43617a; background: #edf4f8; font-size: 10px; }
.security-note svg { width: 14px; height: 14px; }

.field-grid { margin-top: 21px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.field-grid label { min-width: 0; display: grid; gap: 7px; }
.field-grid label > span { color: #525960; font-size: 11px; font-weight: 500; }
.field-grid select { width: 100%; height: 38px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 5px; color: var(--ink); background: #fff; }
.checkbox-label { min-height: 38px; grid-template-columns: 18px minmax(0, 1fr); align-items: center; align-self: end; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 5px; background: #fff; }
.checkbox-label input { width: 15px; height: 15px; accent-color: var(--accent); }
.input-suffix { height: 38px; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; border: 1px solid var(--line-strong); border-radius: 5px; background: #fff; overflow: hidden; }
.input-suffix:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgb(233 54 121 / 9%); }
.input-suffix input { width: 100%; min-width: 0; height: 36px; padding: 0 10px; border: 0; outline: 0; color: var(--ink); background: transparent; font-variant-numeric: tabular-nums; }
.input-suffix span { padding: 0 10px; color: var(--muted); font-size: 10px; border-left: 1px solid var(--line); }
.interval-field.is-muted { opacity: .52; }
.live-mode-banner { margin-top: 18px; padding: 10px 14px; display: flex; align-items: center; gap: 8px; border: 1px solid #e0c36d; border-radius: 7px; color: #7a5910; background: #fff8df; font-size: 11px; }
.live-mode-banner svg { width: 15px; height: 15px; }
.control-actions { margin-top: 18px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.primary-button, .secondary-button { height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 5px; font-size: 12px; font-weight: 600; }
.primary-button { border: 1px solid var(--accent); color: #fff; background: var(--accent); }
.primary-button:hover:not(:disabled) { border-color: var(--accent-dark); background: var(--accent-dark); }
.secondary-button { border: 1px solid var(--line-strong); color: #353a40; background: #fff; }
.secondary-button:hover:not(:disabled) { background: var(--surface-muted); }
.form-error { min-height: 16px; margin-top: 10px; color: var(--red); font-size: 11px; overflow-wrap: anywhere; }

.live-panel { display: flex; flex-direction: column; }
.countdown { min-width: 52px; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; text-align: right; }
.empty-state { flex: 1; min-height: 198px; display: grid; place-content: center; justify-items: center; gap: 10px; color: var(--muted); }
.empty-icon { width: 45px; height: 45px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: var(--surface-muted); }
.empty-state strong { font-size: 12px; font-weight: 500; }
.quote-view { margin-top: 20px; }
.swap-route { min-height: 92px; padding: 15px; display: grid; grid-template-columns: minmax(0, 1fr) 38px minmax(0, 1fr); align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-muted); }
.token-amount { min-width: 0; display: flex; align-items: center; gap: 10px; }
.token-amount.align-right { justify-content: flex-end; text-align: right; }
.token-amount img { width: 33px; height: 33px; flex: 0 0 33px; border-radius: 50%; object-fit: cover; }
.token-amount div { min-width: 0; display: grid; gap: 4px; }
.token-amount span { color: var(--muted); font-size: 10px; }
.token-amount strong { overflow: hidden; font-size: 14px; font-variant-numeric: tabular-nums; text-overflow: ellipsis; }
.route-arrow { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; color: var(--accent); background: #fff; }
.quote-metrics { margin: 13px 0 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.quote-metrics div { min-height: 55px; padding: 10px 12px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.quote-metrics dt { color: var(--muted); font-size: 10px; }
.quote-metrics dd { margin: 5px 0 0; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.result-badge { min-height: 20px; padding: 2px 7px; display: inline-flex; align-items: center; border-radius: 4px; color: var(--green); background: var(--green-soft); font-size: 10px; }
.pool-strip { min-height: 37px; margin-top: auto; padding-top: 14px; display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 10px; }
.pool-strip code { color: #41474d; }
.pool-strip a { margin-left: auto; display: grid; place-items: center; color: var(--muted); }
.pool-strip a:hover { color: var(--accent); }

.history-section { margin-top: 20px; padding: 20px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); }
.icon-button { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 5px; color: var(--muted); background: #fff; }
.icon-button:hover { color: var(--ink); background: var(--surface-muted); }
.table-wrap { margin-top: 15px; overflow-x: auto; }
table { width: 100%; min-width: 860px; border-collapse: collapse; font-size: 11px; }
th { padding: 10px 12px; color: var(--muted); background: var(--surface-muted); font-weight: 500; text-align: left; }
td { padding: 11px 12px; border-bottom: 1px solid #eceff1; font-variant-numeric: tabular-nums; }
tbody tr:last-child td { border-bottom: 0; }
.placeholder-row td { height: 68px; color: var(--muted); text-align: center; }
.direction-cell { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.direction-cell svg { width: 14px; height: 14px; color: var(--accent); }
.table-status { min-height: 20px; padding: 2px 7px; display: inline-flex; align-items: center; border-radius: 4px; color: var(--green); background: var(--green-soft); font-size: 10px; }
.table-status.is-error { color: var(--red); background: var(--red-soft); }
.connection-bar { min-height: 34px; display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 10px; }
#connection-dot { width: 6px; height: 6px; border-radius: 50%; background: #a1a7ad; }
#connection-dot.is-online { background: var(--green); }
.session-button { margin-left: auto; padding: 3px 7px; border: 0; color: var(--muted); background: transparent; font-size: 10px; }
.session-button:hover { color: var(--ink); }
.user-label { padding: 3px 7px; border: 1px solid var(--line); border-radius: 4px; color: var(--ink); background: var(--surface); font-family: "SFMono-Regular", Consolas, monospace; }
.mode-label { padding: 3px 6px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 72px minmax(0, 1fr); }
  .sidebar { padding: 20px 11px; }
  .brand-block { padding: 0; justify-content: center; }
  .brand-block div, .nav-item span, .side-footer span:not(.network-dot), .side-footer code { display: none; }
  .nav-item { justify-content: center; padding: 0; }
  .side-footer { justify-items: center; padding-inline: 0; }
  .workspace-grid, .balance-band { grid-template-columns: 1fr; }
  .wallet-balance-group { border-right: 0; border-bottom: 1px solid var(--line); }
}

@media (max-width: 700px) {
  .app-shell { display: block; }
  .sidebar { position: static; width: 100%; height: 58px; padding: 10px 16px; flex-direction: row; align-items: center; }
  .brand-block { justify-content: flex-start; }
  .brand-block div { display: grid; }
  .brand-mark { width: 34px; height: 34px; }
  .side-nav { margin: 0 0 0 auto; }
  .nav-item { width: 38px; height: 38px; }
  .side-footer { display: none; }
  .main-content { padding: 20px 14px; }
  .topbar h1 { font-size: 20px; }
  .auth-band { margin-top: 30px; padding: 18px; }
  .field-grid { grid-template-columns: 1fr; }
  .wallet-import { grid-template-columns: 1fr; }
  .wallet-import.is-metamask { grid-template-columns: 1fr; }
  .balance-row { grid-template-columns: 1fr; }
  .wallet-balance-group .balance-item { border-right: 0; border-bottom: 1px solid var(--line); }
  .control-panel, .live-panel, .history-section { padding: 16px; }
  .server-wallet-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; }
  .wallet-item-details { grid-column: 1 / -1; }
  .wallet-item-actions { grid-column: 1 / -1; justify-content: flex-end; }
  .swap-route { grid-template-columns: 1fr; gap: 11px; }
  .token-amount.align-right { justify-content: flex-start; text-align: left; }
  .route-arrow { justify-self: center; transform: rotate(90deg); }
  .quote-metrics { grid-template-columns: 1fr; }
}
