/* ============================================================
   ARES INTELLIGENCE - Design System v3
   High-tech, paleta reduzida (indigo/violeta + neutros).
   Fundo de galaxia. Tema claro e escuro.
   ============================================================ */

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;

  --radius-app: 26px;
  --radius-lg: 18px;
  --radius-md: 13px;
  --radius-sm: 9px;

  /* Paleta reduzida: indigo e violeta sao a marca. Um so alerta (ambar) e
     um so critico (vermelho). Todo o resto e neutro. */
  --brand: #6366f1;
  --brand-2: #8b5cf6;
  --brand-hover: #4f46e5;
  --brand-soft: rgba(99, 102, 241, 0.12);
  --attention: #f59e0b;
  --attention-soft: rgba(245, 158, 11, 0.14);
  --critical: #f43f5e;
  --critical-soft: rgba(244, 63, 94, 0.13);

  /* Tema CLARO */
  --bg: #ecedf3;
  --app: #ffffff;
  --sidebar: #ffffff;
  --surface: #ffffff;
  --surface-2: #f5f6f9;
  --surface-inset: #eef0f5;
  --border: #e8eaf0;
  --border-strong: #dee0e9;
  --text: #14151c;
  --text-soft: #61637a;
  --text-mute: #9598ad;
  --ink: #14161f;
  --ink-text: #f6f7fb;
  --shadow-sm: 0 1px 2px rgba(20, 22, 40, 0.05);
  --shadow: 0 6px 30px rgba(20, 22, 40, 0.07);
  --glow: 0 0 0 1px var(--brand-soft), 0 8px 30px rgba(99, 102, 241, 0.12);

  --star: rgba(70, 74, 120, 0.22);
  --grid: rgba(70, 74, 120, 0.05);
  --neb1: rgba(99, 102, 241, 0.07);
  --neb2: rgba(139, 92, 246, 0.06);
  --app-bg: var(--app);
  --app-blur: none;
  /* Bolhas (versao clara: azul claro + lilas claro) */
  --bubble-a: rgba(147, 197, 253, 0.55);
  --bubble-b: rgba(221, 214, 254, 0.6);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #05060c;
    --app: #0c0d16;
    --sidebar: #0d0e18;
    --surface: #14151f;
    --surface-2: #101019;
    --surface-inset: #191a26;
    --border: #21222f;
    --border-strong: #2b2c3c;
    --text: #eef0f7;
    --text-soft: #969ab4;
    --text-mute: #5f6178;
    --ink: #05050b;
    --ink-text: #f6f7fb;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
    --shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    --glow: 0 0 0 1px rgba(99, 102, 241, 0.4), 0 8px 40px rgba(99, 102, 241, 0.28);
    --star: rgba(255, 255, 255, 0.72);
    --grid: rgba(140, 150, 255, 0.05);
    --neb1: rgba(99, 102, 241, 0.18);
    --neb2: rgba(139, 92, 246, 0.15);
    --app-bg: rgba(12, 13, 22, 0.72);
    --app-blur: blur(22px) saturate(120%);
    --bubble-a: rgba(59, 130, 246, 0.55);
    --bubble-b: rgba(139, 92, 246, 0.5);
  }
}

:root[data-theme="dark"] {
  --bg: #05060c;
  --app: #0c0d16;
  --sidebar: #0d0e18;
  --surface: #14151f;
  --surface-2: #101019;
  --surface-inset: #191a26;
  --border: #21222f;
  --border-strong: #2b2c3c;
  --text: #eef0f7;
  --text-soft: #969ab4;
  --text-mute: #5f6178;
  --ink: #05050b;
  --ink-text: #f6f7fb;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  --glow: 0 0 0 1px rgba(99, 102, 241, 0.4), 0 8px 40px rgba(99, 102, 241, 0.28);
  --star: rgba(255, 255, 255, 0.72);
  --grid: rgba(140, 150, 255, 0.05);
  --neb1: rgba(99, 102, 241, 0.18);
  --neb2: rgba(139, 92, 246, 0.15);
  --app-bg: rgba(12, 13, 22, 0.72);
  --app-blur: blur(22px) saturate(120%);
  --bubble-a: rgba(59, 130, 246, 0.55);
  --bubble-b: rgba(139, 92, 246, 0.5);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

body, .app, .sidebar, .topbar, .content, .card, .stat, .provider-card, .btn,
.icon-btn, .nav-item, .badge, .notice, .input, .field input, .field select,
table.ares, table.ares th, table.ares td, .auth-card {
  transition: background-color .45s ease, color .45s ease, border-color .45s ease;
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- Fundo de galaxia high-tech ---------- */
body::before {
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-color: var(--bg);
  background-image:
    radial-gradient(1.5px 1.5px at 12% 20%, var(--star), transparent),
    radial-gradient(1px 1px at 24% 62%, var(--star), transparent),
    radial-gradient(1.5px 1.5px at 39% 14%, var(--star), transparent),
    radial-gradient(1px 1px at 52% 78%, var(--star), transparent),
    radial-gradient(2px 2px at 68% 28%, var(--star), transparent),
    radial-gradient(1px 1px at 79% 58%, var(--star), transparent),
    radial-gradient(1.5px 1.5px at 88% 16%, var(--star), transparent),
    radial-gradient(1px 1px at 7% 86%, var(--star), transparent),
    radial-gradient(1px 1px at 94% 80%, var(--star), transparent),
    radial-gradient(1.5px 1.5px at 34% 92%, var(--star), transparent),
    radial-gradient(1px 1px at 60% 44%, var(--star), transparent),
    radial-gradient(900px 620px at 84% 4%, var(--neb1), transparent),
    radial-gradient(760px 700px at 4% 98%, var(--neb2), transparent);
}
body::after {
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 52px 52px;
  -webkit-mask-image: radial-gradient(120% 120% at 50% 0%, #000 40%, transparent 78%);
          mask-image: radial-gradient(120% 120% at 50% 0%, #000 40%, transparent 78%);
}

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.02em; }
h1 { font-size: 1.65rem; }
h2 { font-size: 1.18rem; }
h3 { font-size: 1rem; }
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-hover); }
.muted { color: var(--text-soft); }

/* ---------- Shell ---------- */
/* Altura fixa: sidebar e topbar ficam parados, so o conteudo rola por dentro.
   Isso evita a sidebar "pular" ao trocar de aba (paginas de alturas diferentes). */
.app {
  position: relative; z-index: 1;
  display: flex; height: calc(100vh - 32px); margin: 16px;
  background: var(--app-bg);
  -webkit-backdrop-filter: var(--app-blur); backdrop-filter: var(--app-blur);
  border: 1px solid var(--border);
  border-radius: var(--radius-app); overflow: hidden; box-shadow: var(--shadow);
}

.sidebar {
  width: 250px; flex-shrink: 0;
  background: var(--sidebar); border-right: 1px solid var(--border);
  padding: 22px 18px; display: flex; flex-direction: column; gap: 8px;
  overflow: hidden auto;
}

/* Logo: sem caixa. Troca positivo/negativo conforme o tema. */
.brand { display: flex; align-items: center; justify-content: center; margin-bottom: 0; padding: 4px; }
.brand .logo-full { width: 100%; max-width: 210px; height: auto; display: block; }
.brand-auth { display: block; width: 100%; margin: 0 auto 8px; }
.brand-auth .logo-full { display: block; width: 100%; max-width: 210px; margin: 0 auto; }
.logo-full.logo-dark { display: none; }
.logo-full.logo-light { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo-full.logo-dark { display: block; }
  :root:not([data-theme="light"]) .logo-full.logo-light { display: none; }
}
:root[data-theme="dark"] .logo-full.logo-dark { display: block; }
:root[data-theme="dark"] .logo-full.logo-light { display: none; }
:root[data-theme="light"] .logo-full.logo-dark { display: none; }
:root[data-theme="light"] .logo-full.logo-light { display: block; }

.welcome { padding: 2px 8px 16px; }
.welcome .hi { font-size: 1.1rem; font-weight: 600; letter-spacing: -0.02em; }
.welcome .sub { font-size: .76rem; color: var(--text-mute); margin-top: 2px; }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .09em; color: var(--text-mute); padding: 8px 12px 4px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px;
  border-radius: var(--radius-md); color: var(--text-soft);
  font-size: .9rem; font-weight: 500;
  transition: background .15s ease, color .15s ease;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }

.sidebar-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--border); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 6px; }
.user-chip .avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff; display: grid; place-items: center; font-weight: 600; flex-shrink: 0;
}
.user-chip .who { min-width: 0; }
.user-chip .who .name { font-size: .84rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip .who .role { font-size: .72rem; color: var(--text-mute); }

/* ---------- Main ---------- */
.main { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.topbar {
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 20px 30px; border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.topbar .title h1 { font-size: 1.35rem; }
.topbar .title p { margin: 2px 0 0; font-size: .84rem; color: var(--text-soft); }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.content { padding: 26px 30px 40px; flex: 1; min-height: 0; overflow: hidden auto; }

/* Scrollbar invisivel nas areas de rolagem (rolagem continua funcionando) */
.content, .sidebar, .notif-list, .modal-backdrop, .table-wrap { scrollbar-width: none; -ms-overflow-style: none; }
.content::-webkit-scrollbar, .sidebar::-webkit-scrollbar,
.notif-list::-webkit-scrollbar, .modal-backdrop::-webkit-scrollbar,
.table-wrap::-webkit-scrollbar { width: 0; height: 0; display: none; }

/* ---------- Botoes ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; border: 1px solid transparent;
  border-radius: var(--radius-md); padding: 10px 16px; font-size: .89rem;
  font-weight: 500; font-family: inherit; cursor: pointer;
  transition: background .15s ease, border-color .15s ease, transform .05s ease, box-shadow .15s ease;
}
.btn svg { width: 16px; height: 16px; }
.btn:active { transform: scale(.98); }
.btn-primary {
  color: #fff;
  background: linear-gradient(120deg, #6366f1, #8b5cf6, #3b82f6, #6366f1);
  background-size: 220% 100%;
  animation: btnFlow 6s ease-in-out infinite;
}
.btn-primary:hover { color: #fff; filter: brightness(1.06); box-shadow: 0 8px 26px rgba(99, 102, 241, .45); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { padding: 7px 12px; font-size: .81rem; }
@keyframes btnFlow { 0%, 100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }
@media (prefers-reduced-motion: reduce) { .btn-primary, .btn-danger { animation: none; } }

.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; background: transparent;
  border: 1px solid var(--border-strong); display: grid; place-items: center;
  cursor: pointer; color: var(--text);
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 18px; height: 18px; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.card-pad { padding: 22px; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.grid-2 { display: grid; gap: 16px; grid-template-columns: 1fr 1fr; }
.grid-3 { display: grid; gap: 16px; grid-template-columns: repeat(3, 1fr); }
@media (max-width: 900px) { .grid-3 { grid-template-columns: 1fr; } }

.stat {
  position: relative; overflow: hidden; border-radius: var(--radius-lg); padding: 20px 22px;
  background: linear-gradient(145deg, #171826, #23243a);
  border: 1px solid rgba(255, 255, 255, .07); color: #f4f5fb;
  box-shadow: var(--shadow-sm);
}
.stat .ic {
  width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center;
  background: rgba(255, 255, 255, .09); color: #fff; margin-bottom: 14px;
}
.stat .ic svg { width: 18px; height: 18px; }
.stat .label { font-size: .77rem; color: rgba(255, 255, 255, .6); font-weight: 500; }
.stat .value { font-size: 2rem; font-weight: 700; letter-spacing: -0.03em; margin-top: 4px; color: #fff; }
.stat .sub { font-size: .74rem; color: rgba(255, 255, 255, .5); margin-top: 4px; }
.stat::after {
  content: ""; position: absolute; right: -34px; top: -34px; width: 130px; height: 130px;
  background: radial-gradient(circle, var(--stat-glow, rgba(139, 92, 246, .38)), transparent 70%);
}
.stat.g-indigo { --stat-glow: rgba(99, 102, 241, .4); }
.stat.g-violeta { --stat-glow: rgba(139, 92, 246, .4); }
.stat.g-azul { --stat-glow: rgba(59, 130, 246, .38); }
.stat.g-ambar { --stat-glow: rgba(245, 158, 11, .32); }

/* ---------- Provedores em containers ---------- */
.provider-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.provider-card {
  position: relative; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px 18px 16px;
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px;
  transition: border-color .18s ease, box-shadow .18s ease, transform .12s ease;
}
.provider-card:hover { border-color: var(--brand); box-shadow: var(--glow); transform: translateY(-2px); }
.provider-fin { position: absolute; top: 14px; right: 14px; }
.provider-logo {
  width: 62px; height: 62px; border-radius: 16px; flex-shrink: 0; overflow: hidden; margin-top: 2px;
  display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text-mute); font-weight: 700; font-size: 1.25rem;
}
.provider-logo img { width: 100%; height: 100%; object-fit: contain; }
.provider-add {
  border: 1.5px dashed var(--border-strong); background: transparent; border-radius: var(--radius-lg);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  min-height: 158px; color: var(--text-soft); cursor: pointer; transition: border-color .15s, color .15s;
}
.provider-add:hover { border-color: var(--brand); color: var(--brand); }
.provider-add svg { width: 26px; height: 26px; }
.provider-name { font-weight: 600; font-size: 1.05rem; line-height: 1.2; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.provider-name a { color: var(--text); }
.provider-name a:hover { color: var(--brand); }
.provider-doc { font-size: .8rem; color: var(--text-mute); margin-top: 3px; }
.provider-badges { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.provider-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); }

.presence { display: inline-flex; align-items: center; gap: 7px; font-size: .78rem; color: var(--text-soft); }
.presence .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-mute); }
.presence.online .dot { background: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }

/* ---------- Tabela ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--border); }
table.ares { width: 100%; border-collapse: collapse; background: var(--surface); }
table.ares th, table.ares td { text-align: left; padding: 14px 18px; border-bottom: 1px solid var(--border); font-size: .89rem; }
table.ares th { color: var(--text-mute); font-weight: 600; font-size: .71rem; text-transform: uppercase; letter-spacing: .05em; background: var(--surface-2); }
table.ares tr:last-child td { border-bottom: none; }
table.ares tbody tr:hover { background: var(--surface-2); }

/* ---------- Selos (paleta reduzida) ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.badge .dot { width: 7px; height: 7px; border-radius: 50%; }
.badge-ok, .badge-brand { background: var(--brand-soft); color: var(--brand); }
.badge-ok .dot, .badge-brand .dot { background: var(--brand); }
.badge-warn { background: var(--attention-soft); color: var(--attention); }
.badge-warn .dot { background: var(--attention); }
.badge-danger { background: var(--critical-soft); color: var(--critical); }
.badge-danger .dot { background: var(--critical); }
.badge-mute { background: var(--surface-inset); color: var(--text-soft); }
.badge-mute .dot { background: var(--text-mute); }

.page-head { margin-bottom: 22px; }
.page-head p { color: var(--text-soft); margin: 4px 0 0; }
.section-title { margin: 30px 0 14px; font-size: 1.08rem; }
.back-link { display: inline-flex; align-items: center; gap: 6px; font-size: .84rem; color: var(--text-soft); margin-bottom: 14px; }
.back-link:hover { color: var(--text); }

.notice { padding: 12px 16px; border-radius: var(--radius-md); font-size: .87rem; margin-bottom: 14px; }
.notice-ok { background: var(--brand-soft); color: var(--brand); }
.notice-warn { background: var(--attention-soft); color: var(--attention); border: 1px solid var(--attention); }

/* ---------- Formularios ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: .83rem; color: var(--text-soft); margin-bottom: 6px; }
.field input, .field select, .field textarea, .input, select.input {
  width: 100%; padding: 11px 14px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-md); background: var(--surface); color: var(--text);
  font-size: .91rem; font-family: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus, .input:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft);
}

/* ---------- Login ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: transparent; position: relative; z-index: 1; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-app); padding: 34px; box-shadow: var(--shadow); }

/* ---------- Setores (containers de usuarios) ---------- */
.setor-block { --accent: var(--brand); margin-bottom: 22px; }
.setor-block[data-cor="azul"] { --accent: #3b82f6; }
.setor-block[data-cor="ceu"] { --accent: #38bdf8; }
.setor-block[data-cor="indigo"] { --accent: var(--brand); }
.setor-block[data-cor="violeta"] { --accent: var(--brand-2); }
.setor-block[data-cor="roxo"] { --accent: #a855f7; }
.setor-block[data-cor="neutro"] { --accent: var(--text-mute); }

.setor-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.setor-head .bar { width: 4px; height: 22px; }

/* Listras coloridas com gradiente animado (usadas em todo o sistema) */
.bar {
  border-radius: 3px;
  background: linear-gradient(180deg, var(--accent), color-mix(in srgb, var(--accent) 45%, #ffffff), var(--accent));
  background-size: 100% 240%;
  animation: stripeFlow 3.2s ease-in-out infinite;
}
@keyframes stripeFlow {
  0%, 100% { background-position: 0 0; }
  50% { background-position: 0 100%; }
}
@media (prefers-reduced-motion: reduce) { .bar { animation: none; } }
.setor-head h2 { font-size: 1.1rem; }
.setor-head .count { font-size: .78rem; color: var(--text-mute); }
.setor-head .spacer { flex: 1; }
.setor-perms { display: flex; flex-wrap: wrap; gap: 6px; }

/* team-grid tambem e a zona de drop do setor */
.team-grid {
  display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  border-radius: var(--radius-lg); transition: outline-color .15s ease, background .15s ease;
  outline: 2px dashed transparent; outline-offset: 4px;
}
.team-grid.drop-hover { outline-color: var(--accent, var(--brand)); background: var(--brand-soft); }
.team-grid .empty-hint {
  grid-column: 1 / -1; text-align: center; color: var(--text-mute);
  font-size: .84rem; padding: 22px; border: 1px dashed var(--border-strong); border-radius: var(--radius-lg);
}
.team-grid:has(.member-card) .empty-hint { display: none; }

.member-card {
  position: relative; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 18px 13px 15px;
  display: flex; flex-direction: column; align-items: center; text-align: center;
  cursor: grab; user-select: none;
  transition: border-color .18s ease, box-shadow .18s ease, transform .12s ease, opacity .15s ease;
}
.member-card:hover { border-color: var(--accent, var(--brand)); box-shadow: var(--glow); transform: translateY(-2px); }
.member-card:active { cursor: grabbing; }
.member-card.dragging { opacity: .45; box-shadow: none; }
.member-photo {
  width: 66px; height: 66px; border-radius: 50%; overflow: hidden;
  display: grid; place-items: center; margin-bottom: 11px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff; font-weight: 600; font-size: 1.32rem; pointer-events: none;
}
.member-photo img { width: 100%; height: 100%; object-fit: cover; }
.member-first { font-weight: 300; font-size: .78rem; color: var(--text-soft); line-height: 1.2; }
.member-last { font-weight: 700; font-size: 1.02rem; letter-spacing: -0.02em; line-height: 1.2; margin-top: 1px; }
.member-cargo { margin-top: 6px; font-size: .73rem; font-weight: 600; color: var(--brand); }
:root[data-theme="dark"] .member-cargo { color: #c2c5df; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .member-cargo { color: #c2c5df; } }
.member-tags { margin-top: 9px; display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }

/* Overlay de edicao: flutua na quina superior direita do card */
.member-card > .edit-overlay {
  position: absolute; top: -11px; right: -11px; left: auto; bottom: auto;
  margin: 0; align-self: auto; z-index: 3;
  width: 30px; height: 30px; border-radius: 9px;
  display: grid; place-items: center; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--border-strong);
  color: var(--text-soft); box-shadow: var(--shadow-sm);
  opacity: 0; transform: scale(.85);
  transition: opacity .16s ease, transform .16s ease, background .16s ease, color .16s ease;
}
.member-card:hover .edit-overlay { opacity: 1; transform: scale(1); }
.edit-overlay:hover { background: var(--brand); color: #fff; border-color: var(--brand); }
.edit-overlay svg { width: 15px; height: 15px; }
/* Tooltip do botao de edicao abre para baixo e alinhado a direita,
   para nao estourar o container (overflow:hidden) na quina do card. */
.edit-overlay[data-tooltip]::after {
  bottom: auto; top: calc(100% + 8px); left: auto; right: 0;
  transform: translateX(0) translateY(-4px);
}
.edit-overlay[data-tooltip]:hover::after { transform: translateX(0) translateY(0); }

/* ---------- Tooltip (botoes de icone) ---------- */
[data-tooltip] { position: relative; }
[data-tooltip]::after {
  content: attr(data-tooltip); position: absolute; bottom: calc(100% + 8px); left: 50%;
  transform: translateX(-50%) translateY(4px); white-space: nowrap;
  background: var(--ink); color: var(--ink-text); font-size: .74rem; font-weight: 500;
  padding: 5px 9px; border-radius: 7px; pointer-events: none;
  opacity: 0; transition: opacity .15s ease, transform .15s ease; z-index: 50;
  box-shadow: var(--shadow);
}
[data-tooltip]:hover::after { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Grade de formulario ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.field input[type="checkbox"], .field input[type="radio"] { width: auto; }
.check-row {
  display: flex; align-items: center; gap: 10px; padding: 11px 14px; margin-bottom: 16px;
  border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-2);
  font-size: .9rem; cursor: pointer;
}
.check-row input { width: auto; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }

/* Checkbox customizado (substitui o checkbox padrao do navegador) */
.checkbox { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-size: .86rem; color: var(--text-soft); }
.checkbox input { position: absolute; opacity: 0; width: 0; height: 0; }
.checkbox .box {
  width: 19px; height: 19px; border-radius: 6px; flex-shrink: 0;
  border: 1.5px solid var(--border-strong); background: var(--surface);
  display: grid; place-items: center; transition: background .15s ease, border-color .15s ease;
}
.checkbox .box svg { width: 12px; height: 12px; color: #fff; opacity: 0; transform: scale(.5); transition: .15s ease; }
.checkbox input:checked + .box { background: var(--brand); border-color: var(--brand); }
.checkbox input:checked + .box svg { opacity: 1; transform: scale(1); }
.checkbox:hover .box { border-color: var(--brand); }

/* Toggle customizado (troca o checkbox padrao do navegador) */
.switch-field {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 15px; margin-bottom: 16px; cursor: pointer;
  border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-2);
  font-size: .9rem; font-weight: 500;
}
.switch { position: relative; width: 46px; height: 26px; flex-shrink: 0; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { position: absolute; inset: 0; border-radius: 999px; background: var(--border-strong); transition: background .2s ease; }
.switch .track::before {
  content: ""; position: absolute; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; top: 3px; left: 3px; transition: transform .2s ease; box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track::before { transform: translateX(20px); }

/* Linha de senha com botoes gerar/copiar */
.pw-row { display: flex; gap: 8px; }
.pw-row input { flex: 1; }
.pw-row .btn { flex-shrink: 0; padding: 0 13px; }
.input[readonly], .field input[readonly] { opacity: .8; cursor: default; background: var(--surface-2); }

/* ---------- Editor de foto de perfil ---------- */
.avatar-edit {
  position: relative; width: 96px; height: 96px; margin: 0 auto 14px;
  padding: 0; border: none; background: none; cursor: pointer; display: block;
}
.avatar-img {
  width: 96px; height: 96px; border-radius: 50%; overflow: hidden;
  display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  transition: filter .15s ease;
}
.avatar-img img { width: 100%; height: 100%; object-fit: cover; }
.avatar-ini { font-size: 2rem; font-weight: 600; }
.avatar-edit:hover .avatar-img { filter: brightness(.82); }
.avatar-cam {
  position: absolute; right: 0; bottom: 0; width: 30px; height: 30px; border-radius: 50%;
  background: var(--brand); color: #fff; display: grid; place-items: center;
  border: 2px solid var(--surface);
}
.avatar-cam svg { width: 15px; height: 15px; }

.foto-tabs { display: flex; gap: 6px; background: var(--surface-2); padding: 4px; border-radius: 12px; margin-bottom: 18px; }
.foto-tab { flex: 1; padding: 9px; border: none; background: transparent; border-radius: 9px; cursor: pointer; color: var(--text-soft); font-weight: 500; font-size: .88rem; font-family: inherit; }
.foto-tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.foto-drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 34px; border: 1.5px dashed var(--border-strong); border-radius: var(--radius-lg);
  cursor: pointer; color: var(--text-soft); text-align: center;
}
.foto-drop:hover { border-color: var(--brand); color: var(--text); }

.cropper-stage {
  position: relative; width: 260px; height: 260px; margin: 0 auto; overflow: hidden;
  border-radius: 14px; background: #0a0a12; touch-action: none; cursor: grab;
}
.cropper-stage:active { cursor: grabbing; }
#crop-img { position: absolute; top: 0; left: 0; -webkit-user-drag: none; user-select: none; }
.cropper-ring { position: absolute; inset: 0; pointer-events: none; }
.cropper-ring::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 232px; height: 232px;
  transform: translate(-50%, -50%); border-radius: 50%;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, .45); border: 2px solid rgba(255, 255, 255, .75);
}

.foto-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 10px; }
.foto-thumb { padding: 0; border: 2px solid transparent; border-radius: 12px; overflow: hidden; cursor: pointer; aspect-ratio: 1; background: none; }
.foto-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.foto-thumb:hover { border-color: var(--brand); }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; display: none;
  align-items: flex-start; justify-content: center; padding: 48px 20px;
  background: rgba(8, 9, 16, 0.55); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  overflow-y: auto;
}
.modal-backdrop.open { display: flex; animation: modalFade .18s ease; }
.modal-box {
  width: 100%; max-width: 620px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-app);
  box-shadow: var(--shadow); animation: modalRise .2s ease; margin: auto 0;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 20px 24px; border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-size: 1.15rem; }
.modal-x {
  width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0;
  background: transparent; border: 1px solid var(--border-strong); color: var(--text-soft);
  display: grid; place-items: center; cursor: pointer; font-size: 1.1rem; line-height: 1;
}
.modal-x:hover { background: var(--surface-2); color: var(--text); }
.modal-body { padding: 22px 24px 24px; }
.modal-busy { padding: 48px; text-align: center; color: var(--text-mute); }
@keyframes modalFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalRise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- Botao de perigo ---------- */
.btn-danger {
  color: #fff;
  background: linear-gradient(120deg, #f43f5e, #e11d48, #fb7185, #f43f5e);
  background-size: 220% 100%;
  animation: btnFlow 6s ease-in-out infinite;
}
.btn-danger:hover { color: #fff; filter: brightness(1.06); box-shadow: 0 8px 26px rgba(244, 63, 94, .4); }

/* ---------- Transicao de tema: fronteira de tinta pingando ----------
   Usa a View Transitions API: o novo tema e revelado por baixo de uma
   mascara de gotas que desce, sem cobrir/opacar o conteudo. */
::view-transition-group(root) { animation-duration: .95s; }
::view-transition-old(root) { animation: none; }
::view-transition-new(root) {
  animation: dripDown .95s cubic-bezier(.4, 0, .2, 1) both;
  -webkit-mask: url("../brand/ink-drip-mask.svg") no-repeat;
          mask: url("../brand/ink-drip-mask.svg") no-repeat;
  -webkit-mask-size: 100% 240vh; mask-size: 100% 240vh;
}
@keyframes dripDown {
  from { -webkit-mask-position: 0 -156vh; mask-position: 0 -156vh; }
  to   { -webkit-mask-position: 0 0;       mask-position: 0 0; }
}

/* ---------- Dialogo de confirmacao ---------- */
.confirm-backdrop {
  position: fixed; inset: 0; z-index: 150; display: none;
  align-items: center; justify-content: center; padding: 24px;
  background: rgba(8, 9, 16, 0.6); -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px);
}
.confirm-backdrop.open { display: flex; animation: modalFade .16s ease; }
.confirm-box {
  width: 100%; max-width: 420px; text-align: center;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-app); box-shadow: var(--shadow);
  padding: 30px 28px 24px; animation: modalRise .18s ease;
}
.confirm-ic {
  width: 54px; height: 54px; border-radius: 50%; margin: 0 auto 16px;
  display: grid; place-items: center; background: var(--critical-soft); color: var(--critical);
}
.confirm-ic.info { background: var(--brand-soft); color: var(--brand); }
.confirm-ic svg { width: 26px; height: 26px; }
.confirm-box h3 { font-size: 1.15rem; margin-bottom: 8px; }
.confirm-box p { font-size: .9rem; margin: 0 0 22px; }
.confirm-actions { display: flex; gap: 10px; }
.confirm-actions .btn { flex: 1; justify-content: center; }

/* ---------- Loading galaxia (criando usuario) ---------- */
.creating {
  position: fixed; inset: 0; z-index: 200; display: none;
  flex-direction: column; align-items: center; justify-content: center; gap: 22px;
  background: rgba(5, 6, 12, 0.74); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.creating.open { display: flex; animation: modalFade .18s ease; }
.creating .orb {
  width: 104px; height: 104px; border-radius: 50%; position: relative; overflow: hidden;
  background: radial-gradient(circle at 50% 45%, #1a1c3a, #05060c 72%);
  box-shadow: 0 0 0 1px rgba(99,102,241,.35), 0 0 50px rgba(99,102,241,.4);
}
.creating .orb::after {
  content: ""; position: absolute; inset: -3px; border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0 65%, var(--brand) 82%, var(--brand-2) 92%, transparent);
  animation: spin 1.1s linear infinite;
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 5px), #000 calc(100% - 4px));
          mask: radial-gradient(farthest-side, transparent calc(100% - 5px), #000 calc(100% - 4px));
}
.creating .orb i {
  position: absolute; width: 2px; height: 2px; border-radius: 50%; background: #fff;
  top: 50%; left: 50%; opacity: 0; animation: streak 1.5s linear infinite;
}
.creating .orb i:nth-child(1) { animation-delay: 0s; --a: -40px; --b: -30px; }
.creating .orb i:nth-child(2) { animation-delay: .25s; --a: 35px; --b: -38px; }
.creating .orb i:nth-child(3) { animation-delay: .5s; --a: -45px; --b: 20px; }
.creating .orb i:nth-child(4) { animation-delay: .75s; --a: 42px; --b: 30px; }
.creating .orb i:nth-child(5) { animation-delay: 1s; --a: 0px; --b: -45px; }
.creating .orb i:nth-child(6) { animation-delay: 1.25s; --a: 20px; --b: 44px; }
.creating .txt { color: #eef0f7; font-weight: 600; letter-spacing: .01em; }
.creating .txt::after { content: ""; animation: dots 1.4s steps(4, end) infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes streak {
  0% { transform: translate(calc(var(--a) * -0.4), calc(var(--b) * -0.4)) scale(.3); opacity: 0; }
  40% { opacity: 1; }
  100% { transform: translate(var(--a), var(--b)) scale(1); opacity: 0; }
}
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }
@media (prefers-reduced-motion: reduce) { .creating .orb::after, .creating .orb i { animation-duration: 2.4s; } }

/* ---------- Swatches de cor (setor) ---------- */
.swatches { display: flex; gap: 12px; flex-wrap: wrap; }
.swatch { position: relative; cursor: pointer; }
.swatch input { position: absolute; opacity: 0; width: 0; height: 0; }
.swatch .fill {
  width: 34px; height: 34px; border-radius: 10px; display: block;
  background: currentColor; box-shadow: inset 0 0 0 1px rgba(255,255,255,.15);
  transition: transform .12s ease;
}
.swatch:hover .fill { transform: scale(1.08); }
.swatch input:checked + .fill { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px currentColor; }

/* ---------- Sino de notificacoes ---------- */
.notif { position: relative; }
.notif-badge {
  position: absolute; top: -3px; right: -3px; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 8px; background: var(--brand); color: #fff; font-size: .62rem; font-weight: 700;
  display: grid; place-items: center; pointer-events: none;
}
.notif-panel {
  position: absolute; right: 0; top: calc(100% + 10px); width: 330px; max-width: 84vw;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); display: none; z-index: 60; overflow: hidden;
}
.notif-panel.open { display: block; animation: modalRise .16s ease; }
.notif-head { display: flex; align-items: center; justify-content: space-between; padding: 13px 16px; border-bottom: 1px solid var(--border); }
.notif-head strong { font-size: .92rem; }
.notif-list { max-height: 360px; overflow-y: auto; }
.notif-item { display: flex; gap: 11px; padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: .84rem; }
.notif-item:last-child { border-bottom: none; }
.notif-item.unread { background: var(--brand-soft); }
.notif-item .ic { width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); }
.notif-item .ic svg { width: 16px; height: 16px; }
.notif-item .when { color: var(--text-mute); font-size: .74rem; margin-top: 2px; }
.notif-empty { padding: 28px 16px; text-align: center; color: var(--text-mute); font-size: .85rem; }

/* ---------- Bolhas animadas de fundo ---------- */
.fx { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.bubble {
  position: absolute; border-radius: 50%;
  filter: blur(64px); opacity: .5; will-change: transform, opacity;
  animation: bubbleGrow var(--dur, 26s) ease-in-out infinite alternate;
  animation-delay: var(--delay, 0s);
}
.bubble.a { background: radial-gradient(circle at 35% 35%, var(--bubble-a), transparent 70%); }
.bubble.b { background: radial-gradient(circle at 35% 35%, var(--bubble-b), transparent 70%); }
/* Sempre nas bordas: centros ancorados fora da area util, so o desfoque entra */
.bubble.b1 { width: 460px; height: 460px; top: -170px; left: -150px; --dur: 24s; }
.bubble.b2 { width: 400px; height: 400px; bottom: -160px; right: -130px; --dur: 30s; --delay: -6s; }
.bubble.b3 { width: 320px; height: 320px; top: -130px; right: -120px; --dur: 27s; --delay: -12s; }
.bubble.b4 { width: 360px; height: 360px; bottom: -150px; left: -130px; --dur: 33s; --delay: -3s; }
.bubble.b5 { width: 300px; height: 300px; top: 38%; left: -180px; --dur: 36s; --delay: -9s; }
.bubble.b6 { width: 300px; height: 300px; top: 44%; right: -180px; --dur: 29s; --delay: -15s; }
@keyframes bubbleGrow {
  from { transform: scale(.6) translate(0, 0); opacity: .24; }
  to   { transform: scale(1.3) translate(28px, 20px); opacity: .62; }
}
@media (prefers-reduced-motion: reduce) { .bubble { animation: none; } }

/* ---------- Responsivo ---------- */
@media (max-width: 900px) {
  .app { flex-direction: column; margin: 0; border-radius: 0; height: auto; min-height: 100vh; }
  .sidebar { width: auto; border-right: none; border-bottom: 1px solid var(--border); overflow: visible; }
  .sidebar-foot { margin-top: 16px; }
  .content { overflow: visible; }
  .grid-2 { grid-template-columns: 1fr; }
  .content, .topbar { padding-left: 18px; padding-right: 18px; }
}
