:root {
  color-scheme: dark;
  --bg: #07111f;
  --bg-deep: #040b14;
  --panel: #0c1a2a;
  --panel-2: #102337;
  --panel-3: #132a41;
  --line: #213d58;
  --line-soft: rgba(151, 190, 219, 0.14);
  --text: #edf8ff;
  --muted: #91a9bd;
  --muted-2: #6f8799;
  --cyan: #52d7ff;
  --mint: #74ebbf;
  --mint-strong: #39cfa1;
  --danger: #ff6f78;
  --warning: #ffc86f;
  --shadow: 0 24px 72px rgba(0, 0, 0, 0.28);
  --radius: 20px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--bg-deep); }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 16% -10%, rgba(82, 215, 255, 0.14), transparent 28rem),
    radial-gradient(circle at 86% 10%, rgba(116, 235, 191, 0.09), transparent 32rem),
    linear-gradient(180deg, #081524 0%, var(--bg) 42%, #050d17 100%);
  color: var(--text);
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
.hidden { display: none !important; }
.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; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 68px;
  padding: 0 5vw;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(5, 14, 24, 0.82);
  border-bottom: 1px solid var(--line-soft);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--text);
  text-decoration: none;
  font-weight: 760;
  letter-spacing: -0.02em;
}

.brand-large { font-size: 1.08rem; }
.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  color: #03231e;
  background: linear-gradient(135deg, var(--mint), var(--cyan));
  box-shadow: 0 8px 24px rgba(82, 215, 255, 0.18);
  font-weight: 900;
}

.topbar-actions, .privacy-label { display: flex; align-items: center; gap: 14px; }
.privacy-label { color: var(--muted); font-size: 0.8rem; }
.status-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 12px rgba(116, 235, 191, 0.8); }

.workspace {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 56px 0 72px;
}

.hero-panel {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
  margin-bottom: 30px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--mint);
  font-size: 0.73rem;
  font-weight: 800;
  letter-spacing: 0.18em;
}

h1, h2, p { margin-top: 0; }
.hero-panel h1 { margin-bottom: 12px; font-size: clamp(2rem, 5vw, 3.5rem); letter-spacing: -0.055em; line-height: 1.04; }
.hero-panel p:not(.eyebrow) { max-width: 690px; margin-bottom: 0; color: var(--muted); font-size: 1rem; line-height: 1.75; }

.account-pill {
  min-width: 220px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(13, 30, 47, 0.82);
}

.account-avatar { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; color: var(--muted); background: var(--panel-3); font-weight: 800; }
.account-pill small, .account-pill strong { display: block; }
.account-pill small { margin-bottom: 3px; color: var(--muted-2); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.1em; }
.account-pill strong { font-size: 0.9rem; }
.account-pill.is-online .account-avatar { color: #06281e; background: linear-gradient(135deg, var(--mint), #5abdf6); }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}

.stat-card {
  min-height: 134px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border: 1px solid var(--line-soft);
  border-radius: 17px;
  background: linear-gradient(145deg, rgba(17, 38, 58, 0.88), rgba(10, 26, 42, 0.88));
}
.stat-card span { color: var(--muted); font-size: 0.8rem; }
.stat-card strong { font-size: 2rem; letter-spacing: -0.05em; }
.stat-card small { color: var(--muted-2); font-size: 0.72rem; }

.control-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; }
.panel { border: 1px solid var(--line-soft); border-radius: var(--radius); background: rgba(10, 25, 41, 0.9); box-shadow: var(--shadow); }
.connection-panel, .scan-panel { padding: 24px; }
.panel-heading, .data-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.panel-heading > div, .data-heading > div:first-child { display: flex; align-items: center; gap: 11px; }
.panel-heading h2, .data-heading h2 { margin: 0; font-size: 1.08rem; letter-spacing: -0.025em; }
.step-number { color: var(--mint); font: 800 0.7rem/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0.08em; }
.panel-copy { margin-bottom: 20px; color: var(--muted); font-size: 0.84rem; line-height: 1.65; }

.badge { padding: 6px 10px; border-radius: 999px; font-size: 0.7rem; font-weight: 750; }
.badge-muted { color: var(--muted); background: rgba(135, 159, 180, 0.1); }
.badge-live { color: var(--mint); background: rgba(116, 235, 191, 0.1); }

.form-grid { display: grid; grid-template-columns: 0.65fr 1.35fr; gap: 14px; }
.form-grid label, .stack-form label, .modal-card label { display: flex; flex-direction: column; gap: 8px; }
.form-grid label > span, .stack-form label, .modal-card label > span, .field-label { color: var(--muted); font-size: 0.76rem; font-weight: 650; }
.full-field { grid-column: 1 / -1; }

input, select, textarea {
  width: 100%;
  min-height: 45px;
  padding: 0 13px;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 11px;
  outline: none;
  background: rgba(5, 17, 29, 0.8);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}
textarea { min-height: 132px; padding-top: 12px; resize: vertical; line-height: 1.55; }
input::placeholder, textarea::placeholder { color: #536a7d; }
input:focus, select:focus, textarea:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(82, 215, 255, 0.1); background: #071725; }
select:disabled, input:disabled, textarea:disabled { cursor: not-allowed; opacity: 0.55; }

.button {
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 11px;
  color: var(--text);
  background: transparent;
  font-weight: 740;
  font-size: 0.82rem;
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease, opacity 0.16s ease;
}
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:focus-visible { outline: 3px solid rgba(82, 215, 255, 0.32); outline-offset: 2px; }
.button:disabled { cursor: not-allowed; opacity: 0.42; }
.button-primary { color: #05231c; background: linear-gradient(135deg, var(--mint), #61d7e9); box-shadow: 0 10px 28px rgba(59, 210, 174, 0.13); }
.button-secondary { color: #08212a; background: var(--cyan); }
.button-ghost { color: var(--muted); border-color: var(--line); background: rgba(18, 39, 59, 0.5); }
.button-danger { color: #ffdce0; border-color: rgba(255, 111, 120, 0.33); background: rgba(255, 111, 120, 0.1); }
.button-text { color: var(--danger); }
.button-small { min-height: 34px; padding: 0 12px; font-size: 0.74rem; }
.button-wide { width: 100%; }

.field-label { display: block; margin-bottom: 8px; }
#group-select { margin-bottom: 15px; }
.source-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 15px 0; }
.check-card { padding: 13px; display: flex; align-items: flex-start; gap: 10px; border: 1px solid var(--line-soft); border-radius: 12px; background: rgba(17, 39, 60, 0.54); cursor: pointer; }
.check-card input { width: 16px; min-height: auto; margin: 3px 0 0; accent-color: var(--mint-strong); }
.check-card strong, .check-card small { display: block; }
.check-card strong { margin-bottom: 5px; font-size: 0.81rem; }
.check-card small { color: var(--muted-2); font-size: 0.68rem; line-height: 1.45; }
#message-limit { margin-bottom: 15px; }
.fine-print { margin: 14px 0 0; color: var(--muted-2); font-size: 0.68rem; line-height: 1.55; }

.connected-account { margin-bottom: 18px; padding: 18px; display: flex; gap: 13px; border: 1px solid rgba(116, 235, 191, 0.2); border-radius: 14px; background: rgba(116, 235, 191, 0.06); }
.connected-icon { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; color: #03251d; background: var(--mint); font-weight: 900; }
.connected-account small, .connected-account strong, .connected-account div > span { display: block; }
.connected-account small { color: var(--muted-2); font-size: 0.67rem; }
.connected-account strong { margin: 2px 0; }
.connected-account div > span { color: var(--cyan); font-size: 0.76rem; }

.accounts-panel { padding: 24px; margin-bottom: 18px; }
.inline-note { margin: 0; text-align: right; }
.account-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.tg-account-card { padding: 18px; border: 1px solid var(--line-soft); border-radius: 16px; background: rgba(15, 34, 52, 0.72); }
.account-card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 17px; }
.account-card-heading strong, .account-card-heading small { display: block; }
.account-card-heading strong { margin: 9px 0 3px; }
.account-card-heading small { color: var(--muted-2); font-size: 0.7rem; }
.slot-chip { display: inline-flex; padding: 4px 8px; border-radius: 999px; color: var(--cyan); background: rgba(82, 215, 255, 0.09); font-size: 0.65rem; font-weight: 800; }
.section-gap { margin-top: 18px; }
.outreach-overview { padding: 24px; }
.mini-stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mini-stat-grid > div { padding: 15px; border: 1px solid var(--line-soft); border-radius: 12px; background: rgba(6, 19, 32, 0.62); }
.mini-stat-grid span, .mini-stat-grid strong { display: block; }
.mini-stat-grid span { margin-bottom: 7px; color: var(--muted-2); font-size: 0.68rem; }
.mini-stat-grid strong { font-size: 1.35rem; }
.guardrail-note { margin-top: 13px; padding: 14px; border: 1px solid rgba(116,235,191,.18); border-radius: 12px; background: rgba(116,235,191,.055); }
.guardrail-note strong, .guardrail-note span { display: block; }
.guardrail-note strong { margin-bottom: 5px; color: var(--mint); font-size: 0.76rem; }
.guardrail-note span { color: var(--muted); font-size: 0.7rem; line-height: 1.55; }

.outreach-panel { overflow: hidden; }
.outreach-forms { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 0 24px 24px; }
.work-card { padding: 18px; border: 1px solid var(--line-soft); border-radius: 15px; background: rgba(7, 21, 35, 0.66); }
.work-card-heading { margin-bottom: 2px; }
.work-card-heading strong, .work-card-heading small { display: block; }
.work-card-heading small { margin-top: 5px; color: var(--muted-2); font-size: 0.68rem; }
.consent-check { padding: 12px; flex-direction: row !important; align-items: flex-start; border: 1px solid rgba(116,235,191,.16); border-radius: 11px; background: rgba(116,235,191,.04); cursor: pointer; }
.consent-check input { width: 17px; min-height: auto; margin-top: 3px; accent-color: var(--mint-strong); }
.consent-check strong, .consent-check small { display: block; }
.consent-check strong { color: var(--text); font-size: 0.76rem; }
.consent-check small { margin-top: 4px; color: var(--muted-2); font-size: 0.66rem; }
.subsection-heading { padding: 18px 24px 12px; border-top: 1px solid var(--line-soft); }
.subsection-heading strong, .subsection-heading span { display: block; }
.subsection-heading strong { margin-bottom: 4px; font-size: 0.84rem; }
.subsection-heading span { color: var(--muted-2); font-size: 0.68rem; }
.log-heading { margin-top: 8px; }
.outreach-table { min-width: 880px; }
.message-log-table { min-width: 980px; }
.source-tag.blocked { color: var(--warning); background: rgba(255, 200, 111, 0.08); }
.result-counts { color: var(--muted-2); }
.result-counts b { font-weight: 800; }
.ok { color: var(--mint); }
.fail { color: var(--danger); }
.reply { color: var(--cyan); }
.log-status { display: inline-flex; padding: 4px 7px; border-radius: 999px; font-size: 0.64rem; font-weight: 760; background: rgba(255,255,255,.05); }
.log-status.ok { color: var(--mint); }
.log-status.fail { color: var(--danger); }
.log-status.reply { color: var(--cyan); }
.cell-subtitle { display: block; margin-top: 4px; color: var(--muted-2); font-size: 0.65rem; }
.message-copy { max-width: 420px; white-space: pre-wrap; word-break: break-word; line-height: 1.55; }

.job-box { margin-top: 15px; padding: 13px; border: 1px solid var(--line-soft); border-radius: 12px; background: rgba(4, 15, 26, 0.7); }
.job-line { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 9px; color: var(--muted); font-size: 0.73rem; }
.job-line strong { color: var(--text); }
.progress-track { height: 5px; overflow: hidden; border-radius: 999px; background: #152d43; }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--mint), var(--cyan)); transition: width 0.3s ease; }

.data-panel { overflow: hidden; }
.data-heading { margin: 0; padding: 22px 24px 18px; }
.export-actions { display: flex; gap: 8px; }
.filters { padding: 0 24px 17px; display: grid; grid-template-columns: minmax(240px, 1fr) 190px auto; gap: 10px; }
.filters .button { white-space: nowrap; }
.table-wrap { overflow-x: auto; border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 14px 24px; text-align: left; border-bottom: 1px solid rgba(157, 188, 211, 0.08); }
th { color: var(--muted-2); background: rgba(7, 20, 33, 0.86); font-size: 0.66rem; letter-spacing: 0.08em; text-transform: uppercase; }
td { color: #cbd9e4; font-size: 0.78rem; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(82, 215, 255, 0.025); }
.person-cell { display: flex; align-items: center; gap: 11px; }
.person-avatar { flex: 0 0 auto; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; color: #082326; background: linear-gradient(135deg, #78e9bc, #76c8f2); font-weight: 850; }
.person-cell strong, .person-cell small { display: block; }
.person-cell strong { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.person-cell small { margin-top: 3px; color: var(--muted-2); font-size: 0.65rem; }
.username { color: var(--cyan); }
.source-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.source-tag { padding: 4px 7px; border-radius: 999px; font-size: 0.63rem; }
.source-tag.member { color: var(--mint); background: rgba(116, 235, 191, 0.08); }
.source-tag.author { color: var(--cyan); background: rgba(82, 215, 255, 0.08); }
.empty-cell { padding: 48px 24px; text-align: center; color: var(--muted-2); }
.pagination { padding: 16px 24px; display: flex; align-items: center; justify-content: space-between; color: var(--muted-2); font-size: 0.72rem; }
.pagination > div { display: flex; align-items: center; gap: 11px; }

.toast-region { position: fixed; top: 82px; right: 22px; z-index: 60; display: grid; gap: 10px; }
.toast { width: min(380px, calc(100vw - 44px)); padding: 13px 15px; border: 1px solid var(--line); border-radius: 12px; background: #10243a; box-shadow: var(--shadow); color: #dceaf3; font-size: 0.78rem; animation: toast-in 0.22s ease both; }
.toast.success { border-color: rgba(116, 235, 191, 0.3); }
.toast.error { border-color: rgba(255, 111, 120, 0.4); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }

.modal { width: min(460px, calc(100vw - 28px)); padding: 0; border: 0; border-radius: 20px; background: transparent; color: var(--text); }
.modal::backdrop { background: rgba(2, 8, 14, 0.76); backdrop-filter: blur(7px); }
.modal-card { position: relative; padding: 30px; border: 1px solid var(--line); border-radius: 20px; background: #0d1d2e; box-shadow: 0 36px 100px rgba(0,0,0,.55); }
.modal-card h2 { margin: 14px 0 8px; font-size: 1.25rem; }
.modal-card p { margin-bottom: 20px; color: var(--muted); font-size: 0.8rem; line-height: 1.65; }
.modal-card label { margin-bottom: 16px; }
.modal-close { position: absolute; top: 14px; right: 14px; width: 30px; height: 30px; border: 0; border-radius: 50%; color: var(--muted); background: rgba(255,255,255,.04); font-size: 1.25rem; }
.modal-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px; color: #07241d; background: var(--mint); font-weight: 900; }
.modal-icon-danger { color: #33080d; background: var(--danger); }
.compact-modal { padding: 28px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; }
.alert { margin-bottom: 15px; padding: 11px 12px; border-radius: 10px; font-size: 0.76rem; }
.alert-error { color: #ffd7db; border: 1px solid rgba(255,111,120,.28); background: rgba(255,111,120,.08); }

.login-page { display: grid; place-items: center; padding: 40px; }
.login-shell { width: min(1080px, 100%); display: grid; grid-template-columns: 1.2fr .8fr; align-items: center; gap: clamp(42px, 8vw, 110px); }
.login-copy h1 { max-width: 690px; margin: 22px 0 20px; font-size: clamp(2.5rem, 6vw, 4.9rem); line-height: 1.02; letter-spacing: -0.065em; }
.login-copy .lead { max-width: 620px; color: var(--muted); font-size: 0.98rem; line-height: 1.85; }
.trust-row { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 25px; }
.trust-row span { padding: 7px 10px; border: 1px solid var(--line-soft); border-radius: 999px; color: var(--muted); background: rgba(17, 38, 58, 0.5); font-size: 0.68rem; }
.login-card { padding: 30px; border: 1px solid var(--line); border-radius: 22px; background: rgba(13, 29, 46, 0.92); box-shadow: var(--shadow); }
.login-card h2 { margin: 22px 0 7px; font-size: 1.35rem; }
.login-card > p:not(.fine-print) { margin-bottom: 22px; color: var(--muted); font-size: 0.8rem; }
.status-chip { display: inline-flex; align-items: center; gap: 8px; padding: 6px 9px; border-radius: 999px; color: var(--mint); background: rgba(116,235,191,.08); font-size: 0.67rem; font-weight: 700; }
.stack-form { display: grid; gap: 15px; }

@media (max-width: 900px) {
  .workspace { width: min(100% - 28px, 760px); padding-top: 36px; }
  .hero-panel { align-items: flex-start; flex-direction: column; }
  .account-pill { width: 100%; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .control-grid { grid-template-columns: 1fr; }
  .account-grid, .outreach-forms { grid-template-columns: 1fr; }
  .inline-note { display: none; }
  .login-shell { grid-template-columns: 1fr; gap: 44px; }
  .login-copy h1 { font-size: clamp(2.35rem, 10vw, 4.4rem); }
}

@media (max-width: 620px) {
  .topbar { padding: 0 16px; }
  .privacy-label { display: none; }
  .workspace { width: min(100% - 20px, 520px); padding-bottom: 40px; }
  .hero-panel h1 { font-size: 2.35rem; }
  .stat-grid { gap: 9px; }
  .stat-card { min-height: 116px; padding: 15px; }
  .stat-card strong { font-size: 1.65rem; }
  .connection-panel, .scan-panel { padding: 18px; }
  .accounts-panel, .outreach-overview { padding: 18px; }
  .panel-heading { align-items: flex-start; }
  .form-grid, .source-options { grid-template-columns: 1fr; }
  .full-field { grid-column: auto; }
  .data-heading { align-items: flex-start; flex-direction: column; }
  .filters { grid-template-columns: 1fr; padding: 0 18px 16px; }
  .pagination { align-items: flex-start; flex-direction: column; gap: 13px; }
  .login-page { padding: 24px 18px; place-items: start center; }
  .login-shell { gap: 30px; }
  .login-card { padding: 23px; }
}

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