:root {
  --font-base: "Manrope", "Segoe UI", "Arial", sans-serif;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 8px 22px rgba(12, 21, 45, 0.08);
  --shadow-md: 0 16px 40px rgba(12, 21, 45, 0.14);

  --color-bg: #eef2f8;
  --color-surface: #ffffff;
  --color-surface-soft: #f8faff;
  --color-border: #dbe3f0;
  --color-text: #162036;
  --color-text-soft: #5b6783;

  --color-brand-primary: #00294d;
  --color-brand-secondary: #423589;

  --color-success: #0d8f60;
  --color-warning: #b77915;
  --color-danger: #be243b;
  --color-info: #2563eb;

  --sidebar-width: 286px;
  --sidebar-bg: #082f61;
  --sidebar-accent: #423589;
  --sidebar-text: #e8efff;

  --sc-background: 0 0% 100%;
  --sc-foreground: 222.2 84% 4.9%;
  --sc-card: 0 0% 100%;
  --sc-card-foreground: 222.2 84% 4.9%;
  --sc-muted: 210 40% 96.1%;
  --sc-muted-foreground: 215.4 16.3% 46.9%;
  --sc-border: 214.3 31.8% 91.4%;
  --sc-input: 214.3 31.8% 91.4%;
  --sc-primary: 221.2 83.2% 53.3%;
  --sc-primary-foreground: 210 40% 98%;
  --sc-secondary: 210 40% 96.1%;
  --sc-secondary-foreground: 222.2 47.4% 11.2%;
  --sc-destructive: 0 84.2% 60.2%;
  --sc-destructive-foreground: 210 40% 98%;
  --sc-ring: 221.2 83.2% 53.3%;
  --sc-radius: 0.5rem;
}

body[data-sidebar-tone="violet"] {
  --sidebar-bg: #423589;
  --sidebar-accent: #6d55dc;
}

body[data-sidebar-tone="slate"] {
  --sidebar-bg: #22385f;
  --sidebar-accent: #3a78d2;
}

html[data-ui-theme="dark"],
body[data-ui-theme="dark"] {
  --sc-background: 222.2 84% 4.9%;
  --sc-foreground: 210 40% 98%;
  --sc-card: 222.2 47.4% 11.2%;
  --sc-card-foreground: 210 40% 98%;
  --sc-muted: 217.2 32.6% 17.5%;
  --sc-muted-foreground: 215 20.2% 65.1%;
  --sc-border: 217.2 32.6% 17.5%;
  --sc-input: 217.2 32.6% 17.5%;
  --sc-primary: 217.2 91.2% 59.8%;
  --sc-primary-foreground: 222.2 47.4% 11.2%;
  --sc-secondary: 217.2 32.6% 17.5%;
  --sc-secondary-foreground: 210 40% 98%;
  --sc-destructive: 0 62.8% 30.6%;
  --sc-destructive-foreground: 210 40% 98%;
  --sc-ring: 224.3 76.3% 48%;

  --color-bg: #020817;
  --color-surface: #0f172a;
  --color-surface-soft: #111827;
  --color-border: #1f2937;
  --color-text: #e5e7eb;
  --color-text-soft: #94a3b8;

  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-base);
  color: hsl(var(--sc-foreground));
  background: hsl(var(--sc-background));
  --sidebar-accent: var(--app-sidebar-accent);
  --sidebar-bg: var(--app-sidebar-bg);
  --color-primary: var(--app-color-primary);
  --color-primary-content: var(--app-color-primary-content);
  --color-secondary: var(--app-color-secondary);
  --color-secondary-content: var(--app-color-secondary-content);
  --color-accent: var(--app-color-accent);
  --color-accent-content: var(--app-color-accent-content);
  --sc-primary: var(--app-sc-primary);
  --sc-primary-foreground: var(--app-sc-primary-foreground);
  --sc-secondary: var(--app-sc-secondary);
  --sc-secondary-foreground: var(--app-sc-secondary-foreground);
  --sc-ring: var(--app-sc-ring);
}

body [data-theme] {
  --color-primary: var(--app-color-primary);
  --color-primary-content: var(--app-color-primary-content);
  --color-secondary: var(--app-color-secondary);
  --color-secondary-content: var(--app-color-secondary-content);
  --color-accent: var(--app-color-accent);
  --color-accent-content: var(--app-color-accent-content);
}

a {
  color: inherit;
  text-decoration: none;
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

p.label {
  white-space: normal;
  overflow-wrap: anywhere;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  transition: grid-template-columns 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 6px 0 40px rgba(10, 18, 35, 0.2);
  z-index: 50;
  overflow-x: hidden;
  transition: width 0.28s cubic-bezier(0.2, 0.8, 0.2, 1), padding 0.24s ease, box-shadow 0.24s ease;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
}

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

.brand-title {
  font-size: 0.94rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-subtitle {
  font-size: 0.75rem;
  color: rgba(232, 239, 255, 0.8);
}

.icon-btn {
  border: 0;
  border-radius: 11px;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  cursor: pointer;
  transition: 0.2s ease;
}

.sidebar .icon-btn {
  background: transparent;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

#toggleSidebar.icon-btn {
  border: 1px solid hsl(var(--sc-border));
  background: hsl(var(--sc-card));
  color: hsl(var(--sc-foreground));
}

#toggleSidebar.icon-btn:hover {
  background: hsl(var(--sc-muted));
  border-color: hsl(var(--sc-ring));
  color: hsl(var(--sc-primary));
}

.sidebar-nav {
  display: grid;
  gap: 6px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  color: rgba(232, 239, 255, 0.94);
  border-radius: var(--radius-sm);
  border: 0;
  transition: 0.2s ease;
  font-weight: 600;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.11);
  border-color: transparent;
}

.nav-link.active {
  background: var(--sidebar-accent);
  border-color: transparent;
  box-shadow: 0 8px 20px rgba(10, 14, 36, 0.35);
}

.nav-icon {
  width: 22px;
  text-align: center;
  opacity: 0.92;
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
}

.sidebar-footer-title {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(232, 239, 255, 0.78);
}

.theme-palette {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.theme-chip {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 0;
  cursor: pointer;
  padding: 0;
  background: transparent;
}

.theme-chip.ocean { background: linear-gradient(150deg, #00294d, #423589); }
.theme-chip.violet { background: linear-gradient(150deg, #2a1f66, #6d55dc); }
.theme-chip.slate { background: linear-gradient(150deg, #1f2b44, #3a78d2); }

.theme-chip.is-active {
  transform: scale(1.08);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.22);
}

.theme-custom-form {
  margin-top: 10px;
  display: grid;
  gap: 6px;
}

.theme-custom-label {
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(232, 239, 255, 0.78);
}

.theme-custom-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.theme-color-input {
  width: 38px;
  height: 30px;
  border: 1px solid rgba(232, 239, 255, 0.25);
  border-radius: 8px;
  background: transparent;
  padding: 2px;
  cursor: pointer;
}

.theme-color-input.is-active {
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.25);
}

.theme-custom-apply {
  border: 1px solid rgba(232, 239, 255, 0.28);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(232, 239, 255, 0.95);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 4px 12px;
  cursor: pointer;
  transition: all 0.18s ease;
}

.theme-custom-apply:hover {
  background: rgba(255, 255, 255, 0.16);
}

.theme-custom-apply.is-active {
  border-color: rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.2);
}

.main {
  padding: 22px;
  background: hsl(var(--sc-background));
  display: flex;
  flex-direction: column;
}

.topbar {
  border: 0;
  background: transparent;
  backdrop-filter: none;
  border-radius: 0;
  padding: 10px 0 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  box-shadow: none;
  margin-bottom: 10px;
}

.topbar-title {
  font-size: 1.28rem;
  font-weight: 800;
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-right {
  margin-left: auto;
}

.topbar-greeting {
  color: hsl(var(--sc-muted-foreground));
  font-size: 0.92rem;
  font-weight: 600;
  max-width: min(48vw, 280px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-footer {
  margin-top: auto;
  padding: 0.8rem 0 0.35rem;
  border-top: 1px solid hsl(var(--sc-border));
  color: hsl(var(--sc-muted-foreground));
  font-size: 0.78rem;
  text-align: center;
}

.app-footer p {
  margin: 0;
}

.app-footer a {
  color: hsl(var(--sc-primary));
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.app-footer a:hover {
  opacity: 0.88;
}

input[type="text"],
input[type="number"],
input[type="email"],
input[type="date"],
input[type="password"],
select,
textarea {
  width: 100%;
  border: 1px solid hsl(var(--sc-input));
  background: hsl(var(--sc-background));
  color: hsl(var(--sc-foreground));
  border-radius: 11px;
  padding: 10px 12px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: hsl(var(--sc-ring));
  box-shadow: 0 0 0 3px hsl(var(--sc-ring) / 0.25);
  outline: none;
}

/* Avoid double border/ring on inputs nested inside daisyUI `.input` wrappers */
.input > input {
  width: 100%;
  min-width: 0;
  border: 0 !important;
  background: transparent !important;
  border-radius: 0 !important;
  padding: 0 !important;
  box-shadow: none !important;
}

.input > input:focus {
  border: 0 !important;
  box-shadow: none !important;
  outline: none !important;
}

/* DataTables theme alignment */
div.dt-container .dt-layout-row .dt-length,
div.dt-container .dt-layout-row .dt-search,
div.dt-container .dt-layout-row .dt-info,
div.dt-container .dt-layout-row .dt-paging {
  color: hsl(var(--sc-muted-foreground));
}

div.dt-container .dt-search input {
  border: 1px solid hsl(var(--sc-input));
  border-radius: 11px;
  background: hsl(var(--sc-background));
  color: hsl(var(--sc-foreground));
}

div.dt-container .dt-paging .dt-paging-button {
  color: hsl(var(--sc-foreground)) !important;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
}

div.dt-container .dt-paging .dt-paging-button:hover {
  color: hsl(var(--sc-primary-foreground)) !important;
  border-color: hsl(var(--sc-primary));
  background: hsl(var(--sc-primary));
}

div.dt-container .dt-paging .dt-paging-button.current,
div.dt-container .dt-paging .dt-paging-button.current:hover {
  color: hsl(var(--sc-foreground)) !important;
  border-color: hsl(var(--sc-border));
  background: hsl(var(--sc-muted));
}

div.dt-container .dt-paging .dt-paging-button.disabled,
div.dt-container .dt-paging .dt-paging-button.disabled:hover,
div.dt-container .dt-paging .dt-paging-button.disabled:active {
  color: hsl(var(--sc-muted-foreground) / 0.58) !important;
  border-color: transparent;
  background: transparent;
}

/* Keep DataTable pagination anchored at the bottom when this wrapper class is used */
.table-wrap-paged-bottom {
  min-height: min(60vh, 680px);
}

.table-wrap-paged-bottom .dt-container {
  min-height: inherit;
  display: flex;
  flex-direction: column;
}

.table-wrap-paged-bottom .dt-container .dt-layout-row:last-child {
  margin-top: auto;
  position: sticky;
  bottom: 0;
  z-index: 5;
  padding-top: 0.6rem;
  border-top: 1px solid hsl(var(--sc-border));
  background: hsl(var(--sc-card));
}

.errorlist {
  list-style: none;
  margin: 0;
  padding: 0;
  color: var(--color-danger);
  font-size: 0.86rem;
}

.flash-list {
  display: grid;
  gap: 9px;
  margin-bottom: 16px;
}

.flash {
  border-radius: 12px;
  border: 1px solid hsl(var(--sc-border));
  padding: 11px 13px;
  font-weight: 600;
  background: hsl(var(--sc-card));
  color: hsl(var(--sc-card-foreground));
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  opacity: 1;
  transform: translateY(0);
  max-height: 140px;
  overflow: hidden;
  transition:
    opacity 0.25s ease,
    transform 0.25s ease,
    max-height 0.25s ease,
    padding 0.25s ease,
    margin 0.25s ease,
    border-width 0.25s ease;
}

.flash-text {
  flex: 1;
  min-width: 0;
}

.flash-close {
  border: 0;
  border-radius: 8px;
  width: 24px;
  height: 24px;
  line-height: 24px;
  text-align: center;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  color: inherit;
  background: transparent;
  opacity: 0.72;
  transition: background 0.2s ease, opacity 0.2s ease;
}

.flash-close:hover {
  opacity: 1;
  background: rgba(15, 23, 42, 0.08);
}

html[data-ui-theme="dark"] .flash-close:hover,
body[data-ui-theme="dark"] .flash-close:hover {
  background: rgba(148, 163, 184, 0.18);
}

.flash.flash-leaving {
  opacity: 0;
  transform: translateY(-8px);
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  margin: 0;
  border-width: 0;
}

.flash.success { border-color: rgba(13, 143, 96, 0.35); background: rgba(13, 143, 96, 0.09); color: #0b6847; }
.flash.warning { border-color: rgba(183, 121, 21, 0.35); background: rgba(183, 121, 21, 0.09); color: #80530f; }
.flash.error { border-color: rgba(190, 36, 59, 0.35); background: rgba(190, 36, 59, 0.09); color: #8d1a2c; }
.flash.info { border-color: rgba(37, 99, 235, 0.35); background: rgba(37, 99, 235, 0.09); color: #1f4fb8; }

.file-input-enhanced {
  width: 100%;
  border: 1px solid hsl(var(--sc-input));
  border-radius: 12px;
  background: hsl(var(--sc-background));
  color: hsl(var(--sc-foreground));
  padding: 8px 10px;
}

.file-input-enhanced::file-selector-button {
  border: 0;
  border-radius: 10px;
  padding: 8px 12px;
  margin-right: 10px;
  background: linear-gradient(120deg, var(--color-brand-secondary), #4f73c6);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.switch {
  position: relative;
  display: inline-flex;
}

.switch-input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.switch-slider {
  width: 58px;
  height: 32px;
  border-radius: 999px;
  background: #c3cede;
  position: relative;
  transition: 0.2s ease;
  cursor: pointer;
}

.switch-slider::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 4px 12px rgba(21, 30, 57, 0.2);
  transition: 0.2s ease;
}

.switch-input:checked + .switch-slider {
  background: linear-gradient(120deg, #0d8f60, #17b680);
}

.switch-input:checked + .switch-slider::after {
  transform: translateX(26px);
}

.overlay {
  display: none;
}

.app-loader {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100dvw;
  min-width: 100vw;
  height: 100dvh;
  min-height: 100vh;
  background: #ffffff;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.28s ease, visibility 0.28s ease;
}

html[data-ui-theme="dark"] .app-loader,
body[data-ui-theme="dark"] .app-loader {
  background: #020817;
}

.app-loader__logo {
  /* Usa tamanho original da logo (100x101) e apenas reduz em telas pequenas. */
  width: auto;
  max-width: min(100px, 36vw);
  max-height: min(101px, 36vh);
  height: auto;
  object-fit: contain;
  object-position: center;
  display: block;
  animation: app-loader-pulse 1.25s ease-in-out infinite;
}

body:not(.app-loaded) {
  overflow: hidden;
}

body:not(.app-loaded) .app-shell {
  pointer-events: none;
}

body.app-loaded .app-loader {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

@keyframes app-loader-pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 0.9;
  }
  50% {
    transform: scale(1.04);
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .app-loader {
    transition: none;
  }

  .app-loader__logo {
    animation: none;
  }
}

.mobile-only {
  display: none;
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-103%);
    transition: transform 0.25s ease;
    width: min(92vw, 320px);
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .overlay {
    position: fixed;
    inset: 0;
    background: rgba(4, 10, 20, 0.45);
    z-index: 45;
  }

  body.sidebar-open .overlay {
    display: block;
  }

  .mobile-only {
    display: inline-flex;
  }

  .topbar {
    padding: 10px 0 12px;
  }

  .main {
    padding: 14px;
  }

}

body.sidebar-compact .app-shell {
  grid-template-columns: 92px minmax(0, 1fr);
}

body.sidebar-compact .sidebar {
  width: 92px;
}

body.sidebar-compact .brand-title,
body.sidebar-compact .brand-subtitle,
body.sidebar-compact .sidebar-footer,
body.sidebar-compact .sidebar-label {
  display: none;
}

body.sidebar-compact .sidebar-header {
  justify-content: center;
}

body.sidebar-compact .nav-link {
  justify-content: center;
  padding: 12px 8px;
}

body.sidebar-compact .nav-icon {
  width: auto;
}

@media (max-width: 860px) {
  body.sidebar-compact .app-shell {
    grid-template-columns: 1fr;
  }

  body.sidebar-compact .sidebar {
    width: min(92vw, 320px);
  }

  body.sidebar-compact .brand-title,
  body.sidebar-compact .brand-subtitle,
  body.sidebar-compact .sidebar-footer,
  body.sidebar-compact .sidebar-label {
    display: initial;
  }
}

/* Sidebar tree + profile menu */
.logo-zone {
  align-items: flex-start;
}

.logo-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.logo-picture {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
}

.logo-mark {
  width: 44px;
  height: 44px;
  object-fit: contain;
}

.sidebar-nav-tree {
  gap: 10px;
}

.nav-svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.sidebar-profile {
  position: relative;
  margin-top: auto;
}

.profile-trigger {
  width: 100%;
  border: 0;
  background: transparent;
  border-radius: 13px;
  color: var(--sidebar-text);
  padding: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: background 0.2s ease, padding 0.24s ease;
}

.profile-trigger:hover {
  background: rgba(255, 255, 255, 0.12);
}

.profile-avatar-wrap {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  overflow: hidden;
  border: 0;
  background: rgba(255, 255, 255, 0.2);
  display: inline-flex;
}

.profile-avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-meta {
  display: grid;
  text-align: left;
  min-width: 0;
}

.profile-meta strong,
.profile-meta small {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-meta strong {
  font-size: 0.88rem;
}

.profile-meta small {
  color: rgba(232, 239, 255, 0.78);
  font-size: 0.75rem;
}

.profile-caret {
  margin-left: auto;
  opacity: 0.86;
}

.profile-dropdown {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 8px);
  border: 0;
  border-radius: 13px;
  padding: 10px;
  background: rgba(6, 13, 33, 0.96);
  box-shadow: 0 16px 28px rgba(5, 12, 30, 0.4);
  display: grid;
  gap: 8px;
  opacity: 0;
  transform: translateY(8px) scale(0.98);
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.24s cubic-bezier(0.2, 0.8, 0.2, 1), visibility 0.22s ease;
}

.sidebar-profile.open .profile-dropdown {
  opacity: 1;
  transform: translateY(0) scale(1);
  visibility: visible;
  pointer-events: auto;
}

.profile-action {
  display: inline-flex;
  width: 100%;
  border: 0;
  border-radius: 10px;
  padding: 8px 10px;
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
  font-size: 0.87rem;
  font-weight: 600;
}

.profile-action:hover {
  background: rgba(255, 255, 255, 0.12);
}

.profile-action-logout {
  cursor: pointer;
  text-align: left;
}

.profile-tone-section {
  border: 0;
  border-radius: 11px;
  background: transparent;
  padding: 9px;
}

.profile-tone-title {
  font-size: 0.75rem;
  color: rgba(232, 239, 255, 0.82);
  margin-bottom: 8px;
}

.profile-tone-section .theme-palette form {
  margin: 0;
}

body.sidebar-compact .sidebar-header {
  justify-content: center;
}

body.sidebar-compact .logo-wrap {
  width: 100%;
  justify-content: center;
}

body.sidebar-compact #toggleCompact {
  display: none;
}

body.sidebar-compact .sidebar-profile {
  display: block;
  margin-top: auto;
}

body.sidebar-compact .profile-meta,
body.sidebar-compact .profile-caret {
  display: none;
}

body.sidebar-compact .profile-trigger {
  width: 44px;
  height: 44px;
  margin: 0 auto;
  padding: 0;
  justify-content: center;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

body.sidebar-compact .profile-avatar-wrap {
  width: 34px;
  height: 34px;
}

@keyframes sidebar-item-reveal {
  from {
    opacity: 0;
    transform: translateX(-8px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@media (hover: hover) and (pointer: fine) {
  body.sidebar-compact .sidebar:hover {
    width: var(--sidebar-width);
  }

  body.sidebar-compact .sidebar:hover .brand-title,
  body.sidebar-compact .sidebar:hover .brand-subtitle,
  body.sidebar-compact .sidebar:hover .sidebar-label {
    display: initial;
  }

  body.sidebar-compact .sidebar:hover .sidebar-footer {
    display: grid;
  }

  body.sidebar-compact .sidebar:hover .sidebar-header {
    justify-content: space-between;
  }

  body.sidebar-compact .sidebar:hover .logo-wrap {
    width: auto;
    justify-content: flex-start;
  }

  body.sidebar-compact .sidebar:hover #toggleCompact {
    display: inline-flex;
  }

  body.sidebar-compact .sidebar:hover .nav-link {
    justify-content: flex-start;
    padding: 12px;
  }

  body.sidebar-compact .sidebar:hover .nav-icon {
    width: 22px;
  }

  body.sidebar-compact .sidebar:hover .logo-picture {
    display: inline-flex;
  }

  body.sidebar-compact .sidebar:hover .logo-mark {
    display: block;
  }

  body.sidebar-compact .sidebar:hover .profile-meta {
    display: grid;
  }

  body.sidebar-compact .sidebar:hover .sidebar-profile {
    display: block;
  }

  body.sidebar-compact .sidebar:hover .profile-caret {
    display: inline;
  }

  body.sidebar-compact .sidebar:hover .profile-trigger {
    justify-content: flex-start;
  }

  body.sidebar-compact.sidebar-hover-expanded .app-shell {
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  }

  body.sidebar-compact.sidebar-hover-expanded .sidebar {
    width: var(--sidebar-width);
  }

  body.sidebar-compact.sidebar-hover-expanded .brand-title,
  body.sidebar-compact.sidebar-hover-expanded .brand-subtitle,
  body.sidebar-compact.sidebar-hover-expanded .sidebar-label {
    display: initial;
  }

  body.sidebar-compact.sidebar-hover-expanded .sidebar-footer {
    display: grid;
  }

  body.sidebar-compact.sidebar-hover-expanded .sidebar-header {
    justify-content: space-between;
  }

  body.sidebar-compact.sidebar-hover-expanded .logo-wrap {
    width: auto;
    justify-content: flex-start;
  }

  body.sidebar-compact.sidebar-hover-expanded #toggleCompact {
    display: inline-flex;
  }

  body.sidebar-compact.sidebar-hover-expanded .nav-link {
    justify-content: flex-start;
    padding: 12px;
  }

  body.sidebar-compact.sidebar-hover-expanded .nav-icon {
    width: 22px;
  }

  body.sidebar-compact.sidebar-hover-expanded .logo-picture {
    display: inline-flex;
  }

  body.sidebar-compact.sidebar-hover-expanded .logo-mark {
    display: block;
  }

  body.sidebar-compact.sidebar-hover-expanded .profile-meta {
    display: grid;
  }

  body.sidebar-compact.sidebar-hover-expanded .sidebar-profile {
    display: block;
  }

  body.sidebar-compact.sidebar-hover-expanded .profile-caret {
    display: inline;
  }

  body.sidebar-compact.sidebar-hover-expanded .profile-trigger {
    justify-content: flex-start;
  }

  body.sidebar-compact .sidebar:hover .brand-title,
  body.sidebar-compact .sidebar:hover .brand-subtitle,
  body.sidebar-compact .sidebar:hover .sidebar-label,
  body.sidebar-compact .sidebar:hover .profile-meta,
  body.sidebar-compact .sidebar:hover .profile-caret,
  body.sidebar-compact .sidebar:hover .sidebar-footer,
  body.sidebar-compact.sidebar-hover-expanded .brand-title,
  body.sidebar-compact.sidebar-hover-expanded .brand-subtitle,
  body.sidebar-compact.sidebar-hover-expanded .sidebar-label,
  body.sidebar-compact.sidebar-hover-expanded .profile-meta,
  body.sidebar-compact.sidebar-hover-expanded .profile-caret,
  body.sidebar-compact.sidebar-hover-expanded .sidebar-footer {
    animation: sidebar-item-reveal 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
  }
}

@media (max-width: 860px) {
  body.sidebar-compact.sidebar-hover-expanded .app-shell {
    grid-template-columns: 1fr;
  }

  body.sidebar-compact.sidebar-hover-expanded .sidebar {
    width: min(92vw, 320px);
  }

  body.sidebar-compact .logo-picture,
  body.sidebar-compact .logo-mark,
  body.sidebar-compact .profile-meta,
  body.sidebar-compact .profile-caret {
    display: initial;
  }

  body.sidebar-compact .sidebar-header {
    justify-content: space-between;
  }

  body.sidebar-compact .logo-wrap {
    width: auto;
    justify-content: flex-start;
  }

  body.sidebar-compact #toggleCompact {
    display: inline-flex;
  }

  body.sidebar-compact .sidebar-profile {
    display: block;
  }

  body.sidebar-compact .profile-trigger {
    width: 100%;
    height: auto;
    margin: 0;
    padding: 7px;
    justify-content: flex-start;
    border-radius: 13px;
    background: transparent;
  }

  body.sidebar-compact .profile-avatar-wrap {
    width: 34px;
    height: 34px;
  }
}

/* Compact visual scale across the app */
:root {
  --sidebar-width: 270px;
}

body {
  font-size: 14px;
  line-height: 1.4;
}

.main {
  padding: 17px;
}

.topbar {
  padding: 10px 0 12px;
  margin-bottom: 10px;
}

.topbar-title {
  font-size: 1.08rem;
}

input[type="text"],
input[type="number"],
input[type="email"],
input[type="date"],
input[type="password"],
input[type="file"],
select,
textarea {
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 0.9rem;
}

.nav-link {
  padding: 9px 10px;
}

.profile-trigger {
  padding: 7px;
}

.profile-avatar-wrap {
  width: 34px;
  height: 34px;
}

.notification-btn {
  position: relative;
  width: 30px;
  height: 30px;
  border-radius: 0;
  border: 0;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: hsl(var(--sc-foreground));
}

.notification-btn:hover {
  color: hsl(var(--sc-primary));
}

.notification-icon {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.notification-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #be243b;
  color: #fff;
  font-size: 0.67rem;
  font-weight: 700;
  padding: 0 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.notifications-root {
  position: relative;
}

.notifications-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: min(380px, 88vw);
  border: 1px solid hsl(var(--sc-border));
  border-radius: 12px;
  background: hsl(var(--sc-card));
  box-shadow: 0 16px 32px rgba(11, 23, 47, 0.16);
  opacity: 0;
  transform: translateY(8px) scale(0.98);
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.22s ease, visibility 0.2s ease;
  z-index: 80;
  overflow: hidden;
}

.notifications-root.open .notifications-dropdown {
  opacity: 1;
  transform: translateY(0) scale(1);
  visibility: visible;
  pointer-events: auto;
}

.notifications-header {
  padding: 10px 12px;
  border-bottom: 1px solid hsl(var(--sc-border));
  background: hsl(var(--sc-muted));
}

.notifications-list {
  max-height: 320px;
  overflow: auto;
}

.notification-item {
  display: grid;
  gap: 3px;
  padding: 10px 12px;
  border-bottom: 1px solid hsl(var(--sc-border));
}

.notification-item:hover {
  background: hsl(var(--sc-muted));
}

.notification-item.is-unread {
  background: hsl(var(--sc-muted) / 0.65);
}

.notification-item-title {
  font-size: 0.84rem;
  font-weight: 700;
  color: hsl(var(--sc-foreground));
}

.notification-item-text {
  font-size: 0.79rem;
  color: hsl(var(--sc-muted-foreground));
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.notification-empty {
  margin: 0;
  padding: 14px 12px;
  color: hsl(var(--sc-muted-foreground));
  font-size: 0.82rem;
}

.notification-view-all {
  display: block;
  text-align: center;
  padding: 10px 12px;
  border-top: 1px solid hsl(var(--sc-border));
  background: hsl(var(--sc-card));
  color: hsl(var(--sc-primary));
  font-size: 0.82rem;
  font-weight: 700;
}

.notification-view-all:hover {
  background: hsl(var(--sc-muted));
}

.theme-toggle-btn {
  width: 30px;
  height: 30px;
  border: 1px solid hsl(var(--sc-border));
  border-radius: 8px;
  background: hsl(var(--sc-background));
  color: hsl(var(--sc-foreground));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.theme-toggle-btn:hover {
  background: hsl(var(--sc-muted));
  border-color: hsl(var(--sc-ring));
}

.theme-toggle-icon {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.theme-icon-sun {
  display: inline;
}

.theme-icon-moon {
  display: none;
}

html[data-ui-theme="dark"] .theme-icon-sun,
body[data-ui-theme="dark"] .theme-icon-sun {
  display: none;
}

html[data-ui-theme="dark"] .theme-icon-moon,
body[data-ui-theme="dark"] .theme-icon-moon {
  display: inline;
}

/* Sidebar refresh */
:root {
  --sidebar-width: 298px;
  --sidebar-compact-width: 86px;
  --sidebar-muted: #95a4b8;
  --sidebar-soft-surface: rgba(255, 255, 255, 0.04);
  --sidebar-soft-surface-hover: rgba(255, 255, 255, 0.09);
  --sidebar-card-surface: rgba(255, 255, 255, 0.05);
  --sidebar-active-bg: linear-gradient(
    135deg,
    color-mix(in srgb, var(--sidebar-accent) 84%, #7587ff 16%) 0%,
    color-mix(in srgb, var(--sidebar-accent) 96%, #1f2756 4%) 100%
  );
  --sidebar-active-shadow: 0 10px 24px rgba(8, 12, 24, 0.36);
}

.sidebar {
  position: sticky;
  top: 0;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  background: var(--sidebar-bg);
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--sidebar-bg) 78%, #20262c 22%) 0%,
    color-mix(in srgb, var(--sidebar-bg) 64%, #171d23 36%) 100%
  );
  box-shadow: 8px 0 30px rgba(12, 18, 30, 0.3);
}

.sidebar::before {
  content: "";
  position: absolute;
  inset: 0;
  display: block;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02) 0%, rgba(255, 255, 255, 0) 24%);
  pointer-events: none;
}

.sidebar::after {
  content: "";
  position: absolute;
  inset: 0;
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.06);
  pointer-events: none;
}

.logo-zone,
.sidebar-context-card,
.sidebar-nav-tree,
.sidebar-profile {
  position: relative;
  z-index: 1;
}

.logo-zone {
  border-radius: 0;
  padding: 10px 8px 6px;
  background: transparent;
  border: 0;
}

.logo-wrap {
  gap: 12px;
}

.logo-picture {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.logo-mark {
  width: 44px;
  height: 44px;
  object-fit: contain;
  filter: none;
}

.brand-title {
  font-size: 0.94rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  line-height: 1.15;
  color: #f4f7ff;
}

.brand-subtitle {
  font-size: 0.74rem;
  letter-spacing: 0.03em;
  color: #8fa0b8;
}

#toggleCompact {
  color: #8f9eb1;
}

#toggleCompact:hover {
  background: var(--sidebar-soft-surface-hover);
  color: #d4def0;
}

.sidebar-context-card {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--sidebar-soft-surface);
  border: 1px solid rgba(255, 255, 255, 0.09);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.sidebar-context-pulse {
  display: none;
}

.sidebar-context-meta {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.sidebar-context-kicker {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #7f91a7;
}

.sidebar-context-title {
  font-size: 0.84rem;
  color: #e8eefc;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-nav-tree {
  display: grid;
  gap: 6px;
  margin-top: 10px;
  padding-right: 2px;
  padding-bottom: 10px;
  margin-right: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-nav-tree::-webkit-scrollbar {
  width: 7px;
}

.sidebar-nav-tree::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.16);
  border-radius: 999px;
}

.nav-link {
  position: relative;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--sidebar-muted);
  backdrop-filter: none;
  box-shadow: none;
}

.nav-link .nav-icon {
  width: 20px;
  min-width: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: inherit;
  opacity: 1;
}

.nav-link .nav-svg {
  width: 17px;
  height: 17px;
  display: block;
}

.nav-link:hover {
  transform: none;
  color: #d5deef;
  background: var(--sidebar-soft-surface-hover);
  border-color: transparent;
}

.nav-link.active {
  color: #ffffff;
  background: var(--sidebar-accent);
  background: var(--sidebar-active-bg);
  border-color: transparent;
  box-shadow: var(--sidebar-active-shadow);
}

.nav-link.active::after {
  display: none;
}

.nav-link.active .nav-icon {
  color: #fff;
  filter: none;
}

.nav-link.active .sidebar-label {
  font-weight: 700;
}

.nav-accordion {
  display: grid;
  gap: 6px;
}

.nav-accordion > summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
}

.nav-accordion > summary::-webkit-details-marker {
  display: none;
}

.nav-sublist {
  display: grid;
  gap: 5px;
  margin-left: 8px;
  padding-left: 10px;
  border-left: 1px solid rgba(159, 175, 198, 0.25);
}

.nav-accordion-caret {
  margin-left: auto;
  font-size: 0.8rem;
  color: #9bacbf;
  opacity: 1;
  transition: transform 0.2s ease;
}

.nav-accordion[open] .nav-accordion-caret {
  transform: rotate(180deg);
  color: #d4def1;
}

.nav-link-sub {
  margin-left: 0;
  padding-top: 9px;
  padding-bottom: 9px;
  font-size: 0.9rem;
}

.nav-link-sub .nav-icon {
  width: 17px;
}

.nav-accordion[open] .nav-sublist {
  margin-left: 8px;
  padding-left: 10px;
  border-left: 1px solid rgba(159, 175, 198, 0.25);
}

.nav-accordion[open] .nav-link-sub {
  background: transparent;
  border-color: transparent;
  backdrop-filter: none;
  box-shadow: none;
}

.nav-accordion[open] .nav-link-sub:hover {
  transform: none;
  background: var(--sidebar-soft-surface-hover);
  border-color: transparent;
}

.nav-accordion[open] .nav-link-sub.active {
  color: #eef2ff;
  background: rgba(92, 109, 255, 0.24);
  border-color: transparent;
  box-shadow: inset 0 0 0 1px rgba(152, 166, 255, 0.3);
}

.nav-accordion[open] .nav-link-sub.active::after {
  display: none;
}

.nav-accordion[open] .nav-link-sub.active .nav-icon {
  color: #fff;
  filter: none;
}

.sidebar-profile {
  position: relative;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.profile-trigger {
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: var(--sidebar-card-surface);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.profile-trigger:hover {
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.1);
}

.profile-avatar-wrap {
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.1);
}

.profile-meta strong {
  color: #f1f5ff;
}

.profile-meta small {
  font-size: 0.68rem;
  color: #8294ac;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.profile-caret {
  color: #8ea0b9;
}

.profile-dropdown {
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(27, 34, 44, 0.98);
  backdrop-filter: blur(16px);
}

body.sidebar-compact .app-shell {
  grid-template-columns: var(--sidebar-compact-width) minmax(0, 1fr);
}

body.sidebar-compact .sidebar {
  width: var(--sidebar-compact-width);
}

body.sidebar-compact .sidebar-context-card {
  display: none;
}

body.sidebar-compact .nav-link {
  padding: 10px 8px;
}

@media (hover: hover) and (pointer: fine) {
  body.sidebar-compact .sidebar:hover,
  body.sidebar-compact.sidebar-hover-expanded .sidebar {
    width: var(--sidebar-width);
  }

  body.sidebar-compact:not(.sidebar-hover-expanded) .sidebar [data-tooltip] {
    position: relative;
  }

  body.sidebar-compact:not(.sidebar-hover-expanded) .sidebar [data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + 12px);
    top: 50%;
    transform: translateY(-50%) translateX(-4px);
    background: rgba(30, 38, 48, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
    padding: 8px 10px;
    border-radius: 10px;
    box-shadow: 0 12px 22px rgba(3, 8, 23, 0.35);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
  }

  body.sidebar-compact:not(.sidebar-hover-expanded) .sidebar [data-tooltip]:hover::after {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
  }
}

@media (max-width: 860px) {
  .sidebar-context-card {
    display: none;
  }

  body.sidebar-compact .sidebar {
    width: min(92vw, 320px);
  }

  body.sidebar-compact .sidebar-context-card {
    display: none;
  }
}

@keyframes sidebar-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(107, 232, 174, 0.62);
  }
  70% {
    box-shadow: 0 0 0 9px rgba(107, 232, 174, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(107, 232, 174, 0);
  }
}

/* Normalize action buttons inside listing tables */
.table td .btn,
table.dataTable td .btn,
.dataTables_wrapper td .btn {
  min-height: 1.75rem;
  padding-inline: 0.55rem;
  font-size: 0.73rem;
  line-height: 1;
  white-space: nowrap;
  gap: 0.3rem;
}

.table td .btn svg,
table.dataTable td .btn svg,
.dataTables_wrapper td .btn svg {
  width: 0.9rem;
  height: 0.9rem;
  flex-shrink: 0;
}

/* Keep action headers aligned with right-aligned action buttons */
.table thead th.text-right,
.table thead th.dt-head-right,
table.dataTable thead th.text-right,
table.dataTable thead th.dt-head-right,
.dataTables_wrapper table thead th.text-right,
.dataTables_wrapper table thead th.dt-head-right {
  text-align: right !important;
}

table.dataTable thead th.text-right .dt-column-header,
table.dataTable thead th.dt-head-right .dt-column-header,
.dataTables_wrapper table thead th.text-right .dt-column-header,
.dataTables_wrapper table thead th.dt-head-right .dt-column-header {
  width: 100%;
  justify-content: flex-end;
  text-align: right;
}

html:not([data-ui-theme="dark"]) body .btn.btn-auto-contrast-light,
body:not([data-ui-theme="dark"]) .btn.btn-auto-contrast-light {
  color: #f8fafc !important;
}

html:not([data-ui-theme="dark"]) body .btn.btn-auto-contrast-dark,
body:not([data-ui-theme="dark"]) .btn.btn-auto-contrast-dark {
  color: #162036 !important;
}

/* Compact fixes requested */
body.sidebar-compact:not(.sidebar-hover-expanded) .nav-link {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: var(--sidebar-muted);
}

body.sidebar-compact:not(.sidebar-hover-expanded) .nav-accordion .nav-sublist {
  display: none;
}

body.sidebar-compact:not(.sidebar-hover-expanded) .nav-accordion .nav-accordion-caret {
  display: none;
}

@media (max-width: 860px) {
  body.sidebar-compact:not(.sidebar-hover-expanded) .nav-link {
    justify-content: flex-start;
    padding: 10px 12px;
  }

  body.sidebar-compact:not(.sidebar-hover-expanded) .nav-accordion .nav-accordion-caret {
    display: inline;
  }

  body.sidebar-compact:not(.sidebar-hover-expanded) .nav-accordion[open] .nav-sublist {
    display: grid;
  }
}

body.sidebar-compact:not(.sidebar-hover-expanded) .nav-link:hover {
  color: #d5deef;
  background: var(--sidebar-soft-surface-hover);
  border-color: transparent;
}

body.sidebar-compact:not(.sidebar-hover-expanded) .nav-link.active {
  color: #fff;
  background: var(--sidebar-accent);
  background: var(--sidebar-active-bg);
  border-color: transparent;
  box-shadow: var(--sidebar-active-shadow);
}

body.sidebar-compact:not(.sidebar-hover-expanded) .nav-link.active::after {
  display: none;
}

body.sidebar-compact:not(.sidebar-hover-expanded) .nav-link.active .nav-icon {
  color: #fff;
  filter: none;
}

@media (hover: hover) and (pointer: fine) {
  body.sidebar-compact .sidebar:hover .profile-trigger,
  body.sidebar-compact.sidebar-hover-expanded .profile-trigger {
    width: 100%;
    height: auto;
    margin: 0;
    padding: 8px;
    justify-content: flex-start;
    border-radius: 14px;
    background: var(--sidebar-card-surface);
    border: 1px solid rgba(255, 255, 255, 0.08);
  }
}

@media (min-width: 861px) {
  body.sidebar-compact:not(.sidebar-hover-expanded) .sidebar:not(:hover) .logo-zone {
    justify-content: center;
    padding: 6px 0;
    background: transparent;
    border-color: transparent;
    box-shadow: none;
  }

  body.sidebar-compact:not(.sidebar-hover-expanded) .sidebar:not(:hover) .logo-wrap {
    width: auto;
    margin: 0 auto;
    justify-content: center;
    gap: 0;
  }

  body.sidebar-compact:not(.sidebar-hover-expanded) .sidebar:not(:hover) .brand {
    display: none;
  }

  body.sidebar-compact:not(.sidebar-hover-expanded) .sidebar:not(:hover) .logo-picture {
    background: transparent;
    border: 0;
    box-shadow: none;
  }
}

/* Global mobile compatibility */
.app-shell {
  min-height: 100dvh;
}

.main {
  min-width: 0;
  width: 100%;
  min-height: 100dvh;
}

.sidebar {
  height: 100dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.topbar-left,
.topbar-right,
.page-hero__headline,
.page-hero__actions {
  min-width: 0;
}

.topbar-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-hero__actions .btn {
  max-width: 100%;
}

.table-card__scroll,
.overflow-x-auto {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}

.table-card__scroll {
  overflow-y: visible;
}

/* Prevent grid/card children from forcing horizontal overflow on narrow viewports */
.main .grid,
.main .grid > *,
.card,
.card-body,
.stats,
.stat {
  min-width: 0;
}

.fieldset,
.fieldset > * {
  min-width: 0;
}

/* Daisy form controls can enforce intrinsic widths that overflow narrow cards */
.input,
.select,
.textarea,
.file-input {
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
}

.stat-title,
.stat-value,
.stat-desc {
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

canvas {
  max-width: 100% !important;
}

div.dt-container table.dataTable thead th,
div.dt-container table.dataTable tbody td {
  vertical-align: middle;
}

@media (max-width: 1024px) {
  .topbar-greeting {
    display: none;
  }

  .notifications-dropdown {
    width: min(92vw, 360px);
  }
}

@media (max-width: 860px) {
  .app-shell {
    display: block;
    min-height: 100dvh;
  }

  .sidebar {
    position: fixed !important;
    left: 0;
    top: 0;
    height: 100dvh;
    width: min(92vw, 320px) !important;
    transform: translateX(-103%);
    z-index: 50;
  }

  body.sidebar-compact .app-shell,
  body.sidebar-compact.sidebar-hover-expanded .app-shell {
    grid-template-columns: 1fr !important;
  }

  body.sidebar-compact .main,
  body.sidebar-compact.sidebar-hover-expanded .main {
    width: 100%;
  }

  body {
    overflow-x: hidden;
  }

  body.sidebar-open {
    overflow: hidden;
    touch-action: none;
  }

  .main {
    padding: 12px;
  }

  .sidebar {
    padding-bottom: max(14px, env(safe-area-inset-bottom));
  }

  .topbar {
    flex-wrap: nowrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
  }

  .topbar-left {
    width: auto;
    min-width: 0;
    flex: 1 1 auto;
  }

  .topbar-right {
    width: auto;
    flex: 0 0 auto;
    margin-left: 0;
    justify-content: flex-end;
    gap: 8px;
  }

  .topbar-title {
    font-size: 1.02rem;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .page-hero {
    border-radius: 1rem;
    padding: 0.85rem;
  }

  .page-hero__content {
    gap: 0.75rem;
  }

  .page-hero__icon {
    width: 3.6rem;
    height: 3.6rem;
    min-width: 3.6rem;
    border-radius: 0.9rem;
  }

  .page-hero__icon svg {
    width: 1.5rem;
    height: 1.5rem;
  }

  .page-hero__title {
    font-size: 1.3rem;
    line-height: 1.2;
  }

  .page-hero__subtitle {
    font-size: 0.8rem;
  }

  .page-hero__actions {
    width: 100%;
    justify-content: flex-start;
    gap: 0.5rem;
  }

  .kpi-grid {
    gap: 0.7rem;
  }

  .kpi-stat-card .card-body {
    padding: 0.85rem;
  }

  .kpi-stat-card .text-3xl {
    font-size: 1.45rem;
  }

  .filter-card .card-body,
  .section-card .card-body {
    padding: 0.9rem;
  }

  .table-card__scroll {
    width: 100%;
    overflow-x: auto;
    padding: 0.75rem !important;
  }

  form[role="search"] {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 0.65rem !important;
  }

  form[role="search"] > * {
    width: 100%;
    min-width: 0;
  }

  form[role="search"] > .flex.items-center,
  form[role="search"] > .flex.items-end {
    justify-content: stretch;
    flex-wrap: wrap;
    gap: 0.55rem !important;
  }

  form[role="search"] > .flex.items-center > .btn,
  form[role="search"] > .flex.items-end > .btn,
  form[role="search"] > .flex.items-center > a.btn,
  form[role="search"] > .flex.items-end > a.btn,
  form[role="search"] > .btn,
  form[role="search"] > a.btn {
    flex: 1 1 calc(50% - 0.4rem);
    min-width: 0;
    width: auto !important;
    justify-content: center;
  }

  .table-card__scroll table.table,
  .table-card__scroll table.dataTable,
  .overflow-x-auto table.table,
  .overflow-x-auto table.dataTable,
  div.dt-container table.dataTable {
    min-width: 700px;
  }

  .table th,
  .table td,
  table.dataTable th,
  table.dataTable td {
    white-space: nowrap;
  }

  .table td .btn,
  table.dataTable td .btn,
  .dataTables_wrapper td .btn {
    min-height: 1.8rem;
    padding-inline: 0.45rem;
    font-size: 0.69rem;
    gap: 0.25rem;
  }

  div.dt-container .dt-layout-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
  }

  div.dt-container .dt-layout-row .dt-layout-cell {
    width: 100%;
  }

  div.dt-container .dt-layout-row .dt-paging {
    justify-content: center;
    flex-wrap: wrap;
  }

  .stats {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .overflow-x-auto table.table.table-no-min-width,
  .table-card__scroll table.table.table-no-min-width {
    min-width: 100% !important;
  }

  .overflow-x-auto table.table.table-no-min-width th,
  .overflow-x-auto table.table.table-no-min-width td,
  .table-card__scroll table.table.table-no-min-width th,
  .table-card__scroll table.table.table-no-min-width td {
    white-space: normal;
  }
}

@media (max-width: 640px) {
  .topbar-left {
    gap: 8px;
  }

  .topbar-title {
    font-size: 0.98rem;
  }

  .notification-btn,
  .theme-toggle-btn {
    width: 32px;
    height: 32px;
  }

  .page-hero__headline {
    flex-direction: column;
    align-items: flex-start;
  }

  .page-hero__icon {
    width: 3.1rem;
    height: 3.1rem;
    min-width: 3.1rem;
    border-radius: 0.8rem;
  }

  .page-hero__title {
    font-size: 1.15rem;
  }

  .page-hero__actions .btn,
  .page-hero__action-btn {
    width: 100%;
    justify-content: center;
  }

  form[role="search"] > .flex.items-center > .btn,
  form[role="search"] > .flex.items-end > .btn,
  form[role="search"] > .flex.items-center > a.btn,
  form[role="search"] > .flex.items-end > a.btn,
  form[role="search"] > .btn,
  form[role="search"] > a.btn {
    flex: 1 1 100%;
    width: 100% !important;
  }

  .btn {
    min-height: 2.35rem;
    font-size: 0.8rem;
    padding-inline: 0.7rem;
  }

  .btn.btn-xs {
    min-height: 1.95rem;
    font-size: 0.72rem;
  }

  .btn.btn-sm {
    min-height: 2.15rem;
    font-size: 0.76rem;
  }

  input[type="text"],
  input[type="number"],
  input[type="email"],
  input[type="date"],
  input[type="password"],
  input[type="file"],
  select,
  textarea,
  .input,
  .select,
  .textarea {
    min-height: 2.5rem;
    font-size: 0.9rem;
  }

  textarea,
  .textarea {
    min-height: 7rem;
  }

  .notifications-dropdown {
    position: fixed;
    top: 58px;
    right: 10px;
    left: 10px;
    width: auto;
    max-height: calc(100dvh - 72px);
  }

  [id$="-modal"].fixed > div,
  [id$="-preview-modal"].fixed > div {
    width: min(100%, 100vw - 1rem) !important;
    max-height: calc(100dvh - 1rem);
    overflow-y: auto;
    margin: auto;
  }

  .dropdown .dropdown-content {
    width: min(15rem, calc(100vw - 1rem));
    max-width: calc(100vw - 1rem);
  }

  .flash {
    padding: 10px 11px;
    font-size: 0.82rem;
  }

  .table-card__scroll {
    padding: 0.65rem !important;
  }

  .table-card__scroll table.table,
  .table-card__scroll table.dataTable,
  .overflow-x-auto table.table,
  .overflow-x-auto table.dataTable,
  div.dt-container table.dataTable {
    min-width: 640px;
  }

  .table td .btn svg,
  table.dataTable td .btn svg,
  .dataTables_wrapper td .btn svg {
    width: 0.8rem;
    height: 0.8rem;
  }
}
