/* ComuniHub - sistema visual
   Paleta derivada do logotipo Comunilog: azul petroleo (marca), acentos em
   teal, laranja e vermelho (os blocos empilhados do simbolo). */

:root {
  --navy-900: #082436;
  --navy-800: #0c3a53;
  --navy-700: #114b6b;
  --navy-600: #175f87;
  --teal: #21bfae;
  --teal-dark: #189184;
  --orange: #f5a623;
  --red: #e8483f;

  --bg: #f2f5f8;
  --card-bg: #ffffff;
  --text: #1b2733;
  --text-muted: #64748b;
  --border: #e3e8ee;
  --shadow: 0 1px 2px rgba(8, 36, 54, 0.06), 0 4px 14px rgba(8, 36, 54, 0.06);
  --shadow-lg: 0 10px 30px rgba(8, 36, 54, 0.14);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-width: 258px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100vh;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

a { color: var(--navy-700); text-decoration: none; }
h1, h2, h3 { font-family: inherit; }
button { font-family: inherit; }

/* =================== Logo mark (reutilizado no header/sidebar/login) =================== */
.brand-mark { display: flex; align-items: center; gap: .6rem; }
.brand-mark__blocks { flex-shrink: 0; }
.brand-mark__text {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--navy-900);
}
.brand-mark--on-dark .brand-mark__text { color: #fff; }
.brand-mark__sub {
  font-size: .62rem;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 1px;
}
.brand-mark--on-dark .brand-mark__sub { color: rgba(255,255,255,.55); }

/* =================== Auth / login =================== */
.auth-page {
  min-height: 100vh;
  display: flex;
}

.auth-visual {
  flex: 1.1;
  position: relative;
  background: linear-gradient(155deg, var(--navy-900) 0%, var(--navy-700) 65%, var(--navy-600) 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 4.5rem;
  overflow: hidden;
}
.auth-visual__shapes { position: absolute; inset: 0; pointer-events: none; opacity: .9; }
.auth-visual__content { position: relative; z-index: 1; max-width: 460px; }
.auth-visual__content .brand-mark__text { font-size: 2rem; }
.auth-visual__tagline {
  margin-top: 1.5rem;
  font-size: 1.05rem;
  line-height: 1.6;
  color: rgba(255,255,255,.82);
}
.auth-visual__apps { margin-top: 2.5rem; display: flex; gap: .6rem; flex-wrap: wrap; }
.auth-visual__app-chip {
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.16);
  padding: .4rem .8rem;
  border-radius: 20px;
  font-size: .8rem;
  color: rgba(255,255,255,.85);
}

.auth-form-panel {
  width: 440px;
  flex-shrink: 0;
  background: var(--card-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}
.auth-form-panel__inner { width: 100%; max-width: 320px; }
.auth-form-panel .brand-mark { margin-bottom: 2.2rem; }
.auth-form-panel h1 { margin: 0 0 .3rem; font-size: 1.4rem; color: var(--navy-900); }
.auth-form-panel p.subtitle { margin: 0 0 1.75rem; color: var(--text-muted); font-size: .9rem; }

@media (max-width: 880px) {
  .auth-visual { display: none; }
  .auth-form-panel { width: 100%; }
}

/* =================== Forms =================== */
.field { margin-bottom: 1.1rem; }
.field label { display: block; font-size: .82rem; font-weight: 600; margin-bottom: .35rem; color: var(--text); }
.field .hint { display: block; font-size: .75rem; color: var(--text-muted); margin-top: .3rem; font-weight: 400; }
.field input, .field select, .field textarea {
  width: 100%;
  padding: .62rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .92rem;
  background: #fff;
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(33, 191, 174, 0.15);
}

button, .btn {
  cursor: pointer;
  border: none;
  border-radius: var(--radius-sm);
  padding: .62rem 1.1rem;
  font-size: .88rem;
  font-weight: 600;
  background: var(--navy-800);
  color: #fff;
  transition: background .15s, transform .05s;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
}
button:hover, .btn:hover { background: var(--navy-900); }
button:active, .btn:active { transform: translateY(1px); }
button.secondary, .btn.secondary { background: #eef2f6; color: var(--text); }
button.secondary:hover { background: #e3e9ef; }
button.danger { background: var(--red); }
button.danger:hover { background: #c9362e; }
button.accent { background: var(--teal); color: #063a34; }
button.accent:hover { background: var(--teal-dark); color: #fff; }
button[disabled] { opacity: .55; cursor: not-allowed; }
button.icon-btn { padding: .4rem .55rem; background: transparent; color: var(--text-muted); }
button.icon-btn:hover { background: #eef2f6; color: var(--text); }

.error-msg { color: var(--red); font-size: .85rem; margin-top: .8rem; min-height: 1.1em; }
.success-msg { color: var(--teal-dark); font-size: .85rem; margin-top: .8rem; min-height: 1.1em; }

/* =================== App shell (sidebar) =================== */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  background: linear-gradient(180deg, var(--navy-900), var(--navy-800));
  display: flex;
  flex-direction: column;
  z-index: 20;
}
.sidebar-logo { padding: 1.5rem 1.5rem 1.1rem; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar-nav { flex: 1; overflow-y: auto; padding: .9rem .8rem; }
.sidebar-section-label {
  text-transform: uppercase; font-size: .68rem; font-weight: 700; letter-spacing: .08em;
  color: rgba(255,255,255,.38); margin: 1.2rem .7rem .5rem;
}
.sidebar-section-label:first-child { margin-top: 0; }
.nav-item {
  display: flex; align-items: center; gap: .75rem;
  padding: .62rem .8rem; border-radius: var(--radius-sm);
  color: rgba(255,255,255,.72); font-size: .89rem; font-weight: 500;
  margin-bottom: .18rem; cursor: pointer;
}
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active { background: var(--teal); color: #063a34; font-weight: 700; }
.nav-item .nav-icon { width: 1.2rem; text-align: center; flex-shrink: 0; }
.nav-item .nav-ext { margin-left: auto; opacity: .55; font-size: .75rem; }

.sidebar-footer { padding: 1rem 1.5rem 1.3rem; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar-user { display: flex; align-items: center; gap: .65rem; margin-bottom: .8rem; }
.sidebar-user .user-name { color: #fff; font-size: .86rem; font-weight: 600; line-height: 1.2; }
.sidebar-user .user-nivel { color: rgba(255,255,255,.5); font-size: .74rem; }
.sidebar-footer button { width: 100%; justify-content: center; background: rgba(255,255,255,.08); color: #fff; }
.sidebar-footer button:hover { background: rgba(255,255,255,.16); }

.main-area { margin-left: var(--sidebar-width); flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 2rem; background: var(--card-bg); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.topbar h1 { margin: 0; font-size: 1.15rem; color: var(--navy-900); }
.topbar .topbar-actions { display: flex; align-items: center; gap: .8rem; }

main.content { padding: 2rem; max-width: 1180px; width: 100%; margin: 0 auto; }

/* =================== Avatar =================== */
.avatar {
  width: 38px; height: 38px; border-radius: 50%; object-fit: cover;
  background: var(--navy-700); color: #fff; display: flex; align-items: center;
  justify-content: center; font-weight: 700; font-size: .85rem; flex-shrink: 0;
  border: 2px solid rgba(255,255,255,.15);
}
.avatar.sm { width: 28px; height: 28px; font-size: .72rem; }
.avatar.lg { width: 88px; height: 88px; font-size: 1.8rem; border: 3px solid var(--card-bg); box-shadow: var(--shadow); }

/* =================== Cards / tiles =================== */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.4rem 1.5rem;
  margin-bottom: 1.4rem;
}
.card h2 { margin: 0 0 .3rem; font-size: 1.05rem; color: var(--navy-900); }
.card .muted { color: var(--text-muted); font-size: .85rem; }
.inline-form { display: flex; gap: .7rem; flex-wrap: wrap; align-items: flex-end; margin-bottom: 1rem; }
.inline-form .field { margin-bottom: 0; }

.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; flex-wrap: wrap; gap: .8rem; }
.page-header h1 { margin: 0 0 .25rem; font-size: 1.5rem; color: var(--navy-900); }
.page-header p { margin: 0; color: var(--text-muted); font-size: .92rem; }

.tiles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.1rem;
}
.tile {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.4rem;
  border-left: 4px solid var(--teal);
  transition: transform .12s, box-shadow .12s;
  display: block;
  color: var(--text);
}
.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.tile .tile-icon { font-size: 1.7rem; margin-bottom: .7rem; display: block; }
.tile h3 { margin: 0 0 .3rem; font-size: 1.02rem; color: var(--navy-900); }
.tile p { margin: 0; font-size: .84rem; color: var(--text-muted); }
.tile .tile-open { margin-top: .9rem; font-size: .78rem; font-weight: 700; color: var(--teal-dark); }

.empty-state {
  text-align: center; padding: 3rem 1.5rem; color: var(--text-muted);
  background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow);
}

/* =================== Links uteis =================== */
.link-tile {
  position: relative;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: transform .12s, box-shadow .12s;
}
.link-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.link-tile > a {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: .6rem; padding: 1.6rem 1rem; color: var(--text);
}
.link-tile i { font-size: 1.9rem; color: var(--teal-dark); }
.link-tile span { font-size: .88rem; font-weight: 600; word-break: break-word; }
.link-tile--inativo { opacity: .5; }
.link-tile-actions {
  position: absolute; top: .5rem; right: .5rem; display: flex; gap: .2rem;
}
.link-tile-actions .icon-btn { background: var(--card-bg); box-shadow: var(--shadow); }
.link-tile-ordem {
  display: flex; align-items: center; justify-content: center;
  width: 1.6rem; height: 1.6rem; border-radius: 50%;
  background: var(--card-bg); box-shadow: var(--shadow);
  font-size: .72rem; font-weight: 700; color: var(--text-muted);
}

.icon-picker-preview { display: flex; align-items: center; gap: .7rem; margin-bottom: .5rem; }
.icon-picker-preview i { font-size: 1.6rem; color: var(--teal-dark); width: 1.8rem; text-align: center; }
.icon-picker-preview input { flex: 1; }
.icon-picker-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: .35rem;
  max-height: 160px; overflow-y: auto; padding: .5rem; border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.icon-picker-btn {
  background: none; border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: .45rem; cursor: pointer; color: var(--text);
}
.icon-picker-btn:hover { background: #f2f5f8; border-color: var(--teal); }

/* =================== Tables =================== */
table { width: 100%; border-collapse: collapse; font-size: .89rem; }
th, td { text-align: left; padding: .7rem .65rem; border-bottom: 1px solid var(--border); }
th { color: var(--text-muted); font-weight: 700; font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; }
tbody tr:hover { background: #f8fafc; }
td.actions-col { text-align: right; white-space: nowrap; }
.row-user { display: flex; align-items: center; gap: .6rem; }

/* =================== Badges =================== */
.badge { display: inline-flex; align-items: center; padding: .2rem .6rem; border-radius: 20px; font-size: .72rem; font-weight: 700; }
.badge-nivel-Administrador { background: #fde7e6; color: #b1362c; }
.badge-nivel-Gestor { background: #fdf0dc; color: #a5620a; }
.badge-nivel-Utilizador { background: #e2f5f2; color: #0f766e; }
.badge-ativo { background: #e2f5f2; color: #0f766e; }
.badge-inativo { background: #f1f2f4; color: #6b7280; }

/* =================== Modal =================== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(8, 36, 54, .45);
  display: flex; align-items: center; justify-content: center; padding: 1.5rem; z-index: 100;
}
.modal {
  background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  width: 100%; max-width: 460px; max-height: 90vh; overflow-y: auto;
}
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border); }
.modal-header h2 { margin: 0; font-size: 1.05rem; color: var(--navy-900); }
.modal-body { padding: 1.5rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: .5rem; }

/* =================== Utils =================== */
.muted { color: var(--text-muted); font-size: .85rem; }
.text-right { text-align: right; }
.flex-row { display: flex; align-items: center; gap: .6rem; }
.avatar-upload-row { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.2rem; }
.loading-spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* =================== Sub-tabs (dentro de um modulo, ex.: STVendas) =================== */
.subtabs { display: flex; gap: .4rem; margin-bottom: 1.25rem; border-bottom: 1px solid var(--border); }
.subtab-btn {
  background: none; color: var(--text-muted); padding: .6rem 1rem;
  border-radius: 8px 8px 0 0; font-weight: 600; font-size: .88rem;
}
.subtab-btn:hover { background: #eef2f6; color: var(--text); }
.subtab-btn--active, .subtab-btn--active:hover { background: var(--card-bg); color: var(--navy-800); box-shadow: 0 -1px 0 var(--card-bg), 0 2px 0 var(--teal); }

/* =================== Filtros =================== */
.filters {
  display: flex; flex-wrap: wrap; gap: .9rem; align-items: flex-end;
  background: var(--card-bg); padding: 1.1rem 1.25rem; border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 1.25rem;
}
.filters .field { margin-bottom: 0; min-width: 150px; }
.month-year-pair { display: flex; gap: .4rem; }
.month-year-pair select { flex: 1; min-width: 0; }
.list-link-row { margin-bottom: 1.25rem; }

/* =================== KPIs =================== */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.kpi-card { background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem 1.25rem; }
.kpi-card .label { color: var(--text-muted); font-size: .8rem; margin-bottom: .35rem; }
.kpi-card .value { font-size: 1.6rem; font-weight: 700; color: var(--navy-900); }

/* =================== Graficos =================== */
.charts-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 1.25rem; }
.chart-card { background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem 1.25rem; }
.chart-card h3 { margin: 0 0 .8rem; font-size: 1rem; color: var(--navy-900); }
.chart-card canvas { max-height: 320px; }
.chart-tall-wrap { position: relative; height: 640px; }
.chart-tall-wrap canvas { max-height: none; }

/* =================== Badges de role (modulos com permissoes proprias) =================== */
.badge-role-admin { background: #fde7e6; color: #b1362c; }
.badge-role-gestor { background: #e6ecfd; color: #3546c9; }
.badge-role-responsavel { background: #fdf0dc; color: #a5620a; }
.badge-role-comercial { background: #e2f5f2; color: #0f766e; }

/* =================== Notificacoes (sino no topo, todas as paginas) =================== */
.notif-bell-wrap { position: relative; }
.notif-bell-btn { position: relative; font-size: 1.05rem; padding: .45rem .55rem; }
.notif-badge {
  position: absolute; top: -4px; right: -4px;
  background: var(--red); color: #fff; font-size: .65rem; font-weight: 700;
  min-width: 17px; height: 17px; border-radius: 9px; padding: 0 4px;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--card-bg);
}
.notif-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 50;
  width: 340px; max-height: 420px; overflow-y: auto;
  background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}
.notif-dropdown-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: .8rem 1rem; border-bottom: 1px solid var(--border);
  font-weight: 700; font-size: .88rem; color: var(--navy-900);
  position: sticky; top: 0; background: var(--card-bg);
}
.notif-dropdown-header .icon-btn { font-size: .75rem; font-weight: 600; color: var(--teal-dark); }
.notif-item {
  display: block; padding: .75rem 1rem; border-bottom: 1px solid var(--border);
  color: var(--text); transition: background .12s;
}
.notif-item:hover { background: #f8fafc; }
.notif-item:last-child { border-bottom: none; }
.notif-item--unread { background: #f0faf8; }
.notif-item--unread:hover { background: #e7f6f3; }
.notif-item-title { font-size: .87rem; font-weight: 600; margin-bottom: .15rem; }
.notif-item--unread .notif-item-title::before {
  content: ''; display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: var(--teal); margin-right: .4rem;
}
.notif-item-msg { font-size: .8rem; color: var(--text-muted); margin-bottom: .3rem; }
.notif-item-time { font-size: .72rem; color: var(--text-muted); }

/* =================== Check-in de bem-estar (escala de smileys) =================== */
.humor-emoji-row { display: flex; justify-content: center; gap: .5rem; margin-top: 1.5rem; }
.humor-emoji-btn {
  background: none; border: 2px solid transparent; border-radius: 50%;
  font-size: 2rem; line-height: 1; padding: .5rem; width: 64px; height: 64px;
  display: flex; align-items: center; justify-content: center;
  transition: transform .12s, border-color .12s, background .12s;
}
.humor-emoji-btn:hover { transform: scale(1.15); background: #f2f5f8; border-color: var(--teal); }
.humor-emoji-btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; }
