/* ============================================
   Layout shell
   ============================================ */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh; /* fallback */
  height: 100dvh;
  overflow: hidden;
  transition: grid-template-columns 0.18s ease;
}
.app[data-collapsed="true"] {
  grid-template-columns: var(--sidebar-w-collapsed) 1fr;
}

/* Sidebar — navy brand surface */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  align-self: start;
  z-index: 100;
  background: var(--c-brand);
  border-right: 1px solid var(--c-brand-700);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: rgba(255, 255, 255, 0.85);
}
.sidebar__brand {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  cursor: pointer;
}
.sidebar__brand .logo-mark {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  flex: none;
}
.sidebar__brand .logo-mark svg {
  display: block;
}
.sidebar__brand .logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  gap: 2px;
}
.sidebar__brand .logo-text b {
  font-family: var(--ff-display);
  font-size: 20px;
  font-weight: 900;
  font-style: italic;
  color: #ffffff;
  letter-spacing: -0.01em;
  line-height: 1;
}
.sidebar__brand .logo-text span {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.55);
}
.app[data-collapsed="true"] .logo-text {
  display: none;
}

.sidebar__section {
  padding: 16px 12px 8px;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.45);
  font-weight: 700;
}
.app[data-collapsed="true"] .sidebar__section {
  opacity: 0;
  height: 8px;
  padding: 0;
  pointer-events: none;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 8px;
}
.nav__item {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 36px;
  padding: 0 10px;
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.72);
  font-weight: 500;
  font-size: 13.5px;
  cursor: pointer;
  position: relative;
  white-space: nowrap;
  border: 1px solid transparent;
}
.nav__item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
}
.nav__item.is-active {
  background: var(--c-accent);
  color: #ffffff;
  border-color: var(--c-accent-600);
  box-shadow: 0 2px 8px -2px rgba(52, 117, 187, 0.5);
}
.nav__item svg {
  flex: none;
  width: 18px;
  height: 18px;
  opacity: 0.9;
}
.nav__item .count {
  margin-left: auto;
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.75);
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 999px;
  font-feature-settings: "tnum";
}
.nav__item.is-active .count {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}
.app[data-collapsed="true"] .nav__item {
  justify-content: center;
  padding: 0;
  width: 40px;
  margin: 0 auto;
}
.app[data-collapsed="true"] .nav__label,
.app[data-collapsed="true"] .nav__item .count {
  display: none;
}

.sidebar__footer {
  margin-top: auto;
  padding: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
}
.user-chip:hover {
  background: rgba(255, 255, 255, 0.06);
}
.user-chip .avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--c-accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 12px;
  flex: none;
}
.user-chip__meta {
  line-height: 1.15;
  overflow: hidden;
}
.user-chip__meta b {
  font-size: 13px;
  display: block;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  color: #ffffff;
}
.user-chip__meta span {
  font-size: 11.5px;
  color: rgba(255, 255, 255, 0.55);
}
.app[data-collapsed="true"] .user-chip__meta {
  display: none;
}
.app[data-collapsed="true"] .user-chip {
  justify-content: center;
  padding: 6px;
}
.app[data-collapsed="true"] .user-chip form {
  display: none;
}

/* Main + topbar */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0; /* necessário para overflow-y funcionar em grid item */
  overflow-y: auto;
  overflow-x: hidden;
}
.topbar {
  height: var(--topbar-h);
  min-height: var(--topbar-h);
  flex-shrink: 0;
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  box-shadow: inset 0 -3px 0 var(--c-brand);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 20;
  width: 100%;
}
.topbar__breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  color: var(--c-ink-3);
}
.topbar__breadcrumbs b {
  color: var(--c-ink);
  font-weight: 600;
}
.topbar__breadcrumbs .sep {
  color: var(--c-ink-4);
}
.topbar__search {
  margin-left: auto;
  position: relative;
  width: 320px;
}
.topbar__search input {
  width: 100%;
  height: 34px;
  padding: 0 10px 0 34px;
  border: 1px solid var(--c-border);
  background: var(--c-surface-2);
  border-radius: 8px;
  outline: none;
  color: var(--c-ink);
}
.topbar__search input:focus {
  border-color: var(--c-brand-500);
  box-shadow: var(--s-focus);
  background: var(--c-surface);
}
.topbar__search svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--c-ink-4);
  width: 16px;
  height: 16px;
}
.topbar__search kbd {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10.5px;
  color: var(--c-ink-3);
  background: var(--c-surface-3);
  border: 1px solid var(--c-border);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--ff-mono);
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  color: var(--c-ink-2);
  position: relative;
}
.icon-btn:hover {
  background: var(--c-surface-3);
  color: var(--c-ink);
}
.icon-btn .dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--c-danger);
  border: 2px solid var(--c-surface);
}
.sidebar .icon-btn {
  color: rgba(255, 255, 255, 0.7);
}
.sidebar .icon-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.page {
  padding: 24px 28px 60px;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
}
.page__header {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 20px;
}
.page__title {
  font-size: var(--fs-24);
  font-weight: 800;
  font-style: italic;
  font-family: var(--ff-display);
  letter-spacing: -0.01em;
  margin: 0;
  line-height: 1.15;
  color: var(--c-brand);
  text-transform: uppercase;
}
.page__subtitle {
  color: var(--c-ink-3);
  font-size: 13.5px;
  margin-top: 4px;
}
.page__actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
}

/* ============================================
   Cards
   ============================================ */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  box-shadow: var(--s-xs);
}
.card__header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--c-border-subtle);
  background: linear-gradient(180deg, var(--c-brand-50), var(--c-surface));
  border-radius: calc(var(--r-lg) - 1px) calc(var(--r-lg) - 1px) 0 0;
  display: flex;
  align-items: center;
  gap: 12px;
}
.card__header h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--c-brand);
}
.card__header .hint {
  color: var(--c-ink-3);
  font-size: 12.5px;
}
.card__header .actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: center;
}
.card__body {
  padding: var(--card-pad);
}
.card__footer {
  padding: 12px 20px;
  border-top: 1px solid var(--c-border-subtle);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background: var(--c-surface-2);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}

/* ============================================
   Buttons
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border-radius: 7px;
  border: 1px solid var(--c-border-strong);
  background: var(--c-surface);
  color: var(--c-ink);
  font-weight: 500;
  font-size: 13.5px;
  cursor: pointer;
  letter-spacing: -0.005em;
  transition: background 0.12s, border-color 0.12s, box-shadow 0.12s,
    transform 0.08s;
  white-space: nowrap;
}
.btn:hover {
  background: var(--c-surface-3);
  border-color: var(--c-border-strong);
}
.btn:active {
  transform: translateY(0.5px);
}
.btn:focus-visible {
  outline: none;
  box-shadow: var(--s-focus);
}
.btn svg {
  width: 15px;
  height: 15px;
}

.btn--primary {
  background: var(--c-brand);
  border-color: var(--c-brand);
  color: #fff;
}
.btn--primary:hover {
  background: var(--c-brand-700);
  border-color: var(--c-brand-700);
}

.btn--ghost {
  background: transparent;
  border-color: transparent;
  color: var(--c-ink-2);
}
.btn--ghost:hover {
  background: var(--c-surface-3);
}

.btn--danger {
  background: var(--c-surface);
  border-color: var(--c-border-strong);
  color: var(--c-danger);
}
.btn--danger:hover {
  background: var(--c-danger-50);
  border-color: var(--c-danger);
}

.btn--success {
  background: var(--c-success);
  border-color: var(--c-success);
  color: #fff;
}
.btn--success:hover {
  filter: brightness(0.94);
}

.btn--sm {
  height: 30px;
  padding: 0 10px;
  font-size: 12.5px;
  border-radius: 6px;
}
.btn--xs {
  height: 26px;
  padding: 0 8px;
  font-size: 12px;
  border-radius: 5px;
}
.btn--block {
  width: 100%;
}
.btn--icon {
  padding: 0;
  width: 34px;
}

/* ============================================
   Forms
   ============================================ */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.field__label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--c-ink-2);
  letter-spacing: -0.005em;
}
.field__label .req {
  color: var(--c-danger);
  margin-left: 2px;
}
.field__hint {
  font-size: 11.5px;
  color: var(--c-ink-3);
}
.input,
.select,
.textarea {
  height: var(--field-h);
  padding: 0 12px;
  background: var(--c-surface);
  border: 1px solid var(--c-border-strong);
  border-radius: 7px;
  outline: none;
  color: var(--c-ink);
  font-size: 13.5px;
  width: 100%;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.input::placeholder,
.textarea::placeholder {
  color: var(--c-ink-4);
}
.input[type="file"] {
  padding: 0;
  display: flex;
  align-items: center;
  cursor: pointer;
}
.input[type="file"]::file-selector-button {
  height: 100%;
  padding: 0 14px;
  background: var(--c-surface-3);
  border: none;
  border-right: 1px solid var(--c-border-strong);
  border-radius: 6px 0 0 6px;
  color: var(--c-ink);
  font-family: var(--ff-sans);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  margin-right: 12px;
  transition: background 0.12s;
}
.input[type="file"]::file-selector-button:hover {
  background: var(--c-border);
}
.input:hover,
.select:hover {
  border-color: var(--c-ink-4);
}
.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--c-brand-500);
  box-shadow: var(--s-focus);
}
.input--invalid {
  border-color: var(--c-danger);
}
.input--invalid:focus {
  box-shadow: 0 0 0 3px rgba(180, 35, 24, 0.15);
}
.textarea {
  height: auto;
  min-height: 80px;
  padding: 10px 12px;
  resize: vertical;
}
.select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path fill='none' stroke='%2364748b' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' d='M3 4.5 6 7.5l3-3'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}
.input-icon {
  position: relative;
}
.input-icon > svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--c-ink-4);
  width: 15px;
  height: 15px;
  pointer-events: none;
}
.input-icon .input {
  padding-left: 32px;
}

.error-text {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--c-danger);
}
.error-text svg {
  width: 14px;
  height: 14px;
  flex: none;
}

.checkbox {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  user-select: none;
}
.checkbox input {
  appearance: none;
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--c-border-strong);
  border-radius: 4px;
  background: var(--c-surface);
  cursor: pointer;
  display: grid;
  place-items: center;
  flex: none;
}
.checkbox input:checked {
  background: var(--c-brand);
  border-color: var(--c-brand);
}
.checkbox input:checked::after {
  content: "";
  width: 9px;
  height: 9px;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'><path fill='none' stroke='white' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round' d='M2 5.3 4.1 7.5 8 2.8'/></svg>")
    center/contain no-repeat;
}

.toggle {
  width: 36px;
  height: 20px;
  background: var(--c-border-strong);
  border-radius: 999px;
  position: relative;
  cursor: pointer;
  transition: background 0.15s;
  flex: none;
}
.toggle::after {
  content: "";
  position: absolute;
  left: 2px;
  top: 2px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
  transition: left 0.15s;
}
.toggle.is-on {
  background: var(--c-brand);
}
.toggle.is-on::after {
  left: 18px;
}

/* Grid helpers */
.grid {
  display: grid;
  gap: 16px;
}
.grid--2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.grid--3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.grid--4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.grid--auto-fill-280 {
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}
@media (max-width: 960px) {
  .grid--2,
  .grid--3,
  .grid--4 {
    grid-template-columns: 1fr;
  }
}
.row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}
.stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.stack--sm {
  gap: 8px;
}
.stack--lg {
  gap: 24px;
}

/* ============================================
   Tabs
   ============================================ */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--c-border);
  margin-bottom: 20px;
}
.tab {
  background: transparent;
  border: none;
  padding: 10px 14px;
  font-size: 13.5px;
  color: var(--c-ink-3);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}
.tab:hover {
  color: var(--c-ink);
}
.tab.is-active {
  color: var(--c-brand);
  border-bottom-color: var(--c-brand);
}
.tab .count {
  background: var(--c-surface-3);
  color: var(--c-ink-3);
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 999px;
  font-feature-settings: "tnum";
}
.tab.is-active .count {
  background: var(--c-brand-100);
  color: var(--c-brand);
}

/* ============================================
   Badges
   ============================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  border: 1px solid var(--c-border);
  background: var(--c-surface-3);
  color: var(--c-ink-2);
  line-height: 1.5;
  white-space: nowrap;
}
.badge--success {
  background: var(--c-success-50);
  color: var(--c-success);
  border-color: transparent;
}
.badge--danger {
  background: var(--c-danger-50);
  color: var(--c-danger);
  border-color: transparent;
}
.badge--warn {
  background: var(--c-warn-50);
  color: var(--c-warn);
  border-color: transparent;
}
.badge--info {
  background: var(--c-info-50);
  color: var(--c-info);
  border-color: transparent;
}
.badge--brand {
  background: var(--c-brand-50);
  color: var(--c-brand);
  border-color: var(--c-brand-100);
}
.badge--neutral {
  background: var(--c-surface-3);
  color: var(--c-ink-2);
  border-color: var(--c-border);
}
.badge .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  display: inline-block;
}

/* ============================================
   Tables
   ============================================ */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  border-radius: 0 0 calc(var(--r-lg) - 1px) calc(var(--r-lg) - 1px);
}
.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13.5px;
}
.table thead th {
  position: sticky;
  top: 0;
  background: var(--c-brand);
  color: rgba(255, 255, 255, 0.9);
  font-weight: 600;
  font-size: 11.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: left;
  padding: 10px 16px;
  border-bottom: 1px solid var(--c-brand-700);
  white-space: nowrap;
}
.table tbody td {
  padding: var(--cell-py) 16px;
  border-bottom: 1px solid var(--c-border-subtle);
  color: var(--c-ink);
  vertical-align: middle;
  height: var(--row-h);
}
.table tbody tr:last-child td {
  border-bottom: none;
}
.table tbody tr:last-child td:first-child {
  border-bottom-left-radius: calc(var(--r-lg) - 1px);
}
.table tbody tr:last-child td:last-child {
  border-bottom-right-radius: calc(var(--r-lg) - 1px);
}
.table tbody tr {
  transition: background 0.08s;
}
.table tbody tr:hover {
  background: var(--c-surface-2);
}
.table tfoot tr {
  background: var(--c-surface-2);
  border-top: 2px solid var(--c-border-strong);
}
.table tfoot td {
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--c-ink-2);
  border-bottom: none;
}
.table td.num,
.table th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}
.table td.actions {
  text-align: right;
  white-space: nowrap;
}
.table td.actions .btn {
  margin-left: 4px;
}
.table .mono {
  font-family: var(--ff-mono);
  font-size: 12.5px;
}
.table .primary-col {
  font-weight: 500;
  color: var(--c-ink);
}

/* ============================================
   KPI cards
   ============================================ */
.kpi {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
  overflow: hidden;
}
.kpi::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--c-accent);
}
.kpi--primary {
  background: linear-gradient(135deg, var(--c-brand) 0%, var(--c-brand-500) 100%);
  border-color: var(--c-brand-700);
  color: #fff;
}
.kpi--primary::before {
  background: var(--c-accent);
  height: 4px;
}
.kpi--primary .kpi__label {
  color: rgba(255, 255, 255, 0.75);
}
.kpi--primary .kpi__value {
  color: #fff;
}
.kpi__label {
  font-size: 12px;
  color: var(--c-ink-3);
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
}
.kpi__label svg {
  width: 14px;
  height: 14px;
  color: var(--c-accent);
}
.kpi--primary .kpi__label svg {
  color: rgba(255, 255, 255, 0.85);
}
.kpi__value {
  font-size: 28px;
  font-weight: 800;
  font-style: italic;
  font-family: var(--ff-display);
  color: var(--c-brand);
  letter-spacing: -0.01em;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
.kpi__delta {
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--c-ink-3);
  margin-top: 2px;
}
.kpi--primary .kpi__delta {
  color: rgba(255, 255, 255, 0.7);
}
.kpi--primary .kpi__delta .up {
  color: #86efac;
}
.kpi--primary .kpi__delta .down {
  color: #fca5a5;
}
.kpi__delta .up {
  color: var(--c-success);
  font-weight: 500;
}
.kpi__delta .down {
  color: var(--c-danger);
  font-weight: 500;
}
.kpi__spark {
  position: absolute;
  right: 10px;
  bottom: 10px;
  opacity: 0.9;
}

/* ============================================
   Empty state
   ============================================ */
.empty {
  padding: 48px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  color: var(--c-ink-3);
}
.empty__icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--c-surface-3);
  color: var(--c-ink-3);
  display: grid;
  place-items: center;
  margin-bottom: 4px;
}
.empty h4 {
  margin: 0;
  font-size: 14px;
  color: var(--c-ink);
  font-weight: 600;
}
.empty p {
  margin: 0;
  font-size: 13px;
  max-width: 360px;
}

/* ============================================
   Alerts
   ============================================ */
.alert {
  display: flex;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--c-border);
  background: var(--c-surface-2);
  font-size: 13px;
  align-items: flex-start;
}
.alert svg {
  flex: none;
  width: 18px;
  height: 18px;
  margin-top: 1px;
}
.alert--danger {
  background: var(--c-danger-50);
  border-color: transparent;
  color: var(--c-danger);
}
.alert--warn {
  background: var(--c-warn-50);
  border-color: transparent;
  color: var(--c-warn);
}
.alert--info {
  background: var(--c-info-50);
  border-color: transparent;
  color: var(--c-info);
}
.alert--success {
  background: var(--c-success-50);
  border-color: transparent;
  color: var(--c-success);
}
.alert b {
  color: inherit;
}

/* ============================================
   Modal
   ============================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: none;
  place-items: center;
  z-index: 100;
  backdrop-filter: blur(2px);
}
.modal-overlay.is-open {
  display: grid;
  animation: fade 0.12s ease;
}
.modal {
  background: var(--c-surface);
  border-radius: 12px;
  width: min(560px, 94vw);
  box-shadow: var(--s-lg);
  overflow: hidden;
  animation: rise 0.14s ease;
  display: flex;
  flex-direction: column;
  max-height: 92dvh;
}
.modal--lg { width: min(760px, 94vw); }
.modal__header {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--c-border-subtle);
}
.modal__header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--c-brand);
}
.modal__header .close {
  margin-left: auto;
}
.modal__body {
  padding: 18px 20px;
  overflow-y: auto;
  flex: 1;
}
.modal__footer {
  padding: 12px 20px;
  border-top: 1px solid var(--c-border-subtle);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  background: var(--c-surface-2);
}

@keyframes fade {
  from {
    opacity: 0;
  }
}
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

/* ============================================
   Toasts
   ============================================ */
.toasts {
  position: fixed;
  top: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
  max-width: 360px;
}
.toast {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 10px;
  box-shadow: var(--s-md);
  padding: 12px 14px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  animation: slideIn 0.2s ease;
}
.toast svg {
  width: 18px;
  height: 18px;
  flex: none;
  margin-top: 1px;
}
.toast--success svg {
  color: var(--c-success);
}
.toast--danger svg {
  color: var(--c-danger);
}
.toast--info svg {
  color: var(--c-info);
}
.toast__body b {
  display: block;
  font-size: 13px;
  margin-bottom: 2px;
}
.toast__body span {
  font-size: 12.5px;
  color: var(--c-ink-3);
}
@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(8px);
  }
}

/* Tweaks panel */
.tweaks {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 280px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 12px;
  box-shadow: var(--s-lg);
  z-index: 300;
  overflow: hidden;
  display: none;
}
.tweaks.is-open {
  display: block;
}
.tweaks__header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--c-border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  font-size: 13px;
}
.tweaks__body {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.tweaks__row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.tweaks__row label {
  font-size: 12px;
  color: var(--c-ink-3);
  font-weight: 500;
}
.segmented {
  display: flex;
  border: 1px solid var(--c-border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--c-surface-2);
}
.segmented button {
  flex: 1;
  padding: 7px 0;
  background: transparent;
  border: none;
  font-size: 12.5px;
  color: var(--c-ink-2);
  cursor: pointer;
  font-weight: 500;
}
.segmented button.is-on {
  background: var(--c-surface);
  color: var(--c-brand);
  box-shadow: inset 0 0 0 1px var(--c-brand-100);
}

/* ============================================
   Calendar
   ============================================ */
.calendar {
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--c-surface);
}
.calendar__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--c-border-subtle);
}
.calendar__head h4 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  text-transform: capitalize;
  color: var(--c-brand);
}
.calendar__head .nav-btns {
  display: flex;
  gap: 4px;
}
.calendar__head .legend {
  margin-left: auto;
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 11.5px;
  color: var(--c-ink-3);
}
.calendar__head .legend .swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  display: inline-block;
  margin-right: 4px;
  vertical-align: middle;
}
.calendar__grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}
.calendar__dow {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--c-ink-3);
  padding: 8px 10px;
  background: var(--c-surface-2);
  border-bottom: 1px solid var(--c-border-subtle);
  border-right: 1px solid var(--c-border-subtle);
}
.calendar__dow:last-child {
  border-right: none;
}
.calendar__cell {
  min-height: 92px;
  padding: 8px;
  border-right: 1px solid var(--c-border-subtle);
  border-bottom: 1px solid var(--c-border-subtle);
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
  background: var(--c-surface);
  cursor: pointer;
  font-size: 12px;
}
.calendar__cell:nth-child(7n) {
  border-right: none;
}
.calendar__cell:hover {
  background: var(--c-surface-2);
}
.calendar__cell.is-outside {
  color: var(--c-ink-4);
  background: var(--c-surface-2);
}
.calendar__cell.is-today .day-num {
  background: var(--c-brand);
  color: #fff;
  border-radius: 999px;
  width: 22px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  font-weight: 600;
}
.calendar__cell.is-holiday {
  background: var(--c-warn-50);
}
.calendar__cell .day-num {
  font-weight: 500;
  font-size: 12px;
  color: var(--c-ink-2);
  font-variant-numeric: tabular-nums;
}
.calendar__cell.is-outside .day-num {
  color: var(--c-ink-4);
}
.calendar__event {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--c-brand-50);
  color: var(--c-brand);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-left: 2px solid var(--c-brand);
}
.calendar__event--warn {
  background: var(--c-warn-50);
  color: var(--c-warn);
  border-color: var(--c-warn);
}
.calendar__event--ok {
  background: var(--c-success-50);
  color: var(--c-success);
  border-color: var(--c-success);
}
.calendar__more {
  font-size: 11px;
  color: var(--c-ink-3);
  font-weight: 500;
}

/* Misc utilities */
.mono {
  font-family: var(--ff-mono);
}
.tnum {
  font-variant-numeric: tabular-nums;
}
.muted {
  color: var(--c-ink-3);
}
.divider {
  height: 1px;
  background: var(--c-border-subtle);
  margin: 16px 0;
}
.right {
  margin-left: auto;
}
.hide {
  display: none !important;
}
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--c-surface-3);
  border: 1px solid var(--c-border);
  border-radius: 999px;
  padding: 2px 4px 2px 10px;
  font-size: 12px;
  color: var(--c-ink);
  font-weight: 500;
}
.tag-chip button {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--c-ink-3);
  padding: 0 4px;
  display: grid;
  place-items: center;
  border-radius: 999px;
}
.tag-chip button:hover {
  background: var(--c-border-strong);
  color: var(--c-ink);
}

@media (max-width: 960px) {
  .app { 
    grid-template-columns: var(--sidebar-w) 1fr; 
  }
  .app[data-collapsed="true"] { 
    grid-template-columns: 0 1fr; 
  }
  .sidebar { 
    position: sticky; 
    left: auto;
    width: 100%; 
    min-width: 0; 
    overflow: hidden;
    box-shadow: none;
    z-index: 50;
  }
  .topbar { padding: 0 12px; }
  .page { padding: 16px 12px 40px; }

  /* Card header: busca ocupa largura total */
  .card__header { flex-wrap: wrap; }
  .card__header .actions { width: 100%; }
  .card__header .actions .input-icon { width: 100% !important; }
}

/* Tabela: ocultar colunas secundárias em mobile */
@media (max-width: 700px) {
  #tabelaUsuarios th:nth-child(2),
  #tabelaUsuarios td:nth-child(2),
  #tabelaUsuarios th:nth-child(4),
  #tabelaUsuarios td:nth-child(4) { display: none; }

  /* Botões de ação: empilhar verticalmente */
  .table td.actions {
    white-space: normal;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    height: auto;
    padding: 8px 12px;
  }
  .table td.actions .btn {
    margin-left: 0;
    min-height: 32px;
    padding: 0 10px;
  }
}

@media (max-width: 500px) {
  .page { padding: 12px 6px 40px; }

  /* Page header: empilha verticalmente em telas muito estreitas */
  .page__header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .page__header .page__actions {
    width: 100%;
  }
  .page__header .page__actions .btn {
    width: 100%;
    justify-content: center;
  }
}

/* ============================================
   FullCalendar Overrides
   ============================================ */
.fc {
  --fc-border-color: var(--c-border-subtle);
  --fc-page-bg-color: var(--c-surface);
  font-family: var(--ff-sans);
}
.fc .fc-toolbar-title {
  font-family: var(--ff-display);
  color: var(--c-brand);
  font-weight: 700;
  font-size: 18px;
}
.fc .fc-button-primary {
  background: var(--c-brand);
  border-color: var(--c-brand);
  font-size: 13px;
  text-transform: capitalize;
}
.fc .fc-button-primary:hover {
  background: var(--c-brand-700);
  border-color: var(--c-brand-700);
}
.fc .fc-daygrid-day.fc-day-today {
  background: var(--c-brand-50);
}
.fc .fc-event {
  background: var(--c-brand-50);
  color: var(--c-brand);
  border: none;
  border-left: 2px solid var(--c-brand);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 11px;
  font-weight: 600;
  margin: 1px 2px;
}
/* FullCalendar legend */
.fc-legend {
  display: flex;
  flex-wrap: nowrap;
  gap: 14px;
  align-items: center;
  font-size: 12px;
  color: var(--c-ink-3);
  margin-right: 8px;
}
.fc-legend__row {
  display: contents; /* itens ficam inline no flex pai */
}

@media (max-width: 870px) {
  .fc-legend {
    flex-direction: column;
    gap: 6px;
    align-items: flex-end;
  }
  .fc-legend__row {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
  }
}

/* ============================================
   Select2 Tag-chip Overrides
   ============================================ */
.select2-container--default .select2-selection--multiple {
  border: 1px solid var(--c-border-strong) !important;
  border-radius: 8px !important;
  min-height: 42px;
  padding: 4px 8px !important;
  background: var(--c-surface);
  transition: border-color 0.12s, box-shadow 0.12s;
}
.select2-container--default.select2-container--focus .select2-selection--multiple {
  border-color: var(--c-brand-500) !important;
  box-shadow: var(--s-focus);
}
.select2-selection__choice {
  background: var(--c-surface-3) !important;
  border: 1px solid var(--c-border) !important;
  border-radius: 999px !important;
  padding: 2px 10px !important;
  font-size: 12px !important;
  color: var(--c-ink) !important;
  margin: 4px 4px 4px 0 !important;
  display: flex !important;
  align-items: center;
  gap: 6px;
}
.select2-selection__choice__remove {
  color: var(--c-ink-3) !important;
  border: none !important;
  background: transparent !important;
  order: 2;
  margin: 0 !important;
  padding: 0 !important;
  font-size: 14px !important;
}
.select2-selection__choice__remove:hover {
  color: var(--c-danger) !important;
}
.select2-search__field {
  margin-top: 6px !important;
  border: none !important;
  outline: none !important;
}

/* ============================================
   Utilities
   ============================================ */
.mb-1 { margin-bottom: 0.25rem !important; }
.mb-2 { margin-bottom: 0.5rem !important; }
.mb-3 { margin-bottom: 1rem !important; }
.mb-4 { margin-bottom: 1.5rem !important; }
.mb-5 { margin-bottom: 3rem !important; }
.mt-1 { margin-top: 0.25rem !important; }
.mt-2 { margin-top: 0.5rem !important; }
.mt-3 { margin-top: 1rem !important; }
.mt-4 { margin-top: 1.5rem !important; }
.mt-5 { margin-top: 3rem !important; }
.mx-auto { margin-left: auto !important; margin-right: auto !important; }
.w-100 { width: 100% !important; }
.d-flex { display: flex !important; }
.justify-content-between { justify-content: space-between !important; }
.align-items-center { align-items: center !important; }
.gap-2 { gap: 0.5rem !important; }
.gap-3 { gap: 1rem !important; }

@media (min-width: 961px) { .d-lg-none { display: none !important; } }

/* ============================================
   Dark Mode Overrides
   ============================================ */
[data-theme="dark"] .sidebar,
[data-theme="dark"] .btn--primary,
[data-theme="dark"] .checkbox input:checked,
[data-theme="dark"] .toggle.is-on,
[data-theme="dark"] .table thead th,
[data-theme="dark"] .calendar__cell.is-today .day-num,
[data-theme="dark"] .fc .fc-button-primary {
  background: var(--c-surface);
}

[data-theme="dark"] .btn--success,
[data-theme="dark"] #btnEnviarEscala {
  background: #17794c;
  border-color: #17794c;
  color: #fff;
}

[data-theme="dark"] .select2-container .select2-selection {
  background: var(--c-surface);
  border: 1px solid var(--c-border-strong);
  border-radius: 7px;
}

[data-theme="dark"] .select2-selection__rendered,
[data-theme="dark"] .select2-selection__placeholder {
  background: transparent !important;
  border: none !important;
  color: var(--c-ink) !important;
}

[data-theme="dark"] .select2-dropdown {
  background: var(--c-surface);
  border: 1px solid var(--c-border-strong);
}

[data-theme="dark"] .select2-search--dropdown {
  background: var(--c-surface);
}

[data-theme="dark"] .select2-search__field {
  background: var(--c-surface-2) !important;
  border: 1px solid var(--c-border-strong) !important;
  color: var(--c-ink) !important;
}

[data-theme="dark"] .select2-results__option {
  color: var(--c-ink);
  background: var(--c-surface);
}

[data-theme="dark"] .select2-results__option--highlighted,
[data-theme="dark"] .select2-results__option--selectable:hover,
[data-theme="dark"] .select2-results__option[aria-selected="true"] {
  background: var(--c-brand-50) !important;
  color: var(--c-brand) !important;
}
