/* ==========================================================================
   GoPascal Lotofácil Smart - Design System & Styles
   ========================================================================== */

:root {
  --bg: #071018;
  --card: #0c1824;
  --card-hover: #112030;
  --border: #1e3550;
  --text: #e5edf8;
  --muted: #8b9ab3;
  --text-subtle: #5f718d;

  --primary: #10b981;
  --primary-press: #059669;
  --primary-soft: rgba(16, 185, 129, .15);

  --accent: #38bdf8;
  --gold: #f59e0b;
  --gold-subtle: rgba(245, 158, 11, .15);
  --gold-border: rgba(245, 158, 11, .4);

  --warn: #f59e0b;
  --ok: #10b981;
  --ok-soft: #064e3b;
  --err: #ef4444;
  --err-soft: #451a1a;

  --sidebar-bg: #050c14;
  --sidebar-border: #15273d;
  --sidebar-text: #93a3bd;
  --sidebar-text-active: #ffffff;
  --topbar-bg: #091320;

  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
  --shadow-lg: 0 24px 60px -12px rgba(0, 0, 0, .55);

  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-w: 16rem;
  --sidebar-w-mini: 4.5rem;
  --topbar-h: 3.75rem;

  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f1f5f9;
  --card: #ffffff;
  --card-hover: #f8fafc;
  --border: #cbd5e1;
  --text: #0f172a;
  --muted: #64748b;
  --text-subtle: #94a3b8;

  --primary: #059669;
  --primary-press: #047857;
  --primary-soft: rgba(5, 150, 105, .12);

  --warn: #d97706;
  --ok: #059669;
  --ok-soft: #d1fae5;
  --err: #dc2626;
  --err-soft: #fee2e2;

  --topbar-bg: #ffffff;
  --sidebar-bg: #0a1726;
  --sidebar-border: #15273d;
  --sidebar-text: #94a3b8;
  --sidebar-text-active: #ffffff;

  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 16px rgba(15, 23, 42, .06);
  --shadow-lg: 0 24px 60px -12px rgba(15, 23, 42, .25);

  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  min-height: 100vh;
}

h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; }
.muted { color: var(--muted); margin: .2rem 0 0; font-size: .9rem; }
.small { font-size: .8rem; margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.badge {
  font-size: .7rem; font-weight: 600; padding: 2px 9px; border-radius: 999px;
  border: 1px solid var(--border); color: var(--muted); white-space: nowrap;
}
.badge.online { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.badge.offline { color: var(--warn); }

/* ==========================================================================
   Gate de Login
   ========================================================================== */
#login-gate {
  position: fixed; inset: 0; z-index: 1000;
  overflow-y: auto; background: radial-gradient(circle at center, #0a1f18 0%, #06111a 100%);
  color: #e8f1ff; display: flex;
}
html.has-token #login-gate { display: none; }

.gate-shade {
  position: fixed; inset: 0; pointer-events: none;
  background:
    radial-gradient(120% 90% at 85% 50%, rgba(3, 7, 18, .78) 0%, rgba(3, 7, 18, .35) 45%, rgba(3, 7, 18, 0) 70%),
    linear-gradient(180deg, rgba(3, 7, 18, .25), rgba(3, 7, 18, .55));
}

.gate-inner {
  position: relative; width: 100%; min-height: 100%;
  display: grid; gap: 24px;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  grid-template-rows: auto 1fr auto;
  grid-template-areas: "brand card" "space card" "copy card";
  padding: max(28px, env(safe-area-inset-top)) clamp(20px, 6vw, 96px) 28px clamp(20px, 4vw, 56px);
}
.gate-brand { grid-area: brand; display: flex; align-items: center; gap: 12px; }
.gate-logo {
  width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center;
  background: linear-gradient(135deg, #10b981, #047857); color: #fff; font-size: 1.3rem;
  box-shadow: 0 8px 24px -6px rgba(16, 185, 129, .55);
}
.gate-brand strong { display: block; font-size: 1.2rem; letter-spacing: -.01em; }
.gate-brand small { display: block; color: #9fb3d6; font-size: .8rem; }
.gate-copy { grid-area: copy; max-width: 480px; text-shadow: 0 2px 16px rgba(0, 0, 0, .6); }
.gate-copy h2 { font-size: clamp(1.8rem, 3.4vw, 2.6rem); font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.gate-copy h2 span {
  background: linear-gradient(90deg, #34d399, #6ee7b7);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.gate-copy p { color: #c3d2ea; margin: 12px 0 16px; line-height: 1.5; }
.gate-chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.gate-chips li {
  font-size: .8rem; font-weight: 600; padding: 6px 12px; border-radius: 999px;
  background: rgba(15, 23, 42, .6); border: 1px solid rgba(52, 211, 153, .28); color: #cdeafe;
  backdrop-filter: blur(6px);
}
.gate-chips i { color: #34d399; margin-right: 4px; }

.gate-card {
  grid-area: card; align-self: center;
  display: grid; gap: 14px; padding: 30px 28px 22px;
  background: rgba(10, 20, 28, .82);
  border: 1px solid rgba(52, 211, 153, .2);
  border-radius: 24px;
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .7), inset 0 1px 0 rgba(255, 255, 255, .06);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
}
.gate-card-ico {
  width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center;
  background: rgba(16, 185, 129, .15); color: #34d399; font-size: 1.5rem;
  border: 1px solid rgba(16, 185, 129, .3);
}
.gate-card h1 { font-size: 1.5rem; font-weight: 750; }
.gate-sub { margin: -8px 0 4px; color: #9fb3d6; font-size: .9rem; }
.gfield { display: grid; gap: 6px; font-size: .8rem; font-weight: 600; color: #a9bbd8; }
.gfield-box {
  position: relative; display: flex; align-items: center;
  background: rgba(3, 8, 22, .7); border: 1px solid rgba(148, 163, 184, .25); border-radius: 12px;
  transition: border-color .15s, box-shadow .15s;
}
.gfield-box:focus-within { border-color: #10b981; box-shadow: 0 0 0 3px rgba(16, 185, 129, .18); }
.gfield-box > i { position: absolute; left: 14px; color: #6b7fa3; font-size: .9rem; pointer-events: none; }
.gfield-box input {
  flex: 1; min-width: 0; font: inherit; font-size: 16px; font-weight: 500; color: #eef4ff;
  background: transparent; border: 0; outline: none; padding: 13px 14px 13px 40px;
}
.gfield-box input::placeholder { color: #5d6f91; }
.gfield-eye {
  border: 0; background: transparent; color: #7f92b5; cursor: pointer;
  padding: 0 14px; height: 44px; font-size: .95rem;
}
.gfield-eye:hover { color: #e0f2fe; }
.btn-gate {
  margin-top: 4px; font: inherit; font-weight: 700; font-size: 1rem; color: #fff; cursor: pointer;
  border: 0; border-radius: 12px; padding: 14px 16px;
  background: linear-gradient(90deg, #10b981, #059669);
  box-shadow: 0 10px 30px -10px rgba(16, 185, 129, .7);
  transition: filter .15s, transform .05s;
}
.btn-gate:hover { filter: brightness(1.08); }
.btn-gate:active { transform: scale(.99); }
.btn-gate:disabled { filter: saturate(.5); cursor: default; }
.btn-gate .lbl-b { display: none; }
.btn-gate.busy .lbl-n { display: none; }
.btn-gate.busy .lbl-b { display: inline; }
.gate-msg { min-height: 1.2em; color: #fca5a5; font-size: .88rem; text-align: center; }
.gate-foot { margin: 0; text-align: center; font-size: .75rem; color: #7f92b5; }
.gate-foot i { color: #10b981; }

@media (max-width: 880px) {
  .gate-inner {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto 1fr auto;
    grid-template-areas: "brand" "card" "copy";
    padding: max(20px, env(safe-area-inset-top)) 16px 24px;
    justify-items: center;
  }
  .gate-brand { justify-self: start; }
  .gate-card { width: min(100%, 420px); padding: 26px 20px 18px; }
  .gate-copy { text-align: center; }
  .gate-copy h2, .gate-copy p { display: none; }
  .gate-chips { justify-content: center; }
}

/* ==========================================================================
   Menu Lateral (Sidebar)
   ========================================================================== */
#sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 120;
  width: var(--sidebar-w);
  display: flex; flex-direction: column;
  background: var(--sidebar-bg); border-right: 1px solid var(--sidebar-border);
  transition: width .22s ease, transform .22s ease;
  overflow: hidden;
}
html.menu-mini #sidebar { width: var(--sidebar-w-mini); }

.sidebar-brand {
  height: var(--topbar-h); display: flex; align-items: center; gap: .75rem;
  padding: 0 1rem; border-bottom: 1px solid var(--sidebar-border); flex-shrink: 0;
}
.sidebar-logo {
  width: 2.4rem; height: 2.4rem; border-radius: .7rem; flex-shrink: 0;
  display: grid; place-items: center; color: #fff; font-size: 1.1rem;
  background: linear-gradient(135deg, #10b981, #047857);
  box-shadow: 0 4px 12px rgba(16, 185, 129, .35);
}
.sidebar-brand-text { min-width: 0; line-height: 1.15; }
.sys-name { display: block; font-weight: 800; color: var(--sidebar-text-active); white-space: nowrap; font-size: 1.02rem; }
.sys-tag { display: block; font-size: .68rem; color: var(--sidebar-text); white-space: nowrap; }

.sidebar-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: .5rem 0 1rem; }
#sidebarNav { list-style: none; margin: 0; padding: 0 .6rem; }

/* Classes geradas pelo TGpShell para o menu lateral */
.nav-section {
  display: flex; align-items: center; gap: .5rem;
  padding: 1rem .7rem .35rem; font-size: .66rem; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase; color: rgba(147, 163, 189, .55);
  list-style: none;
}
.nav-link, .nav-category-btn {
  display: flex; align-items: center; gap: .8rem; width: 100%;
  padding: .62rem .8rem; margin-bottom: .15rem;
  border: 0; border-radius: 10px; background: transparent;
  color: var(--sidebar-text); font: inherit; font-size: .9rem; font-weight: 500;
  text-align: left; text-decoration: none; cursor: pointer;
  transition: background-color .15s, color .15s;
}
.nav-link:hover, .nav-category-btn:hover { background: rgba(255, 255, 255, .06); color: var(--sidebar-text-active); }
.nav-link.active, .nav-link-sub.active {
  background: rgba(16, 185, 129, .15); color: #34d399;
  box-shadow: inset 3px 0 0 #10b981;
}
.nav-icon { width: 1.25rem; text-align: center; flex-shrink: 0; font-size: 1rem; }
.nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-arrow { font-size: .7rem; opacity: .65; transition: transform .2s; }
.nav-category-btn[aria-expanded="true"] .nav-arrow { transform: rotate(90deg); }
.nav-link-sub {
  display: flex; align-items: center; gap: .65rem; margin-left: 1.1rem;
  padding: .5rem .7rem; border-radius: 10px; color: var(--sidebar-text);
  text-decoration: none; font-size: .84rem;
}

.sidebar-footer { padding: .75rem; border-top: 1px solid var(--sidebar-border); }
.logout-btn {
  display: flex; align-items: center; gap: .8rem; width: 100%;
  padding: .65rem .8rem; border: 0; border-radius: 10px; cursor: pointer;
  background: rgba(239, 68, 68, .12); color: #fca5a5; font: inherit; font-size: .88rem; font-weight: 600;
}
.logout-btn:hover { background: rgba(239, 68, 68, .22); color: #fecaca; }

html.menu-mini #sidebar .sidebar-brand-text,
html.menu-mini #sidebar .nav-label,
html.menu-mini #sidebar .nav-arrow,
html.menu-mini #sidebar .logout-label { display: none; }
html.menu-mini #sidebar .sidebar-brand { justify-content: center; padding: 0 .5rem; }
html.menu-mini #sidebar .nav-section { justify-content: center; padding: .9rem 0 .3rem; font-size: 0; }
html.menu-mini #sidebar .nav-section::after {
  content: ""; width: 1.6rem; height: 1px; background: var(--sidebar-border);
}
html.menu-mini .nav-link, html.menu-mini .logout-btn { justify-content: center; padding: .7rem .3rem; }
html.menu-mini .nav-link.active { box-shadow: none; }

#sidebar-backdrop {
  position: fixed; inset: 0; z-index: 110; background: rgba(3, 7, 18, .55);
  opacity: 0; pointer-events: none; transition: opacity .22s;
}

/* ==========================================================================
   Área Principal, Navbar e Abas
   ========================================================================== */
.main-area {
  margin-left: var(--sidebar-w); min-height: 100vh;
  display: flex; flex-direction: column; transition: margin-left .22s ease;
}
html.menu-mini .main-area { margin-left: var(--sidebar-w-mini); }

#navbar {
  position: sticky; top: 0; z-index: 90; height: var(--topbar-h);
  display: flex; align-items: center; gap: .6rem; padding: 0 1.25rem;
  padding-top: env(safe-area-inset-top);
  background: color-mix(in srgb, var(--topbar-bg) 90%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.navbar-title { font-size: 1rem; font-weight: 700; white-space: nowrap; }
.navbar-actions { margin-left: auto; display: flex; align-items: center; gap: .6rem; }
.navbar-icon-btn {
  display: inline-grid; place-items: center; width: 2.4rem; height: 2.4rem;
  border: 0; border-radius: 10px; background: transparent; color: var(--muted); cursor: pointer;
  font-size: 1rem;
}
.navbar-icon-btn:hover { background: var(--primary-soft); color: var(--text); }
:root .ic-moon { display: none; }
:root[data-theme="light"] .ic-sun { display: none; }
:root[data-theme="light"] .ic-moon { display: inline; }

.user-chip { display: flex; align-items: center; gap: .55rem; padding-left: .25rem; }
.user-chip .avatar {
  width: 2.1rem; height: 2.1rem; border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(135deg, #10b981, #059669); color: #fff; font-weight: 800; font-size: .85rem;
}
.user-txt { display: grid; line-height: 1.15; min-width: 0; }
.user-txt .name { font-size: .85rem; font-weight: 700; white-space: nowrap; }
.user-txt .mail { font-size: .7rem; color: var(--muted); white-space: nowrap; }

/* Barra de Abas do TGpShell */
#app-tabs {
  display: flex; align-items: flex-end; gap: .35rem;
  min-height: 2.75rem; padding: .5rem 1rem 0;
  background: var(--topbar-bg); border-bottom: 1px solid var(--border);
  overflow-x: auto; overflow-y: hidden; scrollbar-width: thin;
}
.tab-item {
  display: inline-flex; align-items: center; gap: .5rem; flex-shrink: 0;
  max-width: 14rem; height: 2.2rem; padding: 0 .45rem 0 .8rem;
  border: 1px solid var(--border); border-bottom-color: transparent;
  border-radius: 10px 10px 0 0;
  background: color-mix(in srgb, var(--bg) 70%, var(--card));
  color: var(--muted); font-size: .82rem; font-weight: 600; cursor: pointer; white-space: nowrap;
  user-select: none; transition: background .12s, color .12s;
}
.tab-item i:first-child { font-size: .8rem; }
.tab-title { overflow: hidden; text-overflow: ellipsis; }
.tab-item:hover, .tab-item.active { color: var(--text); background: var(--bg); }
.tab-item.active { box-shadow: inset 0 2px 0 var(--primary); border-bottom-color: var(--bg); margin-bottom: -1px; }
.tab-close {
  display: inline-grid; place-items: center; width: 1.35rem; height: 1.35rem;
  border-radius: 6px; font-size: .7rem; color: inherit; cursor: pointer;
}
.tab-close:hover { background: color-mix(in srgb, var(--err) 18%, transparent); color: var(--err); }
.tab-item:not(:has(.tab-close)) { padding-right: .8rem; }

.page-content { flex: 1; padding: 1.25rem 1.25rem 3rem; }
#tab-content { max-width: 1120px; margin: 0 auto; }
.tab-pane { display: none; }
.tab-pane.active { display: block; animation: fadeIn .18s ease both; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

@media (max-width: 767px) {
  #sidebar, html.menu-mini #sidebar {
    width: min(290px, 86vw); transform: translateX(-100%);
  }
  html.menu-open #sidebar { transform: none; box-shadow: 12px 0 32px rgba(0, 0, 0, .35); }
  html.menu-open #sidebar-backdrop { opacity: 1; pointer-events: auto; }
  html.menu-mini #sidebar .sidebar-brand-text,
  html.menu-mini #sidebar .nav-label,
  html.menu-mini #sidebar .logout-label { display: block; }
  html.menu-mini #sidebar .nav-section { font-size: .66rem; justify-content: flex-start; padding: 1rem .7rem .35rem; }
  html.menu-mini #sidebar .nav-section::after { display: none; }
  html.menu-mini .nav-link, html.menu-mini .logout-btn { justify-content: flex-start; padding: .62rem .8rem; }
  .main-area, html.menu-mini .main-area { margin-left: 0; }
  .user-txt { display: none; }
  #navbar .badge { display: none; }
  #app-tabs { padding: .45rem .6rem 0; }
  .page-content { padding: 1rem .75rem 3rem; }
}

/* ==========================================================================
   Componentes Comuns de Telas e Formulários
   ========================================================================== */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px;
}
.p-4 { padding: 1.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.w-100 { width: 100%; }

.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; margin-bottom: 18px; flex-wrap: wrap;
}
.card-title {
  font-size: 1.05rem; font-weight: 700; margin-bottom: 0.6rem;
  display: flex; align-items: center; gap: 0.5rem;
}
.card-title i { color: var(--primary); }

.field { display: grid; gap: 6px; font-size: .82rem; font-weight: 600; color: var(--muted); }
.field input, .field select {
  font: inherit; font-size: 15px; font-weight: 400; color: var(--text);
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 13px; outline: none; width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.field-row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.hint { margin: -4px 0 0; font-size: .78rem; color: var(--muted); }
.msg { min-height: 1.2em; color: var(--err); font-size: .88rem; text-align: center; }
.msg.left { text-align: left; }
.msg.ok { color: var(--ok); }
.msg.err { color: var(--err); }

.input-inline { display: flex; align-items: flex-end; gap: 0.75rem; }
.btn-carregar { height: 42px; }
.mini-dez { width: 85px; }

/* Botões */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  font: inherit; font-weight: 600; font-size: .88rem; cursor: pointer;
  border-radius: 10px; border: 1px solid transparent; padding: 9px 16px;
  transition: background .15s, transform .05s, box-shadow .15s;
  touch-action: manipulation; text-decoration: none;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .6; cursor: default; }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-press); }
.btn.primary-subtle { background: var(--primary-soft); color: var(--primary); border-color: rgba(16, 185, 129, .3); }
.btn.primary-subtle:hover { background: var(--primary); color: #fff; }
.btn.success { background: linear-gradient(135deg, #10b981, #059669); color: #fff; font-size: 1rem; padding: 12px 18px; }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn.ghost:hover { background: var(--primary-soft); }
.btn.big { width: 100%; padding: 14px 16px; font-size: 1rem; }
.btn.danger { background: transparent; color: var(--err); border-color: color-mix(in srgb, var(--err) 45%, transparent); }
.btn.danger:hover { background: var(--err-soft); }
.btn.danger.armed { background: var(--err); color: #fff; }

.btn .lbl-c, .btn .lbl-b { display: none; }
.btn.armed { background: var(--warn); animation: pulse 1s ease-in-out infinite; }
.btn.armed .lbl-n { display: none; }
.btn.armed .lbl-c { display: inline; }
.btn.busy .lbl-n, .btn.busy .lbl-c { display: none; }
.btn.busy .lbl-b { display: inline; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--warn) 55%, transparent); }
  50% { box-shadow: 0 0 0 8px transparent; }
}

/* ==========================================================================
   TELA DE USUÁRIOS (Conserta o layout unstyled do Screenshot 1)
   ========================================================================== */
.search-bar { display: flex; gap: 10px; align-items: stretch; margin-bottom: 14px; }
.search-bar .field.search { flex: 1; position: relative; }
.search-bar .field.search i {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: .9rem; pointer-events: none;
}
.search-bar .field.search input { padding-left: 38px; }

.list-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0 10px 8px; font-size: .72rem; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--border);
}
.list-head .small { text-transform: none; letter-spacing: 0; font-weight: 500; }

.usr-list { list-style: none; margin: 0; padding: 0; }
.usr-row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 12px;
  padding: 11px 12px; border-bottom: 1px solid var(--border); cursor: pointer; border-radius: 10px;
  transition: background .15s;
}
.usr-row:last-child { border-bottom: 0; }
.usr-row:hover { background: var(--primary-soft); }

.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; font-size: .95rem;
  background: var(--primary-soft); color: var(--primary);
}
.usr-main { display: grid; min-width: 0; }
.usr-main strong, .usr-main small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.usr-main strong { font-size: .92rem; }
.usr-main small { color: var(--muted); font-size: .8rem; }
.usr-tags { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.usr-edit { color: var(--muted); font-size: .85rem; padding: 6px; }
.usr-row:hover .usr-edit { color: var(--primary); }

.tag {
  font-size: .7rem; padding: 1px 8px; border-radius: 999px;
  border: 1px solid var(--border); color: var(--muted); white-space: nowrap;
}
.tag.adm { color: var(--primary); border-color: color-mix(in srgb, var(--primary) 45%, transparent); }
.tag.off { color: var(--err); border-color: color-mix(in srgb, var(--err) 45%, transparent); }
.tag.me { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.tag.when { color: var(--muted); }

@media (max-width: 560px) {
  .usr-row { grid-template-columns: auto minmax(0, 1fr) auto; }
  .usr-tags { grid-column: 2 / 4; grid-row: 2; justify-content: flex-start; }
  .usr-edit { grid-column: 3; grid-row: 1; }
  .search-bar .btn { padding: 10px 12px; }
}

/* ==========================================================================
   Modais (TSmartModal / ModalUsuario)
   ========================================================================== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 500;
  display: none; align-items: center; justify-content: center; padding: 16px;
  background: rgba(2, 6, 17, .65); backdrop-filter: blur(4px);
}
.modal-overlay.is-open { display: flex; animation: fadeIn .15s ease both; }
body:has(.modal-overlay.is-open) { overflow: hidden; }

.modal-dialog {
  width: min(560px, 100%); max-height: calc(100dvh - 32px);
  display: flex; flex-direction: column;
  background: var(--card); border: 1px solid var(--border); border-radius: 18px;
  box-shadow: var(--shadow-lg); overflow: hidden;
}
.modal-head {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--primary) 85%, #000), #047857);
  color: #fff;
}
.modal-head h2 { flex: 1; font-size: 1.05rem; }
.modal-ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: rgba(255, 255, 255, .16); }
.modal-x {
  width: 34px; height: 34px; border: 0; border-radius: 10px; cursor: pointer;
  background: rgba(255, 255, 255, .12); color: #fff; font-size: 1rem;
}
.modal-x:hover { background: rgba(255, 255, 255, .25); }
.modal-body { padding: 18px 18px 8px; overflow-y: auto; display: grid; gap: 12px; }
.modal-foot {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 18px 16px; border-top: 1px solid var(--border);
}
.foot-gap { flex: 1; }

@media (max-width: 560px) {
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal-dialog { width: 100%; border-radius: 18px 18px 0 0; max-height: 92dvh; }
  .modal-foot { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
  .modal-foot .btn.primary, .modal-foot .btn.ghost { flex: 1; }
  .foot-gap { flex-basis: 100%; height: 0; }
  .modal-foot .btn.danger { flex: 1 1 100%; }
}

/* ==========================================================================
   Bolas da Lotofácil (Loto Balls)
   ========================================================================== */
.loto-balls-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.loto-ball {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 700;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(0,0,0,0.25);
  user-select: none;
}

.loto-ball.mini { width: 28px; height: 28px; font-size: 0.8rem; }

.loto-ball.sort {
  background: linear-gradient(135deg, #10b981, #047857);
  border-color: #059669;
  color: #fff;
  box-shadow: 0 2px 8px rgba(16,185,129,0.4);
}

.loto-ball.aus {
  background: var(--bg);
  border-color: var(--border);
  color: var(--text-subtle);
}

.loto-ball.fixa {
  background: linear-gradient(135deg, #f59e0b, #b45309);
  border-color: #f59e0b;
  color: #fff;
  box-shadow: 0 2px 8px rgba(245,158,11,0.45);
}

.loto-ball.hit {
  background: linear-gradient(135deg, #10b981, #065f46);
  border-color: #34d399;
  color: #fff;
  font-weight: 800;
  box-shadow: 0 2px 8px rgba(16,185,129,0.5);
}

.loto-ball.miss {
  background: rgba(255,255,255,0.03);
  border-color: rgba(255,255,255,0.08);
  color: var(--text-subtle);
  opacity: 0.4;
}

/* ==========================================================================
   Grids e Telas Específicas (Gerador, Conferência, Resultados)
   ========================================================================== */
.gerador-grid, .conferencia-grid, .resultados-grid {
  display: grid;
  grid-template-columns: 460px 1fr;
  gap: 1.5rem;
}

@media (max-width: 1024px) {
  .gerador-grid, .conferencia-grid, .resultados-grid {
    grid-template-columns: 1fr;
  }
}

.info-base-box, .sorteio-alvo-box, .resumo-financeiro-box, .simulacao-box {
  background: color-mix(in srgb, var(--bg) 80%, var(--card));
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.85rem;
}

.base-section-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.linhas-display {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.linha-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.linha-tag {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--primary);
  width: 55px;
}

.jogos-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.salvar-box {
  display: flex;
  gap: 0.5rem;
}
.salvar-box input {
  flex: 1;
  padding: 0.6rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.85rem;
}

.jogos-grid-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.jogo-card {
  background: color-mix(in srgb, var(--bg) 60%, var(--card));
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  transition: transform 0.15s, border-color 0.15s;
}
.jogo-card:hover { border-color: var(--primary); transform: translateY(-1px); }

.jogo-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.6rem;
}
.jogo-card-head strong { font-size: 0.95rem; }
.jogo-stats { font-size: 0.75rem; color: var(--muted); }

/* Conferência e Prêmios */
.tabela-premios {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
.tabela-premios th, .tabela-premios td {
  padding: 0.5rem 0.4rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.tabela-premios th { color: var(--muted); font-weight: 600; }

.totais-box {
  background: color-mix(in srgb, var(--bg) 80%, var(--card));
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.tot-linha {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
}
.tot-linha.destaque {
  font-size: 1rem;
  font-weight: 700;
  border-top: 1px solid var(--border);
  padding-top: 0.4rem;
  margin-top: 0.2rem;
}
.saldo-positivo { color: var(--primary); }
.saldo-negativo { color: var(--err); }

.badge-acertos {
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 700;
}
.badge-premio-ouro { background: var(--gold-subtle); color: var(--gold); border: 1px solid var(--gold-border); }
.badge-premio-verde { background: var(--primary-soft); color: var(--primary); }
.badge-normal { background: var(--bg); color: var(--muted); }

.jogo-premiado-ouro { border-color: var(--gold-border); box-shadow: 0 0 15px rgba(245,158,11,0.25); }
.jogo-premiado { border-color: rgba(16,185,129,0.4); }

.simulacao-resultado {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.85rem;
}
.simulacao-resultado h4 { font-size: 0.9rem; margin-bottom: 0.5rem; }
.simulacao-resultado ul { list-style: none; margin: 0 0 0.75rem; padding: 0; font-size: 0.8rem; }
.simulacao-resultado li { margin-bottom: 0.2rem; color: var(--muted); }
.simulacao-resultado li strong { color: var(--text); }

/* Resultados e Histórico */
.concursos-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-height: 600px;
  overflow-y: auto;
}
.concurso-row {
  background: color-mix(in srgb, var(--bg) 60%, var(--card));
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
}
.concurso-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  margin-bottom: 0.35rem;
}
.concurso-footer {
  display: flex;
  gap: 0.5rem;
  font-size: 0.75rem;
  flex-wrap: wrap;
}
.badge-mini {
  background: var(--bg);
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  color: var(--muted);
  border: 1px solid var(--border);
}

.estat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.6rem;
}
.estat-card {
  background: color-mix(in srgb, var(--bg) 60%, var(--card));
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.estat-dados { font-size: 0.75rem; }
.estat-linha { color: var(--muted); }
.text-warning { color: var(--gold); }
.text-success { color: var(--primary); }

/* Toasts */
#toast-container {
  position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom));
  transform: translateX(-50%); display: grid; gap: 8px; z-index: 2000;
  width: min(92vw, 420px);
}
.toast-item {
  padding: 12px 16px; border-radius: 12px; color: #fff; font-weight: 600; font-size: .88rem;
  box-shadow: var(--shadow); background: #1e293b;
}
.toast-success { background: #059669; }
.toast-error { background: #dc2626; }
.toast-warning { background: #d97706; }
.toast-info { background: #0284c7; }

/* Histórico de Jogos Salvos */
.historico-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.historico-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.historico-card:hover {
  border-color: color-mix(in srgb, var(--primary) 50%, var(--border));
  box-shadow: var(--shadow);
}

.historico-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.85rem;
}

.historico-card-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0 0 0.4rem 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text);
}

.historico-card-meta {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.badge-fixas {
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-elim {
  background: var(--err-soft);
  color: var(--err);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.historico-card-btns {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.historico-grid-mini {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.5rem;
  padding-top: 0.75rem;
}

.mini-jogo-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: color-mix(in srgb, var(--bg) 60%, var(--card));
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.6rem;
}

.mini-jogo-num {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--primary);
  width: 1.8rem;
  flex-shrink: 0;
}

.mini-bolas {
  display: flex;
  gap: 0.2rem;
  flex-wrap: wrap;
}

.loto-ball-mini {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 50%;
  font-size: 0.68rem;
  font-weight: 700;
  background: #10b981;
  color: #ffffff;
}

.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

.danger-subtle {
  background: var(--err-soft);
  color: var(--err);
  border: 1px solid rgba(239, 68, 68, 0.3);
}
.danger-subtle:hover {
  background: var(--err);
  color: #fff;
}
