:root {
  color-scheme: dark;
  --bg: #071019;
  --panel: #0e1924;
  --panel-soft: #111f2c;
  --line: #203242;
  --line-bright: #2b4557;
  --text: #f3f8fc;
  --muted: #7f9bb0;
  --green: #3ee0aa;
  --green-soft: rgba(62, 224, 170, .12);
  --orange: #ffad49;
  --red: #ef6a64;
  --shadow: 0 20px 55px rgba(0, 0, 0, .28);
}

/* Coach working library */
[hidden] { display: none !important; }
.coach-library { margin-bottom: 32px; scroll-margin-top: 90px; }
.coach-library h1 { font-size: 25px; margin: 4px 0; }
.coach-tag { padding: 7px 12px; border: 1px solid var(--green); color: var(--green); border-radius: 20px; font-size: 12px; white-space: nowrap; }
.coach-scope { margin: 20px; padding: 14px 16px; border-left: 3px solid var(--green); background: var(--green-soft); line-height: 1.8; font-size: 13px; }
.coach-tools { margin: 16px 20px; display: flex; gap: 12px; align-items: end; flex-wrap: wrap; }
.coach-tools label { display: grid; gap: 8px; font-size: 12px; color: #aac0cf; }
.coach-tools label:first-child { flex: 1; min-width: 220px; }
.coach-tools input,.coach-tools select { width: 100%; padding: 11px 12px; border: 1px solid var(--line-bright); border-radius: 8px; color: var(--text); background: #08141e; min-height: 42px; }
.coach-tools button { min-height: 42px; }
.coach-muted { color: #9db4c4; font-size: 12px; line-height: 1.8; }
.coach-library > .coach-muted,.coach-library > #libraryMessage { margin: 12px 20px; }
#libraryMessage { color: var(--green); min-height: 1.5em; font-size: 13px; }
.coach-tabs { display: flex; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--line); }
#libraryRows { padding: 0 20px 20px; }
.coach-card { padding: 22px; border: 1px solid var(--line); border-radius: 12px; margin-top: 14px; background: #101e2a; }
.coach-card h3 { white-space: pre-line; overflow-wrap: anywhere; font-size: 16px; font-weight: 600; line-height: 1.7; margin: 10px 0; }
.coach-kicker { font-size: 12px; color: var(--green); }
.coach-metrics { display: flex; flex-wrap: wrap; gap: 32px; margin: 20px 0; }
.coach-metrics strong { display: block; font-size: 22px; font-variant-numeric: tabular-nums; }
.coach-metrics span { color: var(--muted); font-size: 12px; }
.coach-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.coach-actions a { text-decoration: none; color: var(--text); display: inline-flex; align-items: center; }
.coach-shop-summary { padding: 20px 0 0; }
.coach-shop-summary h2 { font-size: 20px; }
.coach-product-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 14px; }
.coach-product-grid .coach-card { display: flex; flex-direction: column; align-items: start; }
.coach-product-grid h3 { flex: 1; }
.coach-price { color: var(--green); font-size: 24px; }
.coach-empty { padding: 40px 0; color: var(--muted); }
.topbar nav a { text-decoration: none; color: var(--muted); padding: 0 12px; display: flex; align-items: center; position: relative; white-space: nowrap; font-size: 13px; }
#shopOverview { scroll-margin-top: 90px; }
@media(max-width:1100px) { .topbar { height: auto; min-height:68px; flex-wrap:wrap; padding:14px 5vw; gap:12px; } .top-actions { flex-wrap:wrap; } .coach-product-grid { grid-template-columns:repeat(2,minmax(0,1fr)); } }
@media(max-width:600px) { .coach-product-grid { grid-template-columns:1fr; } .coach-metrics { gap:18px; } .coach-card { padding:16px; } .coach-tools { flex-direction:column; align-items:stretch; } .coach-tools label:first-child { min-width:0; } .topbar { position:static; } .top-actions { margin-left:0; } .topbar nav { height:36px; } .coach-tag { display:none; } }

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: Inter, "Microsoft YaHei UI", "PingFang SC", sans-serif; }
button, input, select { font: inherit; }
button { color: inherit; }
body { background-image: radial-gradient(circle at 78% -20%, rgba(34, 124, 108, .13), transparent 35%), linear-gradient(180deg, #08111a 0, #071019 100%); }

.app-shell { min-height: 100vh; }
.topbar { height: 68px; border-bottom: 1px solid var(--line); display: flex; align-items: center; padding: 0 5vw; gap: 34px; background: rgba(7, 16, 25, .9); position: sticky; top: 0; z-index: 20; backdrop-filter: blur(18px); }
.brand { display: flex; align-items: center; gap: 11px; min-width: 220px; }
.brand-mark { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; background: linear-gradient(135deg, #28b486, #45e5b3); color: #062118; font-weight: 900; box-shadow: 0 8px 28px rgba(62, 224, 170, .25); }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 16px; letter-spacing: .04em; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 11px; }
.topbar nav { display: flex; align-items: stretch; height: 100%; gap: 4px; }
.topbar nav button { border: 0; background: transparent; padding: 0 16px; color: var(--muted); cursor: pointer; position: relative; }
.topbar nav button:hover, .topbar nav .nav-active { color: var(--text); }
.topbar nav .nav-active::after { content: ""; height: 2px; left: 14px; right: 14px; bottom: 0; position: absolute; background: var(--green); box-shadow: 0 0 12px var(--green); }
.top-actions { margin-left: auto; display: flex; gap: 9px; }

.button { min-height: 38px; padding: 0 15px; border: 1px solid var(--line-bright); border-radius: 9px; background: #101c27; cursor: pointer; transition: .18s ease; white-space: nowrap; }
.button:hover:not(:disabled) { transform: translateY(-1px); border-color: #46677d; }
.button:disabled { opacity: .42; cursor: not-allowed; }
.button.primary { color: #06271c; border-color: var(--green); background: var(--green); font-weight: 800; box-shadow: 0 8px 22px rgba(62, 224, 170, .18); }
.button.secondary { background: transparent; }
.button.danger { color: #bd6862; border-color: rgba(239, 106, 100, .25); background: rgba(239, 106, 100, .06); }
.button.ghost { color: var(--muted); background: transparent; border-color: transparent; }

.page { width: min(1480px, 90vw); margin: 0 auto; padding: 30px 0 60px; }
.page-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.page-title h1 { margin: 0 0 4px; font-size: 25px; }
.page-title p { margin: 0; color: #75a0ba; font: 12px ui-monospace, SFMono-Regular, Consolas, monospace; }
.connection-pill { color: var(--muted); font-size: 12px; display: flex; gap: 8px; align-items: center; padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px; }
.connection-pill span { width: 7px; height: 7px; border-radius: 50%; background: var(--orange); box-shadow: 0 0 9px currentColor; }
.connection-pill.connected { color: var(--green); }
.connection-pill.connected span { background: var(--green); }
.connection-pill.failed { color: var(--red); }
.connection-pill.failed span { background: var(--red); }

.status-banner { min-height: 46px; display: flex; align-items: center; padding: 0 16px; border: 1px solid var(--line); border-radius: 10px; color: #8db0c8; background: rgba(14, 25, 36, .72); font-size: 13px; margin-bottom: 18px; }
.status-banner.running { border-color: rgba(62, 224, 170, .35); color: #a1eed2; }
.status-banner.warning { border-color: rgba(244, 166, 67, .42); color: #f2bd75; }
.status-banner.error { border-color: rgba(239, 106, 100, .35); color: #f09994; }

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat-card { min-height: 116px; padding: 21px; border: 1px solid var(--line); border-radius: 13px; background: linear-gradient(145deg, rgba(17, 31, 44, .82), rgba(12, 24, 34, .95)); box-shadow: inset 0 1px rgba(255,255,255,.015); }
.stat-card > span, .stat-card small { display: block; color: #7fa1b8; font-size: 12px; }
.stat-card strong { display: block; margin: 9px 0 5px; font: 800 30px ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: -.03em; }
.stat-card.accent { border-color: rgba(62, 224, 170, .38); background: linear-gradient(145deg, rgba(29, 69, 62, .5), rgba(12, 27, 29, .92)); }
.stat-card.accent strong { color: var(--green); }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 14px; align-items: start; }
.panel { background: rgba(13, 25, 36, .92); border: 1px solid var(--line); border-radius: 13px; overflow: hidden; }
.panel-heading { min-height: 62px; padding: 14px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 14px; }
.panel-heading h2, .side-heading h3 { margin: 0; font-size: 15px; }
.panel-heading p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.panel-heading > div:first-child { margin-right: auto; }
.segmented { display: flex; border: 1px solid var(--line-bright); border-radius: 8px; overflow: hidden; background: #0b1721; }
.segmented button { border: 0; border-right: 1px solid var(--line); color: var(--muted); background: transparent; padding: 7px 12px; cursor: pointer; font-size: 12px; }
.segmented button:last-child { border-right: 0; }
.segmented button.active { color: var(--green); background: var(--green-soft); font-weight: 700; }
.copy-range, .copy-range label { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.copy-range select { color: var(--text); background: #0a151f; border: 1px solid var(--line-bright); border-radius: 7px; padding: 6px 8px; }
.button.compact { min-height: 30px; padding: 0 10px; font-size: 12px; }

.ranking-list { height: 480px; padding: 10px 18px 16px; overflow-y: auto; scrollbar-gutter: stable; }
.ranking-row { height: 43px; display: grid; grid-template-columns: minmax(160px, 230px) minmax(180px, 1fr) 74px 30px; gap: 12px; align-items: center; padding: 0 7px; border-radius: 8px; }
.ranking-row:hover, .ranking-row:nth-child(odd) { background: rgba(62, 224, 170, .055); }
.ranking-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 650; }
.bar-track { height: 11px; border-radius: 999px; background: #172733; overflow: hidden; }
.bar-fill { height: 100%; min-width: 3px; border-radius: inherit; background: linear-gradient(90deg, #299a79, #48dfad); box-shadow: 0 0 10px rgba(62, 224, 170, .12); }
.ranking-value { text-align: right; color: var(--green); font: 700 12px ui-monospace, Consolas, monospace; }
.copy-button, .icon-button { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line-bright); background: transparent; color: #819db1; cursor: pointer; display: grid; place-items: center; }
.copy-button:hover, .icon-button:hover { color: var(--green); border-color: var(--green); }
.empty { min-height: 330px; display: grid; place-content: center; justify-items: center; gap: 8px; color: var(--muted); text-align: center; }
.empty strong { color: #bed0dc; }
.empty-small { color: var(--muted); font-size: 12px; padding: 24px; text-align: center; }

.side-column { display: grid; gap: 14px; }
.side-heading { min-height: 49px; padding: 0 17px; display: flex; align-items: center; border-bottom: 1px solid var(--line); }
.side-heading.warning { color: var(--orange); gap: 9px; }
.side-heading.warning span { font-size: 10px; text-shadow: 0 0 9px var(--orange); }
.warning-panel { border-color: rgba(255, 173, 73, .32); background: linear-gradient(140deg, rgba(45, 29, 15, .5), rgba(17, 22, 26, .92)); }
.side-list { padding: 8px 16px 15px; min-height: 90px; }
.side-item { padding: 12px 0; border-bottom: 1px solid rgba(32, 50, 66, .68); cursor: pointer; }
.side-item:last-child { border-bottom: 0; }
.side-item strong, .side-item small { display: block; }
.side-item strong { font-size: 12px; margin-bottom: 5px; }
.side-item small { color: var(--muted); font-size: 11px; line-height: 1.45; }
.side-item .up { color: var(--green); }

.accounts-panel { margin-top: 14px; }
.accounts-heading { min-height: 72px; }
.search-box { width: min(340px, 38vw); min-height: 38px; border: 1px solid var(--line-bright); border-radius: 9px; display: flex; align-items: center; gap: 8px; padding: 0 11px; color: var(--muted); background: #0a151f; }
.search-box input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 12px; }
.search-box.small { width: 220px; }
.account-table { max-height: 570px; overflow: auto; scrollbar-gutter: stable; }
.account-table-head, .account-row { min-width: 1120px; display: grid; grid-template-columns: minmax(250px, 1.35fr) .62fr .62fr .76fr .42fr .76fr .5fr 1.05fr; align-items: center; column-gap: 14px; padding: 0 20px; }
.account-table-head { position: sticky; top: 0; z-index: 3; height: 42px; color: var(--muted); font-size: 11px; background: #0b1823; border-bottom: 1px solid var(--line); }
.account-row { min-height: 65px; border-top: 1px solid rgba(32, 50, 66, .62); font-size: 12px; }
.account-row:hover { background: rgba(62, 224, 170, .035); }
.account-name { display: flex; align-items: center; min-width: 0; gap: 10px; }
.account-avatar { width: 36px; height: 36px; object-fit: cover; border-radius: 9px; background: #18303b; display: grid; place-items: center; color: var(--green); flex: none; }
.account-name div { min-width: 0; }
.account-name strong, .account-name small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-name small { color: var(--muted); margin-top: 3px; }
.sold { color: #d9fff1; font: 700 14px ui-monospace, Consolas, monospace; }
.status { width: fit-content; padding: 4px 8px; border-radius: 999px; background: var(--green-soft); color: var(--green); }
.status.disabled { color: var(--muted); background: rgba(127, 155, 176, .1); }
.row-actions { display: flex; gap: 6px; }
.row-actions button { padding: 6px 9px; border-radius: 7px; border: 1px solid var(--line-bright); color: #9bb2c2; background: transparent; cursor: pointer; font-size: 11px; }
.row-actions button:hover { color: var(--green); border-color: var(--green); }

.modal-backdrop { position: fixed; z-index: 50; inset: 0; background: rgba(1, 7, 12, .76); backdrop-filter: blur(8px); display: grid; place-items: center; padding: 26px; }
[hidden] { display: none !important; }
.csv-import { padding: 16px 24px; border-top: 1px solid #e4e9ee; }
.csv-import p { line-height: 1.6; color: #536171; }
.csv-import input { display: block; margin: 12px 0; max-width: 100%; }
.approximate-note { display: block; line-height: 1.5; font-size: 11px; color: #d49a42; }
.modal { width: min(920px, 94vw); max-height: 90vh; overflow: auto; border: 1px solid var(--line-bright); border-radius: 15px; background: #0d1924; box-shadow: var(--shadow); }
.modal > header { min-height: 72px; padding: 15px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal h2, .modal h3, .modal p { margin: 0; }
.modal header p { margin-top: 4px; color: var(--muted); font-size: 12px; }
.modal > footer { position: sticky; bottom: 0; display: flex; justify-content: flex-end; gap: 9px; padding: 14px 20px; border-top: 1px solid var(--line); background: #0d1924; }
.setup-note { margin: 18px 20px 0; padding: 13px 15px; color: #92afc2; border: 1px solid rgba(62, 224, 170, .22); background: rgba(62, 224, 170, .055); border-radius: 9px; font-size: 12px; line-height: 1.65; }
.setup-note code { color: var(--green); }
.form-grid { padding: 18px 20px; display: grid; grid-template-columns: 1fr 1fr .65fr; gap: 12px; }
.form-grid label > span { display: block; color: var(--muted); font-size: 11px; margin-bottom: 6px; }
.form-grid input { width: 100%; height: 39px; border: 1px solid var(--line-bright); border-radius: 8px; background: #08131c; color: var(--text); padding: 0 11px; outline: none; }
.form-grid input:focus { border-color: var(--green); }
.form-error { padding: 10px 12px; border: 1px solid rgba(255, 105, 105, .42); border-radius: 7px; background: rgba(125, 31, 31, .2); color: #ffaaaa; font-size: 12px; }
.group-section { border-top: 1px solid var(--line); }
.group-toolbar { min-height: 62px; display: flex; align-items: center; padding: 10px 20px; gap: 9px; }
.group-toolbar > div:first-child { margin-right: auto; }
.group-toolbar strong, .group-toolbar span { display: block; }
.group-toolbar span { color: var(--muted); font-size: 11px; margin-top: 3px; }
.group-list { margin: 0 20px 18px; min-height: 180px; max-height: 310px; overflow: auto; display: grid; grid-template-columns: repeat(2, 1fr); align-content: start; gap: 7px; }
.group-row { min-height: 42px; border: 1px solid var(--line); border-radius: 8px; display: flex; align-items: center; gap: 9px; padding: 0 11px; color: #b9cbd7; font-size: 12px; cursor: pointer; }
.group-row:hover, .group-row.selected { border-color: rgba(62, 224, 170, .42); background: rgba(62, 224, 170, .055); }
.group-row input { accent-color: var(--green); }
.user-row { cursor: default; }
.user-row > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-row > small { margin-left: auto; color: var(--muted); }

.detail-modal { width: min(820px, 94vw); }
.detail-identity { display: flex; gap: 12px; align-items: center; min-width: 0; }
.detail-identity img, .detail-identity .account-avatar { width: 44px; height: 44px; border-radius: 11px; }
.detail-identity strong, .detail-identity small { display: block; }
.detail-identity small { margin-top: 4px; color: var(--muted); }
.detail-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding: 18px 20px 0; }
.detail-grid article { padding: 15px; border: 1px solid var(--line); border-radius: 10px; background: #0a151f; }
.detail-grid span, .detail-grid strong { display: block; }
.detail-grid span { color: var(--muted); font-size: 11px; }
.detail-grid strong { margin-top: 7px; font: 700 19px ui-monospace, Consolas, monospace; }
.chart-card, .snapshot-table { margin: 16px 20px; padding: 16px; border: 1px solid var(--line); border-radius: 10px; }
.chart-card h3, .snapshot-table h3 { font-size: 13px; margin-bottom: 13px; }
.chart-card svg { width: 100%; height: 190px; overflow: visible; }
.snapshot-row { min-height: 42px; display: grid; grid-template-columns: 1fr .7fr .7fr 1fr; align-items: center; gap: 10px; border-top: 1px solid rgba(32, 50, 66, .62); color: #b5cad7; font-size: 11px; }
.snapshot-row strong { color: var(--green); }

.toast { position: fixed; z-index: 80; left: 50%; bottom: 30px; transform: translateX(-50%); padding: 11px 16px; border: 1px solid var(--line-bright); border-radius: 9px; background: #142532; color: #d9e7ef; box-shadow: var(--shadow); font-size: 12px; }

@media (max-width: 1050px) {
  .topbar { padding: 0 3vw; }
  .brand { min-width: auto; }
  .topbar nav { display: none; }
  .page { width: 94vw; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .side-column { grid-template-columns: repeat(3, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .group-toolbar { flex-wrap: wrap; }
}

@media (max-width: 720px) {
  .topbar { height: auto; min-height: 64px; padding: 10px 3vw; flex-wrap: wrap; }
  .brand { margin-right: auto; }
  .top-actions { width: 100%; }
  .top-actions .button { flex: 1; padding: 0 8px; font-size: 11px; }
  .page { padding-top: 20px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stat-card { min-height: 102px; padding: 16px; }
  .stat-card strong { font-size: 24px; }
  .panel-heading { align-items: flex-start; flex-wrap: wrap; }
  .segmented { order: 3; width: 100%; }
  .segmented button { flex: 1; }
  .copy-range { width: 100%; justify-content: flex-end; }
  .ranking-list { height: 420px; }
  .ranking-row { grid-template-columns: minmax(120px, 1fr) 1fr 58px 28px; gap: 7px; }
  .side-column { grid-template-columns: 1fr; }
  .search-box { width: 100%; }
  .group-list { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
}
.auth-modal { width: min(560px, calc(100vw - 32px)); }
.form-grid.single { grid-template-columns: 1fr; }
.stacked-field { display: grid; gap: 8px; margin: 16px 0; color: #9bb2c3; }
.stacked-field textarea, .stacked-field select { width: 100%; padding: 12px; border: 1px solid #29465c; background: #08141e; color: #eef8ff; border-radius: 6px; resize: vertical; }
#loginModal { z-index: 100; cursor: default; }
.login-help { margin: 0 20px 16px; padding: 12px; border: 1px solid #29465c; background: #0a1924; color: #9bb2c3; display: grid; gap: 4px; font-size: 12px; border-radius: 6px; }
.login-help strong { color: #eef8ff; }
.pending-shop-list { padding: 16px 20px; max-height: 520px; overflow: auto; display: grid; gap: 8px; }
.pending-shop-item { display: grid; grid-template-columns: minmax(180px, 1fr) 130px 150px auto; align-items: center; gap: 12px; padding: 12px; border: 1px solid #20384a; background: #091722; border-radius: 6px; }
.pending-shop-item small { color: #7f9bb0; }
.sortable-head { appearance: none; border: 0; background: transparent; color: inherit; padding: 0; text-align: left; cursor: pointer; font: inherit; }
.sortable-head.active { color: #3ee0aa; }
