:root {
  --bg: #f2f5f9;
  --card: #ffffff;
  --ink: #001a34;
  --muted: #70839b;
  --line: #dce3ec;
  --accent: #005bff;
  --accent-hover: #0048cc;
  --accent-ink: #ffffff;
  --danger: #f91155;
  --ok: #10c44c;
  --shadow: 0 8px 24px rgba(0, 26, 52, 0.06);
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at top right, rgba(0, 91, 255, 0.08), transparent 42%),
    linear-gradient(180deg, #eef3f9, var(--bg));
  min-height: 100vh;
  padding: 24px;
}
.login-page {
  display: grid;
  place-items: center;
}
.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
}
h1, h2 { margin: 0 0 8px; }
h1 { color: var(--accent); letter-spacing: -0.02em; }
.muted { color: var(--muted); margin: 0 0 12px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.card-dimmed {
  opacity: 0.45;
  filter: grayscale(0.25);
}
button:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}
.login-card { width: min(400px, 100%); }
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}
.stats {
  display: grid;
  gap: 10px;
  margin: 0;
}
.stats div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}
.stats dt { color: var(--muted); }
.stats dd { margin: 0; font-weight: 600; }
label { display: grid; gap: 8px; margin-bottom: 14px; }
label.check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
input[type="password"], input[type="text"], input[type="file"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: #fff;
}
input[type="password"]:focus, input[type="text"]:focus {
  outline: 2px solid rgba(0, 91, 255, 0.25);
  border-color: var(--accent);
}
.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.tab {
  padding: 8px 14px;
  border-radius: 999px;
  background: #e5eefc;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}
.tab.active {
  background: var(--accent);
  color: #fff;
}
.row-between {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  align-items: flex-start;
  margin-bottom: 12px;
}
.btn-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
}
.badge-pending { background: #fff4d6; color: #9a6b00; }
.badge-sent { background: #e8f9ef; color: #0a8a36; }
.badge-no_message { background: #eef1f5; color: #5a6573; }
.badge-skipped { background: #eef1f5; color: #5a6573; }
.badge-error { background: #ffe8ef; color: var(--danger); }
button, .link {
  appearance: none;
  border: 0;
  border-radius: 12px;
  padding: 0 16px;
  min-height: 44px;
  line-height: 1.2;
  font-size: 0.95rem;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}
button:hover, .link:hover { background: var(--accent-hover); }
button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  background: #8aa4d6;
}
button.primary { width: 100%; }
button.secondary {
  background: #e8eef8;
  color: #1a2b4a;
}
button.secondary:hover { background: #d8e3f4; }
.stack { display: grid; gap: 12px; }
.stack button { width: 100%; }
.btn-row button,
.btn-row button.primary {
  width: auto;
  min-height: 44px;
}
.hint-list {
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}
.hint-list li {
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.hint-list li:last-child { border-bottom: 0; }
.flash {
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 12px;
}
.flash.error { background: #ffe8ef; color: var(--danger); }
.flash.ok { background: #e8f9ef; color: #0a8a36; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}
th, td {
  text-align: left;
  padding: 8px 6px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
th { color: var(--muted); font-weight: 600; }
code {
  background: #e8eef8;
  color: #003a99;
  padding: 1px 6px;
  border-radius: 6px;
}
.table-wrap {
  overflow-x: auto;
}
.nowrap { white-space: nowrap; }
.msg-text {
  white-space: pre-wrap;
  word-break: break-word;
  max-width: 70ch;
}

/* agent queue */
.filters .row { display: flex; gap: 12px; flex-wrap: wrap; }
.filters select, .filters input[type='search'] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: #fff;
  font: inherit;
}
.item-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.item .badge { background: #e5eefc; color: var(--accent); }
.item .meta { display: flex; flex-wrap: wrap; gap: 10px; color: var(--muted); font-size: 0.9rem; margin: 8px 0; }
.item .text { margin: 0 0 12px; white-space: pre-wrap; word-break: break-word; }
.item .actions { display: flex; flex-wrap: wrap; gap: 8px; }
.item .actions form { margin: 0; }
.item .actions button { width: auto; min-height: 40px; }
.item .actions button.primary { width: auto; }
.pager { display: flex; gap: 16px; align-items: center; justify-content: center; margin: 20px 0; }
.pager a { color: var(--accent); font-weight: 600; text-decoration: none; }
