:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-2: #eef3f7;
  --ink: #15212e;
  --muted: #667484;
  --line: #d9e1ea;
  --accent: #177c68;
  --accent-strong: #0f5f50;
  --danger: #bb3a3a;
  --warning: #aa6b13;
  --ok: #21784e;
  --shadow: 0 18px 50px rgba(28, 42, 58, 0.09);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.boot-screen,
.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
}

.loader {
  width: 34px;
  height: 34px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.auth-panel {
  width: min(460px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 30px;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  font-weight: 800;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.15;
}

h1 {
  font-size: 24px;
  font-weight: 750;
}

h2 {
  font-size: 22px;
  font-weight: 730;
}

h3 {
  font-size: 15px;
  font-weight: 720;
}

p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

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

.field {
  display: grid;
  gap: 7px;
}

.field span {
  font-size: 12px;
  font-weight: 700;
  color: #435264;
}

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

textarea {
  min-height: 124px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(23, 124, 104, 0.12);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 9px 13px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 750;
  background: var(--surface-2);
  color: var(--ink);
}

.btn.primary {
  background: var(--accent);
  color: #fff;
}

.btn.primary:hover {
  background: var(--accent-strong);
}

.btn.ghost {
  background: transparent;
  color: var(--muted);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
}

.sidebar {
  background: #15212e;
  color: #fff;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.sidebar .brand-row {
  margin-bottom: 0;
  padding: 0 6px;
}

.sidebar p {
  color: #9eacba;
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 4px;
}

.nav button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 38px;
  border-radius: 7px;
  padding: 0 10px;
  background: transparent;
  color: #c6d1dc;
  text-align: left;
  font-size: 13px;
  font-weight: 650;
}

.nav button.active,
.nav button:hover {
  background: rgba(255, 255, 255, 0.09);
  color: #fff;
}

.content {
  min-width: 0;
  padding: 24px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 22px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

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

.grid {
  display: grid;
  gap: 16px;
}

.stats-grid {
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(34, 48, 68, 0.05);
}

.stat {
  padding: 16px;
}

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

.stat strong {
  display: block;
  margin-top: 10px;
  font-size: 27px;
  line-height: 1;
}

.panel {
  padding: 18px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.split {
  display: grid;
  grid-template-columns: minmax(300px, 0.9fr) minmax(360px, 1.1fr);
  gap: 16px;
}

.progress-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.85fr) minmax(420px, 1.15fr);
  gap: 16px;
  align-items: start;
}

.job-list {
  display: grid;
  gap: 9px;
}

.job-row {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 0.8fr);
  gap: 14px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.job-row.active {
  border-color: rgba(23, 124, 104, 0.5);
  box-shadow: 0 0 0 3px rgba(23, 124, 104, 0.1);
}

.job-row strong,
.job-row small,
.job-row-progress {
  display: block;
}

.job-row small {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.job-row-progress {
  min-width: 0;
}

.progress-bar {
  width: 100%;
  height: 10px;
  display: flex;
  overflow: hidden;
  border-radius: 999px;
  background: #dfe6ee;
}

.progress-bar span {
  display: block;
  height: 100%;
}

.progress-bar .delivered {
  background: #1f8a5b;
}

.progress-bar .sent {
  background: #286bb5;
}

.progress-bar .processed {
  background: #7255a6;
}

.progress-bar .failed {
  background: #c44949;
}

.progress-bar .pending {
  background: #d59128;
}

.progress-bar .queued {
  background: #b8c4cf;
}

.compact-progress {
  display: grid;
  gap: 6px;
  min-width: 180px;
}

.compact-progress span:last-child {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.progress-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 10px;
  margin: 16px 0 18px;
}

.metric {
  min-width: 0;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfd;
}

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

.metric strong {
  display: block;
  margin-top: 7px;
  font-size: 18px;
  line-height: 1;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 10px 0 14px;
}

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

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

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

th {
  color: #435264;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0;
  background: #f9fbfd;
}

td.wrap {
  white-space: normal;
  min-width: 220px;
}

.wrap {
  display: inline-block;
  max-width: 420px;
  white-space: normal;
  overflow-wrap: anywhere;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 750;
  background: #ecf1f5;
  color: #46596b;
}

.status.Delivered,
.status.completed,
.status.active {
  color: var(--ok);
  background: #e8f5ee;
}

.status.Pending,
.status.queueing,
.status.sending,
.status.queued {
  color: var(--warning);
  background: #fff3de;
}

.status.Processed {
  color: #7255a6;
  background: #f0ecf8;
}

.status.Sent {
  color: #286bb5;
  background: #e9f1fb;
}

.status.Failed,
.status.failed {
  color: var(--danger);
  background: #fdeaea;
}

.notice {
  border-left: 3px solid var(--accent);
  background: #edf7f4;
  padding: 12px 13px;
  border-radius: 6px;
  color: #244d45;
  font-size: 13px;
}

.error {
  border-left-color: var(--danger);
  background: #fdeaea;
  color: #7b2424;
}

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.toolbar select,
.toolbar input {
  width: auto;
  min-width: 160px;
}

.code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  color: #384859;
}

.empty-panel {
  max-width: 680px;
}

.empty-panel h3 {
  margin-bottom: 8px;
}

.empty-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 18px;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 2;
  }

  .nav {
    grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  }

  .stats-grid,
  .split,
  .progress-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .content {
    padding: 16px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .nav {
    grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .job-row {
    grid-template-columns: 1fr;
  }

  .auth-panel {
    padding: 22px;
  }
}
