/* RoyalSonic Reseller — User Admin (mailbox) tokens + dark mode
   Icons: Lucide (ISC) in colorful tiles */

:root,
html[data-rs-theme="mailbox"] {
  --accent: #5b7cff;
  --accent-deep: #3d5bd6;
  --accent-hover: #4a6af0;
  --canvas: #f4f6fb;
  --panel: #ffffff;
  --panel-strong: #fafbff;
  --sidebar: #ffffff;
  --line: #e6eaf2;
  --text: #1e293b;
  --muted: #64748b;
  --ink: #1e293b;
  --danger: #ef4444;
  --ok: #16a34a;
  --royal: #e30613;
  --radius: 14px;
  --radius-lg: 16px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.06);
  --font: "Outfit", "Segoe UI", ui-sans-serif, sans-serif;
  --side-w: 260px;
  color-scheme: light;
}

html[data-rs-theme="dark"] {
  --accent: #7c9bff;
  --accent-deep: #5b7cff;
  --accent-hover: #8babff;
  --canvas: #0f1419;
  --panel: #1a2332;
  --panel-strong: #1e293b;
  --sidebar: #141c27;
  --line: #2a3547;
  --text: #e8eef8;
  --muted: #94a3b8;
  --ink: #e8eef8;
  --danger: #f87171;
  --ok: #4ade80;
  --royal: #ff4d57;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 12px 32px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--canvas);
  line-height: 1.5;
  min-height: 100vh;
}

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(ellipse 55% 32% at 8% -4%, rgba(91, 124, 255, 0.12), transparent 55%),
    linear-gradient(180deg, var(--canvas) 0%, var(--canvas) 100%);
}
html[data-rs-theme="dark"] .atmosphere {
  background:
    radial-gradient(ellipse 50% 30% at 10% 0%, rgba(91, 124, 255, 0.18), transparent 55%),
    linear-gradient(180deg, #0f1419, #0b1016);
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); border: 0;
}

/* —— Colorful icon tiles (copy-free Lucide SVGs inside) —— */
.ico-tile {
  display: inline-grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 12px;
  flex-shrink: 0;
  color: #fff;
}
.ico-tile.sm { width: 2rem; height: 2rem; border-radius: 10px; }
.ico-tile svg { width: 1.15rem; height: 1.15rem; stroke-width: 2.2; }
.ico-tile.sm svg { width: 1rem; height: 1rem; }

.ico-blue   { background: linear-gradient(145deg, #5b7cff, #3d5bd6); box-shadow: 0 4px 12px rgba(91,124,255,.35); }
.ico-violet { background: linear-gradient(145deg, #8b5cf6, #6d28d9); box-shadow: 0 4px 12px rgba(139,92,246,.35); }
.ico-cyan   { background: linear-gradient(145deg, #22d3ee, #0891b2); box-shadow: 0 4px 12px rgba(8,145,178,.3); }
.ico-amber  { background: linear-gradient(145deg, #fbbf24, #d97706); box-shadow: 0 4px 12px rgba(217,119,6,.3); }
.ico-green  { background: linear-gradient(145deg, #34d399, #059669); box-shadow: 0 4px 12px rgba(5,150,105,.3); }
.ico-rose   { background: linear-gradient(145deg, #fb7185, #e11d48); box-shadow: 0 4px 12px rgba(225,29,72,.3); }
.ico-indigo { background: linear-gradient(145deg, #818cf8, #4f46e5); box-shadow: 0 4px 12px rgba(79,70,229,.3); }
.ico-teal   { background: linear-gradient(145deg, #2dd4bf, #0d9488); box-shadow: 0 4px 12px rgba(13,148,136,.3); }
.ico-slate  { background: linear-gradient(145deg, #94a3b8, #64748b); box-shadow: 0 4px 12px rgba(100,116,139,.25); }

.brand-word { font-weight: 700; font-size: 1.1rem; letter-spacing: -0.02em; }
.brand-word .royal { color: var(--royal); }
.brand-word .sonic { color: var(--ink); }

/* —— Login —— */
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}
.login-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 1.75rem 1.6rem 1.5rem;
  animation: rise 0.45s ease both;
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-bottom: 1.25rem;
}
.login-sub { margin: 0; color: var(--muted); font-size: 0.85rem; font-weight: 600; }
.login-card h1 { margin: 0 0 0.35rem; font-size: 1.45rem; font-weight: 700; }

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

/* —— Shell —— */
.shell {
  display: grid;
  grid-template-columns: var(--side-w) 1fr;
  min-height: 100vh;
}
.sidebar {
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 1rem 0.85rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.side-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
  padding: 0.35rem 0.5rem 1rem;
}
.side-tag {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.side-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
}
.side-foot {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
  margin-top: 0.75rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  width: 100%;
  text-align: left;
  font: inherit;
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text);
  background: transparent;
  border: none;
  border-radius: 12px;
  padding: 0.45rem 0.55rem;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-item:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.nav-item.is-active {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent-deep);
}
html[data-rs-theme="dark"] .nav-item.is-active { color: var(--accent); }
.ghost-nav { color: var(--muted); font-weight: 500; }

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
}
.topbar {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 1.05rem 1.35rem 0.9rem;
  background: linear-gradient(180deg, var(--panel), color-mix(in srgb, var(--panel) 85%, var(--canvas)));
  border-bottom: 1px solid var(--line);
}
.title-row {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex: 1;
  min-width: 0;
}
.topbar h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--ink);
}
.top-lede {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}
.top-actions { display: flex; gap: 0.4rem; }
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 2.35rem;
  height: 2.35rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.icon-btn svg { width: 1.1rem; height: 1.1rem; }
.mobile-only { display: none; }

.content {
  padding: 1.15rem 1.25rem 2rem;
  flex: 1;
}
.view { animation: rise 0.35s ease both; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.15rem;
}
.panel-head {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.85rem;
}
.panel-head h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
}

.lede { color: var(--muted); margin: 0 0 1rem; }
label {
  display: block;
  margin: 0.65rem 0;
  font-weight: 600;
  font-size: 0.88rem;
}
.inline-label { margin: 0; }
.opt { font-weight: 500; color: var(--muted); }

input, select {
  display: block;
  width: 100%;
  margin-top: 0.3rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  background: var(--panel-strong);
  color: var(--text);
}
input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

button.primary, .primary {
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border-radius: 10px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  padding: 0.55rem 1rem;
  margin-top: 0.35rem;
}
button.primary:hover, .primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.primary.wide { width: 100%; margin-top: 0.85rem; }

.err { color: var(--danger); margin-top: 0.75rem; }
.ok { color: var(--ok); margin-top: 0.75rem; }

/* KPI cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.85rem;
}
.kpi {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem;
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.kpi:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.1);
}
.kpi-body { min-width: 0; }
.kpi-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.kpi strong {
  display: block;
  font-size: 1.35rem;
  font-weight: 700;
  margin: 0.15rem 0;
  letter-spacing: -0.02em;
}
.kpi .kpi-sub { color: var(--muted); font-size: 0.82rem; }

.layout-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
@media (max-width: 960px) {
  .layout-2 { grid-template-columns: 1fr; }
}

.list { display: flex; flex-direction: column; gap: 0.65rem; }
.card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.9rem 1rem;
  background: var(--panel-strong);
}
.card h3 {
  margin: 0 0 0.3rem;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.card .meta { color: var(--muted); font-size: 0.85rem; }
.card .actions {
  margin-top: 0.65rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.card .actions button {
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  padding: 0.4rem 0.65rem;
}
.card .actions button:hover { border-color: var(--accent); color: var(--accent); }
.card .actions a.primary {
  display: inline-block;
  text-decoration: none;
  padding: 0.4rem 0.7rem;
  font-size: 0.82rem;
}

.code {
  background: #0f1419;
  color: #e8eef8;
  padding: 1rem;
  border-radius: 12px;
  overflow: auto;
  font-size: 0.82rem;
  min-height: 8rem;
  margin-top: 1rem;
  border: 1px solid var(--line);
}

[hidden] { display: none !important; }

/* Mobile drawer */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: min(280px, 86vw);
    z-index: 40;
    transform: translateX(-105%);
    transition: transform 0.25s ease;
    box-shadow: var(--shadow);
  }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open::after {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 30;
  }
  .mobile-only { display: inline-grid; }
}
