/* public/css/default.css */
@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap");

/* =========================
   TOKENS
========================= */
:root {
   --bg: #0b1220;
   --elev: #121826;
   --panel: #101624;

   --text: #e7ecf6;
   --muted: #94a3b8;

   --brand: #6c6d6e;
   --brand-contrast: #ffffff;

   --border: rgba(148, 163, 184, 0.18);
   --hover: rgba(59, 130, 246, 0.14);

   --shadow: 0 16px 50px rgba(0, 0, 0, 0.35);
   --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.18);

   --success: #22c55e;
   --warning: #f59e0b;
   --danger: #ef4444;
   --info: #3b82f6;

   --success-bg: color-mix(in oklab, var(--success), #0000 85%);
   --warning-bg: color-mix(in oklab, var(--warning), #0000 85%);
   --danger-bg: color-mix(in oklab, var(--danger), #0000 85%);
   --info-bg: color-mix(in oklab, var(--info), #0000 85%);

   /* Superfície um degrau acima do painel: caixas internas, faixas e
      trilhas. Derivada de --panel/--text, então acompanha o tema sozinha.
      Sem este token os módulos caíam no fallback claro (#f9fafb) e as
      caixas ficavam brancas no tema escuro. */
   --surface-2: color-mix(in oklab, var(--panel), var(--text) 6%);

   /* Cor de destaque/ação usada pelos módulos (timeline, chips, realces). */
   --primary: var(--info);

   --r-sm: 10px;
   --r-md: 14px;
   --r-lg: 18px;
   --r-xl: 22px;

   --s-1: 6px;
   --s-2: 10px;
   --s-3: 14px;
   --s-4: 16px;
   --s-5: 20px;
   --s-6: 24px;
   --s-7: 30px;

   --fs-xs: 0.78rem;
   --fs-sm: 0.88rem;
   --fs-md: 1rem;
   --fs-lg: 1.15rem;
   --fs-xl: 1.45rem;

   --t: 180ms cubic-bezier(0.2, 0.8, 0.2, 1);

   --container: 1100px;
   --header-h: 64px;
   --scrollbar-comp: 0px;

   --overlay: rgba(0, 0, 0, 0.45);
   --ring: color-mix(in oklab, var(--brand), #fff 12%);

   --z-header: 1000;
   --z-sidebar: 950;
   --z-backdrop: 900;
   --z-dropdown: 1200;
   --z-toast: 2000;
   --z-modal: 2100;
}

html[data-theme="light"] {
   --bg: #f5f7fb;
   --elev: #ffffff;
   --panel: #ffffff;

   --text: #0f172a;
   --muted: #475569;

   --border: rgba(2, 6, 23, 0.10);
   --shadow: 0 18px 50px rgba(15, 23, 42, 0.10);
   --hover: rgba(2, 132, 199, 0.10);

   --success-bg: color-mix(in oklab, var(--success), #fff 88%);
   --warning-bg: color-mix(in oklab, var(--warning), #fff 88%);
   --danger-bg: color-mix(in oklab, var(--danger), #fff 88%);
   --info-bg: color-mix(in oklab, var(--info), #fff 88%);
}

/* =========================
   BASE / RESET
========================= */
* {
   box-sizing: border-box;
}

html,
body {
   height: 100%;
}

body {
   margin: 0;
   font-family: "Poppins", system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
   background: var(--bg);
   color: var(--text);
   -webkit-font-smoothing: antialiased;
   -moz-osx-font-smoothing: grayscale;
   text-rendering: optimizeLegibility;
}

img {
   max-width: 100%;
   display: block;
}

a {
   color: inherit;
   text-decoration: none;
}

button,
input,
select,
textarea {
   font: inherit;
}

code,
pre,
kbd,
samp {
   font-family: inherit;
   font-size: 1em;
   background: none;
}

@media (prefers-reduced-motion: no-preference) {

   .btn,
   .btn-outline,
   .btn-ghost,
   .menu-link,
   .section-header,
   .icon-btn,
   .dropdown__item,
   .user-pill,
   .input,
   select.input,
   textarea.input {
      transition:
         background-color 160ms ease,
         color 160ms ease,
         border-color 160ms ease,
         transform 160ms ease;
   }

   .sidebar,
   .dropdown__menu {
      transition:
         transform var(--t),
         opacity var(--t);
   }

   .section-chevron {
      transition: transform var(--t);
   }
}

:focus-visible {
   outline: 2px solid var(--ring);
   outline-offset: 2px;
}

/* Scrollbar */
* {
   scrollbar-width: thin;
   scrollbar-color: color-mix(in oklab, var(--muted), #0000 55%) transparent;
}

*::-webkit-scrollbar {
   width: 10px;
   height: 10px;
}

*::-webkit-scrollbar-thumb {
   background: color-mix(in oklab, var(--muted), #0000 55%);
   border-radius: 999px;
   border: 2px solid transparent;
   background-clip: padding-box;
}

/* =========================
   UTIL
========================= */
.container {
   width: min(var(--container), calc(100% - 32px));
   margin-inline: auto;
}

.hidden {
   display: none !important;
}

.center {
   display: grid;
   place-items: center;
}

.d-flex {
   display: flex;
}

.items-center {
   align-items: center;
}

.justify-between {
   justify-content: space-between;
}

.gap-1 {
   gap: var(--s-1);
}

.gap-2 {
   gap: var(--s-2);
}

.gap-3 {
   gap: var(--s-3);
}

.mt-2 {
   margin-top: var(--s-2);
}

.mt-3 {
   margin-top: var(--s-3);
}

.mt-4 {
   margin-top: var(--s-4);
}

.mb-2 {
   margin-bottom: var(--s-2);
}

.mb-3 {
   margin-bottom: var(--s-3);
}

.text-muted {
   color: var(--muted);
}

.text-center {
   text-align: center;
}

.text-right {
   text-align: right;
}

.truncate {
   white-space: nowrap;
   overflow: hidden;
   text-overflow: ellipsis;
}

.nowrap {
   white-space: nowrap;
}

/* =========================
   TYPO
========================= */
.h1 {
   font-size: clamp(1.35rem, 2vw, 1.8rem);
   font-weight: 700;
   letter-spacing: -0.02em;
}

.h2 {
   font-size: 1.25rem;
   font-weight: 650;
   letter-spacing: -0.01em;
}

.h3 {
   font-size: 1.05rem;
   font-weight: 650;
}

.p {
   font-size: var(--fs-md);
   line-height: 1.6;
}

.small {
   font-size: var(--fs-sm);
}

.mini {
   font-size: var(--fs-xs);
}

/* =========================
   SHELL (menu.js)
========================= */
.app-header {
   position: fixed;
   z-index: var(--z-header);
   top: 0;
   left: 0;
   right: 0;
   height: var(--header-h);
   background: color-mix(in oklab, var(--elev), #fff 2%);
   border-bottom: 1px solid var(--border);
   display: flex;
   align-items: center;
   justify-content: space-between;
   padding-top: 0;
   padding-bottom: 0;
   padding-left: var(--s-4);
   padding-right: calc(var(--s-4) + var(--scrollbar-comp));
}

.header-left,
.header-right {
   display: flex;
   align-items: center;
   gap: var(--s-2);
   min-width: 0;
}

.brand {
   display: flex;
   align-items: center;
   gap: 12px;
   min-width: 0;
   color: inherit;
   text-decoration: none;
   cursor: pointer;
}

.brand-logo {
   height: 34px;
   width: auto;
   max-width: 160px;
   object-fit: contain;
   display: block;
}

.brand-text {
   display: grid;
   line-height: 1.05;
}

.brand-title {
   font-weight: 750;
   letter-spacing: -0.02em;
}

.brand-sub {
   font-size: .88rem;
   margin-top: 2px;
   color: var(--muted);
}

.icon-btn {
   width: 40px;
   height: 40px;
   border-radius: 12px;
   border: 1px solid transparent;
   background: transparent;
   color: var(--text);
   display: grid;
   place-items: center;
   cursor: pointer;
   flex: 0 0 auto;
}

.icon-btn:hover {
   background: var(--hover);
}

.icon-btn i {
   font-size: 20px;
   line-height: 1;
}

.page-help {
   position: relative;
   flex: 0 0 auto;
}

.page-help__btn[aria-expanded="true"] {
   background: var(--hover);
   color: var(--info);
}

.page-help__popover {
   position: absolute;
   top: calc(100% + 8px);
   right: 0;
   width: min(390px, calc(100vw - 24px));
   max-height: min(560px, calc(100dvh - var(--header-h) - 24px));
   overflow: auto;
   border: 1px solid var(--border);
   border-radius: 12px;
   background: var(--panel);
   box-shadow: var(--shadow);
   z-index: var(--z-dropdown);
}

.page-help__popover[hidden] {
   display: none !important;
}

.page-help__header {
   display: grid;
   grid-template-columns: 38px minmax(0, 1fr) 34px;
   gap: 10px;
   align-items: start;
   padding: 12px;
   border-bottom: 1px solid var(--border);
   background: color-mix(in oklab, var(--panel), #fff 1%);
}

.page-help__header-icon {
   width: 38px;
   height: 38px;
   border-radius: 10px;
   display: grid;
   place-items: center;
   color: var(--info);
   background: color-mix(in oklab, var(--info), transparent 86%);
   font-size: 20px;
}

.page-help__heading {
   min-width: 0;
   display: grid;
   gap: 3px;
}

.page-help__heading strong {
   color: var(--text);
   font-size: 0.98rem;
   line-height: 1.25;
}

.page-help__heading span {
   color: var(--muted);
   font-size: var(--fs-xs);
   line-height: 1.4;
}

.page-help__close {
   width: 34px;
   height: 34px;
   border-radius: 10px;
   border: 1px solid transparent;
   background: transparent;
   color: var(--text);
   display: grid;
   place-items: center;
   cursor: pointer;
}

.page-help__close:hover {
   background: var(--hover);
}

.page-help__close i {
   font-size: 18px;
}

.page-help__list {
   display: grid;
   padding: 6px;
}

.page-help__item {
   display: grid;
   grid-template-columns: 34px minmax(0, 1fr);
   gap: 10px;
   padding: 10px;
   border-radius: 8px;
}

.page-help__item + .page-help__item {
   border-top: 1px solid color-mix(in oklab, var(--border), transparent 35%);
}

.page-help__item-icon {
   width: 34px;
   height: 34px;
   border-radius: 8px;
   display: grid;
   place-items: center;
   color: color-mix(in oklab, var(--info), var(--text) 20%);
   background: color-mix(in oklab, var(--info), transparent 90%);
}

.page-help__item-icon i {
   font-size: 18px;
   line-height: 1;
}

.page-help__item-body {
   min-width: 0;
   display: grid;
   gap: 3px;
}

.page-help__item-body strong {
   color: var(--text);
   font-size: var(--fs-sm);
   line-height: 1.35;
}

.page-help__item-body p {
   margin: 0;
   color: var(--muted);
   font-size: var(--fs-xs);
   line-height: 1.45;
}

.page-help__footer {
   margin: 0 12px 12px;
   padding-top: 10px;
   border-top: 1px dashed var(--border);
   color: var(--muted);
   font-size: var(--fs-xs);
   line-height: 1.45;
}

.notification-shell {
   position: relative;
   flex: 0 0 auto;
}

.notification-btn {
   position: relative;
}

.notification-badge {
   position: absolute;
   top: 5px;
   right: 5px;
   min-width: 17px;
   height: 17px;
   padding: 0 5px;
   border-radius: 999px;
   display: inline-flex;
   align-items: center;
   justify-content: center;
   background: var(--danger);
   color: #fff;
   font-size: 0.64rem;
   font-weight: 750;
   line-height: 1;
   border: 2px solid color-mix(in oklab, var(--elev), #fff 2%);
}

.notification-badge[hidden] {
   display: none !important;
}

.notification-popover {
   position: absolute;
   top: calc(100% + 8px);
   right: 0;
   width: min(430px, calc(100vw - 24px));
   max-height: min(560px, calc(100dvh - var(--header-h) - 24px));
   display: flex;
   flex-direction: column;
   overflow: hidden;
   border: 1px solid var(--border);
   border-radius: 12px;
   background: var(--panel);
   box-shadow: var(--shadow);
   z-index: var(--z-dropdown);
}

.notification-popover[hidden] {
   display: none !important;
}

.notification-popover__header {
   display: flex;
   align-items: flex-start;
   justify-content: space-between;
   gap: 10px;
   padding: 11px 12px;
   border-bottom: 1px solid var(--border);
   flex: 0 0 auto;
}

.notification-popover__header>div:first-child {
   display: grid;
   gap: 2px;
   min-width: 0;
}

.notification-popover__header span {
   color: var(--muted);
   font-size: var(--fs-xs);
}

.notification-popover__actions {
   display: flex;
   flex-wrap: wrap;
   justify-content: flex-end;
   gap: 8px;
}

.notification-popover__link {
   border: 0;
   background: transparent;
   color: var(--info);
   font: inherit;
   font-size: var(--fs-sm);
   font-weight: 650;
   cursor: pointer;
}

.notification-popover__link[hidden] {
   display: none !important;
}

.notification-popover__link:hover {
   text-decoration: underline;
}

.notification-composer {
   display: grid;
   gap: 8px;
   padding: 12px 12px 0;
   border-bottom: 1px solid var(--border);
   background: color-mix(in oklab, var(--elev), var(--panel) 70%);
   min-height: 0;
   overflow: auto;
   flex: 1 1 auto;
}

.notification-composer[hidden] {
   display: none !important;
}

.notification-composer .label {
   margin: 0;
   font-size: var(--fs-xs);
   color: var(--muted);
}

.notification-composer textarea.input {
   min-height: 86px;
   resize: vertical;
}

.notification-send-all {
   display: inline-flex;
   align-items: center;
   gap: 8px;
   width: fit-content;
   color: var(--text);
   font-size: var(--fs-sm);
   font-weight: 600;
   cursor: pointer;
}

.notification-send-all input {
   width: 16px;
   height: 16px;
   accent-color: var(--info);
}

.notification-user-picker {
   position: relative;
}

.notification-user-results {
   position: absolute;
   z-index: calc(var(--z-dropdown) + 1);
   top: calc(100% + 6px);
   left: 0;
   right: 0;
   max-height: 220px;
   overflow: auto;
   padding: 4px;
   border: 1px solid var(--border);
   border-radius: 8px;
   background: var(--panel);
   box-shadow: var(--shadow-sm);
}

.notification-user-results[hidden] {
   display: none !important;
}

.notification-user-result {
   width: 100%;
   display: grid;
   gap: 2px;
   padding: 8px;
   border: 0;
   border-radius: 7px;
   background: transparent;
   color: var(--text);
   text-align: left;
   cursor: pointer;
}

.notification-user-result:hover {
   background: var(--hover);
}

.notification-user-picker .input:disabled {
   cursor: not-allowed;
   opacity: .68;
}

.notification-user-result strong {
   font-size: var(--fs-sm);
}

.notification-user-result span,
.notification-user-results__empty,
.notification-recipients__empty {
   color: var(--muted);
   font-size: var(--fs-xs);
}

.notification-recipients {
   display: flex;
   flex-wrap: wrap;
   align-items: center;
   gap: 6px;
   min-height: 28px;
   max-height: min(150px, 26dvh);
   overflow: auto;
   align-content: flex-start;
   padding: 2px 4px 6px 0;
   scrollbar-gutter: stable;
}

.notification-recipient {
   display: inline-flex;
   align-items: center;
   max-width: 100%;
   gap: 6px;
   padding: 4px 8px;
   border: 1px solid var(--border);
   border-radius: 999px;
   background: color-mix(in oklab, var(--info), transparent 92%);
   color: var(--text);
   font-size: var(--fs-xs);
}

.notification-recipient span {
   overflow: hidden;
   text-overflow: ellipsis;
   white-space: nowrap;
}

.notification-recipient button {
   width: 18px;
   height: 18px;
   display: grid;
   place-items: center;
   padding: 0;
   border: 0;
   border-radius: 999px;
   background: transparent;
   color: var(--muted);
   cursor: pointer;
}

.notification-recipient button:hover {
   color: var(--danger);
   background: color-mix(in oklab, var(--danger), transparent 88%);
}

.notification-composer__actions {
   display: flex;
   justify-content: flex-end;
   gap: 8px;
   padding: 10px 0 12px;
   margin-top: 4px;
   position: sticky;
   bottom: 0;
   background: color-mix(in oklab, var(--elev), var(--panel) 70%);
   border-top: 1px solid color-mix(in oklab, var(--border), transparent 40%);
   z-index: 1;
}

.notification-popover__list {
   overflow: auto;
   padding: 6px;
   flex: 1 1 auto;
   min-height: 0;
}

.notification-popover__list[hidden] {
   display: none !important;
}

.notification-popover__empty {
   padding: 18px 12px;
   color: var(--muted);
   text-align: center;
}

.notification-preview {
   width: 100%;
   display: grid;
   grid-template-columns: 34px 1fr;
   gap: 10px;
   padding: 10px;
   border: 0;
   border-radius: 8px;
   background: transparent;
   color: var(--text);
   text-align: left;
   text-decoration: none;
   font: inherit;
   cursor: pointer;
}

.notification-preview:hover {
   background: var(--hover);
}

.notification-preview.is-unread {
   background: color-mix(in oklab, var(--info), transparent 92%);
}

.notification-preview__icon {
   width: 34px;
   height: 34px;
   border-radius: 8px;
   display: grid;
   place-items: center;
   color: var(--info);
   background: color-mix(in oklab, var(--info), transparent 88%);
}

.notification-preview__icon i {
   font-size: 18px;
}

.notification-preview__body {
   min-width: 0;
   display: grid;
   gap: 3px;
}

.notification-preview__title {
   font-size: var(--fs-sm);
   font-weight: 700;
   overflow: hidden;
   text-overflow: ellipsis;
   white-space: nowrap;
}

.notification-preview__message {
   color: var(--muted);
   font-size: var(--fs-xs);
   line-height: 1.4;
   white-space: pre-wrap;
   overflow: hidden;
   display: -webkit-box;
   -webkit-line-clamp: 2;
   -webkit-box-orient: vertical;
   word-break: break-word;
}

.notification-preview__meta {
   display: flex;
   align-items: center;
   gap: 6px;
   color: var(--muted);
   font-size: 0.7rem;
   margin-top: 2px;
   flex-wrap: wrap;
}

.notification-preview__meta-actor {
   font-weight: 600;
   color: color-mix(in oklab, var(--text), var(--muted) 30%);
   overflow: hidden;
   text-overflow: ellipsis;
   white-space: nowrap;
   max-width: 60%;
}

.notification-preview__meta-sep {
   opacity: .55;
}

.notification-preview__meta-date {
   white-space: nowrap;
}

/* =========================
   MODAL DE DETALHES DA NOTIFICAÇÃO
========================= */
.notification-detail {
   position: fixed;
   inset: 0;
   z-index: var(--z-modal);
   display: grid;
   place-items: center;
   padding: 16px;
}

.notification-detail[hidden] {
   display: none !important;
}

.notification-detail__backdrop {
   position: absolute;
   inset: 0;
   background: rgba(0, 0, 0, .5);
   backdrop-filter: blur(2px);
}

.notification-detail__panel {
   position: relative;
   width: min(540px, 100%);
   max-height: min(82dvh, 720px);
   display: flex;
   flex-direction: column;
   background: var(--panel);
   border: 1px solid var(--border);
   border-radius: 14px;
   box-shadow: var(--shadow);
   overflow: hidden;
}

.notification-detail__header {
   display: flex;
   align-items: flex-start;
   gap: 12px;
   padding: 16px 18px;
   border-bottom: 1px solid var(--border);
   background: color-mix(in oklab, var(--panel), #fff 1%);
}

.notification-detail__icon {
   flex: 0 0 auto;
   width: 38px;
   height: 38px;
   border-radius: 10px;
   display: grid;
   place-items: center;
   color: var(--info);
   background: color-mix(in oklab, var(--info), transparent 86%);
   font-size: 20px;
}

.notification-detail__heading {
   flex: 1 1 auto;
   min-width: 0;
   display: grid;
   gap: 2px;
}

.notification-detail__title {
   font-size: 1.05rem;
   font-weight: 700;
   line-height: 1.25;
   word-break: break-word;
}

.notification-detail__module {
   color: var(--muted);
   font-size: var(--fs-xs);
}

.notification-detail__close {
   flex: 0 0 auto;
   width: 36px;
   height: 36px;
   border-radius: 10px;
   border: 1px solid var(--border);
   background: transparent;
   color: var(--text);
   cursor: pointer;
   display: grid;
   place-items: center;
   font-size: 18px;
}

.notification-detail__close:hover {
   background: var(--hover);
   border-color: transparent;
}

.notification-detail__body {
   padding: 16px 18px;
   overflow: auto;
   min-height: 0;
}

.notification-detail__message {
   color: var(--text);
   font-size: 0.95rem;
   line-height: 1.55;
   white-space: pre-wrap;
   word-break: break-word;
}

.notification-detail__meta {
   margin-top: 14px;
   padding-top: 12px;
   border-top: 1px dashed var(--border);
   display: grid;
   gap: 6px;
   color: var(--muted);
   font-size: var(--fs-xs);
}

.notification-detail__meta-row {
   display: flex;
   align-items: center;
   gap: 8px;
   flex-wrap: wrap;
}

.notification-detail__meta-row i {
   font-size: 14px;
   color: color-mix(in oklab, var(--info), var(--muted) 40%);
}

.notification-detail__meta-label {
   color: var(--muted);
}

.notification-detail__meta-value {
   color: var(--text);
   font-weight: 600;
}

.notification-detail__footer {
   padding: 12px 18px 16px;
   display: flex;
   gap: 8px;
   justify-content: flex-end;
   flex-wrap: wrap;
   border-top: 1px solid var(--border);
   background: color-mix(in oklab, var(--panel), #fff 1%);
}

.notification-detail__footer [hidden],
.notification-detail__meta-row[hidden],
.notification-detail [hidden] {
   display: none !important;
}

@media (max-width: 720px) {
   .notification-detail__panel {
      max-height: calc(100dvh - 32px);
   }
}

/* =========================
   MENU SUSPENSO (FLYOUT)
========================= */
.sidebar {
   position: fixed;
   z-index: var(--z-sidebar);
   top: calc(var(--header-h) + 10px);
   left: 12px;

   width: min(360px, calc(100vw - 24px));
   max-height: calc(100dvh - var(--header-h) - 24px);

   background: color-mix(in oklab, var(--elev), #fff 1%);
   border: 1px solid var(--border);
   border-radius: var(--r-xl);
   padding: 12px;
   box-shadow: var(--shadow);

   opacity: 0;
   transform: translateY(-8px);
   pointer-events: none;
}

.sidebar.is-open {
   opacity: 1;
   transform: translateY(0);
   pointer-events: auto;
}

.backdrop {
   position: fixed;
   inset: var(--header-h) 0 0 0;
   background: var(--overlay);
   backdrop-filter: blur(1px);
   z-index: var(--z-backdrop);
}

.backdrop[hidden] {
   display: none;
}

.content {
   min-height: 100dvh;
   padding: calc(var(--header-h) + 20px) var(--s-4) 32px;
   width: 100%;
}

.content > * {
   min-width: 0;
}

/* =========================
   USER / DROPDOWN
========================= */
.dropdown {
   position: relative;
}

.user-pill {
   display: inline-flex;
   align-items: center;
   gap: 10px;
   height: 42px;
   padding: 0 10px;
   border-radius: 999px;
   border: 1px solid var(--border);
   background: color-mix(in oklab, var(--panel), #fff 2%);
   color: var(--text);
   cursor: pointer;
   min-width: 120px;
   max-width: min(360px, 46vw);
}

.user-pill .chev {
   font-size: 18px;
   opacity: .85;
}

#userNameTop {
   min-width: 0;
   white-space: nowrap;
   overflow: hidden;
   text-overflow: ellipsis;
}

.dropdown__menu {
   display: none;
   position: absolute;
   top: calc(100% + 8px);
   right: 0;

   width: 280px;
   max-width: min(320px, 90vw);

   padding: 6px;
   border-radius: var(--r-lg);
   background: var(--panel);
   border: 1px solid var(--border);
   box-shadow: var(--shadow);
   z-index: var(--z-dropdown);
}

.dropdown.is-open .dropdown__menu {
   display: block;
}

.dropdown__item {
   width: 100%;
   border: 0;
   background: transparent;
   color: var(--text);
   display: flex;
   align-items: center;
   gap: 10px;
   padding: 10px 12px;
   border-radius: 12px;
   cursor: pointer;
   text-align: left;
}

.dropdown__item:hover {
   background: var(--hover);
}

.dropdown__item i {
   font-size: 18px;
   line-height: 1;
   width: 20px;
   display: inline-flex;
   justify-content: center;
}

.dropdown__item.danger {
   color: var(--danger);
}

/* =========================
   SIDEBAR MENU
========================= */
.nav-scroll {
   overflow: auto;
   padding-right: 4px;
   min-height: 0;
   max-height: calc(100dvh - var(--header-h) - 64px);
}

.menu {
   display: grid;
   gap: 10px;
   padding: 0 4px 10px 4px;
}

.menu-section {
   border: 1px solid var(--border);
   border-radius: 16px;
   background: color-mix(in oklab, var(--panel), #fff 1%);
   overflow: hidden;
}

.section-header {
   width: 100%;
   border: 0;
   background: transparent;
   color: var(--text);
   display: flex;
   align-items: center;
   justify-content: space-between;
   gap: 10px;
   padding: 10px 12px;
   cursor: pointer;
   font-weight: 650;
}

.section-header:hover {
   background: var(--hover);
}

.section-title {
   display: flex;
   align-items: center;
   gap: 10px;
   min-width: 0;
}

.section-title i {
   font-size: 18px;
   line-height: 1;
}

.section-chevron {
   font-size: 18px;
}

.menu-section.is-collapsed .section-chevron {
   transform: rotate(-90deg);
}

.section-body {
   padding: 6px;
   display: grid;
   gap: 6px;
   border-top: 1px solid var(--border);
}

.menu-link {
   display: flex;
   align-items: center;
   gap: 10px;
   padding: 10px 10px;
   border-radius: 12px;
   color: var(--text);
}

.menu-link i {
   font-size: 18px;
   line-height: 1;
   width: 20px;
   display: inline-flex;
   justify-content: center;
}

.menu-link:hover {
   background: var(--hover);
}

.menu-link.active {
   background: color-mix(in oklab, var(--brand), #0000 85%);
   outline: 2px solid color-mix(in oklab, var(--brand), #fff 18%);
   outline-offset: 0;
}

/* =========================
   COMPONENTS
========================= */
.card {
   background: color-mix(in oklab, var(--panel), #fff 1%);
   border: 1px solid var(--border);
   border-radius: var(--r-xl);
   box-shadow: var(--shadow);
   min-width: 0;
   max-width: 100%;
}

.card.pad {
   padding: var(--s-6);
}

.card-header {
   padding: var(--s-5) var(--s-6);
   border-bottom: 1px solid var(--border);
}

.card-body {
   padding: var(--s-6);
}

.card-footer {
   padding: var(--s-5) var(--s-6);
   border-top: 1px solid var(--border);
}

.btn {
   display: inline-flex;
   align-items: center;
   justify-content: center;
   gap: 10px;
   height: 44px;
   padding: 0 14px;
   border-radius: var(--r-md);
   border: 1px solid transparent;
   background: var(--brand);
   color: var(--brand-contrast);
   font-weight: 650;
   cursor: pointer;
   user-select: none;
}

.btn:hover {
   filter: brightness(1.06);
   transform: translateY(-1px);
}

.btn:active {
   transform: translateY(0);
}

.btn-outline {
   background: transparent;
   border-color: var(--border);
   color: var(--text);
}

.btn-outline:hover {
   background: var(--hover);
   border-color: transparent;
}

.btn-ghost {
   background: transparent;
   border-color: transparent;
   color: var(--text);
}

.btn-ghost:hover {
   background: var(--hover);
}

.btn[disabled],
.btn:disabled {
   opacity: 0.6;
   cursor: not-allowed;
   transform: none;
   filter: none;
}

.spinner {
   width: 16px;
   height: 16px;
   border: 2px solid currentColor;
   border-bottom-color: transparent;
   border-radius: 50%;
   display: inline-block;
   animation: spin .8s linear infinite;
}

@keyframes spin {
   to {
      transform: rotate(360deg);
   }
}

.form {
   display: grid;
   gap: var(--s-4);
}

.field {
   display: grid;
   gap: 8px;
}

.label {
   font-size: var(--fs-sm);
   color: color-mix(in oklab, var(--muted), var(--text) 10%);
   font-weight: 550;
}

.input,
select.input,
textarea.input {
   width: 100%;
   min-width: 0;
   height: 44px;
   border-radius: var(--r-md);
   border: 1px solid var(--border);
   background: transparent;
   color: var(--text);
   padding: 10px 12px;
   outline: none;
}

textarea.input {
   min-height: 110px;
   height: auto;
   resize: vertical;
}

.input:focus,
select.input:focus,
textarea.input:focus {
   border-color: color-mix(in oklab, var(--ring), #fff 5%);
   box-shadow: 0 0 0 4px color-mix(in oklab, var(--ring), #0000 78%);
}

.badge {
   display: inline-flex;
   align-items: center;
   gap: 8px;
   padding: 6px 10px;
   border-radius: 999px;
   border: 1px solid var(--border);
   background: color-mix(in oklab, var(--panel), var(--text) 4%);
   font-weight: 650;
   font-size: var(--fs-xs);
}

.alert {
   border: 1px solid var(--border);
   background: color-mix(in oklab, var(--panel), #fff 2%);
   border-radius: var(--r-lg);
   padding: 12px 14px;
}

.alert.success {
   border-color: color-mix(in oklab, var(--success), #0000 65%);
   background: var(--success-bg);
}

.alert.warning {
   border-color: color-mix(in oklab, var(--warning), #0000 65%);
   background: var(--warning-bg);
}

.alert.danger {
   border-color: color-mix(in oklab, var(--danger), #0000 65%);
   background: var(--danger-bg);
}

.alert.info {
   border-color: color-mix(in oklab, var(--info), #0000 65%);
   background: var(--info-bg);
}

/* =========================
   AVATAR
========================= */
.avatar {
   width: 34px;
   height: 34px;
   min-width: 34px;
   min-height: 34px;
   border-radius: 999px;
   background: color-mix(in oklab, var(--panel), var(--text) 6%);
   display: inline-flex;
   align-items: center;
   justify-content: center;
   overflow: hidden;
   font-weight: 800;
   font-size: 12px;
   letter-spacing: .02em;
   line-height: 1;
   text-align: center;
   border: 1px solid var(--border);
   color: var(--text);
   vertical-align: middle;
   flex: 0 0 auto;
   position: relative;
}

.avatar__img,
.avatar__fallback {
   position: absolute;
   inset: 0;
   width: 100%;
   height: 100%;
}

.avatar__img {
   display: none;
   width: 100%;
   height: 100%;
   object-fit: cover;
   object-position: center center;
   border-radius: inherit;
}

.avatar__fallback {
   display: flex;
   align-items: center;
   justify-content: center;
   font: inherit;
   color: inherit;
}

.avatar.has-image {
   background: transparent;
   border-color: transparent;
}

.avatar.has-image .avatar__img {
   display: block;
}

.avatar.has-image .avatar__fallback {
   display: none;
}

.avatar--sm {
   width: 36px;
   height: 36px;
   min-width: 36px;
   min-height: 36px;
   font-size: 11px;
}

.avatar--lg {
   width: 46px;
   height: 46px;
   min-width: 46px;
   min-height: 46px;
   font-size: 14px;
}

#userAvatar {
   width: 40px;
   height: 40px;
   min-width: 40px;
   min-height: 40px;
   overflow: hidden;
   border-radius: 999px;
}

#userAvatar .avatar__img {
   width: 100%;
   height: 100%;
   object-position: center center;
}

#userAvatar.avatar--cover .avatar__img {
   object-fit: cover;
}

#userAvatar.avatar--contain .avatar__img {
   object-fit: contain;
   background: color-mix(in oklab, var(--panel), #fff 4%);
}

/* bloqueia transições durante a troca de tema */
html.theme-switching *,
html.theme-switching *::before,
html.theme-switching *::after {
   transition: none !important;
}

/* =========================
   MOBILE
========================= */
@media (max-width: 520px) {
   .app-header {
      gap: 6px;
      padding-left: 8px;
      padding-right: calc(8px + var(--scrollbar-comp));
   }

   .header-left,
   .header-right {
      gap: 6px;
   }

   .brand-text {
      display: none;
   }

   .brand-logo {
      max-width: 58px;
   }

   .icon-btn {
      width: 36px;
      height: 36px;
      border-radius: 10px;
   }

   .user-pill {
      height: 38px;
      gap: 6px;
      padding: 0 8px;
      min-width: 108px;
      max-width: 44vw;
   }

   .user-pill .chev {
      display: none;
   }

   .page-help__popover {
      position: fixed;
      top: calc(var(--header-h) + 8px);
      left: 12px;
      right: 12px;
      width: auto;
      max-height: calc(100dvh - var(--header-h) - 20px);
   }

   .notification-popover {
      position: fixed;
      top: calc(var(--header-h) + 8px);
      left: 12px;
      right: 12px;
      width: auto;
      max-height: calc(100dvh - var(--header-h) - 20px);
   }
}

/* =========================
   AUTOFILL
========================= */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active,
textarea:-webkit-autofill,
textarea:-webkit-autofill:hover,
textarea:-webkit-autofill:focus,
select:-webkit-autofill {
   -webkit-text-fill-color: var(--text) !important;
   caret-color: var(--text) !important;
   border: 1px solid var(--border) !important;
   -webkit-box-shadow: 0 0 0 1000px transparent inset !important;
   box-shadow: 0 0 0 1000px transparent inset !important;
   background-color: transparent !important;
   transition: background-color 99999s ease-in-out 0s;
}

html[data-theme="dark"] input:-webkit-autofill,
html[data-theme="dark"] input:-webkit-autofill:hover,
html[data-theme="dark"] input:-webkit-autofill:focus,
html[data-theme="dark"] textarea:-webkit-autofill,
html[data-theme="dark"] select:-webkit-autofill {
   -webkit-text-fill-color: var(--text) !important;
   caret-color: var(--text) !important;
   -webkit-box-shadow: 0 0 0 1000px var(--panel) inset !important;
   box-shadow: 0 0 0 1000px var(--panel) inset !important;
   border: 1px solid var(--border) !important;
}

html[data-theme="light"] input:-webkit-autofill,
html[data-theme="light"] input:-webkit-autofill:hover,
html[data-theme="light"] input:-webkit-autofill:focus,
html[data-theme="light"] textarea:-webkit-autofill,
html[data-theme="light"] select:-webkit-autofill {
   -webkit-text-fill-color: var(--text) !important;
   caret-color: var(--text) !important;
   -webkit-box-shadow: 0 0 0 1000px var(--panel) inset !important;
   box-shadow: 0 0 0 1000px var(--panel) inset !important;
   border: 1px solid var(--border) !important;
}

/* =========================================================
   PAGE FILTERS — padronização entre todas as telas
========================================================= */
.filters-card .section-title {
   display: flex;
   align-items: center;
   gap: 10px;
   margin-bottom: 14px;
   font-weight: 700;
   color: var(--text);
}

.filters-card .section-title i {
   font-size: 20px;
   line-height: 1;
}

.filters-grid {
   display: grid;
   grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
   gap: 12px;
   align-items: end;
}

.filters-grid > div {
   min-width: 0;
}

.filters-actions {
   display: flex;
   align-items: center;
   gap: 10px;
   flex-wrap: wrap;
}

.filters-actions .btn {
   flex: 0 0 auto;
   white-space: nowrap;
}

@media (max-width: 720px) {
   .content {
      padding: calc(var(--header-h) + 14px) 10px 24px;
   }

   .card.pad {
      padding: var(--s-4);
      border-radius: var(--r-lg);
   }

   .h2 {
      font-size: clamp(1.05rem, 4vw, 1.2rem);
   }

   .h3 {
      font-size: clamp(0.98rem, 3.4vw, 1.05rem);
   }

   .filters-grid {
      grid-template-columns: 1fr;
   }

   /* Header padrão: título + ações — colapsa em coluna no mobile */
   .card.pad>.d-flex.items-center.justify-between.gap-2 {
      flex-direction: column;
      align-items: stretch;
   }

   body[data-shell="app"] .card.pad>.d-flex.items-center.justify-between.gap-2 {
      flex-direction: column;
      align-items: stretch;
   }

   .card.pad>.d-flex.items-center.justify-between.gap-2>div:first-child {
      width: 100%;
   }

   body[data-shell="app"] .card.pad>.d-flex.items-center.justify-between.gap-2>div:first-child {
      width: 100%;
      min-width: 0;
   }

   .card.pad>.d-flex.items-center.justify-between.gap-2>div:last-child {
      width: 100%;
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 10px;
   }

   body[data-shell="app"] .card.pad>.d-flex.items-center.justify-between.gap-2>div:last-child {
      width: 100%;
      min-width: 0;
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 10px;
   }

   .card.pad>.d-flex.items-center.justify-between.gap-2>div:last-child .btn {
      width: 100%;
      min-width: 0;
      justify-content: center;
      white-space: normal;
      text-align: center;
      line-height: 1.2;
      padding-inline: 10px;
   }

   body[data-shell="app"] .card.pad>.d-flex.items-center.justify-between.gap-2>div:last-child .btn {
      width: 100%;
      min-width: 0;
      justify-content: center;
      white-space: normal;
      text-align: center;
      line-height: 1.2;
      padding-inline: 10px;
   }

   /* Bloco padrão de ações dentro de filters */
   .filters-actions {
      width: 100%;
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 10px;
   }

   .filters-actions .btn {
      width: 100%;
      min-width: 0;
      justify-content: center;
      white-space: normal;
      text-align: center;
      line-height: 1.2;
      padding-inline: 10px;
   }

   /* Drawer: botão de fechar mais discreto no mobile */
   .drawer__close {
      width: 36px;
      height: 36px;
      border-color: transparent;
      background: transparent;
   }

   .drawer__close:hover {
      background: var(--hover);
   }

   /* Drawer footer: stacked, botões largos */
   .drawer__footer {
      flex-direction: column;
      align-items: stretch;
      gap: 10px;
   }

   .drawer__footer>.btn {
      width: 100%;
      justify-content: center;
   }

   .drawer__footer-spacer {
      display: none;
   }

   .action-btn,
   .icon-btn,
   .drawer__close {
      min-width: 40px;
      min-height: 40px;
   }

   .action-btn {
      width: 40px;
      height: 40px;
   }
}


@media (max-width: 520px) {
   .card.pad>.d-flex.items-center.justify-between.gap-2>div:last-child,
   body[data-shell="app"] .card.pad>.d-flex.items-center.justify-between.gap-2>div:last-child,
   .filters-actions {
      grid-template-columns: 1fr;
   }
}

@media (max-width: 380px) {
   .brand-logo {
      max-width: 46px;
   }

   .user-pill {
      width: 40px !important;
      min-width: 40px;
      max-width: 40px !important;
      padding: 0;
      justify-content: center;
   }

   #userNameTop {
      display: none;
   }
}

/* =========================================================
   TABLE — comportamento mobile padrão
========================================================= */
.table-wrap {
   position: relative;
   max-width: 100%;
   min-width: 0;
}

@media (max-width: 720px) {
   /* Sombra lateral indicando que há scroll horizontal */
   .table-wrap::after {
      content: "";
      position: absolute;
      top: 0;
      right: 0;
      width: 28px;
      height: calc(100% - 12px);
      pointer-events: none;
      background: linear-gradient(to left, var(--panel), transparent);
      border-radius: 0 18px 18px 0;
      opacity: 0.85;
      z-index: 1;
   }

   .table-scroll {
      scroll-snap-type: none;
   }

   .table-scroll table {
      min-width: 720px;
   }
}

@media (max-width: 720px) {
   .table-wrap,
   .table-scroll,
   .monitor-table-wrap {
      max-width: 100%;
      overflow-x: auto;
      overflow-y: hidden;
      -webkit-overflow-scrolling: touch;
   }
}
