/* 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; }
.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-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;
}
.btn:hover { background: #f5f5f5; border-color: #888; }
.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; }
.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%;
}

.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; }

/* ===== 运行日志（对应桌面底部 ScrolledText height=8） ===== */
.log-panel {
  flex-shrink: 0;
  background: #1e1e1e;
  color: #ccc;
  border-top: 2px solid #2b5278;
  height: 200px;
  min-height: 160px;
  max-height: 280px;
  display: flex;
  flex-direction: column;
  resize: vertical;
  overflow: hidden;
}
.log-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 12px;
  background: #2d2d2d;
  color: #fff;
  font-size: 13px;
  flex-shrink: 0;
}
#log-box {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  line-height: 1.55;
}
.log-line.error { color: #f48771; }
.log-line.info { color: #9cdcfe; }

/* ===== 登录遮罩 ===== */
.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: 4em; padding: 5px; border: 1px solid #aca899; border-radius: 3px; font-size: 14px; text-align: center; }
.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-select-row { display: flex; gap: 8px; align-items: center; 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-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; }
}
