:root {
  color-scheme: light;
  --ink: #172026;
  --muted: #61707d;
  --line: #d9e0e5;
  --soft: #f5f7f8;
  --panel: #ffffff;
  --brand: #0f766e;
  --brand-dark: #115e59;
  --warn: #b45309;
  --bad: #b91c1c;
  --good: #15803d;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background: #eef2f4;
  -webkit-text-size-adjust: 100%;
}

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

button {
  border: 1px solid var(--brand);
  background: var(--brand);
  color: #fff;
  border-radius: 6px;
  padding: 9px 12px;
  cursor: pointer;
}

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

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

button:disabled {
  opacity: .6;
  cursor: not-allowed;
}

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

label {
  display: grid;
  gap: 5px;
  font-size: 12px;
  color: var(--muted);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

th, td {
  border-bottom: 1px solid var(--line);
  padding: 9px;
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  background: #f0f4f6;
  color: #33424e;
  font-weight: 700;
}

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-box {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  box-shadow: 0 12px 35px rgba(20, 30, 40, .1);
}

.login-box h1, .page-title h1 {
  margin: 0;
  font-size: 24px;
  letter-spacing: 0;
}

.login-box p, .page-title p {
  color: var(--muted);
  margin: 6px 0 18px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 230px 1fr;
}

.side {
  background: #132427;
  color: #dce7e6;
  padding: 18px 14px;
}

.brand {
  font-weight: 700;
  font-size: 18px;
  margin-bottom: 20px;
}

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

.nav button {
  width: 100%;
  text-align: left;
  background: transparent;
  color: #dce7e6;
  border-color: transparent;
}

.nav button.active {
  background: #1f3a3d;
  border-color: #31595d;
}

.content {
  padding: 20px;
  min-width: 0;
  overflow: auto;
}

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

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 14px;
  overflow-x: auto;
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 16px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 10px;
  align-items: end;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(180px, 1fr));
}

.grid.three {
  grid-template-columns: repeat(3, minmax(160px, 1fr));
}

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

.status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  background: #e8eef1;
}

.status.pending { color: var(--warn); background: #fff7ed; }
.status.cleared { color: var(--good); background: #ecfdf5; }
.status.cancelled, .status.bounced { color: var(--bad); background: #fef2f2; }
.status.security { color: #155e75; background: #ecfeff; }

.metric-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 10px;
}

.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfd;
}

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

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

.message {
  margin: 10px 0;
  color: var(--bad);
  font-weight: 700;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 20, 25, .45);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 10;
}

.modal {
  width: min(980px, 100%);
  max-height: 88vh;
  overflow: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  box-shadow: 0 20px 60px rgba(10, 20, 25, .24);
}

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

.modal h2 {
  margin: 0;
  font-size: 18px;
}

.action-modal {
  max-width: 520px;
}

.modal-actions {
  margin-top: 12px;
}

.checkline {
  display: flex;
  min-height: 39px;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}

.checkline input {
  width: auto;
}

.row-actions {
  align-items: flex-start;
  min-width: 190px;
}

.row-actions button {
  padding: 7px 9px;
}

pre {
  white-space: pre-wrap;
  word-break: break-word;
  background: #f4f6f7;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  max-height: 260px;
  overflow: auto;
}

.ok { color: var(--good); }
.num { text-align: right; white-space: nowrap; }
.muted { color: var(--muted); }
.hide { display: none; }

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .side {
    position: sticky;
    top: 0;
    z-index: 4;
    padding: 12px;
  }
  .brand { margin-bottom: 10px; }
  .nav {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
  }
  .nav button {
    width: auto;
    white-space: nowrap;
    flex: 0 0 auto;
  }
  .grid, .grid.two, .grid.three, .metric-row { grid-template-columns: 1fr; }
  .topbar { display: grid; }
  .content { padding: 14px; }
  .panel { padding: 12px; }
  table { min-width: 760px; }
  th, td { font-size: 12px; }
}

@media (max-width: 520px) {
  .content { padding: 10px; }
  .login-box { padding: 16px; }
  .login-box h1, .page-title h1 { font-size: 21px; }
  button { padding: 10px 11px; }
  .actions { align-items: stretch; }
  .actions button, .actions a { width: 100%; }
  .row-actions button { width: auto; }
  .modal-backdrop {
    align-items: end;
    padding: 0;
  }
  .modal {
    width: 100%;
    max-height: 92vh;
    border-radius: 8px 8px 0 0;
  }
}
