:root {
  --bg: #f4f5f7;
  --bg2: #ffffff;
  --bg3: #eef0f4;
  --bg-hover: #e5e7ec;
  --border: #dfe3eb;
  --text: #1c1f27;
  --text-muted: #687083;
  --primary: #0f766e;
  --primary-dark: #0b5f59;
  --secondary: #2563eb;
  --success: #59b20d;
  --warning: #ff7a00;
  --danger: #d0312d;
  --info: #438fd8;
  --radius-sm: 8px;
  --radius: 8px;
  --radius-lg: 14px;
  --shadow: 0 1px 2px rgba(22,28,45,.08), 0 12px 28px rgba(22,28,45,.10);
  --shadow-sm: 0 1px 2px rgba(22,28,45,.06);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

:root[data-theme="dark"] {
  --bg: #0a0b0f;
  --bg2: #121319;
  --bg3: #191b23;
  --bg-hover: #21232e;
  --border: #262835;
  --text: #f1f2f6;
  --text-muted: #8c92a4;
  --shadow: 0 2px 4px rgba(0,0,0,.35), 0 10px 30px rgba(0,0,0,.3);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.25);
}

* { box-sizing: border-box; }

html { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
  transition: background-color .2s ease, color .2s ease;
}

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

::selection { background: var(--primary); color: #fff; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 20px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

.app-shell { display: flex; height: 100vh; overflow: hidden; position: relative; }

.sidebar {
  width: 232px;
  min-width: 232px;
  background: #111827;
  border-right: 1px solid rgba(255,255,255,.12);
  display: flex;
  flex-direction: column;
  padding: 18px 0;
  transition: width .18s ease, min-width .18s ease;
}
.btn-toggle-sidebar {
  position: absolute;
  top: 18px;
  left: 232px;
  transform: translateX(-50%);
  z-index: 90;
  width: 20px;
  height: 36px;
  padding: 0;
  border: 1px solid rgba(255,255,255,.16);
  background: #1a2030;
  color: rgba(255,255,255,.75);
  border-radius: 0 8px 8px 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  box-shadow: var(--shadow-sm);
  transition: left .18s ease;
}
.btn-toggle-sidebar:hover { color: #fff; background: #232a3d; }
.app-shell.sidebar-recolhida .sidebar { width: 0; min-width: 0; overflow: hidden; border-right: none; }
.app-shell.sidebar-recolhida .btn-toggle-sidebar { left: 0; }
.sidebar .brand {
  font-weight: 800;
  font-size: 16px;
  letter-spacing: -.01em;
  padding: 0 16px 18px 20px;
  display: flex;
  align-items: center;
  gap: 9px;
  border-bottom: 1px solid rgba(255,255,255,.12);
  margin-bottom: 10px;
  color: #fff;
}
.sidebar .brand .brand-nome { flex: 1; }
.sidebar .brand .logo-dot {
  width: 26px; height: 26px; border-radius: 8px;
  background: linear-gradient(135deg, #0f766e, #2563eb);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; flex-shrink: 0;
}
.sidebar nav { flex: 1; overflow-y: auto; padding: 4px 10px; }
.sidebar a.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  margin-bottom: 2px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.72);
  font-size: 13.5px;
  font-weight: 500;
  transition: background-color .15s ease, color .15s ease;
}
.sidebar a.nav-item:hover { background: rgba(255,255,255,.10); text-decoration: none; color: #fff; }
.sidebar a.nav-item.active { background: linear-gradient(135deg, rgba(15,118,110,.45), rgba(37,99,235,.28)); color: #fff; font-weight: 600; }
.sidebar .nav-secao {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: rgba(255,255,255,.56);
  padding: 16px 12px 6px;
  opacity: .7;
}
.sidebar .rodape {
  padding: 14px 20px 16px;
  border-top: 1px solid rgba(255,255,255,.12);
  font-size: 12.5px;
  color: rgba(255,255,255,.70);
  display: none;
  flex-direction: column;
  gap: 8px;
}
.sidebar .rodape a { color: rgba(255,255,255,.70); }
.sidebar .rodape a:hover { color: #fff; }
.sidebar .rodape .linha-usuario { display: flex; align-items: center; justify-content: space-between; }
.sidebar .rodape .usuario-nome { color: #fff; font-weight: 600; }

.main {
  flex: 1;
  overflow-y: auto;
  padding: 28px 32px;
}
.main.sem-padding { padding: 0; overflow: hidden; }

.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

h1, h2, h3 { margin-top: 0; letter-spacing: -.01em; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 16px; font-weight: 700; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  font-family: var(--font);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  background: var(--bg3);
  color: var(--text);
  transition: transform .1s ease, filter .15s ease, box-shadow .15s ease;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: scale(.98); }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--secondary)); color: #fff; box-shadow: 0 4px 14px rgba(15,118,110,.24); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 11px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color .15s ease, color .15s ease;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-size: 12.5px; font-weight: 600; color: var(--text-muted); }
.form-control {
  width: 100%;
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--text);
  font-family: var(--font);
  font-size: 13.5px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(15,118,110,.16); }
textarea.form-control { resize: vertical; min-height: 80px; }

table { width: 100%; border-collapse: collapse; }
table th, table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); font-size: 13px; }
table th { color: var(--text-muted); font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
table tbody tr { transition: background-color .12s ease; }
table tbody tr:hover { background: var(--bg3); }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 700;
}
.badge-ok { background: rgba(34,197,94,.15); color: var(--success); }
.badge-risco { background: rgba(245,158,11,.15); color: var(--warning); }
.badge-estourado { background: rgba(239,68,68,.15); color: var(--danger); }
.badge-info { background: rgba(14,165,233,.15); color: var(--info); }

.toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  min-width: 240px;
  box-shadow: var(--shadow);
  font-size: 13px;
  animation: entrada-toast .2s ease;
}
@keyframes entrada-toast { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.toast.erro { border-left-color: var(--danger); }
.toast.sucesso { border-left-color: var(--success); }

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 15% 15%, rgba(15,118,110,.18), transparent 45%),
    radial-gradient(circle at 85% 85%, rgba(37,99,235,.14), transparent 45%),
    var(--bg);
}
.login-card { width: 100%; max-width: 380px; padding: 36px; border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.login-card .logo-dot {
  width: 64px; height: 64px; border-radius: 18px; margin: 0 auto 18px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex; align-items: center; justify-content: center; font-size: 30px;
  box-shadow: 0 8px 24px rgba(15,118,110,.34);
}
.login-card h1 { text-align: center; margin-bottom: 4px; }
.login-card p.subtitulo { text-align: center; color: var(--text-muted); margin-top: 0; margin-bottom: 26px; font-size: 13.5px; }
.erro-msg { color: var(--danger); font-size: 13px; margin-bottom: 12px; min-height: 16px; text-align: center; }

.toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; gap: 12px; flex-wrap: wrap; }
.toolbar .form-control { max-width: 260px; }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(10,12,18,.6);
  display: flex; align-items: center; justify-content: center; z-index: 100;
  animation: entrada-toast .15s ease;
}
.modal { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; width: 100%; max-width: 420px; box-shadow: var(--shadow); }
.modal .modal-acoes { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

.permissoes-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; margin-top: 6px; }
.permissoes-grid label { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 400; color: var(--text); }

[hidden] { display: none !important; }

/* ------------------------------------------------------------------
   Responsivo (celular): a sidebar vira gaveta deslizante, aberta pelo
   botão ☰ injetado via app.js. Ver também as regras mobile em chat.css.
   ------------------------------------------------------------------ */
.btn-menu-mobile { display: none; }
.sidebar-backdrop { display: none; }

@media (max-width: 768px) {
  .btn-menu-mobile {
    display: flex; align-items: center; justify-content: center;
    position: fixed; top: 10px; left: 12px; z-index: 70;
    width: 40px; height: 40px; border-radius: 10px;
    background: var(--bg2); border: 1px solid var(--border); color: var(--text);
    box-shadow: var(--shadow); font-size: 17px; cursor: pointer;
  }
  .sidebar-backdrop {
    display: block; position: fixed; inset: 0; background: rgba(8,9,14,.5);
    z-index: 75; opacity: 0; pointer-events: none; transition: opacity .2s ease;
  }
  .sidebar-backdrop.visivel { opacity: 1; pointer-events: auto; }

  .btn-toggle-sidebar { display: none; }

  .sidebar {
    position: fixed; top: 0; left: 0; height: 100vh; z-index: 80;
    width: 78vw; max-width: 300px;
    transform: translateX(-100%); transition: transform .22s ease;
    box-shadow: var(--shadow);
  }
  .sidebar.aberta { transform: translateX(0); }

  .main { padding: 68px 16px 20px; }
  .main.sem-padding { padding: 56px 0 0; }

  .toolbar { gap: 10px; }
  .card { padding: 16px; }

  .modal { max-width: none; width: calc(100vw - 32px); }

  table { display: block; overflow-x: auto; white-space: nowrap; }
}


