/* Telegram拉人助手 网页版 — 对齐桌面版 1000×700 大布局 */
* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  min-width: 1000px;
  font-size: 14px;
  font-family: "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  background: #ece9d8;
  color: #1a1a1a;
  overflow: hidden;
}

body.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ===== 顶栏（对应桌面标题+状态） ===== */
.topbar {
  flex-shrink: 0;
  background: linear-gradient(180deg, #3a6ea5 0%, #2b5278 100%);
  color: #fff;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #1e3d5c;
  min-height: 44px;
}
.topbar h1 { font-size: 16px; font-weight: 600; white-space: nowrap; }
.topbar .ver { font-size: 12px; opacity: 0.85; font-weight: normal; margin-left: 8px; }
.status-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.badge.warn {
  background: #fff3e0;
  border: 1px solid #ff9800;
  color: #e65100;
  font-weight: 600;
}
.target-hint {
  margin: 8px 0 12px;
  padding: 10px 12px;
  background: #fff8e1;
  border: 1px solid #ffb74d;
  border-radius: 4px;
  color: #bf360c;
  font-size: 14px;
  line-height: 1.5;
}
.target-hint.hidden { display: none; }
.badge {
  background: rgba(255,255,255,0.18);
  padding: 4px 12px;
  border-radius: 3px;
  font-size: 13px;
  white-space: nowrap;
}
.badge.on { background: #2e7d32; }
.badge.off { background: rgba(0,0,0,0.25); }

/* ===== 标签页（对应 ttk.Notebook） ===== */
.tabs {
  flex-shrink: 0;
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  background: #f0f0f0;
  border-bottom: 1px solid #aca899;
  padding: 0;
  gap: 0;
}
.tab {
  border: none;
  border-right: 1px solid #aca899;
  background: #ece9d8;
  padding: 10px 18px;
  cursor: pointer;
  font-size: 14px;
  color: #333;
  white-space: nowrap;
  min-height: 38px;
}
.tab:hover { background: #fff; }
.tab.active {
  background: #fff;
  font-weight: 600;
  color: #2b5278;
  border-bottom: 2px solid #2b5278;
  margin-bottom: -1px;
}

/* ===== 主内容区（占满中间，可滚动） ===== */
.content {
  flex: 1 1 auto;
  overflow: auto;
  padding: 12px 16px;
  width: 100%;
  max-width: none;
  background: #fff;
  min-height: 0;
}

.panel { display: none; }
.panel.active {
  display: block;
  min-height: 100%;
}
.panel h2 {
  margin-bottom: 12px;
  font-size: 16px;
  font-weight: 600;
  color: #2b5278;
  padding-bottom: 6px;
  border-bottom: 1px solid #ddd;
}
.panel h3 {
  margin: 14px 0 8px;
  font-size: 14px;
  font-weight: 600;
  color: #444;
}

/* ===== 表单 ===== */
.form-grid {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 10px 16px;
  align-items: center;
  width: 100%;
  max-width: none;
  margin-bottom: 12px;
}
.form-grid label { font-size: 14px; color: #333; white-space: nowrap; }
.form-grid input[type="text"],
.form-grid input[type="number"],
.form-grid input[type="password"],
.form-grid select {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid #aca899;
  border-radius: 3px;
  font-size: 14px;
  min-height: 32px;
}
.form-grid > span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.form-grid .input-sm-num,
.form-grid input.input-sm-num {
  width: 4.2em;
  min-width: 3.2em;
  max-width: 5em;
  padding: 4px 6px;
  min-height: 28px;
  text-align: center;
  flex: 0 0 auto;
}
.form-grid-compact {
  grid-template-columns: minmax(120px, auto) auto;
  gap: 8px 12px;
  max-width: 640px;
}
.form-grid-compact label {
  justify-self: end;
  padding-right: 4px;
}
.form-grid-wide { grid-template-columns: 160px 1fr 160px 1fr; }

.checkbox-row {
  display: flex;
  flex-wrap: wrap;
  gap: 20px 28px;
  margin: 12px 0;
  font-size: 14px;
}
.checkbox-row label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  white-space: nowrap;
}
.checkbox-row input[type="checkbox"],
.checkbox-row input[type="radio"] {
  width: 16px;
  height: 16px;
}

/* ===== 按钮工具栏 ===== */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
  align-items: center;
}
.toolbar.vertical { flex-direction: column; align-items: stretch; }
.btn {
  padding: 7px 16px;
  border: 1px solid #aca899;
  background: linear-gradient(180deg, #fff 0%, #ece9d8 100%);
  border-radius: 3px;
  cursor: pointer;
  font-size: 14px;
  min-height: 32px;
  white-space: nowrap;
  touch-action: manipulation;
  user-select: none;
  transition: transform 0.08s ease, opacity 0.12s ease, box-shadow 0.12s ease;
}
.btn:hover:not(:disabled):not(.is-busy) { background: #f5f5f5; border-color: #888; }
.btn:active:not(:disabled):not(.is-busy) { transform: scale(0.98); }
.btn:disabled,
.btn.is-busy {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}
body.api-pending { cursor: progress; }
body.api-pending .btn.primary { box-shadow: 0 0 0 1px rgba(43, 82, 120, 0.25); }

.toast-host {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 360px;
  pointer-events: none;
}
.toast-item {
  pointer-events: auto;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 14px;
  line-height: 1.4;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  animation: toast-in 0.2s ease;
  background: #fff;
  border: 1px solid #ccc;
  color: #222;
}
.toast-item.err { background: #ffebee; border-color: #e57373; color: #b71c1c; }
.toast-item.ok { background: #e8f5e9; border-color: #81c784; color: #1b5e20; }
.toast-item.warn { background: #fff8e1; border-color: #ffb74d; color: #e65100; }
@keyframes toast-in {
  from { opacity: 0; transform: translateX(12px); }
  to { opacity: 1; transform: translateX(0); }
}
.btn.primary {
  background: linear-gradient(180deg, #4a7ab0 0%, #2b5278 100%);
  color: #fff;
  border-color: #1e3d5c;
}
.btn.primary:hover { background: #1e3d5c; }
.btn.lg { padding: 10px 24px; font-size: 15px; min-height: 40px; }
.btn.sm { padding: 4px 12px; font-size: 13px; min-height: 28px; }
.btn.danger { background: #e57373; color: #fff; border-color: #c62828; }
.btn.success { background: #43a047; color: #fff; border-color: #2e7d32; }
.btn.purple { background: #7e57c2; color: #fff; border-color: #5e35b1; }

.file-btn {
  display: inline-flex;
  align-items: center;
  padding: 7px 16px;
  border: 1px solid #aca899;
  background: #fff;
  border-radius: 3px;
  cursor: pointer;
  font-size: 14px;
  min-height: 32px;
}
.file-btn:hover { background: #f0f0f0; }

/* ===== 文本域 / 输入 ===== */
textarea,
input[type="text"],
input[type="number"],
input[type="password"],
select {
  font-family: inherit;
  font-size: 14px;
}
textarea {
  width: 100%;
  max-width: none;
  min-height: 100px;
  padding: 8px 10px;
  border: 1px solid #aca899;
  border-radius: 3px;
  margin-bottom: 8px;
  resize: vertical;
  line-height: 1.5;
}
textarea.tall { min-height: 160px; }
textarea.short { min-height: 70px; }

/* ===== 数据表格（桌面 Treeview 高度） ===== */
.table-wrap {
  width: 100%;
  overflow: auto;
  border: 1px solid #aca899;
  background: #fff;
  min-height: 280px;
  max-height: 420px;
  margin-top: 8px;
}
.table-wrap.tall { min-height: 360px; max-height: 520px; }
.table-wrap.short { min-height: 180px; max-height: 280px; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin: 0;
  box-shadow: none;
}
.data-table th, .data-table td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid #e0e0e0;
  white-space: nowrap;
}
.data-table th {
  background: #f0f0f0;
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 1;
  border-bottom: 2px solid #aca899;
}
.data-table tbody tr:nth-child(even) { background: #fafafa; }
.data-table.clickable tbody tr { cursor: pointer; }
.data-table.clickable tbody tr:hover { background: #e3f2fd; }

/* ===== 卡片 / 分区 ===== */
.card {
  background: #fafafa;
  border: 1px solid #aca899;
  border-radius: 4px;
  padding: 14px 16px;
  margin-bottom: 12px;
}
.card h3 { font-size: 14px; margin-bottom: 10px; color: #2b5278; border: none; }
.card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
}

.pwd-box {
  border: 1px solid #aca899;
  border-radius: 4px;
  padding: 14px 16px;
  margin: 14px 0;
  background: #fafafa;
  width: 100%;
}
.pwd-box legend { font-weight: 600; padding: 0 8px; font-size: 14px; }

.hint { color: #666; font-size: 13px; margin: 6px 0; line-height: 1.5; }
.highlight { color: #2b5278; font-weight: 600; }
.highlight.warn-text { color: #e65100; }
.stats-line { font-weight: 600; margin: 8px 0; color: #2b5278; font-size: 14px; }
.step-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 32px;
  padding: 12px 0;
  font-weight: 600;
  font-size: 14px;
  color: #444;
}

/* ===== 分栏布局（群组管理等） ===== */
.split-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 16px;
  width: 100%;
  min-height: 480px;
}
.split-main { min-width: 0; }
.split-side {
  background: #fafafa;
  border: 1px solid #aca899;
  border-radius: 4px;
  padding: 14px;
}
.split-side p { margin: 6px 0; font-size: 14px; line-height: 1.6; }
.split-side .toolbar.vertical .btn { width: 100%; margin-bottom: 6px; }

/* ===== 子标签 ===== */
.sub-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  flex-wrap: wrap;
  border-bottom: 1px solid #ddd;
  padding-bottom: 4px;
}
.sub-tab {
  padding: 8px 16px;
  border: 1px solid #aca899;
  border-bottom: none;
  background: #ece9d8;
  cursor: pointer;
  border-radius: 4px 4px 0 0;
  font-size: 14px;
  min-height: 36px;
}
.sub-tab.active {
  background: #2b5278;
  color: #fff;
  border-color: #2b5278;
}
.sub-panel { display: none; margin-bottom: 12px; width: 100%; }
.sub-panel.active { display: block; }

/* ===== 群列表勾选 ===== */
.check-list {
  min-height: 280px;
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid #aca899;
  padding: 10px;
  background: #fff;
  margin: 8px 0;
  border-radius: 3px;
  width: 100%;
}
.check-list label {
  display: block;
  padding: 4px 0;
  font-size: 13px;
  line-height: 1.5;
  cursor: pointer;
}
.check-list label:hover { background: #f0f7ff; }

.progress-wrap {
  height: 22px;
  background: #e0e0e0;
  border: 1px solid #aca899;
  border-radius: 3px;
  margin: 10px 0;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #4a7ab0, #2b5278);
  transition: width 0.3s;
  min-width: 0;
}

.log-preview {
  background: #1e1e1e;
  color: #d4d4d4;
  padding: 12px;
  border-radius: 3px;
  font-size: 13px;
  min-height: 120px;
  max-height: 240px;
  overflow: auto;
  margin-top: 10px;
  white-space: pre-wrap;
  width: 100%;
}

.inv-results-box { margin-top: 12px; }
.inv-results-wrap { max-height: 220px; margin-top: 8px; }
.inv-results-wrap .ok-row td { color: #2e7d32; }
.inv-results-wrap .fail-row td { color: #c62828; }

.sep { border: none; border-top: 1px solid #ddd; margin: 16px 0; }
.hidden { display: none !important; }

/* ===== 底部状态栏 ===== */
.bottom-status {
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 16px;
  background: #ece9d8;
  border-top: 1px solid #aca899;
  font-size: 13px;
  min-height: 32px;
}
.bottom-stats { color: #555; }
#conn-status.ok { color: #2e7d32; font-weight: 600; }
#auth-conn-status.ok { color: #2e7d32; font-weight: 600; }

/* ===== 运行日志（表格，对齐彩虹群发 LogPanel） ===== */
.log-panel {
  flex-shrink: 0;
  background: #fffef5;
  color: #222;
  border-top: 2px solid #c4b896;
  height: 240px;
  min-height: 180px;
  max-height: 360px;
  display: flex;
  flex-direction: column;
  resize: vertical;
  overflow: hidden;
}
.log-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: #f5f0d8;
  color: #333;
  font-size: 13px;
  flex-shrink: 0;
  border-bottom: 1px solid #ddd9c8;
}
.log-header-hint { color: #777; font-size: 12px; font-weight: normal; flex: 1; }
.log-header-btns { display: flex; gap: 6px; }
.log-table-wrap {
  flex: 1;
  overflow: auto;
  padding: 0;
}
.log-op-table {
  font-size: 12px;
  background: #fffef5;
}
.log-op-table thead th {
  position: sticky;
  top: 0;
  background: #f0ebd6;
  z-index: 1;
  white-space: nowrap;
}
.log-op-table td {
  padding: 4px 8px;
  border-bottom: 1px solid #ebe6d4;
  vertical-align: top;
  word-break: break-all;
}
.log-op-table tr.log-fail td { color: #b71c1c; }
.log-op-table tr.log-ok td { color: #1b5e20; }
.log-op-table td:nth-child(1) { width: 36px; text-align: right; color: #888; }
.log-op-table td:nth-child(2) { width: 168px; white-space: nowrap; }
.log-op-table td:nth-child(3) { width: 120px; }
.log-op-table td:nth-child(4) { width: 72px; }
.log-op-table td:nth-child(5) { min-width: 180px; }
.log-op-table td:nth-child(6) { min-width: 140px; }

/* ===== 登录遮罩 ===== */
.auth-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.65);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
}
.auth-overlay.hidden { display: none; }
.auth-box {
  background: #fff;
  padding: 28px;
  border-radius: 6px;
  width: 380px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.35);
}
.auth-box h3 { margin-bottom: 8px; font-size: 16px; }
.auth-box p { font-size: 14px; color: #666; margin-bottom: 12px; }
.auth-box input {
  width: 100%;
  padding: 10px;
  margin-bottom: 12px;
  border: 1px solid #aca899;
  border-radius: 3px;
  font-size: 14px;
}

/* 通用输入类（替代 inline style） */
.input-flex { flex: 1; min-width: 200px; padding: 7px 10px; border: 1px solid #aca899; border-radius: 3px; font-size: 14px; min-height: 32px; }
.input-md { width: 220px; padding: 7px 10px; border: 1px solid #aca899; border-radius: 3px; font-size: 14px; min-height: 32px; }
.input-sm-num {
  width: 4.2em;
  padding: 4px 6px;
  border: 1px solid #aca899;
  border-radius: 3px;
  font-size: 14px;
  text-align: center;
}
.limits-inline .sep { color: #666; padding: 0 2px; user-select: none; }

.queue-table-wrap {
  max-height: 320px;
  overflow: auto;
  margin-top: 8px;
}
.select-full { width: 100%; padding: 7px 10px; border: 1px solid #aca899; border-radius: 3px; font-size: 14px; min-height: 32px; }
.inv-group-row { display: flex; gap: 8px; align-items: center; width: 100%; }
.inv-group-row input { flex: 1; }

/* ===== 转发功能（对齐桌面版） ===== */
.fw-list-label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 14px; }
.fw-config-list {
  width: 100%;
  min-height: 180px;
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid #aca899;
  background: #fff;
  font-family: Consolas, "Microsoft YaHei", sans-serif;
  font-size: 13px;
  line-height: 1.6;
}
.fw-config-item {
  padding: 4px 10px;
  cursor: pointer;
  border-bottom: 1px solid #eee;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fw-config-item:hover { background: #e3f2fd; }
.fw-config-item.selected { background: #0078d7; color: #fff; }
.fw-log-box { flex: 1; }
.fw-log {
  width: 100%;
  min-height: 200px;
  max-height: 320px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid #aca899;
  padding: 10px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  margin: 0;
}
.fw-group-block { width: 100%; }
.fw-filter-row { margin-top: 6px; }
.fw-filter-row input[type="search"] {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  border: 1px solid #64b5f6;
  border-radius: 4px;
  font-size: 14px;
  background: #f5faff;
}
.fw-filter-row input[type="search"]:focus {
  outline: none;
  border-color: #1976d2;
  background: #fff;
}
.fw-filter-hint {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: #666;
}
.fw-select-row { display: flex; gap: 8px; align-items: flex-start; margin-top: 6px; }
.fw-select-row select, .fw-select-row input { flex: 1; min-width: 0; padding: 7px 10px; border: 1px solid #aca899; border-radius: 3px; font-size: 14px; }
.fw-select-row select.fw-group-select {
  min-height: 132px;
  font-size: 13px;
  line-height: 1.35;
}
.fw-form { grid-template-columns: 130px 1fr; }
.fw-form textarea { margin-bottom: 0; }

/* ===== 弹窗 ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 9000;
}
.modal-overlay.hidden { display: none; }
.modal-dialog {
  background: #ece9d8;
  border: 1px solid #888;
  border-radius: 4px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.35);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
}
.fw-modal { width: 520px; min-width: 520px; }
.fw-detail-modal { width: 600px; min-width: 600px; max-height: 80vh; }
.fw-start-modal { width: 420px; min-width: 420px; }
.fw-start-body { padding: 16px 20px 12px; }
.fw-start-title { font-weight: 600; font-size: 14px; margin-bottom: 10px; text-align: center; }
.fw-start-list {
  width: 100%;
  min-height: 220px;
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid #aca899;
  background: #fff;
  padding: 4px 0;
}
.fw-start-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  font-size: 13px;
  cursor: pointer;
  line-height: 1.4;
}
.fw-start-item:hover { background: #e3f2fd; }
.fw-start-item input { width: 16px; height: 16px; flex-shrink: 0; }
.fw-start-footer { justify-content: space-between; }
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px;
  background: linear-gradient(180deg, #3a6ea5 0%, #2b5278 100%);
  color: #fff;
}
.modal-header h3 { font-size: 15px; font-weight: 600; }
.modal-header .btn { background: rgba(255,255,255,0.2); color: #fff; border-color: rgba(255,255,255,0.3); }
.modal-body { padding: 16px 20px; overflow-y: auto; flex: 1; background: #f0f0f0; }
.modal-footer {
  padding: 12px 20px;
  display: flex; gap: 10px; justify-content: center;
  border-top: 1px solid #aca899;
  background: #ece9d8;
}

@media (max-width: 1100px) {
  .card-grid { grid-template-columns: 1fr; }
  .split-layout { grid-template-columns: 1fr; }
}
