:root {
  --bg: #0b1220;
  --surface: #111827;
  --surface-2: #182033;
  --border: #273349;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --brand: #6366f1;
  --brand-2: #4f46e5;
  --ok: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 'Segoe UI', system-ui, -apple-system, Helvetica, Arial, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--bad); min-height: 1.2em; margin: 4px 0; font-size: 13px; }
.ok { color: var(--ok); min-height: 1.2em; margin: 4px 0; font-size: 13px; }
.mono { font-family: 'Cascadia Code', Consolas, monospace; font-size: 12px; }
.nowrap { white-space: nowrap; }

/* brand */
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.brand h1 { margin: 0; font-size: 20px; font-weight: 800; letter-spacing: -0.3px; }
.brand h1 span { color: #a5b4fc; }
.brand p { margin: 0; color: var(--muted); font-size: 12px; }
.brand.small { margin-bottom: 18px; }
.brand-badge { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; font-weight: 800; font-size: 18px; }

/* auth */
.auth { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 32px; box-shadow: 0 24px 64px rgba(0, 0, 0, 0.4); }
label { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 4px; }
input, select, textarea { width: 100%; height: 38px; border: 1px solid var(--border); background: var(--bg); color: var(--text); border-radius: 8px; padding: 0 12px; font: inherit; outline: none; }
textarea { height: auto; padding: 8px 12px; min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2); }
input[type='checkbox'] { width: auto; height: auto; margin-right: 8px; vertical-align: middle; }
.check { display: flex; align-items: center; gap: 8px; margin: 12px 0 4px; color: var(--text); font-size: 13px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { filter: brightness(1.12); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--brand-2); border-color: var(--brand-2); color: #fff; }
.btn.danger { background: rgba(239, 68, 68, 0.15); border-color: rgba(239, 68, 68, 0.4); color: #fca5a5; }
.btn.ghost { background: transparent; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn.wide { width: 100%; margin-top: 14px; }
.link { background: none; border: 0; color: #a5b4fc; cursor: pointer; font: inherit; margin-top: 12px; display: block; width: 100%; text-align: center; }
.icon-btn { background: none; border: 0; color: var(--muted); font-size: 22px; cursor: pointer; line-height: 1; }

/* shell */
.shell { display: flex; min-height: 100%; }
.sidebar { width: 230px; flex: 0 0 230px; background: #080d19; border-right: 1px solid var(--border); padding: 20px 16px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.sidebar nav a { display: block; padding: 9px 12px; border-radius: 8px; color: var(--muted); font-weight: 500; margin-bottom: 2px; }
.sidebar nav a:hover { background: var(--surface-2); color: var(--text); }
.sidebar nav a.active { background: rgba(99, 102, 241, 0.18); color: #c7d2fe; }
.sidebar-foot { margin-top: auto; }
.me { display: flex; flex-direction: column; font-size: 12px; margin-bottom: 8px; padding: 0 4px; }
.me span:first-child { font-weight: 600; }
.content { flex: 1; min-width: 0; padding: 28px 32px; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h2 { margin: 0; font-size: 22px; }
.page-head .actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.page-head input, .page-head select { height: 36px; width: auto; min-width: 180px; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; margin-bottom: 24px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.card .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
.card .value { font-size: 28px; font-weight: 800; margin-top: 4px; }
.card .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; }
.panel h3 { margin: 0 0 12px; font-size: 15px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } .sidebar { display: none; } }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px; }
tr:hover td { background: rgba(255, 255, 255, 0.02); }
td .btn + .btn { margin-left: 6px; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.empty { padding: 28px; text-align: center; color: var(--muted); }

.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: 0.2px; }
.pill.active, .pill.sent, .pill.ok { background: rgba(34, 197, 94, 0.15); color: #86efac; }
.pill.suspended, .pill.failed, .pill.bad { background: rgba(239, 68, 68, 0.15); color: #fca5a5; }
.pill.pending, .pill.warn { background: rgba(245, 158, 11, 0.15); color: #fcd34d; }
.pill.expired { background: rgba(148, 163, 184, 0.15); color: #cbd5e1; }
.pill.admin { background: rgba(99, 102, 241, 0.18); color: #c7d2fe; }
.pill.user, .pill.neutral { background: rgba(148, 163, 184, 0.12); color: #cbd5e1; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #475569; margin-right: 6px; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.2); }

.modal { position: fixed; inset: 0; background: rgba(2, 6, 23, 0.7); display: grid; place-items: center; padding: 20px; z-index: 50; }
.modal-card { width: 100%; max-width: 640px; max-height: 92vh; overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); }
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-body { padding: 16px 20px 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
details { margin-top: 10px; }
summary { cursor: pointer; color: #a5b4fc; font-weight: 600; }

.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--surface-2); border: 1px solid var(--border); border-left: 4px solid var(--brand); padding: 10px 14px; border-radius: 10px; min-width: 240px; max-width: 420px; box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4); font-size: 13px; animation: in 0.15s ease-out; }
.toast.ok { border-left-color: var(--ok); }
.toast.bad { border-left-color: var(--bad); }
@keyframes in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid rgba(255, 255, 255, 0.25); border-top-color: #fff; border-radius: 50%; animation: spin 0.8s linear infinite; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.hint { font-size: 12px; color: var(--muted); margin: 2px 0 0; }
