/* =====================================================================
   LKDESK MANUAIS v2 — folha de estilos
   ===================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg-app: #0B0C0F;
  --bg-sidebar: #111318;
  --bg-surface: #16181D;
  --bg-surface-2: #1C1F26;
  --bg-surface-3: #20232B;
  --border: #262A33;
  --border-subtle: #1E2128;

  --text-primary: #F2F3F5;
  --text-secondary: #9AA0AC;
  --text-tertiary: #6B7280;

  --accent: #FF7A1A;
  --accent-ink: #14110B;

  --success: #34C77B;
  --success-bg: rgba(52, 199, 123, 0.12);
  --danger: #F0475B;
  --danger-bg: rgba(240, 71, 91, 0.12);
  --warn: #F5A623;
  --warn-bg: rgba(245, 166, 35, 0.10);
  --neutral-bg: rgba(148, 158, 174, 0.14);

  --role-admin: #8B93F8;
  --role-admin-bg: rgba(139, 147, 248, 0.14);
  --role-agent: #F5A623;
  --role-agent-bg: rgba(245, 166, 35, 0.14);
  --role-reader: #34BFC7;
  --role-reader-bg: rgba(52, 191, 199, 0.14);

  --cat-a: #5B9DF9;   --cat-a-bg: rgba(91, 157, 249, 0.14);
  --cat-b: #FF7A1A;   --cat-b-bg: rgba(255, 122, 26, 0.14);
  --cat-c: #34BFC7;   --cat-c-bg: rgba(52, 191, 199, 0.14);
  --cat-d: #C77DFF;   --cat-d-bg: rgba(199, 125, 255, 0.14);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .22), 0 1px 1px rgba(0, 0, 0, .14);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, .28);
  --radius: 12px;
  --radius-lg: 16px;
  --page-x: 36px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg-app);
  color: var(--text-primary);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
}

a { color: inherit; text-decoration: none; }
code, .mono { font-family: 'JetBrains Mono', monospace; }

/* ---------- layout shell ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  display: flex;
  flex-direction: column;
  width: 240px;
  flex-shrink: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-logo { display: flex; align-items: center; gap: 10px; padding: 4px 8px 26px; }
.sidebar-logo .mark {
  width: 34px; height: 34px; border-radius: 9px; background: transparent;
  object-fit: contain; flex-shrink: 0;
}
.sidebar-logo .wordmark { display: flex; flex-direction: column; line-height: 1.15; }
.sidebar-logo .wordmark b { font-weight: 800; font-size: 15px; }
.sidebar-logo .wordmark span { font-size: 10px; color: var(--text-tertiary); letter-spacing: .09em; text-transform: uppercase; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 8px;
  color: var(--text-secondary); font-size: 13.5px; font-weight: 500; position: relative;
}
.nav-item:hover { background: var(--bg-surface); }
.nav-item svg { flex-shrink: 0; }
.nav-item.active { background: var(--bg-surface-2); color: var(--text-primary); font-weight: 600; }
.nav-item.active svg { color: var(--accent); }
.nav-item.active::before {
  content: ''; position: absolute; left: -14px; top: 6px; bottom: 6px; width: 3px; border-radius: 3px; background: var(--accent);
}
.nav-divider { height: 1px; background: var(--border-subtle); margin: 16px 4px; }
.sidebar-spacer { flex: 1; }

.user-card {
  display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 10px;
  background: var(--bg-surface); border: 1px solid var(--border-subtle);
}
.user-card .avatar {
  width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px; flex-shrink: 0;
}
.avatar-admin { background: var(--role-admin-bg); color: var(--role-admin); }
.avatar-atendente { background: var(--role-agent-bg); color: var(--role-agent); }
.avatar-leitor { background: var(--role-reader-bg); color: var(--role-reader); }
.user-card .info { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.user-card .info b { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-card .info span { font-size: 10.5px; color: var(--text-tertiary); }
.user-card form { display: flex; }
.user-card button.icon-link { background: none; border: none; padding: 4px; cursor: pointer; color: var(--text-tertiary); display: flex; }
.user-card button.icon-link:hover { color: var(--text-primary); }

.main { display: flex; flex-direction: column; flex: 1; min-width: 0; }

.topbar {
  display: flex; align-items: center; gap: 8px; height: 68px; flex-shrink: 0; padding: 0 var(--page-x);
  border-bottom: 1px solid var(--border-subtle);
}
.topbar .crumb-muted { font-size: 12.5px; color: var(--text-tertiary); font-weight: 500; }
.topbar .crumb-current { font-size: 12.5px; color: var(--text-primary); font-weight: 600; }
.topbar .spacer { flex: 1; }

.content { flex: 1; padding: 32px var(--page-x) 48px; display: flex; flex-direction: column; gap: 22px; max-width: 1360px; width: 100%; margin: 0 auto; }
.content.narrow { max-width: 940px; }

/* ---------- cabeçalho de página ---------- */
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.page-header .eyebrow { font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--accent); margin-bottom: 6px; }
.page-header h1 { font-size: 24px; font-weight: 800; margin: 0; letter-spacing: -.01em; }
.page-header .sub { font-size: 13px; color: var(--text-secondary); margin-top: 5px; }
.page-header .side { font-size: 12px; color: var(--text-tertiary); text-align: right; }
.page-header .side b { color: var(--text-secondary); font-weight: 600; display: block; }

/* ---------- escala de ícones ---------- */
.icon-wrap { display: flex; align-items: center; justify-content: center; border-radius: 9px; flex-shrink: 0; }
.icon-wrap-sm { width: 28px; height: 28px; border-radius: 7px; }
.icon-wrap-md { width: 36px; height: 36px; border-radius: 9px; }
.icon-wrap-lg { width: 44px; height: 44px; border-radius: 11px; }

/* ---------- grade do painel ---------- */
.dash-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 22px; align-items: start; }
.module-list-card { padding: 6px; }
.module-list-head { padding: 14px 16px 12px; }
.module-list-head .title { font-size: 14px; font-weight: 700; }
.module-list-head .sub { font-size: 12.5px; color: var(--text-secondary); margin-top: 3px; }
.module-list-card .nav-item { padding: 12px 16px; }
.module-list-card .nav-item span.grow { flex: 1; font-weight: 500; }
.module-list-card .nav-item span.count { font-size: 11.5px; color: var(--text-tertiary); font-family: 'JetBrains Mono', monospace; }
.side-panel { display: flex; flex-direction: column; gap: 14px; }
.side-panel-head { display: flex; align-items: center; gap: 10px; }
.side-panel-head .title { font-size: 13.5px; font-weight: 700; }
.side-panel-head .sub { font-size: 11px; color: var(--text-tertiary); }
.side-panel .desc { font-size: 12px; color: var(--text-tertiary); line-height: 1.55; }

.mail-row {
  position: relative; display: grid; grid-template-columns: 220px 1fr 110px; align-items: center; gap: 14px;
  padding: 12px 14px 12px 22px; border-radius: 8px; font-size: 13px; color: var(--text-secondary);
}
.mail-row:hover { background: var(--bg-surface); }
.mail-row + .mail-row { border-top: 1px solid var(--border-subtle); }
.mail-row-from { font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mail-row-subject { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mail-row-date { font-size: 11.5px; color: var(--text-tertiary); text-align: right; font-family: 'JetBrains Mono', monospace; }
.mail-row.unread .mail-row-from, .mail-row.unread .mail-row-subject { font-weight: 700; color: var(--text-primary); }
.mail-row.unread::before {
  content: ''; position: absolute; left: 8px; top: 50%; transform: translateY(-50%);
  width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
}

.mail-detail-subject { font-size: 17px; font-weight: 700; margin-bottom: 6px; }
.mail-detail-meta { font-size: 12px; color: var(--text-tertiary); padding-bottom: 16px; margin-bottom: 16px; border-bottom: 1px solid var(--border-subtle); }
.mail-detail-body { font-size: 13.5px; color: var(--text-primary); line-height: 1.7; white-space: pre-wrap; }

.page-title { font-size: 20px; font-weight: 800; }
.page-subtitle { font-size: 12.5px; color: var(--text-secondary); margin-top: 4px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: 8px;
  font-size: 12.5px; font-weight: 700; border: 1px solid transparent; cursor: pointer; font-family: inherit;
}
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; border-color: var(--border-subtle); color: var(--text-secondary); font-weight: 600; }
.btn-ghost:hover { background: var(--bg-surface-2); }
.btn-danger-ghost { background: transparent; border-color: var(--border-subtle); color: var(--danger); font-weight: 600; }
.btn-danger-ghost:hover { background: var(--danger-bg); }

.icon-btn {
  width: 30px; height: 30px; border-radius: 7px; display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-secondary); border: 1px solid var(--border-subtle); background: transparent; cursor: pointer;
}
.icon-btn:hover { background: var(--bg-surface-3); color: var(--text-primary); }
.icon-btn.danger { color: var(--danger); }

/* ---------- filter bar ---------- */
.filter-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.filter-search {
  display: flex; align-items: center; gap: 8px; width: 300px; padding: 9px 12px; border-radius: 8px;
  background: var(--bg-surface); border: 1px solid var(--border-subtle);
}
.filter-search svg { flex-shrink: 0; color: var(--text-tertiary); }
.filter-search input {
  border: none; background: transparent; outline: none; color: var(--text-primary); font-size: 12.5px; width: 100%; font-family: inherit;
}
.filter-search input::placeholder { color: var(--text-tertiary); }
.filter-select {
  padding: 9px 12px; border-radius: 8px; background: var(--bg-surface); border: 1px solid var(--border-subtle);
  font-size: 12.5px; color: var(--text-secondary); font-family: inherit;
}
.filter-bar .btn-ghost.filter-submit { padding: 9px 14px; }

/* ---------- cards / stats ---------- */
.card { border-radius: var(--radius); background: var(--bg-surface); border: 1px solid var(--border-subtle); box-shadow: var(--shadow-sm); }
.card-pad { padding: 20px 22px; }
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.stat-card { display: flex; flex-direction: column; gap: 16px; padding: 20px 22px; transition: border-color .15s ease, transform .15s ease; }
.stat-card:hover { border-color: var(--border); transform: translateY(-1px); }
.stat-card .stat-top { display: flex; align-items: center; justify-content: space-between; }
.stat-card .trend { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; font-weight: 700; color: var(--text-tertiary); }
.stat-card .value { font-size: 28px; font-weight: 800; letter-spacing: -.01em; }
.stat-card .label { font-size: 12.5px; color: var(--text-secondary); margin-top: 2px; }
.stat-card .mini-track { height: 5px; border-radius: 999px; background: var(--bg-surface-2); overflow: hidden; margin-top: 2px; }
.stat-card .mini-fill { display: block; height: 100%; border-radius: 999px; }

/* ---------- table ---------- */
.table-wrap { border-radius: 12px; background: var(--bg-surface); border: 1px solid var(--border-subtle); overflow: hidden; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 640px; }
thead tr { border-bottom: 1px solid var(--border-subtle); }
th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-tertiary); font-weight: 600; padding: 12px 20px; white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border-subtle); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-surface-2); }
td { padding: 12px 20px; font-size: 13px; vertical-align: middle; }
.td-title { font-weight: 600; }
.td-muted { color: var(--text-secondary); font-size: 12.5px; }
.td-actions { text-align: right; white-space: nowrap; }
.row-actions { display: inline-flex; gap: 6px; }
.empty-state { padding: 40px 20px; text-align: center; color: var(--text-tertiary); font-size: 13px; }

/* ---------- busca: destaque do termo e prévia de trecho encontrado ---------- */
mark.search-hl {
  background: rgba(255, 196, 0, .38); color: inherit; border-radius: 3px; padding: 0 1px; font-weight: 700;
}
.row-search-preview {
  display: block; white-space: normal; font-size: 12px; color: var(--text-secondary);
  line-height: 1.5; margin-top: 3px; max-width: 480px;
}

/* ---------- paginação ---------- */
.pagination-bar { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 16px; font-size: 12.5px; color: var(--text-secondary); }
.pagination-bar .disabled { pointer-events: none; opacity: .4; }

/* ---------- guia de ajuda ---------- */
.ajuda-toc-link {
  display: flex; align-items: center; gap: 9px; padding: 8px 6px; border-radius: 8px;
  font-size: 12.5px; font-weight: 600; color: var(--text-secondary); text-decoration: none;
}
.ajuda-toc-link:hover { background: var(--bg-surface-2); color: var(--text-primary); }

/* ---------- badges / chips ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-success .dot { background: var(--success); }
.badge-neutral { background: var(--neutral-bg); color: var(--text-secondary); }
.badge-neutral .dot { background: var(--text-tertiary); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-danger .dot { background: var(--danger); }
.badge-warning { background: var(--role-agent-bg); color: var(--role-agent); }
.badge-warning .dot { background: var(--role-agent); }
.badge-info { background: var(--role-reader-bg); color: var(--role-reader); }
.badge-info .dot { background: var(--role-reader); }
.badge-role { text-transform: uppercase; letter-spacing: .03em; border-radius: 999px; }
.badge-admin { background: var(--role-admin-bg); color: var(--role-admin); }
.badge-atendente { background: var(--role-agent-bg); color: var(--role-agent); }
.badge-leitor { background: var(--role-reader-bg); color: var(--role-reader); }
.badge-pinned { background: var(--accent-bg, rgba(255,122,26,.14)); color: var(--accent); }

/* ---------- mural de avisos ---------- */
.announce-list { display: flex; flex-direction: column; gap: 14px; }
.announce-card { padding: 18px 20px; border-left: 3px solid var(--border-subtle); }
.announce-card.pinned { border-left-color: var(--accent); }
.announce-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.announce-title { font-size: 14.5px; font-weight: 700; }
.announce-spacer { flex: 1; }
.announce-body { font-size: 13px; color: var(--text-secondary); line-height: 1.65; }
.announce-meta { font-size: 11.5px; color: var(--text-tertiary); margin-top: 12px; }

/* ---------- painel inicial: Mural de Avisos e Agenda em destaque ---------- */
.dash-announce-list { display: flex; flex-direction: column; }
.dash-announce-item { display: block; padding: 12px 0; border-top: 1px solid var(--border-subtle); }
.dash-announce-item:first-child { border-top: none; padding-top: 8px; }
.dash-announce-item:hover .dash-announce-title { color: var(--accent); }
.dash-announce-pin { margin-bottom: 6px; }
.dash-announce-title { font-size: 13.5px; font-weight: 700; color: var(--text-primary); }
.dash-announce-preview { font-size: 12px; color: var(--text-secondary); line-height: 1.5; margin-top: 4px; }
.dash-announce-meta { font-size: 11px; color: var(--text-tertiary); margin-top: 6px; }

.dash-agenda-list { display: flex; flex-direction: column; }
.dash-agenda-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border-subtle); }
.dash-agenda-item:first-child { border-top: none; padding-top: 6px; }
.dash-agenda-item:hover .dash-agenda-title { color: var(--accent); }
.dash-agenda-date {
  flex-shrink: 0; width: 46px; height: 40px; border-radius: 8px; background: var(--bg-surface-3);
  display: flex; align-items: center; justify-content: center; text-align: center;
  font-size: 11.5px; font-weight: 700; color: var(--text-secondary);
}
.dash-agenda-date.is-today { background: var(--role-reader-bg); color: var(--role-reader); }
.dash-agenda-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.dash-agenda-title { font-size: 13px; font-weight: 600; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- templates de resposta ---------- */
.template-list { display: flex; flex-direction: column; gap: 14px; }
.template-card { padding: 18px 20px; }
.template-head { display: flex; align-items: flex-start; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.template-title-wrap { flex: 1; min-width: 200px; }
.template-title { font-size: 14px; font-weight: 700; }
.template-body { font-size: 12.5px; color: var(--text-secondary); line-height: 1.6; white-space: pre-wrap; padding: 12px 14px; background: var(--bg-surface-2); border-radius: 8px; border: 1px solid var(--border-subtle); }
.template-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.template-tabs { display: flex; align-items: center; gap: 4px; border-bottom: 1px solid var(--border-subtle); margin-bottom: 4px; }
.template-tab {
  display: flex; align-items: center; gap: 6px; padding: 10px 14px; font-size: 12.5px; font-weight: 600;
  color: var(--text-secondary); border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.template-tab:hover { color: var(--text-primary); }
.template-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.template-tab .count {
  display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px; background: var(--neutral-bg); color: var(--text-tertiary); font-size: 10.5px; font-weight: 700;
}
.template-tab.active .count { background: var(--accent-bg, rgba(255,122,26,.14)); color: var(--accent); }

.template-badges { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 7px; }
.badge-visibility { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; font-size: 10.5px; font-weight: 600; }
.badge-private { background: var(--neutral-bg); color: var(--text-secondary); }
.badge-public { background: var(--success-bg); color: var(--success); }
.badge-shared { background: var(--role-reader-bg); color: var(--role-reader); }
.badge-owner { background: var(--role-admin-bg); color: var(--role-admin); font-weight: 500; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ---------- lista compacta de templates (linhas + favoritos + FAB) ---------- */
.tpl-list { display: flex; flex-direction: column; gap: 2px; }
.tpl-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 10px;
  border: 1px solid transparent;
}
.tpl-row:hover { background: var(--bg-surface-2); border-color: var(--border-subtle); }
.tpl-row-icon {
  width: 32px; height: 32px; border-radius: 9px; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  background: var(--neutral-bg); color: var(--text-tertiary);
}
.tpl-fav-form { flex-shrink: 0; }
.tpl-fav-btn {
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; border-radius: 7px;
  color: var(--text-tertiary); background: transparent; cursor: pointer;
}
.tpl-fav-btn:hover { background: var(--bg-surface-3); color: var(--role-agent); }
.tpl-fav-btn.is-fav { color: var(--role-agent); }
.tpl-row-main { flex: 1; min-width: 0; }
.tpl-row-title-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tpl-row-title { font-size: 13px; font-weight: 700; }
.chip-sm { padding: 2px 8px; font-size: 10.5px; }
.tpl-row-preview {
  font-size: 11.5px; color: var(--text-tertiary); margin-top: 2px; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; max-width: 100%;
}
.tpl-row-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.icon-btn.copy-btn { position: relative; }
.icon-btn.copy-btn.is-copied { color: var(--success); border-color: var(--success); }
.icon-btn.copy-btn.is-copied::after {
  content: 'Copiado!'; position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); margin-bottom: 6px;
  background: var(--success); color: #06120C; font-size: 10.5px; font-weight: 700; padding: 3px 8px; border-radius: 6px;
  white-space: nowrap; pointer-events: none;
}

.tpl-fab {
  position: fixed; right: 40px; bottom: 32px; width: 52px; height: 52px; border-radius: 50%;
  background: var(--accent); color: #14110B; display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-md); z-index: 20;
}
.tpl-fab:hover { filter: brightness(1.08); }

.visibility-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.visibility-option {
  display: flex; align-items: flex-start; gap: 9px; padding: 12px 14px; border-radius: 10px;
  border: 1px solid var(--border-subtle); background: var(--bg-surface-2); cursor: pointer;
}
.visibility-option:has(input:checked) { border-color: var(--accent); background: var(--accent-bg, rgba(255,122,26,.10)); }
.visibility-option input { margin-top: 2px; }
.visibility-option-title { font-size: 12.5px; font-weight: 700; }
.visibility-option-sub { font-size: 11px; color: var(--text-tertiary); margin-top: 2px; }

.share-list {
  display: flex; flex-direction: column; gap: 2px; max-height: 220px; overflow-y: auto;
  border: 1px solid var(--border-subtle); border-radius: 10px; padding: 6px;
}
.share-item { display: flex; align-items: center; gap: 9px; padding: 7px 8px; border-radius: 7px; font-size: 12.5px; }
.share-item:hover { background: var(--bg-surface-2); }
.share-item-role { margin-left: auto; font-size: 10.5px; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: .03em; }

/* ---------- agenda ---------- */
.agenda-layout { display: grid; grid-template-columns: 1fr 300px; gap: 22px; align-items: start; }
.agenda-toolbar { display: flex; align-items: center; gap: 12px; padding: 4px 4px 2px; }
.agenda-toolbar .month-label { font-size: 15px; font-weight: 700; flex: 1; text-align: center; }
.agenda-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px; background: var(--border-subtle); border: 1px solid var(--border-subtle); border-radius: 12px; overflow: hidden; }
.agenda-weekday { background: var(--bg-surface-2); text-align: center; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-tertiary); padding: 8px 0; }
.agenda-day { background: var(--bg-surface); min-height: 92px; padding: 6px; display: flex; flex-direction: column; gap: 4px; }
.agenda-day.outside { background: var(--bg-app); }
.agenda-day.today .day-num { background: var(--accent); color: var(--accent-ink); }
.agenda-day-head { display: flex; align-items: center; justify-content: space-between; }
.agenda-day .day-num { font-size: 11.5px; font-weight: 700; color: var(--text-secondary); width: 20px; height: 20px; border-radius: 6px; display: flex; align-items: center; justify-content: center; }
.agenda-day.outside .day-num { color: var(--text-tertiary); }
.agenda-day-add { color: var(--text-tertiary); opacity: 0; }
.agenda-day:hover .agenda-day-add { opacity: 1; }
.agenda-pill { display: block; font-size: 10.5px; font-weight: 600; padding: 2px 6px; border-radius: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agenda-pill-evento { background: var(--role-reader-bg); color: var(--role-reader); }
.agenda-pill-plantao { background: var(--warn-bg); color: var(--warn); }
.agenda-pill-more { font-size: 10px; color: var(--text-tertiary); padding: 0 6px; }
.agenda-upcoming { display: flex; flex-direction: column; gap: 4px; }
.agenda-upcoming-row { display: flex; align-items: center; gap: 10px; padding: 9px 4px; border-bottom: 1px solid var(--border-subtle); }
.agenda-upcoming-row:last-child { border-bottom: none; }
.agenda-date-badge { flex-shrink: 0; width: 40px; height: 40px; border-radius: 9px; background: var(--bg-surface-2); display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1; }
.agenda-date-badge b { font-size: 14px; font-weight: 800; }
.agenda-date-badge span { font-size: 9px; color: var(--text-tertiary); text-transform: uppercase; }
.agenda-upcoming-info { min-width: 0; flex: 1; }
.agenda-upcoming-info .t { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agenda-upcoming-info .s { font-size: 11px; color: var(--text-tertiary); margin-top: 2px; }

.bar-row { display: flex; align-items: center; gap: 10px; }
.bar-row .bar-label { width: 172px; flex-shrink: 0; font-size: 12.5px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .bar-track { flex: 1; height: 8px; background: var(--bg-surface-2); border-radius: 999px; overflow: hidden; }
.bar-row .bar-fill { display: block; height: 100%; border-radius: 999px; transition: width .3s ease; }
.bar-row .bar-value { width: 30px; flex-shrink: 0; text-align: right; font-size: 12.5px; font-weight: 700; color: var(--text-primary); font-family: 'JetBrains Mono', monospace; }

/* ---------- gráficos (SVG) ---------- */
.chart-row, .chart-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.chart-card-body { display: flex; flex-direction: column; gap: 11px; margin-top: 16px; }
.donut-row { display: flex; align-items: center; gap: 24px; margin-top: 6px; }
.donut-row svg { flex-shrink: 0; }
.donut-center-value { font-size: 20px; font-weight: 800; }
.donut-center-label { font-size: 9.5px; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: .05em; }
.donut-legend { display: flex; flex-direction: column; gap: 10px; flex: 1; }
.donut-legend-row { display: flex; align-items: center; gap: 9px; font-size: 12.5px; color: var(--text-secondary); }
.donut-legend-dot { width: 9px; height: 9px; border-radius: 3px; flex-shrink: 0; }
.donut-legend-row b { color: var(--text-primary); margin-left: auto; font-family: 'JetBrains Mono', monospace; font-size: 12.5px; }

.chip { display: inline-flex; padding: 4px 10px; border-radius: 7px; border: 1px solid var(--border); font-size: 11.5px; color: var(--text-secondary); font-weight: 500; }
.chip-more { background: var(--neutral-bg); border: none; font-weight: 600; }
.chip-list { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; max-width: 320px; }
.cat-chip { border-radius: 7px; font-weight: 600; padding: 4px 10px; font-size: 11.5px; display: inline-flex; }

/* ---------- forms ---------- */
.form-card { max-width: 640px; display: flex; flex-direction: column; gap: 18px; padding: 24px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.form-group .hint { font-size: 11.5px; color: var(--text-tertiary); }
input[type=text], input[type=email], input[type=password], input[type=search], textarea, select.field {
  width: 100%; padding: 10px 12px; border-radius: 8px; background: var(--bg-surface-2);
  border: 1px solid var(--border); font-size: 13px; color: var(--text-primary); font-family: inherit; outline: none;
}
input:focus, textarea:focus, select.field:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 110px; }
.role-toggle { display: flex; gap: 8px; }
.role-option { flex: 1; text-align: center; padding: 10px; border-radius: 8px; border: 1px solid var(--border); font-size: 12.5px; font-weight: 600; color: var(--text-secondary); cursor: pointer; }
.role-option input { display: none; }
.role-option:has(input:checked) { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
.checkbox-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 2px; max-height: 260px; overflow: auto;
  border: 1px solid var(--border-subtle); border-radius: 8px; padding: 6px;
}
.checkbox-row { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 6px; font-size: 12.5px; }
.checkbox-row:hover { background: var(--bg-surface-3); }
.checkbox-row input { accent-color: var(--accent); width: 15px; height: 15px; }
.credential-row { display: grid; grid-template-columns: 1.3fr 1fr 1fr auto; gap: 10px; align-items: center; }
.form-actions { display: flex; gap: 10px; padding-top: 4px; }

/* ---------- article detail ---------- */
.article-head { display: flex; align-items: flex-start; gap: 14px; }
.article-head .icon-wrap { width: 44px; height: 44px; border-radius: 11px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.article-title-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.article-title-row h1 { font-size: 19px; font-weight: 800; margin: 0; }
.article-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.article-meta .muted { font-size: 12px; color: var(--text-tertiary); }
.warning-banner { display: flex; gap: 12px; padding: 14px 16px; border-radius: 10px; background: var(--warn-bg); border: 1px solid rgba(245,166,35,.25); color: #E8C27A; font-size: 12px; line-height: 1.6; }
.warning-banner svg { flex-shrink: 0; margin-top: 1px; color: var(--warn); }
.section-label { display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 700; color: var(--text-primary); }

.quote-banner { display: flex; align-items: flex-start; gap: 16px; padding: 20px 22px; }
.quote-banner .icon-wrap { width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.quote-banner blockquote { margin: 0; font-size: 14.5px; font-style: italic; color: var(--text-primary); line-height: 1.55; }
.quote-banner .quote-tag { margin-top: 9px; font-size: 10.5px; color: var(--text-tertiary); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }

.ref-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.ref-card-title { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.ref-card-title .icon-wrap { width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.ref-card-title b { font-size: 13.5px; font-weight: 700; display: block; }
.ref-card-title span { font-size: 11px; color: var(--text-tertiary); }
.ref-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.ref-subhead { font-size: 11px; font-weight: 700; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: .05em; margin: 14px 0 2px; }
.ref-subhead:first-child { margin-top: 4px; }

.spec-row { display: flex; align-items: center; gap: 9px; padding: 6px 0; border-bottom: 1px solid var(--border-subtle); }
.spec-row:last-child { border-bottom: none; }
.spec-row .spec-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.spec-row .spec-label { flex: 1; font-size: 12px; color: var(--text-secondary); }
.spec-row .spec-value { font-weight: 700; color: var(--text-primary); font-size: 11.5px; font-family: 'JetBrains Mono', monospace; text-align: right; }

.check-row { display: flex; align-items: flex-start; gap: 8px; padding: 5px 0; }
.check-row svg { flex-shrink: 0; margin-top: 3px; }
.check-row span { font-size: 12px; color: var(--text-secondary); line-height: 1.5; }
.credential-pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 7px;
  border: 1px solid var(--border-subtle); font-size: 12.5px; font-family: 'JetBrains Mono', monospace;
}
button.credential-pill {
  appearance: none; background: transparent; color: var(--text-primary); cursor: pointer;
}
button.credential-pill:hover { background: var(--bg-surface-3); border-color: var(--border); }

/* ---------- flash messages ---------- */
.flash { padding: 12px 16px; border-radius: 10px; font-size: 12.5px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.flash-success { background: var(--success-bg); color: var(--success); }
.flash-error { background: var(--danger-bg); color: var(--danger); }

/* ---------- login page ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 22px; padding: 32px; }
.login-card .sidebar-logo { padding: 0; justify-content: center; }
.login-card h1 { font-size: 16px; font-weight: 800; text-align: center; margin: 0; }
.login-card p.sub { text-align: center; font-size: 12.5px; color: var(--text-secondary); margin: -12px 0 0; }
.login-forgot { text-align: center; margin-top: -8px; }
.login-forgot a { font-size: 12.5px; color: var(--text-tertiary); text-decoration: underline; }
.login-forgot a:hover { color: var(--accent); }

/* ---------- empty / info boxes ---------- */
.info-box { display: flex; gap: 12px; padding: 16px 18px; border-radius: 10px; background: var(--bg-surface); border: 1px dashed var(--border); font-size: 12px; color: var(--text-tertiary); line-height: 1.6; }
.info-box svg { flex-shrink: 0; margin-top: 1px; }

/* ---------- anexos ---------- */
.upload-dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  padding: 26px 18px; border-radius: 10px; border: 1.5px dashed var(--border); background: var(--bg-surface-2);
  text-align: center; cursor: pointer;
}
.upload-dropzone:hover { border-color: var(--accent); background: var(--bg-surface-3); }
.upload-dropzone svg { color: var(--text-tertiary); }
.upload-dropzone .title { font-size: 12.5px; font-weight: 700; color: var(--text-primary); }
.upload-dropzone .hint { font-size: 11px; color: var(--text-tertiary); }
.upload-dropzone input[type=file] { display: none; }
.attachment-list { display: flex; flex-direction: column; gap: 8px; }
.attachment-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 9px;
  background: var(--bg-surface-2); border: 1px solid var(--border-subtle);
}
.attachment-row .icon-wrap { width: 34px; height: 34px; border-radius: 8px; flex-shrink: 0; background: var(--bg-surface-3); display: flex; align-items: center; justify-content: center; }
.attachment-row .meta { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.attachment-row .meta b { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attachment-row .meta span { font-size: 11px; color: var(--text-tertiary); }
.attachment-row .row-actions { flex-shrink: 0; }
.attachment-row .icon-wrap img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; }

/* ---------- sininho de notificações (Avisos e Agenda) ---------- */
.notif-wrap { position: relative; }
.notif-bell { position: relative; }
.notif-badge {
  position: absolute; top: -4px; right: -4px; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 999px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; line-height: 1;
}
.notif-popup {
  position: absolute; z-index: 40; top: 100%; right: 0; margin-top: 8px; display: flex; flex-direction: column;
  background: var(--bg-surface-2); border: 1px solid var(--border); border-radius: 10px; width: 320px;
  box-shadow: 0 12px 28px rgba(0,0,0,.4); overflow: hidden;
}
.notif-popup[hidden] { display: none !important; }
.notif-popup-section { padding: 12px 14px; border-bottom: 1px solid var(--border-subtle); }
.notif-popup-section:last-of-type { border-bottom: none; }
.notif-popup-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-tertiary); margin-bottom: 8px; }
.notif-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 0; font-size: 12.5px; color: var(--text-primary); }
.notif-item:hover { color: var(--accent); }
.notif-item-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notif-item-meta { flex-shrink: 0; font-size: 10.5px; color: var(--text-tertiary); }
.notif-empty { font-size: 12px; color: var(--text-tertiary); padding: 4px 0; }
.notif-popup-footer { display: block; text-align: center; padding: 10px; font-size: 12px; font-weight: 600; color: var(--accent); background: var(--bg-surface-3); }
.notif-popup-footer:hover { filter: brightness(1.1); }

/* ---------- seletor de emoji ---------- */
.title-with-emoji { display: flex; gap: 8px; align-items: center; position: relative; }
.title-with-emoji input[type=text] { flex: 1; }
.emoji-picker-btn {
  width: 40px; height: 40px; flex-shrink: 0; border-radius: 8px; background: var(--bg-surface-2);
  border: 1px solid var(--border); font-size: 17px; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.emoji-picker-btn:hover { background: var(--bg-surface-3); }
.emoji-picker-popup {
  position: absolute; z-index: 40; top: 100%; left: 0; margin-top: 6px; display: flex; flex-direction: column; gap: 6px;
  background: var(--bg-surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 8px; width: 230px;
  box-shadow: 0 12px 28px rgba(0,0,0,.4);
}
/* O atributo "hidden" perde de qualquer regra de "display" do próprio CSS
   (mesmo uma regra simples como a de cima), então sem isto o popup nunca
   fecharia de verdade, mesmo com hidden=true via JavaScript. */
.emoji-picker-popup[hidden] { display: none !important; }
.emoji-picker-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 2px; }
.emoji-picker-item { border: none; background: transparent; font-size: 18px; padding: 6px; border-radius: 6px; cursor: pointer; }
.emoji-picker-item:hover { background: var(--bg-surface-3); }
.emoji-picker-close {
  align-self: flex-end; border: none; background: transparent; color: var(--text-secondary); font-size: 12px;
  cursor: pointer; padding: 2px 6px; border-radius: 6px;
}
.emoji-picker-close:hover { background: var(--bg-surface-3); color: var(--text-primary); }

/* ---------- editor de texto rico (TinyMCE) ---------- */
.rich-editor-toolbar-extra { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.rich-editor-status { font-size: 11.5px; color: var(--text-tertiary); display: block; margin-top: 6px; }
.rich-editor-status.warn { color: var(--warn); }

/* ---------- conteúdo de artigo (HTML vindo do editor) ---------- */
.rich-content h1, .rich-content h2, .rich-content h3, .rich-content h4 { font-weight: 800; margin: 18px 0 8px; }
.rich-content h1 { font-size: 19px; } .rich-content h2 { font-size: 16.5px; } .rich-content h3 { font-size: 14.5px; }
.rich-content p { margin: 0 0 12px; }
.rich-content ul, .rich-content ol { margin: 0 0 12px; padding-left: 22px; }
.rich-content li { margin-bottom: 4px; }
.rich-content a { color: var(--accent); text-decoration: underline; }
.rich-content img { max-width: 100%; max-height: 480px; width: auto; height: auto; display: block; border-radius: 10px; margin: 14px auto; border: 1px solid var(--border-subtle); cursor: zoom-in; }
.rich-content iframe { max-width: 100%; border-radius: 8px; margin: 6px 0; }
.rich-content table { width: 100%; border-collapse: collapse; margin: 10px 0; }
.rich-content th, .rich-content td { border: 1px solid var(--border-subtle); padding: 8px 10px; font-size: 12.5px; }
.rich-content blockquote { border-left: 3px solid var(--accent); margin: 10px 0; padding: 4px 14px; color: var(--text-secondary); }
.rich-content code { font-family: 'JetBrains Mono', monospace; background: var(--bg-surface-2); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.lkdesk-file-card { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 8px; background: var(--bg-surface-2); border: 1px solid var(--border-subtle); color: var(--text-primary); text-decoration: none !important; font-size: 13px; font-weight: 600; }
.lkdesk-file-card:hover { background: var(--bg-surface-3); }

@media (max-width: 1180px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chart-row, .chart-grid-2 { grid-template-columns: 1fr; }
  .ref-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-grid { grid-template-columns: 1fr; }
  .agenda-layout { grid-template-columns: 1fr; }
}

@media (max-width: 880px) {
  .sidebar { display: none; }
  .stat-grid { grid-template-columns: 1fr; }
  .ref-grid { grid-template-columns: 1fr; }
  .ref-columns { grid-template-columns: 1fr; }
  .checkbox-grid { grid-template-columns: 1fr; }
  .visibility-choice { grid-template-columns: 1fr; }
  .tpl-fab { right: 18px; bottom: 18px; }
  :root { --page-x: 18px; }
}
