:root {
  --bg: #f3f5fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --sidebar-bg: linear-gradient(180deg, #0f172a 0%, #171836 100%);
  --sidebar-text: #cbd5e1;
  --accent: #6c4ce6;
  --accent-soft: rgba(108, 76, 230, 0.12);
  --green: #16a34a;
  --green-soft: #dcfce7;
  --amber: #d97706;
  --amber-soft: #fef3c7;
  --red: #dc2626;
  --red-soft: #fee2e2;
  --radius: 16px;
  --shadow: 0 4px 20px rgba(15, 23, 42, 0.05);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Layout Shell */
.shell {
  display: grid;
  grid-template-columns: 268px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, #6c4ce6, #ec4899);
  display: grid;
  place-items: center;
  font-weight: 800;
  color: #fff;
  font-size: 18px;
  box-shadow: 0 6px 16px rgba(108, 76, 230, 0.35);
}

.brand h1 {
  margin: 0;
  font-size: 16px;
  color: #fff;
  letter-spacing: -0.01em;
}

.brand small {
  display: block;
  font-size: 11px;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* Game Switcher */
.game-switcher {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  padding: 10px 12px;
}

.game-switcher label {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: #94a3b8;
  margin-bottom: 6px;
}

.game-switcher select {
  width: 100%;
  background: rgba(15, 23, 42, 0.75);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 11px;
  color: #cbd5e1;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s ease;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  text-decoration: none;
}

.nav-link.active {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 6px 16px rgba(108, 76, 230, 0.32);
}

.nav-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.9;
}

.sidebar-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 14px;
}

.btn-logout {
  width: 100%;
  background: rgba(255, 255, 255, 0.06);
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.btn-logout:hover { background: rgba(239, 68, 68, 0.2); border-color: rgba(239, 68, 68, 0.4); color: #fff; }

/* Main Content */
.content-wrap {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-title h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.game-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: var(--accent-soft);
  color: var(--accent);
}

.main {
  padding: 26px 28px 48px;
  max-width: 1380px;
  width: 100%;
}

/* Flash Alerts */
.flash {
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  margin: 0 0 18px;
  border: 1px solid transparent;
}
.flash.ok { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; }
.flash.erro { background: #fef2f2; color: #991b1b; border-color: #fecaca; }

/* Cards & Grids */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.card-head h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.muted { color: var(--muted); font-size: 13px; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.kpi::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: var(--kpi-color, var(--accent));
}

.kpi-label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.kpi-value { font-size: 28px; font-weight: 800; margin: 6px 0 2px; letter-spacing: -0.02em; }
.kpi-sub { font-size: 12px; color: var(--muted); }

.grid-2 { display: grid; grid-template-columns: 1.2fr 1fr; gap: 20px; }
.grid-even { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }

/* Studio Portfolio Strip */
.studio-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.game-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  border-top: 4px solid var(--g-color, var(--accent));
}

.game-card:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(15, 23, 42, 0.09); }
.game-card-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.game-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 22px; background: var(--surface-2); border: 1px solid var(--border); }
.game-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; background: var(--surface-2); border-radius: 10px; padding: 10px; text-align: center; }
.game-stats strong { display: block; font-size: 16px; }
.game-stats span { font-size: 11px; color: var(--muted); }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge.verde, .badge.ativo { background: var(--green-soft); color: var(--green); }
.badge.amarelo, .badge.producao { background: var(--amber-soft); color: var(--amber); }
.badge.vermelho, .badge.pausado { background: var(--red-soft); color: var(--red); }
.badge.vazio { background: #e2e8f0; color: #475569; }
.badge.roxo { background: var(--accent-soft); color: var(--accent); }

/* Bars & Charts */
.bar-row { display: grid; grid-template-columns: 150px 1fr 72px; align-items: center; gap: 12px; margin-bottom: 10px; font-size: 13px; }
.bar-track { height: 10px; background: #e2e8f0; border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent), #a855f7); border-radius: 999px; }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--border); }
td { padding: 12px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
tr:hover td { background: #f8fafc; }

/* Buttons & Forms */
.btn, button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  transition: all 0.15s ease;
}
.btn:hover, button:hover { filter: brightness(1.06); text-decoration: none; }
.btn.sec, button.sec { background: #fff; color: var(--text); border-color: var(--border); }
.btn.sec:hover, button.sec:hover { background: var(--surface-2); }
.btn.danger, button.danger { background: #fee2e2; color: #b91c1c; border-color: #fecaca; }
.btn.sm, button.sm { padding: 6px 11px; font-size: 12px; border-radius: 8px; }

input[type="text"], input[type="password"], input[type="number"], input[type="datetime-local"], input[type="color"], select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: inherit;
  font-size: 13.5px;
  background: #fff;
  color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
label.field { display: block; margin-bottom: 12px; font-size: 12.5px; font-weight: 600; color: #334155; }
label.field > input, label.field > select, label.field > textarea { margin-top: 5px; font-weight: 400; }

/* Catalog Visual Grid */
.pill-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.pill {
  padding: 6px 13px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--border);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
}
.pill.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.dropzone {
  border: 2px dashed #cbd5e1;
  border-radius: 14px;
  padding: 24px;
  text-align: center;
  background: var(--surface-2);
  transition: all 0.15s ease;
}
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); }

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.media-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.04);
}
.media-thumb {
  position: relative;
  aspect-ratio: 1 / 1;
  background: #e2e8f0;
  overflow: hidden;
}
.media-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-badges {
  position: absolute;
  top: 8px; left: 8px; right: 8px;
  display: flex;
  justify-content: space-between;
  gap: 4px;
}
.media-body { padding: 12px; display: flex; flex-direction: column; gap: 8px; }

/* Phone Push Preview */
.phone-preview {
  background: linear-gradient(160deg, #1e293b, #0f172a);
  border-radius: 26px;
  padding: 22px 18px;
  color: #fff;
  box-shadow: 0 16px 32px rgba(15, 23, 42, 0.22);
}
.push-toast {
  background: rgba(255, 255, 255, 0.96);
  color: #0f172a;
  border-radius: 16px;
  padding: 14px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
}
.push-toast-icon {
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--accent); color: #fff;
  display: grid; place-items: center; font-size: 20px; flex-shrink: 0;
}

/* Login Page */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 55%, #312e81 100%);
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border-radius: 20px;
  padding: 32px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.35);
}

@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .grid-2, .grid-even { grid-template-columns: 1fr; }
}
