:root {
  --bg: #f4f6f5; --card: #fff; --text: #17201d; --muted: #63706b; --line: #e2e7e5;
  --brand: #128c7e; --brand-dark: #075e54; --brand-soft: #e5f4f1;
  --ok: #1f9d55; --warn: #c27c0e; --bad: #c53030; --info: #2b6cb0;
  --radius: 12px; --shadow: 0 1px 2px rgba(16, 24, 20, .06), 0 4px 16px rgba(16, 24, 20, .04);
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
.hidden { display: none !important; }
h1 { font-size: 20px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
a { color: var(--brand-dark); }

.logo { font-size: 17px; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.logo b { color: var(--brand); font-weight: 700; }
.logo-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 800; }

.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 20px; padding: 10px 24px; background: #fff; border-bottom: 1px solid var(--line); }
.topbar nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.topbar nav button { border: 0; background: none; padding: 8px 14px; border-radius: 8px; font: inherit; color: var(--muted); cursor: pointer; white-space: nowrap; }
.topbar nav button:hover { background: var(--bg); color: var(--text); }
.topbar nav button.active { background: var(--brand-soft); color: var(--brand-dark); font-weight: 600; }
.me { display: flex; align-items: center; gap: 10px; color: var(--muted); white-space: nowrap; }

.view { max-width: 1180px; margin: 0 auto; padding: 24px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.grid { display: grid; gap: 14px; }
.stats { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin-bottom: 18px; }
.stat .num { font-size: 26px; font-weight: 700; }
.stat .label { color: var(--muted); font-size: 12.5px; }
.two { grid-template-columns: 1fr 1fr; }
@media (max-width: 860px) { .two { grid-template-columns: 1fr; } .topbar { flex-wrap: wrap; padding: 10px 16px; } .view { padding: 16px; } }

.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.checklist li:last-child { border-bottom: 0; }
.dot { width: 18px; height: 18px; border-radius: 50%; flex: none; display: grid; place-items: center; color: #fff; font-size: 11px; margin-top: 2px; }
.dot.ok { background: var(--ok); } .dot.no { background: var(--warn); }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: var(--bg); color: var(--muted); white-space: nowrap; }
.badge.CONNECTED, .badge.APPROVED, .badge.Read, .badge.Delivered, .badge.GREEN { background: #e3f6ea; color: var(--ok); }
.badge.ATTENTION, .badge.PENDING, .badge.YELLOW, .badge.Queued { background: #fdf3e1; color: var(--warn); }
.badge.DISCONNECTED, .badge.REJECTED, .badge.Failed, .badge.RED, .badge.PAUSED { background: #fde8e8; color: var(--bad); }
.badge.Sent, .badge.Received { background: #e8f0fb; color: var(--info); }

.btn { border: 1px solid var(--line); background: #fff; color: var(--text); padding: 8px 14px; border-radius: 8px; font: inherit; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { border-color: #c8d1cd; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { color: var(--bad); }
.btn.ghost { border-color: transparent; background: none; }
.btn.small { padding: 4px 10px; font-size: 12.5px; }
.btn:disabled { opacity: .55; cursor: wait; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }

label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 12px; }
label .hint { font-weight: 400; color: var(--muted); font-size: 12px; display: block; }
input, select, textarea { display: block; width: 100%; margin-top: 4px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: #fff; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
textarea { min-height: 110px; resize: vertical; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 600px) { .row { grid-template-columns: 1fr; } }
.error { color: var(--bad); min-height: 1em; margin: 6px 0; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: linear-gradient(160deg, var(--brand-dark), var(--brand)); }
.login-card { width: 100%; max-width: 380px; }
.login-card .logo { margin-bottom: 6px; }
.login-card .btn { width: 100%; justify-content: center; margin-top: 4px; }

dialog { border: 0; border-radius: var(--radius); padding: 0; width: min(620px, calc(100vw - 32px)); max-height: calc(100vh - 48px); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(10, 20, 16, .45); }
#modal-body { padding: 22px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #17201d; color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); z-index: 20; max-width: calc(100vw - 32px); }
.toast.bad { background: var(--bad); }

.tpl { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 10px; }
.tpl-body { white-space: pre-wrap; background: #f0f7f4; border-radius: 8px; padding: 10px; margin-top: 8px; font-size: 13px; }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.copy { cursor: pointer; border-bottom: 1px dashed var(--muted); }
.test-out { margin-top: 10px; line-height: 1.5; word-break: break-word; }
