:root {
  color-scheme: light;
  --bg: #f4f6fb;
  --panel: #ffffff;
  --panel-soft: #f8f9ff;
  --text: #152033;
  --muted: #667085;
  --line: #d8deea;
  --line-strong: #c8d0df;
  --brand: #4353ff;
  --brand-dark: #2734cc;
  --brand-soft: #eef0ff;
  --slate: #0f172a;
  --slate-soft: #1e293b;
  --purple: #a855f7;
  --danger: #a3303a;
  --danger-bg: #fff0f1;
  --success: #17633a;
  --success-bg: #eaf7ef;
  --warning: #8a5200;
  --warning-bg: #fff6df;
  --shadow: 0 16px 40px rgba(21, 32, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(67, 83, 255, 0.08), transparent 260px),
    var(--bg);
  color: var(--text);
  font:
    15px/1.45 system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

a {
  color: var(--brand);
  text-decoration: none;
}

a:hover {
  color: var(--brand-dark);
}

.topbar {
  min-height: 68px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: var(--slate);
  box-shadow: 0 8px 28px rgba(15, 23, 42, 0.18);
}

.brand {
  color: #fff;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand:hover {
  color: #fff;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 16px;
  line-height: 1.1;
}

.brand small {
  color: #cbd5e1;
  font-size: 12px;
  font-weight: 600;
  margin-top: 2px;
}

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

nav a {
  color: #d7def0;
  font-weight: 700;
  padding: 8px 10px;
  border-radius: 6px;
}

nav a:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

nav form {
  margin: 0;
}

.layout {
  max-width: 1180px;
  margin: 0 auto;
  padding: 30px 20px 48px;
}

.page-head {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  margin-bottom: 18px;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.15;
  margin-bottom: 6px;
  letter-spacing: 0;
}

h2 {
  font-size: 18px;
  margin-bottom: 14px;
}

p {
  color: var(--muted);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}

.narrow {
  max-width: 460px;
}

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

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

.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 4px solid var(--brand);
  border-radius: 8px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  color: var(--text);
  font-size: 28px;
  line-height: 1.1;
  margin-top: 6px;
}

.metric-attention {
  border-left-color: var(--danger);
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.section-head h2 {
  margin-bottom: 0;
}

.section-head span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.form {
  display: grid;
  gap: 14px;
}

.form.grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 700;
}

.wide {
  grid-column: 1 / -1;
}

.check {
  display: grid;
  align-content: start;
  gap: 6px;
  color: var(--text);
  min-height: 42px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.field-help,
.submit-help {
  color: var(--muted);
  font-size: 12px;
  font-weight: 200;
  line-height: 1.4;
}

.submit-help {
  margin: 0;
  max-width: 520px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 10px 11px;
  color: var(--text);
  background: #fff;
  font: inherit;
}

input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--brand);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(67, 83, 255, 0.16);
  outline: 0;
}

button,
.button {
  border: 0;
  border-radius: 6px;
  background: var(--brand);
  color: #fff;
  padding: 10px 14px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  white-space: nowrap;
}

button:hover,
.button:hover {
  background: var(--brand-dark);
  color: #fff;
}

.button-secondary {
  background: #eef0ff;
  color: var(--brand-dark);
  border: 1px solid #cad0ff;
}

.button-secondary:hover {
  background: #dfe3ff;
  color: var(--brand-dark);
}

.button-danger {
  background: var(--danger);
}

.button-danger:hover {
  background: #7e2029;
}

.topbar button {
  background: var(--slate-soft);
  color: #eef2ff;
}

.topbar button:hover {
  background: var(--brand);
}

.wide-button {
  justify-content: center;
  width: 100%;
}

hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 20px 0;
}

.inline-form {
  display: flex;
  gap: 8px;
  align-items: center;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 12px 8px;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  white-space: nowrap;
}

tbody tr:hover {
  background: var(--panel-soft);
}

.status,
.type-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.status {
  background: var(--brand-soft);
  color: var(--brand-dark);
}

.status-completed {
  background: var(--success-bg);
  color: var(--success);
}

.status-rejected,
.status-failed {
  background: var(--danger-bg);
  color: var(--danger);
}

.status-running,
.status-queued,
.status-waiting-mail-export,
.status-waiting-lockout {
  background: #eef7ff;
  color: #175c8a;
}

.status-manual-action-required {
  background: var(--warning-bg);
  color: var(--warning);
}

.type-pill {
  background: #f1f4f9;
  color: #344054;
}

dl {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 9px 12px;
  margin: 0;
}

dt {
  color: var(--muted);
  font-weight: 800;
}

dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.events {
  padding-left: 0;
  margin: 0;
  list-style: none;
}

.events li {
  margin-bottom: 14px;
  padding-left: 16px;
  border-left: 3px solid var(--brand-soft);
}

.events li:last-child {
  margin-bottom: 0;
}

.events span,
.events small {
  color: var(--muted);
}

.events p {
  margin: 4px 0;
  color: var(--text);
}

.messages {
  margin-bottom: 16px;
}

.message {
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #eef2f7;
  font-weight: 700;
}

.message.error {
  background: var(--danger-bg);
  border-color: #f0b9bf;
  color: var(--danger);
}

.message.success {
  background: var(--success-bg);
  border-color: #b8e3c8;
  color: var(--success);
}

.empty {
  color: var(--muted);
  text-align: center;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  overflow-wrap: anywhere;
}

@media (max-width: 900px) {
  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .topbar,
  .page-head,
  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    padding: 14px 16px;
  }

  nav,
  .actions,
  .inline-form {
    align-items: stretch;
    flex-direction: column;
  }

  nav a,
  button,
  .button {
    width: 100%;
  }

  .form.grid,
  .split,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  dl {
    grid-template-columns: 1fr;
  }

  table {
    display: block;
    overflow-x: auto;
  }
}
