:root {
  --bg: #0b0f1a;
  --panel: #131a2b;
  --panel-2: #182238;
  --border: #24314d;
  --text: #e6ebf5;
  --muted: #8b9bb4;
  --brand: #7c5cff;
  --brand-2: #22d3ee;
  --green: #34d399;
  --amber: #fbbf24;
  --red: #f87171;
  --radius: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background:
    radial-gradient(1200px 600px at 15% -10%, rgba(124, 92, 255, .25), transparent 60%),
    radial-gradient(1000px 500px at 100% 0%, rgba(34, 211, 238, .18), transparent 55%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
}

a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- auth ---------- */
body.auth { display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card {
  width: 100%; max-width: 420px; background: var(--panel);
  border: 1px solid var(--border); border-radius: 22px; padding: 34px;
  box-shadow: 0 30px 70px rgba(0, 0, 0, .55);
}
.auth-card h1 { margin: 0 0 6px; font-size: 24px; }
.auth-card p { margin: 0 0 22px; color: var(--muted); }
.form-grid { display: grid; gap: 14px; }
label { font-size: 13px; color: var(--muted); display: grid; gap: 6px; }
input, select, textarea {
  background: #0d1424; border: 1px solid var(--border); color: var(--text);
  border-radius: 12px; padding: 11px 13px; font-size: 14px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(124,92,255,.5); border-color: transparent; }
button, .btn {
  background: linear-gradient(135deg, var(--brand), #5b3df0); color: #fff; border: 0;
  border-radius: 12px; padding: 12px 18px; font-weight: 600; font-size: 14px;
  cursor: pointer; display: inline-flex; align-items: center; gap: 8px; text-decoration: none;
}
button:hover, .btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn.secondary { background: #24314d; }
.btn.ghost { background: transparent; border: 1px solid var(--border); }
.btn.danger { background: linear-gradient(135deg, #ef4444, #b91c1c); }
.btn.small { padding: 7px 12px; font-size: 12px; border-radius: 10px; }
.error { background: rgba(248,113,113,.14); color: #fecaca; padding: 10px 12px; border-radius: 10px; font-size: 13px; margin-bottom: 14px; }
.remember-label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.remember-label input { width: auto; }

/* ---------- layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; backdrop-filter: blur(10px);
  background: rgba(11,15,26,.82); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 18px; padding: 12px 22px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: .2px; }
.brand .dot { width: 12px; height: 12px; border-radius: 50%; background: linear-gradient(135deg, var(--brand), var(--brand-2)); }
.nav { display: flex; gap: 6px; flex-wrap: wrap; margin-left: 8px; }
.nav a {
  padding: 8px 13px; border-radius: 10px; color: var(--muted); font-size: 13.5px; font-weight: 600;
}
.nav a.active, .nav a:hover { background: var(--panel-2); color: var(--text); text-decoration: none; }
.spacer { flex: 1; }
.wrap { max-width: 1280px; margin: 0 auto; padding: 22px; }
h2.page-title { margin: 4px 0 18px; font-size: 22px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ---------- cards / stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--border); border-radius: var(--radius); padding: 18px;
}
.stat .k { color: var(--muted); font-size: 12.5px; text-transform: uppercase; letter-spacing: .6px; }
.stat .v { font-size: 30px; font-weight: 800; margin-top: 8px; }
.stat .s { color: var(--muted); font-size: 12px; margin-top: 4px; }

.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 20px; }
.panel h3 { margin: 0 0 14px; font-size: 16px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 11px 13px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { background: var(--panel-2); color: var(--muted); font-weight: 600; text-transform: uppercase; font-size: 11px; letter-spacing: .5px; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(124,92,255,.07); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; }
.badge.green { background: rgba(52,211,153,.15); color: #6ee7b7; }
.badge.amber { background: rgba(251,191,36,.15); color: #fcd34d; }
.badge.red { background: rgba(248,113,113,.15); color: #fca5a5; }
.badge.gray { background: rgba(139,155,180,.15); color: #cbd5e1; }
.badge.blue { background: rgba(34,211,238,.15); color: #67e8f9; }

/* Action cell: ONE line of buttons, never wrapped. Letting them wrap turned a normal row into a
   double-height row on Senders / Installs / Trials (5 buttons per row). */
td.actions { display: flex; align-items: center; gap: 6px; flex-wrap: nowrap; }
td.actions > form { margin: 0; }

/* Compact emoji-only buttons (⚡ grant / ✏️ edit end). The emoji carries the meaning, so the
   button stays transparent like the pencil instead of a coloured pill.
   NB: .btn.small sets padding/font-size with the SAME specificity as .btn.small.btn-icon, so this
   rule must stay BELOW .btn.small (it does) and use both classes. */
.btn.small.btn-icon { padding: 5px 8px; font-size: 14px; line-height: 1; border-radius: 9px; }

/* Secondary text inside a cell (device specs, local end time, ...).
   FORCED INLINE on purpose: a block-level child of a <td> always adds a LINE to the row, which is
   what made the Installs / Trials rows twice as tall as the Senders rows. Inline + the
   `white-space: nowrap` already set on th/td means extra info can only make the COLUMN wider
   (the table scrolls sideways), never the ROW taller. */
.cell-sub { display: inline; font-size: 11px; line-height: 1.35; white-space: nowrap; }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar form { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.toolbar input, .toolbar select { width: auto; min-width: 180px; }

.gene { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 860px) { .gene { grid-template-columns: 1fr; } }
pre.code {
  background: #0a0f1c; border: 1px solid var(--border); border-radius: 12px; padding: 16px;
  overflow: auto; font-size: 12.5px; color: #cbe3ff;
}
.empty { padding: 40px; text-align: center; color: var(--muted); }

/* ---------- iOS-style sliding ON/OFF switch (same as the Analytics Reports page) ---------- */
button.ios-switch {
  position: relative;
  display: inline-block;
  width: 72px;
  min-width: 72px;
  height: 42px;
  min-height: 42px;
  max-height: 42px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: #34c759;                          /* green = ON */
  box-shadow: inset 0 1px 4px rgba(0, 0, 0, .25);
  overflow: hidden;
  cursor: pointer;
  transition: background-color .3s ease;
  -webkit-tap-highlight-color: transparent;
}
button.ios-switch.is-off { background: #ff3b30; }  /* red = OFF */

/* neutralise the global button hover/shadow so the switch stays flat */
button.ios-switch:hover,
button.ios-switch:active { filter: none; box-shadow: inset 0 1px 4px rgba(0, 0, 0, .25); }
button.ios-switch:focus-visible { outline: 2px solid #22d3ee; outline-offset: 2px; }

.ios-switch-text {
  position: absolute;
  top: 0;
  height: 100%;
  display: flex;
  align-items: center;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .5px;
  color: #fff;
  text-shadow: 0 1px 1px rgba(0, 0, 0, .3);
  pointer-events: none;
  transition: left .3s cubic-bezier(.4, 0, .2, 1);
}
button.ios-switch.is-on  .ios-switch-text { left: 8px; }
button.ios-switch.is-off .ios-switch-text { left: 40px; }

.ios-switch-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, .35), 0 0 0 .5px rgba(0, 0, 0, .06);
  transition: transform .3s cubic-bezier(.4, 0, .2, 1);
}
button.ios-switch.is-on .ios-switch-knob { transform: translateX(30px); }
