:root {
  color-scheme: dark;
  --bg: #0c0e0d;
  --surface: #151817;
  --surface-2: #1b1f1d;
  --line: #303632;
  --text: #f2f5f3;
  --muted: #9da7a1;
  --accent: #66d39a;
  --accent-strong: #26ae70;
  --good: #67d69e;
  --warn: #e5bd61;
  --bad: #f07178;
  --cyan: #69bed2;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: "Segoe UI", Arial, "Microsoft YaHei", sans-serif; line-height: 1.45; }
button, input, select, textarea { font: inherit; }
button { min-height: 38px; border: 1px solid #319064; border-radius: 6px; background: #207c54; color: #fff; padding: 8px 14px; cursor: pointer; }
button:hover { background: #289564; }
button:disabled { cursor: not-allowed; opacity: .55; }
button.secondary { border-color: var(--line); background: var(--surface-2); }
button.secondary:hover { background: #252b28; }
input, select, textarea { width: 100%; min-height: 42px; border: 1px solid var(--line); border-radius: 6px; background: #101311; color: var(--text); padding: 9px 10px; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
input[type="checkbox"] { width: 18px; min-height: 18px; accent-color: var(--accent-strong); }
a { color: inherit; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 25px; letter-spacing: 0; }
h2 { margin-bottom: 14px; font-size: 18px; letter-spacing: 0; }
h3 { margin-bottom: 8px; font-size: 14px; letter-spacing: 0; }

.topbar { min-height: 82px; display: flex; align-items: center; justify-content: space-between; gap: 24px; border-bottom: 1px solid var(--line); padding: 16px 28px; background: #111311; }
.eyebrow { margin-bottom: 4px; color: var(--accent); font-size: 12px; }
.header-status { display: grid; justify-items: end; gap: 2px; color: var(--muted); }
.header-status strong { color: var(--text); font-size: 19px; }
main { width: min(1560px, 100%); margin: 0 auto; padding: 18px 28px 48px; }
.hidden { display: none !important; }
.notice { border: 1px solid var(--line); border-radius: 6px; padding: 12px; margin-bottom: 16px; background: var(--surface); }
.auth-layout { display: grid; grid-template-columns: repeat(2, minmax(0, 420px)); gap: 28px; justify-content: center; padding: 7vh 0; }
.auth-form { display: grid; gap: 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); padding: 22px; }
.auth-form label { color: var(--muted); font-size: 13px; }
.auth-form button { margin-top: 8px; }
.form-message { min-height: 20px; margin: 4px 0 0; font-size: 13px; color: var(--good); }
.toolbar { display: flex; align-items: center; gap: 9px; margin-bottom: 14px; }
.toolbar .meta { margin-left: auto; }
.summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 6px; margin-bottom: 18px; overflow: hidden; }
.metric { min-height: 92px; border-right: 1px solid var(--line); background: var(--surface); padding: 12px 14px; }
.metric:last-child { border-right: 0; }
.metric span, .metric small { display: block; color: var(--muted); }
.metric strong { display: block; margin: 6px 0 4px; font-size: 21px; }
.push-control { display: flex; align-items: center; justify-content: space-between; gap: 18px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin: 0 0 20px; padding: 11px 2px; }
.push-control > div:first-child { display: grid; gap: 2px; min-width: 0; }
.push-control strong { font-size: 14px; }
.push-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.push-actions button { min-height: 34px; padding: 6px 10px; font-size: 12px; }
.app-tabs { position: sticky; top: 0; z-index: 20; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 6px; margin: 0 0 18px; overflow: hidden; background: #101311; }
.app-tabs.user-tabs { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.app-tab { min-width: 0; min-height: 44px; border: 0; border-right: 1px solid var(--line); border-radius: 0; background: #101311; color: var(--muted); padding: 8px 6px; font-size: 13px; font-weight: 650; }
.app-tab:last-child { border-right: 0; }
.app-tab:hover { background: var(--surface-2); color: var(--text); }
.app-tab.active { background: #1a5e43; color: #fff; }
.app-view { display: none; }
.app-view.active { display: block; }
.feed-grid { display: grid; grid-template-columns: minmax(0, 1.18fr) minmax(400px, .82fr); gap: 24px; align-items: start; }
.section-band { border-top: 1px solid var(--line); padding: 20px 0 26px; min-width: 0; }
.primary-feed, .x-feed { border-top: 2px solid var(--line); }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.status-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; }
.status-grid.spaced { margin-top: 9px; }
.pill { min-height: 84px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); padding: 10px; overflow-wrap: anywhere; }
.pill b { display: block; margin-bottom: 4px; }
.pill strong { display: block; color: var(--text); font-size: 18px; margin-bottom: 3px; }
.ok { color: var(--good) !important; }
.warn { color: var(--warn) !important; }
.bad, .error { color: var(--bad) !important; }
.meta { color: var(--muted); font-size: 12px; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; }
.list, .transaction-list, .tweet-list { display: grid; gap: 9px; }
.item, .transaction-card, .tweet-card { border: 1px solid var(--line); border-radius: 6px; background: var(--surface); overflow-wrap: anywhere; }
.item { padding: 11px; }
.compact .item { font-size: 13px; }
.empty { border: 1px dashed var(--line); border-radius: 6px; color: var(--muted); padding: 18px; text-align: center; }
.tag, .chain-badge { display: inline-flex; align-items: center; min-height: 21px; border: 1px solid #436257; border-radius: 4px; background: #19251f; color: #b6e9ce; padding: 1px 6px; margin-right: 5px; font-size: 11px; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.actions, .link-row { display: flex; flex-wrap: wrap; gap: 7px; }
.actions { margin-top: 8px; }
.actions button { min-height: 32px; padding: 5px 9px; font-size: 12px; }

.transaction-card { position: relative; padding: 14px; border-left: 3px solid var(--good); }
.transaction-card.sell { border-left-color: var(--bad); }
.transaction-head, .tweet-head, .tweet-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.transaction-head time, .tweet-head time { color: var(--muted); font-size: 12px; white-space: nowrap; }
.side-label { color: var(--good); font-size: 12px; font-weight: 700; }
.sell .side-label { color: var(--bad); }
.wallet-identity { display: grid; gap: 3px; margin: 10px 0 4px; }
.wallet-identity strong { color: var(--muted); font-size: 13px; font-weight: 650; }
.wallet-address { color: #a8dbe5; font-size: 11px; overflow-wrap: anywhere; text-decoration: none; }
.wallet-address:hover { color: #d5f4fb; text-decoration: underline; }
.trade-sentence { margin-bottom: 12px; color: var(--text); font-size: 16px; font-weight: 650; }
.trade-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin-bottom: 10px; }
.trade-stats > div { padding: 8px 7px; border-right: 1px solid var(--line); min-width: 0; }
.trade-stats > div:first-child { padding-left: 0; }
.trade-stats > div:last-child { border-right: 0; }
.trade-stats span, .trade-stats strong { display: block; }
.trade-stats span { color: var(--muted); font-size: 11px; }
.trade-stats strong { margin-top: 2px; font-size: 14px; overflow-wrap: anywhere; }
.contract-row { display: grid; grid-template-columns: 48px minmax(0, 1fr); align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.contract-value { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 7px; min-width: 0; }
.contract-link { color: #a8dbe5; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.copy-button { min-height: 29px; padding: 4px 8px; white-space: nowrap; font-size: 11px; }
.history-controls { display: flex; justify-content: center; padding-top: 12px; }
.transaction-meta { display: flex; flex-wrap: wrap; gap: 12px; min-height: 18px; margin: 6px 0 10px; color: var(--muted); font-size: 11px; }
.link-button { display: inline-flex; align-items: center; justify-content: center; min-height: 31px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface-2); color: #d7e6dd; padding: 5px 9px; font-size: 12px; text-decoration: none; }
.link-button:hover { border-color: var(--accent-strong); color: #fff; }

.tweet-card { padding: 14px; }
.account-link { color: #d9f4e6; font-weight: 700; text-decoration: none; }
.account-link:hover { color: var(--accent); text-decoration: underline; }
.x-type { display: inline-flex; margin-left: 7px; color: var(--cyan); font-size: 11px; font-weight: 700; }
.narrative-row, .evidence-row { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 9px; }
.bilingual-text { display: grid; gap: 0; margin-top: 10px; border: 1px solid var(--line); border-radius: 5px; overflow: hidden; }
.translation-text, .original-text { padding: 9px 10px; }
.translation-text { background: #121a16; }
.translation-label, .original-label { color: var(--accent); font-size: 11px; font-weight: 700; }
.original-label { color: var(--muted); }
.translated-text { margin: 5px 0 0; color: var(--text); font-size: 15px; white-space: pre-wrap; }
.pending-text { color: var(--warn); }
.original-text { border-top: 1px solid var(--line); }
.original-text p { margin: 5px 0 0; color: #c4cac6; font-size: 13px; white-space: pre-wrap; }
.media-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; margin-top: 10px; }
.media-link { display: block; aspect-ratio: 16 / 10; overflow: hidden; border: 1px solid var(--line); border-radius: 5px; background: #080a09; }
.media-link img { width: 100%; height: 100%; display: block; object-fit: cover; }
.enrichment { margin-top: 10px; padding-top: 9px; border-top: 1px solid var(--line); }
.enrichment b { font-size: 12px; color: var(--cyan); }
.enrichment p { margin: 5px 0 0; font-size: 13px; }
.analysis-meta { margin-top: 4px; color: var(--muted); font-size: 11px; }
.analysis-line { display: grid; grid-template-columns: 60px minmax(0, 1fr); gap: 7px; margin-top: 6px; color: #cbd2ce; font-size: 12px; }
.analysis-line b { color: var(--muted); }
.analysis-line.risk { color: var(--warn); }
.signal { margin-left: 4px; color: var(--warn); }
.signal.high, .signal.critical { color: var(--bad); }
.tweet-footer { margin-top: 11px; min-height: 31px; color: var(--muted); font-size: 11px; }
.tweet-footer > .link-row { justify-content: flex-end; margin-left: auto; }
.cluster-item { display: grid; gap: 12px; padding: 14px; }
.cluster-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.cluster-head time { color: var(--muted); font-size: 12px; white-space: nowrap; }
.cluster-token { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: baseline; gap: 8px 12px; }
.cluster-token > span { color: var(--muted); font-size: 12px; }
.cluster-token h3 { margin: 0; color: var(--text); font-size: 18px; }
.cluster-token > strong { color: var(--good); font-size: 13px; }
.cluster-ca { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 8px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 9px 0; }
.cluster-ca > span { color: var(--muted); font-size: 11px; }
.cluster-ca code { color: #a8dbe5; overflow-wrap: anywhere; font-size: 12px; }
.cluster-members { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 7px 14px; }
.cluster-member { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 0; }
.cluster-member > div { display: grid; min-width: 0; }
.cluster-member strong { color: var(--text); font-size: 13px; }
.cluster-member .mono, .cluster-member > span { color: var(--muted); font-size: 11px; }
.cluster-member .mono { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cluster-member > span { text-align: right; white-space: nowrap; }
.cluster-count { font-weight: 650; }
.delivery-band { margin-top: 2px; }
.delivery-item { min-height: 70px; }
.system-details { border-top: 1px solid var(--line); padding-top: 0; }
.details-band { margin-top: 14px; }
.admin-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 6px; margin-bottom: 14px; overflow: hidden; }
.admin-tab { border: 0; border-right: 1px solid var(--line); border-radius: 0; background: #101311; color: var(--muted); }
.admin-tab:last-child { border-right: 0; }
.admin-tab.active { background: #1a5e43; color: #fff; }
.admin-pane { display: none; }
.admin-pane.active { display: block; }
.admin-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; border-bottom: 1px solid var(--line); padding-bottom: 18px; margin-bottom: 18px; }
.admin-form label { display: grid; align-content: start; gap: 4px; color: var(--muted); font-size: 12px; }
.admin-form .span-2 { grid-column: 1 / -1; }
.admin-form .check-field { display: flex; flex-direction: row; align-items: center; gap: 7px; min-height: 42px; color: var(--text); }
.form-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.form-actions .form-message { margin: 0; }
.admin-list-head { display: grid; grid-template-columns: minmax(0, 1fr) minmax(220px, 360px); align-items: center; gap: 12px; margin-bottom: 10px; }
.admin-list-head h3 { margin: 0; }
.admin-list { max-height: 620px; overflow: auto; padding-right: 2px; }
.admin-record-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.admin-record-head > div { min-width: 0; }
.admin-record-id { margin-top: 3px; overflow-wrap: anywhere; }

@media (max-width: 1180px) {
  .feed-grid { grid-template-columns: 1fr; }
  .x-feed { border-top-width: 1px; }
  .tweet-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .status-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric:nth-child(2) { border-right: 0; }
  .metric:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .tweet-list, .auth-layout, .split { grid-template-columns: 1fr; }
  .cluster-token { grid-template-columns: 1fr; gap: 3px; }
  .cluster-ca { grid-template-columns: 1fr auto; }
  .cluster-ca > span { grid-column: 1 / -1; }
  .admin-form { grid-template-columns: 1fr; }
  .admin-form .span-2 { grid-column: auto; }
}

@media (max-width: 560px) {
  .topbar { align-items: flex-start; padding: 14px; }
  .header-status { justify-items: end; }
  h1 { font-size: 19px; }
  main { padding: 12px 12px calc(86px + env(safe-area-inset-bottom)); }
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .status-grid { grid-template-columns: 1fr; }
  .metric { min-height: 78px; border-right: 0; border-bottom: 1px solid var(--line); }
  .metric:nth-child(odd) { border-right: 1px solid var(--line); }
  .metric:nth-last-child(-n+2) { border-bottom: 0; }
  .app-tabs { position: fixed; inset: auto 0 0; z-index: 40; margin: 0; border-width: 1px 0 0; border-radius: 0; padding-bottom: env(safe-area-inset-bottom); box-shadow: 0 -8px 24px rgba(0,0,0,.28); }
  .app-tab { min-height: 56px; padding: 7px 3px; font-size: 12px; }
  .section-heading { align-items: flex-start; }
  .trade-stats { grid-template-columns: 1fr; }
  .trade-stats > div { border-right: 0; border-bottom: 1px solid var(--line); padding: 7px 0; }
  .trade-stats > div:last-child { border-bottom: 0; }
  .transaction-head, .tweet-head { align-items: flex-start; }
  .media-grid { grid-template-columns: 1fr; }
  .contract-row { grid-template-columns: 40px minmax(0, 1fr); }
  .push-control { align-items: flex-start; flex-direction: column; gap: 9px; }
  .push-actions { justify-content: flex-start; width: 100%; }
  .admin-list-head { grid-template-columns: 1fr; }
}
