:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --ink: #111827;
  --muted: #64748b;
  --faint: #94a3b8;
  --line: #dbe3ee;
  --line-strong: #cbd5e1;
  --brand: #176b87;
  --brand-dark: #0e5066;
  --brand-soft: #e7f4f7;
  --blue: #0f62fe;
  --blue-dark: #0b4ed8;
  --blue-soft: #eef5ff;
  --purple: #7c3aed;
  --purple-soft: #f3ecff;
  --danger: #b42318;
  --danger-soft: #fff1f0;
  --ok: #087443;
  --ok-soft: #e8f7ef;
  --warn: #b54708;
  --warn-soft: #fff4e5;
  --shadow: 0 12px 34px rgba(15, 23, 42, 0.07);
  --shadow-strong: 0 22px 60px rgba(15, 23, 42, 0.11);
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

[hidden],
.hidden {
  display: none !important;
}

body {
  position: relative;
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, #f6f8fb 0%, #eef4f8 45%, #f8fbff 100%);
  color: var(--ink);
  font-family: Inter, "Segoe UI", Arial, "Microsoft YaHei", sans-serif;
  overflow-x: hidden;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
}

body::before {
  z-index: 0;
  background:
    radial-gradient(circle at 9% 8%, rgba(15, 98, 254, 0.13), transparent 29%),
    radial-gradient(circle at 88% 4%, rgba(80, 162, 181, 0.13), transparent 27%),
    radial-gradient(circle at 92% 82%, rgba(37, 99, 235, 0.06), transparent 28%);
  filter: blur(2px);
}

body::after {
  z-index: 0;
  background-image:
    radial-gradient(circle, rgba(15, 98, 254, 0.16) 1px, transparent 1.5px),
    radial-gradient(circle, rgba(23, 107, 135, 0.1) 1px, transparent 1.5px);
  background-position: left 80px top 130px, right 80px bottom 80px;
  background-size: 18px 18px, 20px 20px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.46), transparent 72%);
}

.login-body {
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  position: relative;
  z-index: 1;
  width: min(420px, 100%);
  padding: 30px;
  border-radius: 16px;
  box-shadow: var(--shadow-strong);
}

.app-shell {
  position: relative;
  z-index: 1;
  max-width: 1720px;
  margin: 0 auto;
  padding: 22px 28px 30px;
}

.app-loading-screen {
  position: fixed;
  inset: 0;
  z-index: 1;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #f6f8fb 0%, #eef4f8 45%, #f8fbff 100%);
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.app-loading-screen.hidden {
  display: none !important;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.34);
  backdrop-filter: blur(8px);
}

.tutorial-modal {
  width: min(680px, 100%);
  max-height: min(760px, calc(100vh - 48px));
  overflow: auto;
  padding: 22px;
  border: 1px solid rgba(203, 213, 225, 0.95);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: var(--shadow-strong);
}

.tutorial-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.tutorial-modal-header h2 {
  margin: 4px 0 0;
  font-size: 20px;
}

.modal-close {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.modal-close:hover {
  background: var(--blue-soft);
  border-color: rgba(15, 98, 254, 0.28);
  color: var(--blue);
}

.tutorial-steps {
  display: grid;
  gap: 10px;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
  counter-reset: tutorial-step;
}

.tutorial-steps li {
  position: relative;
  min-height: 42px;
  padding: 10px 12px 10px 46px;
  border: 1px solid rgba(219, 227, 238, 0.95);
  border-radius: 12px;
  background: linear-gradient(180deg, #fbfdff, #f8fbff);
  color: #334155;
  font-size: 14px;
  line-height: 1.65;
}

.tutorial-steps li::before {
  counter-increment: tutorial-step;
  content: counter(tutorial-step);
  position: absolute;
  left: 12px;
  top: 11px;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
}

.tutorial-steps strong {
  color: var(--ink);
}

.app-loading-screen::before {
  content: "";
  width: 28px;
  height: 28px;
  margin-bottom: 52px;
  border: 3px solid #d8e6fa;
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 82px;
  margin-bottom: 14px;
  padding: 14px 18px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(219, 227, 238, 0.9);
  border-radius: 16px;
  box-shadow: 0 16px 42px rgba(15, 23, 42, 0.09);
  backdrop-filter: blur(12px);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 310px;
}

.brand-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.brand-icon {
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  border-radius: 12px;
  background: linear-gradient(135deg, #0f62fe, #1d4ed8);
  color: #fff;
  font-size: 24px;
  box-shadow: 0 12px 26px rgba(15, 98, 254, 0.24);
}

.tutorial-trigger {
  height: 28px;
  padding: 0 10px;
  border: 1px solid rgba(15, 98, 254, 0.2);
  border-radius: 999px;
  background: #f4f8ff;
  color: #0f4fba;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease, background 0.16s ease;
}

.tutorial-trigger:hover {
  background: #eef5ff;
  border-color: rgba(15, 98, 254, 0.38);
  box-shadow: 0 8px 18px rgba(15, 98, 254, 0.12);
  transform: translateY(-1px);
}

.tutorial-trigger:focus-visible,
.modal-close:focus-visible {
  outline: 3px solid rgba(15, 98, 254, 0.18);
  outline-offset: 2px;
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(380px, 30%);
  gap: 20px;
  align-items: start;
}

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

.overview-card {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 104px;
  padding: 16px 18px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(219, 227, 238, 0.92);
  border-radius: 12px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.055);
  backdrop-filter: blur(10px);
}

.overview-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 19px;
}

.overview-icon.blue {
  background: var(--blue-soft);
  color: var(--blue);
}

.overview-icon.orange {
  background: var(--warn-soft);
  color: var(--warn);
}

.overview-icon.green {
  background: var(--ok-soft);
  color: var(--ok);
}

.overview-icon.purple {
  background: var(--purple-soft);
  color: var(--purple);
}

.overview-card p {
  margin: 0 0 4px;
  color: #334155;
  font-size: 13px;
  font-weight: 800;
}

.overview-card strong {
  display: block;
  color: var(--ink);
  font-size: 26px;
  line-height: 1.05;
}

.overview-card small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.workspace,
.results-panel {
  min-width: 0;
}

.eyebrow,
.section-kicker {
  margin: 0 0 5px;
  color: var(--brand);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.2;
}

h2 {
  font-size: 16px;
  line-height: 1.35;
}

p {
  margin: 7px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.panel {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.login-panel h1 {
  margin-bottom: 20px;
}

.login-panel label {
  margin-bottom: 14px;
}

.login-panel button {
  width: 100%;
  margin-top: 4px;
  background: var(--brand);
  color: #fff;
  box-shadow: 0 10px 22px rgba(23, 107, 135, 0.2);
}

.login-panel button:hover {
  background: var(--brand-dark);
}

.login-note {
  margin-top: 14px;
  color: var(--faint);
  font-size: 12px;
  text-align: center;
}

.summary-text {
  min-height: 18px;
  margin-top: 12px;
  color: var(--danger);
  font-size: 13px;
  line-height: 1.45;
}

.panel + .panel,
.split-grid + .panel {
  margin-top: 14px;
}

.flow-panel {
  position: relative;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 10px;
  padding: 14px 16px 16px 14px;
}

.flow-panel::before {
  content: "";
  position: absolute;
  left: 31px;
  top: 47px;
  bottom: -16px;
  width: 1px;
  background: linear-gradient(to bottom, #c9dcf7, transparent);
}

.flow-panel:last-of-type::before {
  display: none;
}

.step-label {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  margin: 0 auto;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  font-size: 12px;
  font-weight: 850;
  box-shadow: 0 8px 18px rgba(15, 98, 254, 0.25);
}

.flow-content {
  min-width: 0;
}

.panel-heading,
.result-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.panel-heading.compact {
  align-items: center;
}

.split-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  gap: 18px;
}

.upload-panel {
  gap: 10px;
}

.upload-actions,
.template-actions,
.export-actions,
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.upload-actions {
  padding: 8px 0 2px;
  background: transparent;
  border: 0;
  border-radius: 8px;
}

.upload-panel .panel-heading {
  margin-bottom: 8px;
}

.upload-panel .template-hint {
  margin-top: 8px;
  padding: 10px 12px;
  background: #f7fbff;
  border: 1px solid #d8e6fa;
  border-radius: 8px;
}

.summary-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.summary-chip {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 28px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: #334155;
  font-size: 12px;
  font-weight: 750;
}

.summary-chip strong {
  margin-right: 4px;
  color: var(--muted);
}

.channel-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 8px 0 16px;
  padding: 13px 14px;
  background: linear-gradient(135deg, #f7fbff, #f2f7ff);
  border: 1px solid #d8e6fa;
  border-radius: 10px;
}

.channel-box p {
  margin-top: 4px;
  font-size: 13px;
}

.channel-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.safety-grid,
.template-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.9fr);
  gap: 14px;
  align-items: start;
}

.template-grid {
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.8fr);
}

.field-label {
  margin-top: 14px;
  color: #334155;
  font-size: 13px;
  font-weight: 800;
}

.template-hint,
.notice {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.notice {
  min-height: 0;
  padding: 10px 12px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.notice strong {
  color: var(--ink);
  margin-right: 4px;
}

.notice span {
  display: block;
  margin-top: 3px;
}

.notice:empty {
  display: none;
}

.notice.inline {
  margin-top: 12px;
}

.notice.muted {
  background: #fbfdff;
}

.variable-help {
  margin: 0;
  padding: 14px;
  background: linear-gradient(180deg, #f7fbfd, #f3f8fb);
  border: 1px solid #d7e8ef;
  border-radius: 10px;
}

.variable-help-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  color: var(--ink);
  font-size: 14px;
}

.info-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

.variable-help-copy p {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.variable-help-copy p strong {
  color: var(--ink);
}

.variable-help code {
  padding: 1px 5px;
  border-radius: 5px;
  background: rgba(23, 107, 135, 0.1);
  color: var(--brand-dark);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
}

.example-block {
  margin-top: 8px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(207, 225, 234, 0.82);
  border-radius: 8px;
}

.example-block span,
.example-block small {
  display: block;
}

.example-block span {
  color: var(--ink);
  font-size: 13px;
}

.example-block small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.variable-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.variable-tag {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 9px;
  border: 1px solid #cfe1ea;
  border-radius: 999px;
  background: #fff;
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease, transform 0.16s ease;
}

.variable-tag:hover {
  background: var(--brand-soft);
  border-color: #a8cad8;
  transform: translateY(-1px);
}

.sub-panel {
  margin-bottom: 16px;
  padding: 14px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  margin-top: 12px;
  color: #334155;
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

textarea {
  min-height: 260px;
  resize: vertical;
  line-height: 1.62;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(23, 107, 135, 0.12);
}

.file-picker input {
  display: none;
}

.btn,
.button-link,
.file-picker span,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 8px;
  font: inherit;
  font-size: 13px;
  font-weight: 760;
  padding: 0 14px;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease, border-color 0.12s ease;
}

.btn:hover,
.button-link:hover,
.file-picker span:hover,
button:hover {
  transform: translateY(-1px);
}

.btn-sm {
  min-height: 30px;
  padding: 0 9px;
  font-size: 12px;
  border-radius: 7px;
}

.btn-primary,
.file-picker span {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
  box-shadow: 0 8px 18px rgba(15, 98, 254, 0.2);
}

.btn-primary:hover,
.file-picker span:hover {
  background: var(--blue-dark);
}

.btn-strong {
  background: #1f2937;
  color: #fff;
}

.btn-secondary,
button.secondary {
  background: #edf5ff;
  border-color: #cfe0fb;
  color: var(--blue-dark);
}

.btn-secondary:hover,
button.secondary:hover {
  background: #e4ebf3;
}

.btn-outline,
.secondary-link,
button.ghost {
  background: #fff;
  border-color: #b8d0fb;
  color: var(--blue);
}

.btn-outline:hover,
.secondary-link:hover,
button.ghost:hover {
  background: var(--blue-soft);
  border-color: #9bbcf7;
}

.btn-muted {
  background: #eef2f7;
  border-color: #d8e0ea;
  color: #64748b;
}

.btn-muted:hover {
  background: #e6edf5;
}

.file-picker .btn-secondary {
  background: #edf5ff;
  border-color: #cfe0fb;
  color: var(--blue-dark);
  box-shadow: none;
}

.file-picker .btn-secondary:hover {
  background: #e4ebf3;
}

.file-picker .btn-muted {
  background: #eef2f7;
  border-color: #d8e0ea;
  color: #64748b;
  box-shadow: none;
}

.file-picker .btn-muted:hover {
  background: #e6edf5;
}

.btn-danger,
button.danger {
  background: #b9382f;
  color: #fff;
  box-shadow: 0 8px 18px rgba(185, 56, 47, 0.16);
}

.btn-danger:hover,
button.danger:hover {
  background: #9f2f28;
}

.btn-danger-soft {
  background: var(--danger-soft);
  border-color: #f2b8b4;
  color: var(--danger);
}

button:disabled,
.btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
  box-shadow: none;
  filter: grayscale(0.08);
}

button:disabled:hover,
.btn:disabled:hover {
  transform: none;
}

.action-bar {
  margin-top: 16px;
}

.check-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0;
  padding: 10px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-weight: 650;
}

.check-row input {
  width: 16px;
  height: 16px;
  margin: 2px 0 0;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.chip,
.badge,
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border: 1px solid #cfe1ea;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 760;
  padding: 4px 9px;
}

.status-pill.ok {
  background: var(--ok-soft);
  border-color: #bfe8d1;
  color: var(--ok);
}

.status-pill.user {
  background: #f7f9ff;
  border-color: #d8e4fb;
  color: #264164;
}

.chip {
  cursor: pointer;
}

.badge-muted,
.status-pill.neutral {
  background: #f8fafc;
  border-color: var(--line);
  color: var(--muted);
}

.status-pill.gmail {
  background: #f8fafc;
  border-color: var(--line);
  color: #334155;
}

.badge-ok,
.sent {
  color: var(--ok);
  background: var(--ok-soft);
  border-color: #bfe8d1;
}

.badge-fail,
.failed {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: #f2b8b4;
}

.badge-skip,
.skipped {
  color: var(--warn);
  background: var(--warn-soft);
  border-color: #f7d7a9;
}

.badge-fail-soft {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: #f2b8b4;
}

.badge-user {
  color: var(--blue-dark);
  background: var(--blue-soft);
  border-color: #cfe0fb;
}

.badge-admin {
  color: var(--purple);
  background: var(--purple-soft);
  border-color: #ddc8ff;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 10px;
}

.metric strong {
  display: block;
  font-size: 18px;
}

.metric span {
  color: var(--muted);
  font-size: 12px;
}

.preview-list {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.preview-card,
.empty-state {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--panel-soft);
}

.preview-card strong {
  display: block;
  margin-bottom: 6px;
}

.preview-card pre {
  margin: 8px 0 0;
  white-space: pre-wrap;
  word-break: break-word;
  color: #344054;
  font: inherit;
}

.empty-state {
  display: grid;
  justify-items: center;
  gap: 8px;
  color: var(--muted);
  text-align: center;
  padding: 28px 18px;
}

.empty-state span {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--blue-soft);
  color: var(--blue);
  font-weight: 850;
}

.empty-state p {
  margin: 0;
}

.empty-state.compact {
  padding: 18px 12px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

th,
td {
  border-top: 1px solid var(--line);
  padding: 10px 9px;
  text-align: left;
  vertical-align: top;
  line-height: 1.45;
}

th {
  color: var(--muted);
  font-weight: 800;
  background: #f6f9fd;
}

tbody tr:hover {
  background: #f8fafc;
}

.results-table table {
  min-width: 0;
  table-layout: fixed;
}

.results-table {
  max-height: 260px;
  overflow: auto;
}

.results-table th:nth-child(1),
.results-table td:nth-child(1) {
  width: 42px;
}

.results-table th:nth-child(2),
.results-table td:nth-child(2) {
  width: 31%;
  overflow-wrap: anywhere;
}

.results-table th:nth-child(3),
.results-table td:nth-child(3) {
  width: 76px;
}

.results-table th:nth-child(4),
.results-table td:nth-child(4) {
  width: 31%;
  overflow-wrap: anywhere;
}

.results-table th:nth-child(5),
.results-table td:nth-child(5) {
  width: 120px;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.cell-muted {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.admin-panel {
  margin-top: 18px;
}

.admin-content[hidden] {
  display: none;
}

.admin-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 160px 160px auto;
  gap: 10px;
  align-items: center;
  margin: 14px 0;
}

.create-user-panel {
  background: #f7faff;
}

.user-table table {
  min-width: 860px;
}

.table-state {
  padding: 26px 12px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
  font-weight: 700;
}

.table-skeleton {
  display: grid;
  gap: 10px;
  padding: 18px 10px;
}

.table-skeleton span {
  display: block;
  height: 16px;
  border-radius: 999px;
  background: linear-gradient(90deg, #eef4fb 0%, #f8fbff 50%, #eef4fb 100%);
  background-size: 220% 100%;
  animation: shimmer 1.2s ease-in-out infinite;
}

.table-skeleton span:nth-child(2) {
  width: 88%;
}

.table-skeleton span:nth-child(3) {
  width: 72%;
}

@keyframes shimmer {
  to {
    background-position: -220% 0;
  }
}

.side-stack {
  display: grid;
  gap: 14px;
}

.activity-list {
  display: grid;
  gap: 12px;
  max-height: 240px;
  overflow-y: auto;
  padding-right: 4px;
}

.activity-list::-webkit-scrollbar,
.results-table::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.activity-list::-webkit-scrollbar-thumb,
.results-table::-webkit-scrollbar-thumb {
  background: #cbd8e8;
  border-radius: 999px;
}

.activity-list::-webkit-scrollbar-track,
.results-table::-webkit-scrollbar-track {
  background: transparent;
}

.activity-item {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
  color: #334155;
  font-size: 13px;
}

.activity-item p {
  margin: 0;
  color: #334155;
}

.activity-item time {
  color: var(--muted);
  font-size: 12px;
}

.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 0 0 4px rgba(15, 98, 254, 0.1);
}

.activity-dot.ok {
  background: var(--ok);
  box-shadow: 0 0 0 4px rgba(8, 116, 67, 0.1);
}

.activity-dot.warn {
  background: var(--warn);
  box-shadow: 0 0 0 4px rgba(181, 71, 8, 0.1);
}

.activity-dot.fail {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(180, 35, 24, 0.1);
}

.activity-dot.neutral {
  background: var(--faint);
  box-shadow: 0 0 0 4px rgba(148, 163, 184, 0.14);
}

.guide-list {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.guide-list li {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 20px;
  gap: 10px;
  align-items: center;
}

.guide-list span {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  font-size: 12px;
  font-weight: 850;
}

.guide-list p {
  margin: 0;
  color: #334155;
  font-size: 13px;
  font-weight: 650;
}

.guide-list strong {
  color: var(--ok);
}

.sticky {
  position: sticky;
  top: 18px;
  max-height: none;
  overflow: visible;
}

@media (max-width: 1180px) {
  .content-grid,
  .overview-grid {
    grid-template-columns: 1fr;
  }

  .sticky {
    position: static;
    max-height: none;
  }
}

@media (max-width: 820px) {
  .app-shell {
    padding: 14px;
  }

  .topbar,
  .panel-heading,
  .result-header {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions,
  .upload-actions,
  .export-actions {
    justify-content: flex-start;
  }

  .brand-block {
    min-width: 0;
  }

  .flow-panel {
    grid-template-columns: 34px minmax(0, 1fr);
  }

  .flow-panel::before {
    left: 31px;
  }

  .split-grid,
  .field-grid,
  .variable-help-grid,
  .safety-grid,
  .template-grid,
  .admin-toolbar,
  .metrics {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 22px;
  }
}
