:root {
  --sidebar: #15233d;
  --sidebar-soft: #1c2d4a;
  --sidebar-text: #c7d1e4;
  --sidebar-muted: #9aa8c0;
  --bg: #eef1f8;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #4b5563;
  --line: #e5e7eb;
  --blue: #3b6ef5;
  --blue-tint: #eaf0ff;
  --green: #15803d;
  --green-tint: #ecfdf3;
  --amber: #a96913;
  --amber-tint: #fff4dc;
  --red: #ce5254;
  --red-tint: #fff0f0;
  --shadow: 0 1px 2px rgba(21,35,61,.06), 0 8px 24px rgba(21,35,61,.04);
  --font: 15px;
  --title: 27px;
  --card-title: 18px;
  --label: 14px;
  --hint: 13.5px;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font-family: "Noto Sans CJK SC", "Noto Sans CJK SC Regular", "Source Han Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 15px; line-height: 1.55;
}
body { display: flex; min-height: 100vh; }

.sidebar {
  width: 248px; background: var(--sidebar); color: var(--sidebar-text);
  flex: none; display: flex; flex-direction: column;
  padding: 20px 16px 18px;
  min-height: 100vh; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; gap: 12px; align-items: center; padding: 2px 6px 18px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 9px; background: var(--blue); color: #fff;
  font-weight: 700; display: flex; align-items: center; justify-content: center;
  font-size: 13px; letter-spacing: .04em;
}
.brand-name { color: #f6f8ff; font-size: 20px; font-weight: 700; letter-spacing: .04em; }
.brand-sub { color: var(--sidebar-muted); font-size: 13px; margin-top: 2px; }
.user-card {
  display: flex; gap: 10px; align-items: center; background: var(--sidebar-soft);
  border-radius: 12px; padding: 12px 14px; margin-bottom: 20px;
}
.avatar {
  width: 36px; height: 36px; border-radius: 50%; background: #414d63; color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 650; font-size: 15px;
}
.user-label { color: #8995ab; font-size: 13px; }
.user-name { color: #f5f7fb; font-weight: 650; font-size: 16px; }
.user-role { color: #9eabc0; font-size: 13.5px; }
.nav-label { color: #8a97ad; font-size: 12px; letter-spacing: .12em; padding: 0 10px 10px; }
.nav-btn {
  display: flex; align-items: center; gap: 8px; width: 100%; border: 0; background: transparent;
  color: var(--sidebar-text); text-align: left; padding: 11px 12px; border-radius: 8px;
  font-size: 15px; margin-bottom: 4px; cursor: pointer; text-decoration: none;
}
.nav-btn.active { background: var(--blue); color: #fff; font-weight: 600; }
.logout {
  margin-top: auto; width: 100%; border: 1px solid #33405a; background: transparent;
  color: var(--sidebar-text); padding: 11px 12px; border-radius: 8px; font-size: 15px; cursor: pointer;
}

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 100vh; }
.topbar {
  height: 56px; display: flex; align-items: center; justify-content: flex-end;
  gap: 16px; padding: 0 32px; border-bottom: 1px solid #e3e7f0; background: #f7f8fc;
}
.server-hint { color: #6b7280; font-size: var(--hint); }
.user-chip { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 7px 14px; font-size: 14px; color: var(--text); }
.content {
  flex: 1; width: 100%; max-width: 1440px; margin: 0 auto;
  padding: 24px 32px 48px;
}
.crumb { color: #4b5563; font-size: 14px; margin-bottom: 6px; }
.crumb strong { color: var(--text); font-weight: 600; }
.page-title { font-size: 27px; font-weight: 700; letter-spacing: -.03em; margin: 0 0 6px; line-height: 1.25; color: #111827; }
.page-sub { color: #374151; margin: 0 0 18px; font-size: 15px; line-height: 1.55; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: stretch; }
.card { background: var(--card); border: 1px solid #e8ebf2; border-radius: 14px; padding: 20px 22px 22px; box-shadow: var(--shadow); }
.card-head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 14px; }
.icon-box {
  width: 36px; height: 36px; border-radius: 8px; background: var(--blue-tint); color: var(--blue);
  display: flex; align-items: center; justify-content: center; flex: none; font-size: 16px;
}
.card-title { font-size: 18px; font-weight: 700; color: #111827; }
.card-sub { color: #374151; font-size: 14px; line-height: 1.5; margin-top: 3px; }
.section-title { font-size: 18px; font-weight: 700; margin: 22px 0 12px; }

.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.tab { padding: 8px 16px; font-size: 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab.active { color: var(--blue); font-weight: 600; border-bottom-color: var(--blue); }

.textarea, .input, .select {
  width: 100%; border: 1px solid #d7dbe3; border-radius: 8px;
  padding: 11px 13px; font-size: 15px; color: var(--text); background: #fff; font-family: inherit; line-height: 1.45;
}
.textarea { min-height: 150px; resize: vertical; line-height: 1.55; color: #374151; }
.row { display: flex; gap: 10px; margin-top: 12px; align-items: center; }
.btn {
  border: 0; border-radius: 8px; padding: 10px 18px; font-size: 15px; font-weight: 600;
  font-family: inherit; cursor: pointer; line-height: 1.3;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary.btn-lg { padding: 14px 28px; font-size: 16px; min-width: 160px; }
.btn-ghost { background: #f3f4f6; color: var(--text); border: 1px solid #e5e7eb; }
.btn-danger { background: #fff; color: var(--red); border: 1px solid #f0c9c9; }
.btn-wide { flex: 1; }
.help { color: #374151; font-size: 13.5px; line-height: 1.55; margin-top: 8px; }
.file-input { font-size: 14px; }

.tpl-item { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center; }
.tpl-item.sel { border-color: var(--blue); background: var(--blue-tint); }
.tpl-name { font-weight: 600; font-size: 15px; }
.tpl-meta { color: #6b7280; font-size: 13.5px; }

.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 16px 0; }
.metric { background: #fff; border: 1px solid #e8ebf2; border-radius: 12px; padding: 12px 16px; }
.metric .lab { font-size: 13px; color: #374151; font-weight: 600; }
.metric .val { font-size: 26px; font-weight: 700; letter-spacing: -.03em; margin-top: 4px; line-height: 1.25; }
.metric .note { font-size: 12.5px; color: #4b5563; margin-top: 3px; }
.metric.green { background: var(--green-tint); }
.metric.green .val { color: var(--green); }
.metric.red { background: var(--red-tint); }
.metric.red .val { color: var(--red); }
.metric.blue { background: var(--blue-tint); }
.metric.blue .val { color: var(--blue); }
.metric.amber { background: var(--amber-tint); }
.metric.amber .val { color: var(--amber); }

.toolbar { display: flex; gap: 10px; flex: 1; align-items: center; }
.search { flex: 3; }
.filter { flex: 1.1; }
.caption { color: #4b5563; font-size: 13.5px; margin: 8px 0 10px; }
.abn-title { margin: 12px 0 8px; font-weight: 700; color: #b45309; font-size: 15px; }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; font-weight: 650; color: #374151; background: #f3f4f6;
  border-bottom: 1px solid var(--line); padding: 11px 12px;
}
.table td { padding: 11px 12px; border-bottom: 1px solid #eff1f4; vertical-align: middle; color: #1f2937; line-height: 1.45; }
.table-wrap { overflow-x: auto; }
table.stats { font-size: 14px; }
table.stats th, table.stats td { padding: 11px 12px; }

.badge { display: inline-block; border-radius: 999px; padding: 3px 9px; font-size: 13px; font-weight: 650; }
.badge.bad { background: var(--red-tint); color: var(--red); }
.badge.warn { background: var(--amber-tint); color: var(--amber); }
.badge.good { background: var(--green-tint); color: var(--green); }
.badge.run { background: var(--blue-tint); color: var(--blue); }
.badge.done { background: var(--green-tint); color: var(--green); }

.expander {
  border: 1px solid var(--line); border-radius: 8px; background: #fafbfe;
  padding: 10px 14px; color: var(--text); font-size: 14px; margin-top: 10px; display: block;
}
.expander summary { cursor: pointer; font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.expander span { color: #6b7280; font-weight: 500; font-size: 13.5px; }

.progress-wrap { margin-top: 6px; }
.bar { height: 10px; background: #e8ebf2; border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; width: 70%; background: var(--blue); border-radius: 99px; }
.prog-meta { color: var(--muted); font-size: 13.5px; margin: 8px 0 0; line-height: 1.5; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Full-width progress strip: compact when idle, highlighted when a job is active */
.progress-strip {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  background: #fff; border: 1px solid #e8ebf2; border-radius: 14px;
  padding: 12px 18px; margin: 0 0 18px; box-shadow: var(--shadow);
}
.progress-strip.is-idle { padding: 10px 18px; background: #f8f9fc; }
.progress-strip.is-active { border-color: #c9d6fb; background: linear-gradient(180deg, #f7f9ff 0%, #fff 100%); }
.progress-strip.is-running { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(59,110,245,.12); }
.progress-strip-left { display: flex; align-items: center; gap: 12px; min-width: 220px; }
.progress-strip-title { font-size: 16px; font-weight: 700; color: #111827; }
.progress-strip-sub { font-size: 13.5px; color: #4b5563; margin-top: 2px; }
.progress-strip-mid { flex: 1; min-width: 280px; }
.progress-nums { display: flex; gap: 18px; align-items: baseline; margin-bottom: 6px; font-size: 14px; }
.progress-nums b { font-size: 20px; font-weight: 700; }
.progress-nums .ok b { color: var(--green); }
.progress-nums .bad b { color: var(--red); }
.progress-nums .run b { color: var(--blue); }
.progress-strip-right { display: flex; gap: 8px; align-items: center; flex: none; }

.banner { background: #fff8e8; border: 1px solid #f1deaa; color: #7a5410; border-radius: 10px; padding: 10px 14px; font-size: 13.5px; margin-bottom: 14px; }
.filters { display: flex; align-items: end; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.filters label { display: block; font-size: 14px; color: var(--muted); margin-bottom: 5px; }
.metrics3 { grid-template-columns: repeat(3, 1fr); }
.mgmt { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.user-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid #f0f2f6; font-size: 15px; }
.user-row:last-child { border-bottom: 0; }
.tag { font-size: 13px; background: #f3f4f6; color: #4b5563; border-radius: 999px; padding: 2px 8px; }
.limit-note { font-size: 13.5px; color: #4b5563; margin: 0 0 12px; }

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; }

.preview-banner {
  background: #fff8e8; border-bottom: 1px solid #f1deaa; color: #7a5410;
  padding: 11px 32px; font-size: 13.5px; line-height: 1.55;
}
.preview-banner strong { font-weight: 700; }
.alert { border-radius: 10px; padding: 11px 14px; margin: 0 0 14px; font-size: 14px; }
.alert-ok { background: var(--green-tint); color: var(--green); border: 1px solid #bbf7d0; }
.alert-err { background: var(--red-tint); color: #9f1239; border: 1px solid #fecdd3; }
.alert-warn { background: var(--amber-tint); color: #7a5410; border: 1px solid #f1deaa; }
.alert-info { background: var(--blue-tint); color: #1e3a8a; border: 1px solid #dbe4ff; }
.announcement {
  margin: 0 0 1rem; padding: 1rem 1.2rem; border-radius: 12px;
  border: 1px solid #fde68a; background: linear-gradient(180deg, #fffbeb 0%, #fef3c7 100%);
}
.announcement h3 { margin: 0 0 .55rem; color: #92400e; font-size: 18px; }
.announcement .body { color: #451a03; line-height: 1.7; font-size: 15px; }
.announcement .sig { text-align: right; margin-top: .75rem; font-weight: 600; color: #334155; }

.login-shell { min-height: 100vh; width: 100%; display: flex; align-items: center; justify-content: center; background: #eef1f8; }
.login-card { width: 440px; background: #fff; border-radius: 20px; padding: 40px 36px 32px; box-shadow: 0 20px 50px rgba(21,35,61,.08); }
.login-logo { width: 52px; height: 52px; border-radius: 12px; background: var(--blue); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; margin: 0 auto 12px; font-size: 16px; }
.login-card h1 { text-align: center; margin: 0; font-size: 26px; }
.login-card .hint { text-align: center; color: var(--muted); margin: 8px 0 22px; font-size: 14px; }
.login-page, .login-page .main { background: #eef1f8; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 14px; color: #374151; margin-bottom: 5px; font-weight: 600; }

.job-card { border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; margin-bottom: 12px; background: #fff; }
.job-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.job-id { font-size: 13.5px; color: #6b7280; }
.job-subject { font-weight: 650; margin-top: 2px; font-size: 16px; }
.job-meta { color: #6b7280; font-size: 13.5px; margin-top: 8px; }
.tabs-bar { display: flex; gap: 8px; margin-bottom: 16px; }
.tabs-bar a, .tabs-bar .tab-link {
  padding: 8px 16px; border-radius: 999px; background: #fff; border: 1px solid var(--line);
  color: var(--muted); font-size: 14px;
}
.tabs-bar a.active { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 600; }
.pager { display: flex; gap: 8px; align-items: center; margin-top: 14px; font-size: 14px; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .span-2 { grid-column: 1 / -1; }
label.chk { display: flex; align-items: flex-start; gap: 8px; font-size: 14px; line-height: 1.5; margin: 6px 0; }
.muted { color: var(--muted); font-size: 13.5px; }
hr.soft { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
.hidden { display: none !important; }

.send-settings { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 24px; align-items: start; }
.send-submit {
  background: #f7f9ff; border: 1px solid #dbe4ff; border-radius: 12px;
  padding: 18px 18px 20px; text-align: center;
}
.send-submit .help { text-align: left; margin: 0 0 14px; }
.stack { display: flex; flex-direction: column; gap: 18px; }

@media (max-width: 1100px) {
  .grid-2, .mgmt, .metrics, .metrics3, .send-settings, .form-grid { grid-template-columns: 1fr; }
  .content { padding: 20px 18px 36px; }
  .sidebar { width: 220px; }
}

.queue-list {
  background: #fff; border: 1px solid #e8ebf2; border-radius: 14px;
  padding: 12px 18px 8px; margin: -6px 0 18px; box-shadow: var(--shadow);
}
.queue-head { font-size: 14px; font-weight: 700; color: #92400e; margin-bottom: 6px; }
.queue-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 0; border-top: 1px dashed #e5e7eb; font-size: 14px;
}
.queue-item .batch { font-weight: 700; color: #a96913; margin-right: 8px; }
.queue-item .muted { margin-left: 8px; }

/* Compact log/job tables: subject stays on one line with ellipsis */
.table.logs-compact, .table.stats { table-layout: fixed; width: 100%; }
.table.logs-compact th, .table.logs-compact td,
.table.stats th, .table.stats td { overflow: hidden; text-overflow: ellipsis; }
.table th.col-time, .table td.col-time { white-space: nowrap; width: 12%; }
.table th.col-user, .table td.col-user { white-space: nowrap; width: 10%; }
.table th.col-email, .table td.col-email { white-space: nowrap; width: 16%; }
.table th.col-subject, .table td.col-subject {
  width: 28%; max-width: 320px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.table th.col-status, .table td.col-status { white-space: nowrap; width: 8%; }
.table th.col-note, .table td.col-note {
  width: 14%; max-width: 220px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.job-subject {
  max-width: 720px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.btn-sm { padding: 6px 12px; font-size: 13px; }
.queue-item-actions { display: flex; align-items: center; gap: 8px; flex: none; }

/* Job recipient preview modal — lives outside the 3s progress poll region */
.modal { position: fixed; inset: 0; z-index: 80; display: flex; align-items: flex-start; justify-content: center; padding: 8vh 16px 24px; }
.modal.hidden { display: none !important; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(17, 24, 39, .45); }
.modal-card {
  position: relative; background: #fff; border-radius: 14px;
  width: min(960px, 100%); max-height: 84vh; display: flex; flex-direction: column;
  box-shadow: 0 20px 50px rgba(15, 23, 42, .2);
}
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 16px 20px 12px; border-bottom: 1px solid #e8ebf2; }
.modal-title { font-size: 18px; font-weight: 700; }
.modal-sub { color: #4b5563; font-size: 13.5px; margin-top: 4px; line-height: 1.5; }
.modal-body { overflow: auto; padding: 12px 20px 20px; }
.modal-body .table { width: 100%; }
.modal-body .col-dup { white-space: nowrap; width: 1%; }
.badge.dup { background: #fff7ed; color: #c2410c; border: 1px solid #fdba74; }
body.modal-open { overflow: hidden; }
