:root {
  --bg: #f4f5f7; --panel: #fff; --text: #1d2330; --muted: #6b7280; --line: #e3e6eb;
  --accent: #2563eb; --accent-text: #fff; --ok: #16a34a; --bad: #dc2626; --warn: #d97706; --chip: #eef2ff;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font: 14px/1.45 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; background: var(--bg); color: var(--text); }
.hidden { display: none !important; }
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: var(--accent); color: var(--accent-text); border: 0; border-radius: 6px; padding: 7px 12px; cursor: pointer; }
button:hover { filter: brightness(1.08); }
button.secondary { background: #e5e7eb; color: var(--text); }
button.danger { background: var(--bad); }
button.link { background: none; color: var(--accent); padding: 4px 6px; }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; width: 100%; }
textarea { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; min-height: 220px; }
label { display: block; font-size: 12px; color: var(--muted); margin: 8px 0 3px; }
.muted { color: var(--muted); }
.err { color: var(--bad); margin-top: 8px; min-height: 1em; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }

.login { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; }
.login-box { background: var(--panel); padding: 28px 30px; border-radius: 12px; width: 360px; box-shadow: 0 10px 30px rgba(0,0,0,.08); }
.login-box h1 { margin: 0 0 4px; }
.login-box p { margin: 0 0 16px; }
.login-box input { margin-bottom: 10px; }
.login-box button { width: 100%; }

header { display: flex; align-items: center; gap: 18px; padding: 0 20px; height: 52px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 700; letter-spacing: .5px; }
nav a { padding: 6px 10px; border-radius: 6px; color: var(--text); }
nav a.active { background: var(--chip); color: var(--accent); }
.spacer { flex: 1; }
main { padding: 20px; max-width: 1400px; margin: 0 auto; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 16px; }
.card h2, .card h3 { margin: 0 0 12px; font-size: 16px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }
.row > * { flex: 1 1 160px; }
.row > .auto { flex: 0 0 auto; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .grid2 { grid-template-columns: 1fr; } }
.kv { display: grid; grid-template-columns: 180px 1fr; gap: 4px 12px; }
.kv div:nth-child(odd) { color: var(--muted); }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; align-items: center; }
.toolbar input, .toolbar select { width: auto; min-width: 160px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .3px; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: #f8fafc; }
.table-wrap { overflow-x: auto; }

.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #9ca3af; margin-right: 6px; }
.dot.on { background: var(--ok); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; background: #e5e7eb; }
.badge.done { background: #dcfce7; color: #166534; }
.badge.failed { background: #fee2e2; color: #991b1b; }
.badge.sent { background: #fef3c7; color: #92400e; }
.badge.queued { background: #e5e7eb; }
pre { background: #f8fafc; border: 1px solid var(--line); border-radius: 8px; padding: 10px; overflow: auto; font-size: 12px; margin: 0; }

.modal { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: flex; align-items: center; justify-content: center; z-index: 20; padding: 20px; }
.modal-body { background: var(--panel); border-radius: 12px; padding: 20px; width: 100%; max-width: 560px; max-height: 90vh; overflow: auto; }
.modal-body h3 { margin: 0 0 10px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #111827; color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 30; box-shadow: 0 6px 20px rgba(0,0,0,.2); }
.toast.bad { background: var(--bad); }
.qr { max-width: 360px; width: 100%; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.chips span { display: inline-block; background: var(--chip); color: var(--accent); padding: 2px 8px; border-radius: 999px; margin: 2px 4px 2px 0; font-size: 12px; }
.stat { display: inline-block; margin-right: 14px; }
.stat b { font-size: 18px; }
