:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --text-xs: 12px;
  --text-sm: 13px;
  --text-base: 14px;
  --text-lg: 18px;
  --text-xl: 24px;
  --surface-base: #f6f7f9;
  --surface-raised: #ffffff;
  --surface-muted: #eef2f6;
  --surface-page: #f6f8fb;
  --surface-card: #ffffff;
  --surface: var(--surface-raised);
  --surface-subtle: var(--surface-muted);
  --border-subtle: #e1e7ef;
  --border-strong: #b8c3d3;
  --border: var(--border-subtle);
  --shadow-sm: 0 4px 14px rgb(15 23 42 / 0.06);
  --shadow-md: 0 16px 36px rgb(15 23 42 / 0.12);
  --text-strong: #111827;
  --text-body: #293241;
  --text-muted: #64748b;
  --brand: #155eef;
  --brand-strong: #0f46c7;
  --semantiq-navy: #082a63;
  --semantiq-blue: #075eea;
  --semantiq-cyan: #08b8cf;
  --semantiq-ink: #10213b;
  --semantiq-surface: #f5f8fc;
  --success-bg: #e8f8ef;
  --success-text: #17633a;
  --danger-bg: #fdecec;
  --danger-text: #a12121;
  --warning-bg: #fff7df;
  --warning-text: #8a5b00;
  --info-bg: #eaf2ff;
  --info-text: #174ea6;
  --sidebar-bg: #111b2b;
  --sidebar-hover: rgb(255 255 255 / 0.08);
  --sidebar-active: #2563eb;
  --sidebar-text: #d8e1ee;
  --sidebar-muted: #8ea0b8;
  --sidebar-width: 276px;
  --sidebar-collapsed-width: 72px;
  --content-max: 1920px;
}

*,
*::before,
*::after { box-sizing: border-box; }

html {
  height: 100%;
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  height: 100%;
  min-height: 100%;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  background:
     linear-gradient(rgb(246 248 251 / 0.94),
     rgb(246 248 251 / 0.94)), linear-gradient(90deg, rgb(99 116 145 / 0.09) 1px,
     transparent 1px), linear-gradient(rgb(99 116 145 / 0.09) 1px, transparent 1px),
     var(--surface-page);
  background-size: auto, 28px 28px, 28px 28px, auto;
  color: var(--text-body);
  font-size: var(--text-base);
  line-height: 1.42;
  text-rendering: optimizeLegibility;
}

.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-strong); text-decoration: underline; }

:focus-visible {
  outline: 3px solid rgb(21 94 239 / 0.28);
  outline-offset: 2px;
}

.permissions-admin {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  gap: var(--space-md);
  align-items: start;
}

.permissions-groups,
.permissions-editor {
  min-width: 0;
}

.permissions-side-head,
.permissions-editor-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.permissions-filter,
.permissions-new-group,
.permissions-editor-fields,
.permissions-tools {
  display: grid;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.permissions-editor-fields {
  grid-template-columns: minmax(220px, 1.1fr) minmax(260px, 1.5fr) auto minmax(120px, auto);
  align-items: end;
}

.permissions-tools {
  grid-template-columns: minmax(260px, 1fr) minmax(240px, 360px);
}

.permissions-group-list {
  display: grid;
  gap: var(--space-xs);
  max-height: min(70vh, 760px);
  overflow: auto;
  padding-right: 2px;
}

.permissions-group-card {
  display: grid;
  gap: 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: var(--space-sm);
  color: var(--text-body);
}

.permissions-group-card:hover,
.permissions-group-card.is-active {
  text-decoration: none;
  border-color: rgb(37 99 235 / 0.5);
  background: rgb(239 246 255 / 0.85);
}

.permissions-group-card span,
.permissions-group-card small {
  color: var(--text-muted);
}

.permission-module-tabs {
  display: flex;
  gap: var(--space-xs);
  overflow-x: auto;
  padding-bottom: var(--space-xs);
  margin: var(--space-sm) 0;
}

.permission-module-tabs button {
  white-space: nowrap;
  background: var(--surface-subtle);
  color: var(--text-body);
}

.permission-module-tabs button.is-active {
  background: var(--brand);
  color: #fff;
}

.permission-tab-panel {
  display: none;
}

.permission-tab-panel.is-active {
  display: block;
}

.permission-module-actions {
  display: flex;
  gap: var(--space-xs);
  flex-wrap: wrap;
  margin-bottom: var(--space-sm);
}

.permission-subject-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  margin-bottom: var(--space-sm);
  overflow: hidden;
}

.permission-subject-card > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  cursor: pointer;
  padding: var(--space-sm);
  background: var(--surface-subtle);
}

.permission-subject-card > summary span {
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.permission-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--space-xs);
  padding: var(--space-sm);
}

.permission-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  gap: var(--space-xs);
  align-items: start;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-xs);
  min-height: 76px;
  background: #fff;
}

.permission-row.is-scope {
  border-color: rgb(37 99 235 / 0.3);
  background: rgb(239 246 255 / 0.6);
}

.permission-row.is-sensitive {
  border-color: rgb(245 158 11 / 0.5);
  background: rgb(255 251 235 / 0.7);
}

.permission-row span {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.permission-row small,
.permission-row code {
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

.permission-row em {
  border-radius: 999px;
  padding: 2px 7px;
  background: rgb(219 234 254);
  color: rgb(30 64 175);
  font-style: normal;
  font-size: var(--text-xs);
  font-weight: 700;
}

.permission-row em.warn {
  background: rgb(254 243 199);
  color: rgb(146 64 14);
}

.permission-summary-grid,
.permission-compare-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.permission-summary-grid > div,
.permission-compare-grid > div,
.permission-change-summary,
.permission-templates,
.permission-compare {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: var(--space-sm);
}

.permission-compare-grid small {
  display: block;
  margin-top: var(--space-xs);
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

.sidebar {
  position: relative;
  grid-column: 1;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgb(22 32 49 / 0.94), rgb(8 13 22 / 0.98)),
    var(--sidebar-bg);
  color: #fff;
  padding: var(--space-sm);
  border-right: 1px solid rgb(255 255 255 / 0.08);
  z-index: 20;
}

.sidebar::after {
  content: "";
  position: absolute;
  inset: 0 0 0 auto;
  width: 1px;
  background: linear-gradient(180deg, transparent, rgb(96 165 250 / 0.35), transparent);
}

.sidebar-shell {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.sidebar-head {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.brand {
  display: flex;
  align-items: center;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 42px;
  margin: 0;
  padding: var(--space-sm) 10px;
  border-radius: var(--radius-lg);
  border: 1px solid rgb(255 255 255 / 0.07);
  background: rgb(255 255 255 / 0.04);
}

.brand img { display: block; width: 158px; max-width: 100%; height: auto; }
.brand-logo-compact { display: none !important; }

.sidebar-toggle {
  display: inline-grid;
  place-items: center;
  flex: 0 0 30px;
  width: 30px;
  min-height: 30px;
  border: 1px solid rgb(255 255 255 / 0.09);
  border-radius: var(--radius-md);
  background: rgb(255 255 255 / 0.05);
  color: var(--sidebar-text);
  cursor: pointer;
}

.sidebar-toggle span {
  font-size: 20px;
  line-height: 1;
}

.sidebar-toggle:hover {
  background: var(--sidebar-hover);
  color: #fff;
}

.sidebar-nav {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 3px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 2px 4px var(--space-lg) 2px;
  scrollbar-width: thin;
  scrollbar-color: rgb(148 163 184 / 0.55) transparent;
}

.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgb(148 163 184 / 0.45);
}
.sidebar-nav::-webkit-scrollbar-thumb:hover {
  background: rgb(191 219 254 / 0.75);
}

.nav-item,
.nav-subitem,
.nav-group summary,
.link-button {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 32px;
  padding: 7px 9px;
  border: 0;
  border-radius: var(--radius-md);
  color: var(--sidebar-text);
  background: transparent;
  text-align: left;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease, transform 150ms ease;
}

.nav-item:hover,
.nav-subitem:hover,
.nav-group summary:hover,
.link-button:hover,
.nav-item.is-active,
.nav-subitem.is-active {
  color: #ffffff;
  background: var(--sidebar-hover);
  text-decoration: none;
}

.nav-item.is-active,
.nav-subitem.is-active {
  background: linear-gradient(90deg, rgb(37 99 235 / 0.32), rgb(37 99 235 / 0.12));
  box-shadow: inset 3px 0 0 var(--sidebar-active);
}

.nav-group {
  margin: 2px 0;
}

.nav-group summary {
  list-style: none;
  color: #f3f7fd;
  font-weight: 750;
}

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

.nav-group summary::after {
  content: "";
  width: 7px;
  height: 7px;
  margin-left: auto;
  border-right: 1.5px solid var(--sidebar-muted);
  border-bottom: 1.5px solid var(--sidebar-muted);
  transform: rotate(-45deg);
  transition: transform 150ms ease;
}

.nav-group[open] summary::after {
  transform: rotate(45deg);
}

.nav-children {
  display: grid;
  gap: 2px;
  margin: 1px 0 4px 31px;
  padding-left: 7px;
  border-left: 1px solid rgb(255 255 255 / 0.10);
}

.nav-nested {
  display: grid;
  gap: 2px;
}

.nav-nested summary {
  min-height: 28px;
  padding: 5px 8px;
  border-radius: var(--radius-md);
  color: var(--sidebar-muted);
  font-size: 12px;
  font-weight: 750;
  list-style: none;
  cursor: pointer;
}

.nav-nested summary::-webkit-details-marker { display: none; }
.nav-nested summary:hover { background: var(--sidebar-hover); color: #fff; }
.nav-nested > div {
  display: grid;
  gap: 2px;
  margin-left: var(--space-sm);
}

.nav-subitem {
  min-height: 29px;
  padding: 6px 8px;
  color: var(--sidebar-muted);
  font-size: 12.5px;
}

.nav-ico {
  flex: 0 0 18px;
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  color: #93c5fd;
}

.nav-ico svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar-footer {
  flex: 0 0 auto;
  display: grid;
  gap: 2px;
  padding: var(--space-sm);
  border: 1px solid rgb(255 255 255 / 0.08);
  border-radius: var(--radius-lg);
  background: rgb(255 255 255 / 0.045);
  color: var(--sidebar-muted);
  font-size: var(--text-xs);
}

.sidebar-footer strong {
  color: #fff;
  font-size: var(--text-sm);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar form { margin: var(--space-2) 0 0; }

.main {
  flex: 1 1 auto;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  margin-left: 0;
  min-width: 0;
  max-width: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  padding-bottom: 24px;
  scroll-padding-bottom: 56px;
}

.app-version {
  flex: 0 0 auto;
  margin-top: var(--space-sm);
  padding: var(--space-sm) var(--space-lg);
  color: var(--text-muted);
  font-size: var(--text-xs);
  text-align: right;
}

body.sidebar-collapsed .sidebar {
  width: 100%;
}

body.sidebar-collapsed .app-shell {
  display: flex;
  grid-template-columns: none;
}

body.sidebar-collapsed .main {
  margin-left: 0;
  max-width: 100%;
}

body.sidebar-collapsed .brand {
  justify-content: center;
  padding-inline: 6px;
}

body.sidebar-collapsed .sidebar-head {
  flex-direction: column;
}

body.sidebar-collapsed .sidebar-toggle span {
  transform: rotate(180deg);
}

body.sidebar-collapsed .brand img {
  width: 34px;
  height: 34px;
  object-fit: contain;
  object-position: left center;
}
body.sidebar-collapsed .brand-logo-full { display: none !important; }
body.sidebar-collapsed .brand-logo-compact { display: block !important; }

body.sidebar-collapsed .nav-item,
body.sidebar-collapsed .nav-group summary,
body.sidebar-collapsed .sidebar-footer,
body.sidebar-collapsed .link-button {
  justify-content: center;
}

body.sidebar-collapsed .nav-item span:not(.nav-ico),
body.sidebar-collapsed .nav-group summary span:not(.nav-ico),
body.sidebar-collapsed .nav-subitem span,
body.sidebar-collapsed .sidebar-footer span,
body.sidebar-collapsed .sidebar-footer strong {
  display: none;
}

body.sidebar-collapsed .nav-group summary::after,
body.sidebar-collapsed .nav-children,
body.sidebar-collapsed .nav-nested {
  display: none;
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  z-index: 15;
  background: rgb(2 6 23 / 0.42);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}

@media (min-width: 761px) {
  .sidebar,
  .sidebar-overlay {
    display: none !important;
  }
}

.topbar,
.app-topbar {
  min-height: 50px;
  background:
    linear-gradient(180deg, rgb(255 255 255 / 0.96), rgb(248 251 255 / 0.94));
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  gap: var(--space-4);
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-5);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(10px);
  box-shadow: 0 6px 18px rgb(15 23 42 / 0.04);
  min-width: 0;
}

.app-topbar {
  min-height: 56px;
  padding: 7px var(--space-5);
  position: sticky;
  top: 0;
  z-index: 1000;
}

.app-topbar-left {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  min-width: 0;
  flex: 1 1 0;
  overflow: visible;
}

.app-launcher-wrap {
  position: relative;
  flex: 0 0 auto;
}

.app-launcher-wrap summary::-webkit-details-marker,
.module-more summary::-webkit-details-marker {
  display: none;
}

.app-launcher-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid #d4e0ef;
  border-radius: var(--radius-lg);
  background: #fff;
  color: var(--text-strong);
  font-size: var(--text-sm);
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 12px rgb(15 23 42 / 0.04);
}

.app-launcher-button:hover,
.app-launcher-wrap[open] .app-launcher-button {
  border-color: #b7cdfb;
  background: #f8fbff;
}

.app-launcher-icon {
  display: grid;
  grid-template-columns: repeat(2, 6px);
  gap: 3px;
}

.app-launcher-icon span {
  width: 6px;
  height: 6px;
  border-radius: 2px;
  background: #155eef;
}

.app-launcher-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 1100;
  width: min(520px, calc(100vw - 24px));
  max-height: calc(100dvh - 76px);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2);
  overflow: auto;
  padding: var(--space-3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: #ffffff;
  box-shadow: var(--shadow-md);
}

.app-launcher-panel a {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  column-gap: var(--space-2);
  row-gap: 2px;
  align-items: center;
  min-height: 58px;
  padding: var(--space-3);
  border: 1px solid #e1e7ef;
  border-radius: var(--radius-lg);
  color: var(--text-body);
  background: #fbfcfe;
  text-decoration: none;
}

.app-launcher-panel .launcher-glyph {
  grid-row: 1 / span 2;
  grid-column: 1;
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-lg);
  background:
    linear-gradient(135deg, rgb(255 255 255 / 0.65), transparent 56%),
    #155eef;
  color: #fff;
  font-size: var(--text-sm);
  font-weight: 850;
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.38);
}

.app-launcher-panel a:nth-of-type(3n + 2) .launcher-glyph { background-color: #0891b2; }
.app-launcher-panel a:nth-of-type(3n + 3) .launcher-glyph { background-color: #16a34a; }
.app-launcher-panel a:nth-of-type(4n + 4) .launcher-glyph { background-color: #7c3aed; }

.app-launcher-panel a:hover,
.app-launcher-panel a.is-active {
  border-color: #b7cdfb;
  background: #eef5ff;
  color: var(--text-strong);
}

.app-launcher-panel a > strong {
  grid-column: 2;
  font-size: var(--text-sm);
  color: var(--text-strong);
}

.app-launcher-panel a > span:not(.launcher-glyph) {
  grid-column: 2;
  color: var(--text-muted);
  font-size: var(--text-xs);
}

.topbar-brand {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  width: 136px;
  min-height: 38px;
}

.topbar-brand img {
  display: block;
  width: 126px;
  height: auto;
}

.app-footer {
  margin-top: auto;
  padding: var(--space-4) var(--space-6);
  color: var(--text-muted);
  font-size: var(--text-xs);
  text-align: center;
}

.print-brand-footer {
  margin-top: 28px;
  padding-top: 10px;
  border-top: 1px solid #dbe4f0;
  color: #64748b;
  font-size: 11px;
  text-align: center;
}

.app-logo {
  padding: 2px 4px;
  border-radius: var(--radius-md);
}

.module-title {
  display: grid;
  gap: 0;
  min-width: 112px;
  max-width: 210px;
  flex: 0 1 180px;
}

.module-title strong {
  color: var(--text-strong);
  font-size: var(--text-sm);
}

.module-title span {
  overflow: hidden;
  color: var(--text-muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.module-nav {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px 0;
  scrollbar-width: thin;
  white-space: nowrap;
}

.module-nav > a,
.module-more > summary {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  min-height: 34px;
  padding: 7px 10px;
  border-radius: var(--radius-md);
  color: var(--text-body);
  font-size: var(--text-sm);
  font-weight: 750;
  text-decoration: none;
}

.module-nav > a:hover,
.module-nav > a.is-active,
.module-more > summary:hover,
.module-more[open] > summary {
  background: #eef5ff;
  color: var(--brand-strong);
}

.module-more {
  position: relative;
  flex: 0 0 auto;
}

.module-more > summary {
  cursor: pointer;
}

.module-more > summary::after {
  content: "";
  width: 7px;
  height: 7px;
  margin-left: 8px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  opacity: 0.7;
  transform: rotate(45deg) translateY(-2px);
}

.module-more[open] > summary::after {
  transform: rotate(225deg) translate(-1px, -1px);
}

.module-more > div {
  position: fixed;
  top: var(--module-menu-top, 56px);
  left: var(--module-menu-left, 0);
  z-index: 1200;
  min-width: 230px;
  width: var(--module-menu-width, max-content);
  max-width: calc(100vw - 24px);
  max-height: calc(100dvh - 90px);
  display: grid;
  gap: 2px;
  overflow: auto;
  padding: var(--space-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: #ffffff;
  box-shadow: var(--shadow-md);
}

.module-more a {
  min-height: 32px;
  padding: 7px 9px;
  border-radius: var(--radius-md);
  color: var(--text-body);
  font-size: var(--text-sm);
  font-weight: 700;
  text-decoration: none;
}

.module-more a:hover,
.module-more a.is-active {
  background: var(--surface-muted);
  color: var(--text-strong);
}

.module-more.is-active > summary {
  background: #eef5ff;
  color: var(--brand-strong);
}

.mobile-menu-button {
  display: none;
  width: 36px;
  min-width: 36px;
  padding: 0;
}

.topbar-title {
  display: grid;
  gap: 1px;
  min-width: 0;
}

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

.topbar strong { color: var(--text-strong); font-size: var(--text-sm); }

.topbar-actions {
  display: flex;
  gap: var(--space-sm);
  align-items: center;
  flex: 0 0 auto;
  min-width: 0;
  position: relative;
  z-index: 2;
}

.tenant-switch { display: flex; gap: var(--space-sm); align-items: end; }

.tenant-switch label {
  display: grid;
  gap: 2px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 750;
}

.tenant-switch select { min-width: 190px; }

.app-topbar .tenant-switch {
  align-items: center;
}

.app-topbar .tenant-switch label {
  display: block;
}

.app-topbar .tenant-switch label > span {
  display: none;
}

.app-topbar .tenant-switch select {
  width: clamp(180px, 20vw, 300px);
  min-width: 180px;
  max-width: 300px;
}

.app-topbar .tenant-switch button {
  min-height: 34px;
}

.tenant-switch select,
.user-chip {
  border-color: #d4e0ef;
  box-shadow: 0 4px 12px rgb(15 23 42 / 0.04);
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 4px 9px 4px 5px;
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  background: #fff;
  cursor: pointer;
  list-style: none;
}

.user-menu {
  position: relative;
}

.user-menu summary::-webkit-details-marker { display: none; }

.user-menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 25;
  min-width: 230px;
  display: grid;
  gap: var(--space-2);
  padding: var(--space-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: #fff;
  box-shadow: var(--shadow-md);
}

.user-menu-section {
  display: grid;
  gap: 2px;
}

.user-menu-panel a,
.user-menu-panel .link-button {
  min-height: 34px;
  padding: 7px 9px;
  border-radius: var(--radius-md);
  color: var(--text-body);
  background: transparent;
  border: 0;
  justify-content: flex-start;
  font-size: var(--text-sm);
  font-weight: 700;
}

.user-menu-panel .user-menu-primary {
  color: var(--text-strong);
  font-weight: 850;
}

.user-menu-subitems {
  display: grid;
  gap: 2px;
  margin-left: var(--space-2);
  padding-left: var(--space-2);
  border-left: 1px solid var(--border-subtle);
}

.user-menu-subitems a {
  color: var(--text-body);
  font-size: var(--text-sm);
  font-weight: 700;
}

.user-menu-panel form {
  margin: 0;
  padding-top: var(--space-2);
  border-top: 1px solid var(--border-subtle);
}

.user-menu-panel a:hover,
.user-menu-panel .link-button:hover {
  background: var(--surface-muted);
  color: var(--text-strong);
  text-decoration: none;
}

.link-button.danger { color: var(--danger-text); }

.user-chip span {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: var(--info-bg);
  color: var(--info-text);
  font-size: var(--text-xs);
  font-weight: 800;
  text-transform: uppercase;
}

.avatar-image {
  display: block;
  aspect-ratio: 1;
  border-radius: 999px;
  object-fit: cover;
  max-width: none;
  max-height: none;
}

.avatar-image-sm {
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
}

.user,
.muted {
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.page-head {
  width: min(100% - 40px, var(--content-max));
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-lg) 0 var(--space-sm);
  min-width: 0;
  max-width: min(calc(100% - 40px), var(--content-max));
}

h1,
h2,
h3,
p { margin-top: 0; }

h1 {
  margin-bottom: 0;
  color: var(--text-strong);
  font-size: 22px;
  line-height: 1.15;
  letter-spacing: 0;
}

h2 {
  margin: var(--space-lg) 0 var(--space-sm);
  color: var(--text-strong);
  font-size: 16px;
  line-height: 1.25;
}

h3 { font-size: var(--text-base); }

.panel > h2:first-child,
.card > h2:first-child { margin-top: 0; }

.cards {
  width: min(100% - 40px, var(--content-max));
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: var(--space-sm);
  padding: var(--space-xs) 0 var(--space-sm);
}

.card,
.panel {
  background: var(--surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  min-width: 0;
  transition: box-shadow 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.card:hover,
.panel:hover {
  box-shadow: 0 8px 22px rgb(15 23 42 / 0.08);
  border-color: #d2ddec;
}

.card {
  min-height: 104px;
  padding: var(--space-md);
}

.tax-assessment-cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 14px 0; }
.tax-assessment-cards .card { min-width: 0; }
.tax-quarter-cards { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.tax-quarter-cards .reserve { border-color: var(--primary, #2563eb); }
.tax-quarter-projection h3 { margin-top: 24px; }
.tax-quarter-projection td small { display: block; margin-top: 4px; }
@media (max-width: 900px) { .tax-assessment-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .tax-assessment-cards { grid-template-columns: 1fr; } }

.card span {
  display: block;
  min-height: 0;
  margin-bottom: var(--space-sm);
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
}

.card strong {
  display: block;
  color: var(--text-strong);
  font-size: clamp(15px, 1.6vw, 27px);
  line-height: 1.05;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.panel {
  width: min(100% - 40px, var(--content-max));
  max-width: min(calc(100% - 40px), var(--content-max));
  margin: var(--space-sm) auto;
  padding: var(--space-lg);
  background:
    linear-gradient(180deg, rgb(255 255 255 / 0.98), rgb(248 251 255 / 0.98)),
    var(--surface-raised);
}

form.panel h2 {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin: var(--space-lg) 0 var(--space-md);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid #e6edf7;
}

form.panel h2::before {
  content: "";
  width: 4px;
  height: 18px;
  border-radius: 999px;
  background: linear-gradient(180deg, #2f7df4, #16a3b8);
}

form.panel h2:first-child {
  margin-top: 0;
}

.panel.actions,
.page-head .actions {
  justify-content: flex-end;
}

.panel p:last-child { margin-bottom: 0; }

.table-wrap {
  width: min(100% - 40px, var(--content-max));
  max-width: min(calc(100% - 40px), var(--content-max));
  max-height: min(64dvh, 720px);
  margin: var(--space-sm) auto;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: rgb(100 116 139 / 0.55) transparent;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: var(--surface-raised);
  box-shadow: 0 8px 22px rgb(15 23 42 / 0.07);
}

.table-scroll {
  width: 100%;
  max-width: 100%;
  overflow: auto;
  border-radius: var(--radius-lg);
}

main.main > table.table {
  display: block;
  width: min(100% - 40px, var(--content-max));
  max-width: min(calc(100% - 40px), var(--content-max));
  margin: var(--space-sm) auto;
  overflow-x: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

main.main > table.table thead,
main.main > table.table tbody {
  display: table;
  min-width: 760px;
  width: 100%;
}

.table-wrap::-webkit-scrollbar,
.data-table-wrap::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.table-wrap::-webkit-scrollbar-track,
.data-table-wrap::-webkit-scrollbar-track {
  background: transparent;
}

.table-wrap::-webkit-scrollbar-thumb,
.data-table-wrap::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgb(100 116 139 / 0.46);
}

.data-table-wrap {
  width: 100%;
  max-width: 100%;
  overflow: auto;
  border-radius: var(--radius-lg);
  background: var(--surface-raised);
}

.panel .table-wrap {
  width: 100%;
  max-width: 100%;
  margin: var(--space-3) 0 0;
  box-shadow: none;
}

.payment-term-editor {
  display: grid;
  gap: var(--space-md);
}

.payment-term-lines {
  overflow-x: auto;
}

.payment-term-lines-table {
  min-width: 0;
  table-layout: fixed;
}

.payment-term-lines-table th:nth-child(1),
.payment-term-lines-table td:nth-child(1) { width: 8%; }
.payment-term-lines-table th:nth-child(2),
.payment-term-lines-table td:nth-child(2) { width: 13%; }
.payment-term-lines-table th:nth-child(3),
.payment-term-lines-table td:nth-child(3) { width: 11%; }
.payment-term-lines-table th:nth-child(4),
.payment-term-lines-table td:nth-child(4) { width: 10%; }
.payment-term-lines-table th:nth-child(5),
.payment-term-lines-table td:nth-child(5) { width: 17%; }
.payment-term-lines-table th:nth-child(6),
.payment-term-lines-table td:nth-child(6) { width: 10%; }
.payment-term-lines-table th:nth-child(7),
.payment-term-lines-table td:nth-child(7) { width: 21%; }
.payment-term-lines-table th:nth-child(8),
.payment-term-lines-table td:nth-child(8) { width: 10%; }

.payment-term-lines-table input,
.payment-term-lines-table select {
  width: 100%;
  min-width: 0;
}

.table {
  width: 100%;
  min-width: 760px;
  margin: 0;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface-raised);
  font-size: 12.5px;
}

.table-wrap .table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
}

.table.compact-list-table {
  min-width: 0;
  table-layout: fixed;
}

.table.compact-list-table th,
.table.compact-list-table td {
  max-width: none;
  white-space: normal;
  overflow: hidden;
  text-overflow: ellipsis;
}

.table.compact-list-table td {
  vertical-align: top;
}

.table.compact-list-table strong,
.table.compact-list-table small,
.cell-line {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cell-line {
  white-space: nowrap;
}

.finance-entries-table th:nth-child(1),
.finance-entries-table td:nth-child(1) { width: 9%; }
.finance-entries-table th:nth-child(2),
.finance-entries-table td:nth-child(2) { width: 14%; }
.finance-entries-table th:nth-child(3),
.finance-entries-table td:nth-child(3) { width: 27%; }
.finance-entries-table th:nth-child(4),
.finance-entries-table td:nth-child(4) { width: 22%; }
.finance-entries-table th:nth-child(5),
.finance-entries-table td:nth-child(5) { width: 14%; }
.finance-entries-table th:nth-child(6),
.finance-entries-table td:nth-child(6) { width: 14%; }

.partner-benefits-wrap {
  max-height: none;
  overflow-x: auto;
  overflow-y: visible;
}

.partner-benefits-table {
  min-width: 980px;
  table-layout: fixed;
}

.partner-benefits-table th:nth-child(1),
.partner-benefits-table td:nth-child(1) { width: 18%; }
.partner-benefits-table th:nth-child(2),
.partner-benefits-table td:nth-child(2) { width: 20%; }
.partner-benefits-table th:nth-child(3),
.partner-benefits-table td:nth-child(3) { width: 8%; }
.partner-benefits-table th:nth-child(4),
.partner-benefits-table td:nth-child(4) { width: 20%; }
.partner-benefits-table th:nth-child(5),
.partner-benefits-table td:nth-child(5) { width: 18%; }
.partner-benefits-table th:nth-child(6),
.partner-benefits-table td:nth-child(6) { width: 16%; }

.finance-titles-table th:nth-child(1),
.finance-titles-table td:nth-child(1) { width: 15%; }
.finance-titles-table th:nth-child(2),
.finance-titles-table td:nth-child(2) { width: 22%; }
.finance-titles-table th:nth-child(3),
.finance-titles-table td:nth-child(3) { width: 13%; }
.finance-titles-table th:nth-child(4),
.finance-titles-table td:nth-child(4) { width: 12%; }
.finance-titles-table th:nth-child(5),
.finance-titles-table td:nth-child(5) { width: 18%; }
.finance-titles-table th:nth-child(6),
.finance-titles-table td:nth-child(6) { width: 12%; }
.finance-titles-table th:nth-child(7),
.finance-titles-table td:nth-child(7) { width: 9%; }
.finance-titles-table th:nth-child(8),
.finance-titles-table td:nth-child(8) { width: 7%; }

.sales-orders-table th:nth-child(1),
.sales-orders-table td:nth-child(1) { width: 10%; }
.sales-orders-table th:nth-child(2),
.sales-orders-table td:nth-child(2) { width: 34%; }
.sales-orders-table th:nth-child(3),
.sales-orders-table td:nth-child(3) { width: 15%; }
.sales-orders-table th:nth-child(4),
.sales-orders-table td:nth-child(4) { width: 12%; }
.sales-orders-table th:nth-child(5),
.sales-orders-table td:nth-child(5) { width: 21%; }
.sales-orders-table th:nth-child(6),
.sales-orders-table td:nth-child(6) { width: 8%; }

.sales-orders-table {
  min-width: 1040px;
}

.sales-orders-table th,
.sales-orders-table td,
.sales-orders-table strong,
.sales-orders-table small {
  white-space: nowrap;
}

.sales-orders-table strong,
.sales-orders-table small {
  display: inline;
}

.cost-centers-wrap {
  max-height: min(62dvh, 680px);
}

.cost-centers-table {
  min-width: 920px;
  table-layout: fixed;
}

.cost-centers-table th:nth-child(1),
.cost-centers-table td:nth-child(1) { width: 10%; }
.cost-centers-table th:nth-child(2),
.cost-centers-table td:nth-child(2) { width: 22%; }
.cost-centers-table th:nth-child(3),
.cost-centers-table td:nth-child(3) { width: 26%; }
.cost-centers-table th:nth-child(4),
.cost-centers-table td:nth-child(4) { width: 10%; }
.cost-centers-table th:nth-child(5),
.cost-centers-table td:nth-child(5) { width: 32%; }

.cost-center-edit-form {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(180px, 1fr) auto auto;
  gap: var(--space-sm);
  align-items: center;
}

.cost-center-edit-form input,
.cost-center-edit-form button {
  min-width: 0;
}

.partners-table th:nth-child(1),
.partners-table td:nth-child(1) { width: 20%; }
.partners-table th:nth-child(2),
.partners-table td:nth-child(2) { width: 50%; }
.partners-table th:nth-child(3),
.partners-table td:nth-child(3) { width: 20%; }
.partners-table th:nth-child(4),
.partners-table td:nth-child(4) { width: 10%; }

.table th,
.table td {
  text-align: left;
  padding: 7px 9px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
  white-space: nowrap;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f9fafc;
  color: #475569;
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
}

.table td {
  color: #263242;
  font-variant-numeric: tabular-nums;
}

.table td:is(:nth-last-child(1), :nth-last-child(2)) { text-align: right; }
.table td a { font-weight: 650; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #f8fbff; }

.row-link {
  color: var(--primary);
  font-weight: 800;
  white-space: nowrap;
}

.table-meta {
  display: block;
  margin-top: 3px;
  font-size: 11px;
  line-height: 1.25;
}

.stock-summary-grid {
  width: min(100% - 40px, var(--content-max));
  margin: 0 auto var(--space-3);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: var(--space-sm);
}

.stock-kpi {
  display: grid;
  gap: 3px;
  min-height: 76px;
  padding: var(--space-3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.stock-kpi span {
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: 750;
  text-transform: uppercase;
}

.stock-kpi strong {
  color: var(--text-strong);
  font-size: 1.7rem;
  line-height: 1;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: var(--space-sm);
  align-items: center;
  margin-bottom: var(--space-sm);
}

.section-head h2 {
  margin: 0;
}

.stock-table {
  min-width: 980px;
  table-layout: fixed;
}

.stock-table td {
  overflow: hidden;
  text-overflow: ellipsis;
}

.stock-table td:nth-child(2),
.stock-movements-table td:nth-child(3) {
  white-space: normal;
}

.stock-table td.num,
.stock-table th:last-child,
.stock-table th:nth-last-child(2) {
  text-align: right;
}

.sort-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: inherit;
  text-decoration: none;
}

.sort-link span {
  color: var(--accent);
  font-size: 12px;
}

.cell-truncate {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.table-pagination {
  display: flex;
  justify-content: space-between;
  gap: var(--space-sm);
  align-items: center;
  flex-wrap: wrap;
  overflow: visible;
  min-width: 0;
}

.table-pagination .actions {
  min-width: 0;
  justify-content: flex-end;
}

.sales-orders-wrap {
  width: min(100% - 40px, var(--content-max));
  max-width: min(calc(100% - 40px), var(--content-max));
  margin: var(--space-sm) auto;
  contain: inline-size;
}

.sales-orders-pagination {
  width: min(100% - 40px, var(--content-max));
  max-width: min(calc(100% - 40px), var(--content-max));
}

.finance-titles-wrap,
.finance-titles-pagination,
.finance-entries-pagination {
  width: min(100% - 40px, var(--content-max));
  max-width: min(calc(100% - 40px), var(--content-max));
}

.finance-titles-pagination,
.finance-entries-pagination {
  overflow-x: auto;
}

.finance-titles-pagination .actions,
.finance-entries-pagination .actions {
  flex-wrap: nowrap;
}

.button.disabled {
  pointer-events: none;
  opacity: 0.45;
}

.filters,
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
  gap: var(--space-sm);
  align-items: end;
  min-width: 0;
}

.fiscal-summary-grid {
  align-items: start;
}

.fiscal-summary-grid p,
.break-value {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.fiscal-summary-grid strong {
  display: inline-block;
  margin-bottom: 2px;
}

.filters {
  margin-top: 0;
  padding: var(--space-sm);
  border-radius: var(--radius-md);
  overflow: visible;
}

.filter-wide {
  grid-column: span 2;
}

.filter-xl {
  grid-column: span 3;
}

.filter-actions {
  display: flex;
  gap: var(--space-sm);
  align-items: end;
  flex-wrap: wrap;
}

.sales-commercial-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
  align-items: start;
}

.sales-commercial-grid .field-with-action {
  grid-column: span 2;
}

form.panel label,
.filters label,
.login-box label,
.form-grid label,
.panel > label {
  display: grid;
  gap: var(--space-1);
  color: #465568;
  font-size: var(--text-xs);
  font-weight: 700;
}

label:has(input[type="checkbox"]) {
  display: flex;
  flex-direction: row;
  gap: var(--space-2);
  align-items: center;
  min-height: 34px;
}

input,
select,
textarea,
button,
.button {
  min-height: 32px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 6px 9px;
  font: inherit;
  font-size: var(--text-sm);
}

input,
select,
textarea {
  width: 100%;
  background: #ffffff;
  color: var(--text-strong);
}

select {
  overflow: hidden;
  text-overflow: ellipsis;
  background-image: linear-gradient(180deg, #ffffff, #fbfdff);
  font-weight: 700;
}

input:hover,
select:hover,
textarea:hover {
  border-color: #8ea4c3;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgb(21 94 239 / 0.12);
  outline: none;
}

.select-search {
  min-height: 30px;
  margin-bottom: 4px;
  background: #f8fbff;
  border-color: #c7d4e6;
}

.field-with-action {
  min-width: min(100%, 280px);
}

.field-control-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-xs);
  align-items: end;
}

.field-control-row .select-search {
  grid-column: 1 / -1;
}

.field-control-row select {
  min-width: 0;
}

.remote-lookup {
  position: relative;
  display: block;
  min-width: 0;
}

.is-search-select-source {
  position: absolute;
  width: 1px !important;
  min-width: 1px !important;
  max-width: 1px !important;
  height: 1px;
  margin: 0;
  opacity: 0;
  pointer-events: none;
}

.search-select {
  position: relative;
  display: block;
  min-width: min(100%, 220px);
}

.search-select input[type="search"] {
  padding-right: 36px;
  background-image: linear-gradient(180deg, #ffffff, #fbfdff);
  font-weight: 700;
}

.search-select-clear {
  position: absolute;
  right: 6px;
  top: 50%;
  width: 24px;
  height: 24px;
  min-height: 24px;
  padding: 0;
  transform: translateY(-50%);
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #64748b;
  font-size: 18px;
  line-height: 1;
}

.search-select-clear:hover,
.search-select-clear:focus {
  background: #eaf2ff;
  color: #0f46c7;
}

.remote-lookup input[type="search"] {
  padding-right: 32px;
  background-image: linear-gradient(180deg, #ffffff, #fbfdff);
  font-weight: 750;
}

.remote-lookup::after {
  content: "⌕";
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: #64748b;
  font-size: 15px;
  pointer-events: none;
}

.remote-lookup-menu {
  position: absolute;
  left: 0;
  top: calc(100% + 6px);
  z-index: 80;
  display: none;
  width: min(760px, calc(100vw - 48px));
  max-height: min(360px, 46vh);
  overflow-y: auto;
  padding: 6px;
  border: 1px solid #bfd0e7;
  border-radius: var(--radius-lg);
  background: #fff;
  box-shadow: 0 20px 48px rgb(15 23 42 / 0.18);
}

.remote-lookup.is-open .remote-lookup-menu {
  display: grid;
  gap: 2px;
}

.search-select.is-open .remote-lookup-menu {
  display: grid;
  gap: 2px;
}

.remote-lookup-option {
  width: 100%;
  min-height: 34px;
  padding: 7px 9px;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-strong);
  text-align: left;
  font-weight: 650;
  white-space: normal;
}

.remote-lookup-option small {
  display: block;
  margin-top: 2px;
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: 600;
}

.remote-lookup-option:hover,
.remote-lookup-option:focus,
.remote-lookup-option.is-active {
  background: #eaf2ff;
  color: #0f46c7;
}

.remote-lookup-empty {
  padding: 10px;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.icon-action {
  white-space: nowrap;
  min-height: 32px;
  padding-inline: 10px;
  font-weight: 800;
  border-color: #c5d6ee;
  background: #f2f7ff;
  color: #0f46c7;
}

input[type="checkbox"] {
  width: 16px;
  min-height: 16px;
  accent-color: var(--brand);
}

input[readonly],
textarea[readonly] {
  background: #f8fafc;
  color: var(--text-muted);
}

textarea {
  min-height: 70px;
  resize: vertical;
}

button,
.button {
  width: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  line-height: 1.15;
  text-decoration: none;
  white-space: nowrap;
}

button:hover,
.button:hover {
  background: var(--brand-strong);
  border-color: var(--brand-strong);
  color: #fff;
  text-decoration: none;
}

.button.secondary,
button.secondary {
  background: #ffffff;
  color: #263242;
  border-color: var(--border-strong);
}

.button.secondary:hover,
button.secondary:hover {
  background: var(--surface-muted);
  border-color: #94a3b8;
  color: #111827;
}

.actions {
  display: flex;
  gap: var(--space-sm);
  align-items: center;
  flex-wrap: wrap;
}

.actions form { margin: 0; }

.dfe-documents-table {
  min-width: 1360px;
}

.dfe-documents-table th:nth-child(1),
.dfe-documents-table td:nth-child(1) { width: 130px; }
.dfe-documents-table th:nth-child(2),
.dfe-documents-table td:nth-child(2) { width: 280px; }
.dfe-documents-table th:nth-child(3),
.dfe-documents-table td:nth-child(3) { width: 230px; }
.dfe-documents-table th:nth-child(10),
.dfe-documents-table td:nth-child(10) {
  width: 330px;
  min-width: 330px;
  max-width: none;
  overflow: visible;
  text-align: left;
}

.dfe-documents-table .actions {
  flex-wrap: nowrap;
  justify-content: flex-start;
  gap: 8px;
  min-width: 0;
  white-space: nowrap;
}

.dfe-documents-table .actions form,
.dfe-manifest-form {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.dfe-documents-table .button.compact,
.dfe-documents-table button,
.dfe-documents-table select {
  min-height: 34px;
}

.dfe-documents-table .button.compact,
.dfe-documents-table button {
  padding: 7px 10px;
  white-space: nowrap;
}

.dfe-documents-table select {
  width: 170px;
  min-width: 150px;
}

.fiscal-action-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--space-md);
  align-items: start;
  margin: var(--space-md) 0;
}

.fiscal-action-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: var(--space-md);
  background: var(--surface);
}

.fiscal-action-card h3 {
  margin: 0 0 var(--space-sm);
  font-size: 0.95rem;
}

.fiscal-action-card .inline-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-sm);
  align-items: end;
}

.fiscal-action-card .inline-form button {
  min-height: 38px;
}

.modal-dialog {
  width: min(760px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 0;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow-md);
}

.modal-dialog::backdrop {
  background: rgb(15 23 42 / 0.45);
}

.modal-form {
  display: grid;
  gap: var(--space-md);
  padding: var(--space-md);
  background: #ffffff;
  border-radius: 8px;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  gap: var(--space-md);
  align-items: center;
}

.modal-head h2 {
  margin: 0;
  font-size: 1.15rem;
}

.quick-partner-dialog {
  width: min(840px, calc(100vw - 28px));
}

.quick-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: var(--space-sm);
}

.quick-form-grid label {
  display: grid;
  gap: var(--space-1);
  color: #465568;
  font-size: var(--text-xs);
  font-weight: 700;
}

.checklist {
  display: grid;
  gap: var(--space-sm);
}

.checklist label {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.subnav {
  display: none !important;
  width: min(100% - 40px, var(--content-max));
  margin: 0 auto var(--space-xs);
  display: flex;
  gap: var(--space-xs);
  overflow-x: auto;
  padding: var(--space-xs) 0 var(--space-sm);
}

.subnav.is-compact {
  justify-content: space-between;
  align-items: center;
  overflow: visible;
}

.subnav-main,
.subnav-secondary {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
}

.subnav-secondary details {
  position: relative;
}

.subnav-secondary summary {
  min-height: 32px;
  padding: 6px 9px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
  color: #263242;
  font-size: var(--text-sm);
  font-weight: 700;
  list-style: none;
  cursor: pointer;
}

.subnav-secondary summary::-webkit-details-marker { display: none; }

.subnav-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 8;
  min-width: 220px;
  display: grid;
  gap: 2px;
  padding: var(--space-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: #fff;
  box-shadow: var(--shadow-md);
}

.subnav .subnav-menu a {
  width: 100%;
  border: 0;
  background: transparent;
}

.profile-grid {
  width: min(100% - 40px, var(--content-max));
  margin: 0 auto var(--space-6);
  display: grid;
  grid-template-columns: minmax(260px, 0.8fr) minmax(320px, 1fr);
  gap: var(--space-sm);
}

.profile-grid .panel {
  width: 100%;
  margin: 0;
}

.profile-summary {
  display: flex;
  gap: var(--space-4);
  align-items: center;
}

.profile-avatar {
  flex: 0 0 72px;
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--info-bg);
  color: var(--info-text);
  font-size: 28px;
  font-weight: 800;
  overflow: hidden;
}

.avatar-image-lg {
  width: 72px;
  height: 72px;
}

.profile-page,
.about-page {
  width: min(100% - 40px, var(--content-max));
  margin: 0 auto var(--space-6);
}

.profile-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-5) 0 var(--space-4);
}

.profile-hero h1,
.about-card h1 {
  margin: 0;
  color: var(--text-strong);
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--brand);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.profile-layout {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  gap: var(--space-4);
  align-items: start;
}

.profile-content {
  display: grid;
  gap: var(--space-4);
  min-width: 0;
}

.profile-card {
  min-width: 0;
  padding: var(--space-5);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: rgb(255 255 255 / 0.96);
  box-shadow: var(--shadow-sm);
}

.profile-identity {
  position: sticky;
  top: 76px;
  display: grid;
  gap: var(--space-4);
}

.profile-identity h2,
.profile-card h2 {
  margin: 0;
  color: var(--text-strong);
}

.profile-identity p {
  margin: 4px 0 var(--space-sm);
  color: var(--text-muted);
}

.profile-avatar-xl {
  width: 96px;
  height: 96px;
  font-size: 34px;
}

.avatar-image-xl {
  width: 96px;
  height: 96px;
  object-fit: cover;
}

.profile-jump-nav {
  display: grid;
  gap: 2px;
  padding-top: var(--space-sm);
  border-top: 1px solid var(--border-subtle);
}

.profile-jump-nav a {
  min-height: 32px;
  padding: 7px 9px;
  border-radius: var(--radius-md);
  color: var(--text-body);
  font-size: var(--text-sm);
  font-weight: 750;
}

.profile-jump-nav a:hover {
  background: var(--surface-muted);
  color: var(--text-strong);
  text-decoration: none;
}

.profile-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
}

.profile-security-grid,
.profile-setup-grid,
.profile-edit-grid {
  display: grid;
  gap: var(--space-3);
}

.profile-security-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: var(--space-4);
}

.profile-security-grid p {
  margin: 0;
  padding: var(--space-3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: #fbfcff;
}

.profile-security-grid strong,
.profile-security-grid span {
  display: block;
}

.profile-security-grid span {
  margin-top: 3px;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.profile-setup-grid {
  grid-template-columns: 220px minmax(0, 1fr);
  align-items: start;
}

.profile-secret-box {
  display: grid;
  gap: var(--space-sm);
  min-width: 0;
}

.profile-secret-box code {
  overflow-wrap: anywhere;
  padding: var(--space-3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--surface-muted);
}

.profile-inline-form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: var(--space-3);
  align-items: end;
  margin-top: var(--space-4);
}

.profile-edit-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.profile-edit-grid .profile-card {
  display: grid;
  align-content: start;
}

.about-page {
  display: grid;
  min-height: calc(100dvh - 96px);
  place-items: center;
  padding: var(--space-6) 0;
}

.about-card {
  width: min(560px, 100%);
  display: grid;
  gap: var(--space-4);
  padding: var(--space-6);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: #fff;
  box-shadow: var(--shadow-md);
}

.about-logo img {
  width: 156px;
  height: auto;
}

.about-facts {
  display: grid;
  gap: var(--space-sm);
}

.about-facts p {
  display: flex;
  justify-content: space-between;
  gap: var(--space-4);
  margin: 0;
  padding: var(--space-3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: #fbfcff;
}

.partners-filter {
  grid-template-columns: minmax(360px, 1fr) minmax(180px, 250px) minmax(160px, 220px) minmax(120px, 220px);
}

.partners-table-wide {
  min-width: 1120px;
}

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

.partners-table-wide .cell-truncate {
  max-width: 420px;
}

.partner-address-grid {
  grid-template-columns:
    minmax(180px, 1.4fr)
    minmax(86px, 0.45fr)
    minmax(150px, 0.9fr)
    minmax(140px, 0.8fr)
    minmax(150px, 0.9fr)
    minmax(105px, 0.55fr)
    minmax(72px, 0.35fr)
    minmax(105px, 0.55fr)
    minmax(120px, 0.65fr)
    auto;
}

.partner-contact-list {
  display: grid;
  gap: var(--space-sm);
}

.partner-contact-row {
  display: grid;
  grid-template-columns:
    minmax(170px, 1.1fr)
    minmax(190px, 1.2fr)
    minmax(130px, 0.8fr)
    minmax(130px, 0.8fr)
    repeat(4, minmax(88px, auto))
    auto;
  gap: var(--space-sm);
  align-items: end;
  padding: var(--space-sm);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: #fbfcff;
}

.partner-contact-row label:has(input[type="checkbox"]) {
  align-self: end;
  min-height: 32px;
}

.partner-contact-remove {
  align-self: end;
}

.subnav a {
  flex: 0 0 auto;
  min-height: 32px;
  padding: 6px 9px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
  color: #263242;
  font-size: var(--text-sm);
  font-weight: 700;
}

.subnav a:hover {
  background: var(--surface-muted);
  color: var(--text-strong);
  text-decoration: none;
}

.settlement-inline input,
.settlement-inline select {
  width: 128px;
}

.table-toolbar {
  width: min(100% - 40px, var(--content-max));
  margin: var(--space-sm) auto 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
}

.table-toolbar > div:first-child {
  display: grid;
  gap: 1px;
}

.row-editor {
  position: relative;
  min-width: 88px;
}

.row-editor summary {
  cursor: pointer;
  color: var(--primary);
  font-weight: 700;
  list-style-position: inside;
  white-space: nowrap;
}

.row-editor form {
  position: absolute;
  right: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) 130px minmax(280px, 1.6fr) 90px 96px 86px 90px;
  gap: var(--space-sm);
  align-items: end;
  width: min(980px, calc(100vw - 340px));
  margin-top: var(--space-2);
  padding: var(--space-sm);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #ffffff;
  box-shadow: var(--shadow-md);
}

.row-editor label {
  display: grid;
  gap: var(--space-1);
  min-width: 0;
  color: #465568;
  font-size: var(--text-xs);
  font-weight: 700;
}

.row-editor input,
.row-editor select {
  min-width: 0;
}

@media (max-width: 1100px) {
  .row-editor form {
    position: static;
    grid-template-columns: 1fr;
    width: min(420px, 78vw);
  }
}

.dashboard-grid {
  width: min(100% - 40px, var(--content-max));
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: var(--space-sm);
}

.dashboard-grid .panel {
  width: 100%;
  margin: var(--space-sm) 0;
}

.shortcut-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: var(--space-sm);
}

.shortcut-grid a,
.status-list a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  min-height: 36px;
  padding: 8px 10px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: #fbfcfe;
  color: var(--text-body);
  font-size: var(--text-sm);
  font-weight: 700;
}

.shortcut-grid a:hover,
.status-list a:hover {
  background: var(--surface-muted);
  color: var(--text-strong);
  text-decoration: none;
}

.status-list {
  display: grid;
  gap: var(--space-sm);
}

.status-list strong {
  color: var(--text-strong);
  font-variant-numeric: tabular-nums;
}

.dashboard-hero {
  width: min(100% - 40px, var(--content-max));
  margin: 0 auto var(--space-sm);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-lg);
  padding: 22px;
  border: 1px solid #dbe5f2;
  border-radius: var(--radius-lg);
  background:
    linear-gradient(135deg, rgb(255 255 255 / 0.92), rgb(240 247 255 / 0.88)),
    #ffffff;
  box-shadow: var(--shadow-sm);
}

.dashboard-hero h1 { margin: 2px 0 var(--space-sm); font-size: 26px; }
.dashboard-hero p { max-width: 760px; margin: 0; color: var(--text-muted); }

.dashboard-eyebrow {
  color: #47617d;
  font-size: var(--text-xs);
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.dashboard-day {
  display: grid;
  place-items: center;
  min-width: 92px;
  min-height: 84px;
  border: 1px solid #d7e3f1;
  border-radius: var(--radius-lg);
  background: #ffffff;
}

.dashboard-day span,
.dashboard-kpi-copy > span,
.section-title span {
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: 800;
  text-transform: uppercase;
}

.dashboard-day strong {
  color: var(--text-strong);
  font-size: 30px;
  line-height: 1;
}

.dashboard-kpis {
  width: min(100% - 40px, var(--content-max));
  margin: 0 auto var(--space-sm);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(218px, 1fr));
  gap: var(--space-sm);
}

.dashboard-kpi {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: var(--space-md);
  min-height: 118px;
  padding: var(--space-md);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: var(--surface-raised);
  box-shadow: var(--shadow-sm);
  color: var(--text-body);
  transition: transform 150ms ease, box-shadow 150ms ease, border-color 150ms ease;
}

.dashboard-kpi:hover {
  transform: translateY(-1px);
  border-color: var(--tone-border, var(--border-strong));
  box-shadow: 0 10px 24px rgb(15 23 42 / 0.09);
  text-decoration: none;
}

.dashboard-kpi-icon {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: var(--radius-lg);
  background: var(--tone-bg, #eef2f6);
  color: var(--tone-text, var(--brand));
}

.dashboard-kpi svg,
.quick-actions svg,
.shortcut-cards svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.dashboard-kpi-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.dashboard-kpi-copy strong {
  color: var(--text-strong);
  font-size: 30px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.dashboard-kpi-copy small {
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.tone-blue { --tone-bg: #eaf2ff; --tone-text: #155eef; --tone-border: #b8d2ff; }
.tone-green { --tone-bg: #e8f8ef; --tone-text: #177245; --tone-border: #b9e7cd; }
.tone-amber { --tone-bg: #fff6df; --tone-text: #916300; --tone-border: #f2d891; }
.tone-violet { --tone-bg: #f1ecff; --tone-text: #6442c8; --tone-border: #d8c9ff; }
.tone-teal { --tone-bg: #e4f8f7; --tone-text: #087a78; --tone-border: #a8dfdd; }
.tone-rose { --tone-bg: #fff0f2; --tone-text: #b4233c; --tone-border: #f5c1ca; }
.tone-orange { --tone-bg: #fff0e5; --tone-text: #ae4f00; --tone-border: #f4c59d; }
.tone-indigo { --tone-bg: #edf0ff; --tone-text: #3d4fc7; --tone-border: #c9d1ff; }

.dashboard-layout {
  width: min(100% - 40px, var(--content-max));
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(312px, 0.36fr);
  gap: var(--space-sm);
  align-items: start;
}

.dashboard-main,
.dashboard-side {
  display: grid;
  gap: var(--space-sm);
}

.dashboard-section {
  width: 100%;
  margin: 0;
  padding: var(--space-lg);
  min-width: 0;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.section-title h2 { margin: 0; }

.profile-grid,
.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: var(--space-sm);
}

.profile-tile,
.mini-chart {
  padding: var(--space-md);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: #fbfcff;
  min-width: 0;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.profile-tile { min-height: 142px; }
.profile-tile:hover,
.mini-chart:hover {
  transform: translateY(-1px);
  border-color: #c8d8ef;
  box-shadow: 0 10px 22px rgb(15 23 42 / 0.07);
}
.profile-tile h3,
.mini-chart h3 { margin: 0 0 6px; color: var(--text-strong); }
.profile-tile p {
  min-height: 38px;
  margin: 0 0 var(--space-md);
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.profile-tile div {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-sm);
}

.profile-tile span {
  display: grid;
  gap: 2px;
  min-width: 0;
  color: var(--text-muted);
  font-size: var(--text-xs);
}

.profile-tile strong {
  color: var(--text-strong);
  font-size: 20px;
  line-height: 1;
}

.quick-actions,
.shortcut-cards,
.pending-list,
.activity-list {
  display: grid;
  gap: var(--space-sm);
}

.quick-actions a,
.shortcut-cards a {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  gap: var(--space-sm);
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: #fbfcfe;
  color: var(--text-body);
  font-weight: 750;
  transition: transform 150ms ease, box-shadow 150ms ease, border-color 150ms ease, background 150ms ease;
}

.quick-actions a:hover,
.shortcut-cards a:hover,
.pending-list a:hover {
  transform: translateY(-1px);
  border-color: #b7c8df;
  background: #ffffff;
  box-shadow: 0 8px 18px rgb(15 23 42 / 0.07);
  text-decoration: none;
}

.quick-actions svg,
.shortcut-cards svg { color: #42627f; }

.pending-list a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  min-height: 52px;
  padding: 10px 12px;
  border: 1px solid var(--border-subtle);
  border-left: 4px solid #c5d0dd;
  border-radius: var(--radius-lg);
  background: #ffffff;
  color: var(--text-body);
}

.pending-list span {
  display: grid;
  gap: 3px;
  font-weight: 750;
}

.pending-list small {
  color: var(--text-muted);
  font-size: var(--text-xs);
  text-transform: uppercase;
}

.pending-list strong {
  color: var(--text-strong);
  font-size: 20px;
}

.pending-list .priority-alta { border-left-color: #df3f55; }
.pending-list .priority-media { border-left-color: #d79023; }
.pending-list .priority-baixa { border-left-color: #2d9f72; }

.mini-chart {
  min-height: 204px;
}

.mini-chart h3 {
  margin-bottom: var(--space-md);
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(88px, 0.85fr) minmax(84px, 1fr) auto;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: 10px;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.bar-row div {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8edf4;
}

.bar-row i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #5578d8;
}

.bar-row.positive i { background: #2f9e6c; }
.bar-row.negative i { background: #d55b6c; }

.bar-row strong {
  color: var(--text-strong);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
}

.spark-bars {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  align-items: end;
  gap: var(--space-sm);
  min-height: 150px;
}

.spark-bars span {
  display: grid;
  grid-template-rows: 1fr auto;
  align-items: end;
  gap: 6px;
  height: 150px;
  color: var(--text-muted);
  text-align: center;
  font-size: var(--text-xs);
}

.spark-bars i {
  display: block;
  min-height: 4px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: linear-gradient(180deg, #57a0d7, #5fc3a5);
}

.activity-list > div {
  display: grid;
  grid-template-columns: minmax(170px, 0.9fr) minmax(160px, 1fr) minmax(110px, auto);
  gap: var(--space-sm);
  align-items: center;
  min-height: 42px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.activity-list > div:last-child { border-bottom: 0; }

.activity-list span {
  color: var(--text-strong);
  font-weight: 750;
}

.activity-list strong,
.activity-list small {
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-sm);
}

.summary-grid > div {
  display: grid;
  gap: var(--space-1);
  min-width: 0;
}

.summary-grid strong {
  color: var(--text-strong);
  overflow-wrap: anywhere;
}

.summary-grid-spaced {
  margin-top: var(--space-3);
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--surface-muted);
  color: #475569;
  border: 1px solid #dbe3ec;
  font-size: var(--text-xs);
  font-weight: 750;
  white-space: nowrap;
}

.badge-sm {
  min-height: 18px;
  padding: 2px 6px;
  font-size: 10.5px;
}

.badge.ok,
.badge.active,
.badge.authorized,
.badge.approved,
.badge.paid,
.badge.generated,
.badge.validated,
.badge.settled,
.badge.issued,
.badge.ready,
.badge.invoiced,
.badge.partially_invoiced,
.badge.financial_generated,
.badge.released_for_billing,
.badge.moved,
.badge.reserved {
  background: var(--success-bg);
  color: var(--success-text);
  border-color: #b7e5ca;
}

.badge.off,
.badge.rejected,
.badge.cancelled,
.badge.overdue,
.badge.failed,
.badge.error,
.badge.provider_error {
  background: var(--danger-bg);
  color: var(--danger-text);
  border-color: #f5b8b8;
}

.badge.warn,
.badge.pending,
.badge.draft,
.badge.open,
.badge.waiting,
.badge.processing,
.badge.pending_approval,
.badge.billing_pending,
.badge.financial_pending,
.badge.pending_authorization {
  background: var(--warning-bg);
  color: var(--warning-text);
  border-color: #f4dc93;
}

.badge.info,
.badge.skipped,
.badge.none,
.badge.nao_aplicavel,
.badge.homologation,
.badge.production {
  background: var(--info-bg);
  color: var(--info-text);
  border-color: #bed3ff;
}

.alert {
  width: min(100% - 40px, var(--content-max));
  margin: var(--space-3) auto;
  padding: var(--space-3) var(--space-4);
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  font-weight: 650;
}

.alert.error { background: var(--danger-bg); color: var(--danger-text); border-color: #f5b8b8; }
.alert.warn { background: var(--warning-bg); color: var(--warning-text); border-color: #f4dc93; }
.alert.info { background: var(--info-bg); color: var(--info-text); border-color: #b7cdfb; }

.empty-state {
  padding: var(--space-6);
  color: var(--text-muted);
  text-align: center;
  background: var(--surface-raised);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--space-6);
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(rgb(6 26 61 / 0.08), rgb(6 26 61 / 0.08)),
    url("/static/branding/semantiq-login-background.svg") center / cover no-repeat,
    radial-gradient(circle at 18% 18%, rgb(8 184 207 / 0.26), transparent 34%),
    radial-gradient(circle at 82% 82%, rgb(7 94 234 / 0.30), transparent 38%),
    linear-gradient(135deg, #061a3d 0%, var(--semantiq-navy) 54%, #0a4ba8 100%);
}

.login-page::before,
.login-page::after {
  content: "";
  position: fixed;
  pointer-events: none;
  border: 1px solid rgb(255 255 255 / 0.10);
  transform: rotate(30deg);
}
.login-page::before { width: 440px; height: 440px; left: -180px; top: -210px; }
.login-page::after { width: 520px; height: 520px; right: -260px; bottom: -300px; }

.login-box {
  width: min(396px, 100%);
  display: grid;
  gap: var(--space-3);
  background: var(--surface-raised);
  padding: var(--space-6);
  border: 1px solid rgb(255 255 255 / 0.58);
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  position: relative;
  z-index: 1;
}

.login-box .alert { width: 100%; margin: 0; }
.login-logo { display: block; width: min(300px, 100%); height: auto; margin: 0 auto; }
.login-attribution, .login-domain { margin: 0; text-align: center; color: var(--text-muted); }
.login-attribution { font-size: var(--text-sm); }
.login-domain { font-size: var(--text-xs); }

.sales-lines {
  display: grid;
  gap: var(--space-2);
}

.sales-line {
  display: grid;
  grid-template-columns: minmax(280px, 2fr) minmax(72px, .55fr) repeat(3, minmax(112px, 1fr)) minmax(108px, auto) auto;
  gap: var(--space-2);
  align-items: end;
  padding: var(--space-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: #fbfcfe;
}

.sales-line-classification {
  grid-column: 1 / -1;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  background: #f8fafc;
}

.sales-line-classification summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--text-muted);
}

.compact-grid {
  margin-top: var(--space-2);
}

.sales-line-field {
  display: grid;
  gap: 4px;
  min-width: 0;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}

.sales-line-field input,
.sales-line-field select {
  width: 100%;
  min-width: 0;
}

.sales-line-total {
  display: grid;
  gap: 4px;
  min-height: 42px;
  align-content: center;
  text-align: right;
}

.sales-line-total span {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}

.sales-line-total strong {
  color: var(--text-strong);
  font-variant-numeric: tabular-nums;
}

.price-policy-hint {
  grid-column: 1 / -2;
  min-height: 16px;
  color: var(--muted);
  font-size: 12px;
}

.price-policy-hint.danger {
  color: #b91c1c;
  font-weight: 700;
}

.totals {
  max-width: none;
  margin-top: var(--space-3);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--space-3);
}

.production-order-panel,
.production-form {
  overflow: visible;
}

.production-form .form-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(230px, 100%), 1fr));
  align-items: end;
}

.production-form .panel.subtle {
  width: 100%;
  max-width: 100%;
  margin: var(--space-md) 0;
  background: #f8fbff;
}

.production-components-wrap {
  width: 100%;
  max-width: 100%;
  max-height: min(42dvh, 460px);
  overflow: auto;
  overscroll-behavior: contain;
}

.production-components-table {
  min-width: 1120px;
  table-layout: fixed;
}

.production-components-table th:nth-child(1),
.production-components-table td:nth-child(1) { width: 34%; }
.production-components-table th:nth-child(2),
.production-components-table td:nth-child(2) { width: 14%; }
.production-components-table th:nth-child(3),
.production-components-table td:nth-child(3) { width: 19%; }
.production-components-table th:nth-child(4),
.production-components-table td:nth-child(4) { width: 12%; }
.production-components-table th:nth-child(5),
.production-components-table td:nth-child(5) { width: 12%; }
.production-components-table th:nth-child(6),
.production-components-table td:nth-child(6) { width: 9%; }

.production-components-table td {
  vertical-align: top;
}

.production-components-table select,
.production-components-table input {
  min-width: 0;
}

.production-components-table small {
  display: block;
  margin-top: 3px;
  white-space: normal;
}

.production-form > .actions {
  margin-top: var(--space-sm);
}

.totals p {
  display: grid;
  gap: var(--space-1);
  margin: 0;
  min-width: 0;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: #fbfcfe;
}

.totals strong {
  font-size: 1.05rem;
  color: var(--text-strong);
  font-variant-numeric: tabular-nums;
}

.totals p:last-child {
  background: #eef5ff;
  border-color: #b7cff7;
}

.print-page {
  background: #ffffff;
}

.print-sheet {
  width: min(100% - 40px, 900px);
  margin: var(--space-6) auto;
  padding: var(--space-6);
  background: #ffffff;
  color: #111827;
}

.print-sheet .table-wrap {
  width: 100%;
  margin: var(--space-4) 0;
}

.print-header {
  display: flex;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
  border-bottom: 1px solid #d6dee9;
  padding-bottom: var(--space-4);
}

.print-block {
  margin: 0 0 var(--space-5);
}

.print-signatures {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-5);
  margin-top: 64px;
  text-align: center;
}

.print-signatures span {
  display: block;
  border-top: 1px solid #111827;
  margin-bottom: var(--space-2);
  height: 1px;
}

.document-actions {
  print-color-adjust: exact;
}

.document-layout-grid {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: var(--space-4);
  width: calc(100% - 48px);
  margin: 0 auto var(--space-5);
}

.document-layout-preview {
  min-width: 0;
  overflow: auto;
  padding: var(--space-3);
}

.document-a4 {
  position: relative;
  width: min(100%, 210mm);
  min-height: 297mm;
  margin: var(--space-5) auto;
  padding: 18mm;
  overflow: hidden;
  border: 1px solid #d8e0ec;
  border-radius: 6px;
  background: #ffffff;
  color: #111827;
  box-shadow: 0 18px 45px rgb(15 23 42 / 0.12);
  font-family: var(--doc-font), Inter, system-ui, sans-serif;
  print-color-adjust: exact;
}

.document-style-background {
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--doc-primary) 8%, transparent), transparent 35%),
    #ffffff;
}

.document-style-boxed .doc-parties,
.document-style-boxed .doc-facts,
.document-style-boxed .doc-bottom {
  border: 1px solid #dbe4f0;
  border-radius: 8px;
}

.doc-watermark {
  position: absolute;
  inset: 40% auto auto 50%;
  transform: translate(-50%, -50%) rotate(-22deg);
  color: rgb(15 23 42 / 0.07);
  font-size: 82px;
  font-weight: 900;
  letter-spacing: 0.08em;
  white-space: nowrap;
  pointer-events: none;
}

.doc-header {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 24px;
  align-items: start;
  padding-bottom: 18px;
  border-bottom: 3px solid var(--doc-primary);
}

.doc-brand {
  display: grid;
  gap: 6px;
}

.doc-brand img {
  max-width: 155px;
  max-height: 70px;
  object-fit: contain;
}

.doc-brand strong {
  color: var(--doc-secondary);
  font-size: 24px;
}

.doc-brand span,
.doc-title p,
.doc-items small,
.doc-footer {
  color: #64748b;
}

.doc-title {
  text-align: right;
}

.doc-title h1 {
  margin: 8px 0 3px;
  color: var(--doc-secondary);
  font-size: 31px;
  letter-spacing: 0;
}

.doc-status {
  display: inline-flex;
  padding: 5px 10px;
  border: 1px solid color-mix(in srgb, var(--doc-primary) 45%, #ffffff);
  border-radius: 999px;
  background: color-mix(in srgb, var(--doc-primary) 9%, #ffffff);
  color: var(--doc-primary);
  font-size: 12px;
  font-weight: 800;
}

.doc-parties {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-top: 20px;
  padding: 15px;
  background: #f8fafc;
}

.doc-parties h2,
.doc-notes h2 {
  margin: 0 0 7px;
  color: var(--doc-primary);
  font-size: 12px;
  text-transform: uppercase;
}

.doc-parties p,
.doc-notes p {
  margin: 0;
  line-height: 1.55;
}

.doc-facts {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  margin-top: 16px;
  background: #dbe4f0;
}

.doc-facts p {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 12px;
  background: #ffffff;
}

.doc-facts span,
.doc-totals span {
  color: #64748b;
  font-size: 12px;
}

.doc-items {
  width: 100%;
  margin-top: 18px;
  border-collapse: collapse;
  font-size: 13px;
}

.doc-items th {
  padding: 10px;
  background: var(--doc-secondary);
  color: #ffffff;
  text-align: left;
}

.doc-items td {
  padding: 10px;
  border-bottom: 1px solid #e2e8f0;
  vertical-align: top;
}

.doc-items small {
  display: block;
  margin-top: 3px;
}

.doc-items .num {
  text-align: right;
  white-space: nowrap;
}

.doc-bottom {
  display: grid;
  grid-template-columns: 1fr 250px;
  gap: 18px;
  margin-top: 18px;
  align-items: start;
}

.doc-notes {
  padding: 14px;
  background: #f8fafc;
}

.doc-totals {
  display: grid;
  gap: 8px;
}

.doc-totals p {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin: 0;
  padding: 8px 0;
  border-bottom: 1px solid #e2e8f0;
}

.doc-totals p:last-child {
  padding: 12px;
  border: 0;
  border-radius: 6px;
  background: var(--doc-primary);
  color: #ffffff;
}

.doc-totals p:last-child span {
  color: #eaf1ff;
}

.doc-footer {
  position: absolute;
  right: 18mm;
  bottom: 10mm;
  left: 18mm;
  padding-top: 10px;
  border-top: 1px solid #e2e8f0;
  font-size: 11px;
  text-align: center;
}

@media (max-width: 1020px) {
  :root { --sidebar-width: 248px; }
  .sidebar { padding-inline: var(--space-2); }
  .brand img { width: 156px; }
  .page-head,
  .panel,
  .cards,
  .dashboard-hero,
  .dashboard-kpis,
  .dashboard-layout,
  .subnav,
  .table-wrap,
  .alert { width: calc(100% - 28px); }
  .dashboard-layout { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  body {
    background-color: var(--surface-page);
    height: auto;
    min-height: 100%;
    overflow: auto;
  }
  .app-shell {
    display: block;
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: min(86vw, 320px);
    height: 100vh;
    height: 100dvh;
    max-height: 100dvh;
    transform: translateX(-105%);
    transition: transform 180ms ease;
    box-shadow: var(--shadow-md);
  }
  body.mobile-sidebar-open .sidebar { transform: translateX(0); }
  body.mobile-sidebar-open .sidebar-overlay {
    opacity: 1;
    pointer-events: auto;
  }
  .sidebar-shell { min-height: 0; }
  .brand { margin-bottom: 0; }
  .sidebar-nav {
    grid-template-columns: 1fr;
    overflow-y: auto;
  }
  .nav-group { min-width: 0; }
  .nav-group summary { min-height: 34px; }
  .nav-children { margin-left: 27px; padding-left: 7px; border-left: 1px solid rgb(255 255 255 / 0.10); }
  .sidebar-footer { display: none; }
  .sidebar form { margin: 0; }
  .main {
    height: auto;
    min-height: 100dvh;
    margin-left: 0;
    max-width: 100%;
    overflow: visible;
  }
  .dashboard-hero {
    grid-template-columns: 1fr;
    padding: var(--space-lg);
  }
  .dashboard-day {
    justify-items: start;
    place-items: start;
    min-width: 0;
    min-height: 0;
    padding: var(--space-md);
  }
  .dashboard-kpis {
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  }
  .activity-list > div,
  .bar-row {
    grid-template-columns: 1fr;
  }
  .profile-tile div {
    grid-template-columns: repeat(3, minmax(64px, 1fr));
  }
  body.sidebar-collapsed .sidebar { width: min(86vw, 320px); }
  body.sidebar-collapsed .main { margin-left: 0; max-width: 100%; }
  body.sidebar-collapsed .sidebar-head { flex-direction: row; }
  body.sidebar-collapsed .brand { justify-content: flex-start; padding: var(--space-sm) 10px; }
  body.sidebar-collapsed .brand img { width: 156px; height: auto; }
  body.sidebar-collapsed .nav-item,
  body.sidebar-collapsed .nav-group summary,
  body.sidebar-collapsed .sidebar-footer,
  body.sidebar-collapsed .link-button { justify-content: flex-start; }
  body.sidebar-collapsed .nav-item span:not(.nav-ico),
  body.sidebar-collapsed .nav-group summary span:not(.nav-ico),
  body.sidebar-collapsed .nav-subitem span,
  body.sidebar-collapsed .sidebar-footer span,
  body.sidebar-collapsed .sidebar-footer strong {
    display: inline;
  }
  body.sidebar-collapsed .nav-group summary::after,
  body.sidebar-collapsed .nav-children,
  body.sidebar-collapsed .nav-nested {
    display: grid;
  }
  .topbar {
    align-items: center;
    flex-direction: row;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
  }
  .app-topbar {
    align-items: stretch;
    flex-direction: column;
    min-height: 0;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
  }
  .app-topbar-left {
    flex-wrap: wrap;
    gap: var(--space-2);
  }
  .topbar-brand {
    width: 104px;
  }
  .topbar-brand img {
    width: 96px;
  }
  .module-title {
    flex: 1 1 auto;
    max-width: none;
  }
  .module-nav {
    order: 10;
    flex: 1 0 100%;
    width: 100%;
    padding-bottom: 2px;
  }
  .app-launcher-panel {
    position: fixed;
    top: 54px;
    right: 10px;
    left: 10px;
    width: auto;
    grid-template-columns: 1fr;
  }
  .module-more > div {
    left: var(--module-menu-left, 12px);
    width: min(280px, calc(100vw - 24px));
  }
  .mobile-menu-button { display: inline-grid; place-items: center; }
  .topbar-title { min-width: 0; flex: 1 1 auto; }
  .topbar-title .muted {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .topbar-actions { align-items: center; flex-direction: row; }
  .floating-assistant {
    right: 12px;
    bottom: 12px;
  }
  .floating-assistant-button {
    width: 44px;
    height: 44px;
  }
  .assistant-drawer {
    height: min(560px, calc(100vh - 92px));
  }
  .assistant-widget-composer {
    grid-template-columns: 1fr;
  }
  .tenant-switch { display: none; }
  .user-chip strong { display: none; }
  .user-menu-panel { right: 0; }
  .tenant-switch { width: 100%; }
  .tenant-switch label { flex: 1 1 auto; }
  .tenant-switch button { flex: 0 0 auto; }
  .page-head {
    align-items: stretch;
    flex-direction: column;
    padding-top: var(--space-4);
  }
  h1 { font-size: 22px; }
  .filters,
  .form-grid,
  .cards,
  .profile-grid,
  .profile-layout,
  .profile-edit-grid,
  .profile-security-grid,
  .profile-setup-grid,
  .profile-inline-form,
  .partners-filter,
  .partner-address-grid,
  .partner-contact-row,
  .document-layout-grid,
  .dashboard-grid { grid-template-columns: 1fr; }
  .profile-page,
  .about-page { width: calc(100% - 20px); }
  .profile-hero {
    align-items: stretch;
    flex-direction: column;
  }
  .profile-identity {
    position: static;
  }
  .subnav.is-compact {
    align-items: stretch;
    flex-direction: column;
    overflow: visible;
  }
  .subnav-main a { flex: 1 1 calc(50% - var(--space-xs)); }
  .subnav-secondary details { width: 100%; }
  .subnav-secondary summary { width: 100%; }
  .subnav-menu {
    position: static;
    margin-top: var(--space-xs);
    box-shadow: var(--shadow-sm);
  }
  .panel,
  .card,
  .login-box { padding: var(--space-3); }
  .document-a4 {
    width: calc(100vw - 22px);
    min-height: 0;
    margin: var(--space-3) auto;
    padding: 18px;
  }
  .doc-header,
  .doc-parties,
  .doc-bottom { grid-template-columns: 1fr; }
  .doc-title { text-align: left; }
  .doc-facts { grid-template-columns: 1fr 1fr; }
  .doc-footer { position: static; margin-top: 20px; }
  .sales-line { grid-template-columns: 1fr; }
  .field-control-row { grid-template-columns: 1fr; }
  .remote-lookup-menu { width: min(100%, calc(100vw - 32px)); }
  .actions,
  .page-head .actions,
  .panel.actions {
    align-items: stretch;
  }
  .actions > *,
  .actions form,
  .actions button,
  .actions .button {
    width: 100%;
  }
}

@media (max-width: 430px) {
  .nav-item,
  .nav-subitem,
  .nav-group summary,
  .link-button {
    min-height: 32px;
    padding: 7px 8px;
    font-size: 12px;
  }
  .page-head,
  .panel,
  .cards,
  .dashboard-hero,
  .dashboard-kpis,
  .dashboard-layout,
  .table-wrap,
  .alert { width: calc(100% - 20px); }
  main.main > table.table { width: calc(100% - 20px); }
  .dashboard-kpis,
  .profile-grid,
  .chart-grid {
    grid-template-columns: 1fr;
  }
  .table th,
  .table td { padding: 8px 9px; }
}

.assistant-thread {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
}

.assistant-message {
  max-width: 860px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-muted);
}

.assistant-message.is-user {
  justify-self: end;
  background: #edf4ff;
}

.assistant-message p {
  margin: 6px 0 0;
  white-space: pre-wrap;
}

.assistant-composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.assistant-composer textarea {
  min-height: 78px;
  resize: vertical;
}

.floating-assistant {
  position: fixed;
  right: 18px;
  bottom: 14px;
  z-index: 1200;
  display: grid;
  justify-items: end;
  gap: 12px;
  pointer-events: none;
}

.floating-assistant-actions {
  display: grid;
  gap: 10px;
  pointer-events: auto;
}

.floating-assistant-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 999px;
  background: #1f5eff;
  color: #fff;
  font-weight: 800;
  box-shadow: 0 12px 28px rgb(15 23 42 / 0.22);
  text-decoration: none;
  cursor: pointer;
}

.floating-assistant-button svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}

.assistant-drawer {
  width: min(520px, calc(100vw - 28px));
  height: min(620px, calc(100vh - 118px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 18px 60px rgb(15 23 42 / 0.28);
  pointer-events: auto;
}

.floating-assistant.is-expanded .assistant-drawer {
  width: min(860px, calc(100vw - 28px));
  height: min(780px, calc(100vh - 40px));
}

.assistant-identity, .assistant-header-actions { display: flex; align-items: center; gap: 9px; }
.assistant-identity small { display: block; color: var(--muted); font-size: var(--text-xs); }
.assistant-avatar { display: grid; place-items: center; flex: 0 0 40px; width: 40px; height: 40px; overflow: hidden; border-radius: 12px; background: linear-gradient(145deg, #102a77, #1f5eff); }
.assistant-avatar img { width: 40px; height: 40px; display: block; object-fit: contain; }

.assistant-drawer[hidden] {
  display: none;
}

.assistant-drawer header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border-bottom: 1px solid var(--border);
}

.assistant-drawer header span {
  display: block;
  color: var(--muted);
  font-size: var(--text-xs);
}

.assistant-widget-thread {
  display: grid;
  align-content: start;
  gap: 10px;
  overflow: auto;
  padding: 14px;
  background: var(--surface-muted);
}

.assistant-widget-thread .assistant-message {
  max-width: 92%;
}

.assistant-widget-composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.assistant-widget-composer small { grid-column: 1 / -1; color: var(--muted); font-size: var(--text-xs); }
.assistant-loading { padding: 8px 14px; color: var(--muted); background: var(--surface-muted); font-size: var(--text-sm); }
.assistant-suggestions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.assistant-suggestions button { min-height: 30px; padding: 5px 9px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text); font-size: var(--text-xs); text-align: left; cursor: pointer; }
.assistant-suggestions.is-inline { margin-top: 6px; }
.assistant-suggestions button:hover { border-color: #1f5eff; color: #1749c7; }
.assistant-suggestions button:focus-visible, .assistant-result-actions a:focus-visible, .assistant-header-actions button:focus-visible { outline: 3px solid rgb(31 94 255 / 0.35); outline-offset: 2px; }
.assistant-result-card { display: grid; gap: 8px; margin-top: 10px; padding: 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.assistant-result-card.is-guidance { border-left: 3px solid #1f5eff; border-top-color: transparent; border-right-color: transparent; border-bottom-color: transparent; background: transparent; }
.assistant-result-card.is-alert { border-color: #f0c36a; background: #fff9e8; }
.assistant-result-card.is-technical_error { border-color: #ef9a9a; background: #fff4f4; }
.assistant-result-sources { color: var(--muted); display: block; line-height: 1.35; }
.assistant-result-totals { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.assistant-result-total { padding: 8px; border-radius: 7px; background: var(--surface-muted); }
.assistant-result-total strong, .assistant-result-total span { display: block; }
.assistant-result-filters { color: var(--muted); font-size: var(--text-xs); }
.assistant-result-warning, .assistant-correlation-id { display: block; color: var(--muted); font-size: var(--text-xs); overflow-wrap: anywhere; }
.assistant-result-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.assistant-result-actions a { padding: 7px 10px; border-radius: 7px; background: #1f5eff; color: #fff; text-decoration: none; }
.assistant-result-actions a:hover { background: #1749c7; }
html.assistant-open, html.assistant-open body, html.assistant-open .main { overflow: hidden; }

@media (max-width: 640px) {
  .assistant-drawer, .floating-assistant.is-expanded .assistant-drawer { position: fixed; inset: 8px; width: auto; height: auto; max-height: none; }
  .assistant-header-actions { gap: 4px; }
  .assistant-result-totals { grid-template-columns: 1fr; }
}

.assistant-widget-composer textarea {
  min-height: 48px;
  max-height: 130px;
  resize: vertical;
}

.assistant-widget-composer.is-loading button {
  opacity: 0.65;
  pointer-events: none;
}

.qr-fallback {
  width: 132px;
  min-height: 132px;
  display: grid;
  place-items: center;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background:
    linear-gradient(90deg, #111 50%, transparent 50%) 0 0 / 16px 16px,
    linear-gradient(#111 50%, transparent 50%) 0 0 / 16px 16px,
    #fff;
  color: #111;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 800;
  text-align: center;
}

.qr-code-box {
  display: inline-grid;
  place-items: center;
  width: 196px;
  height: 196px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.recovery-code-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

.recovery-code-grid code {
  display: block;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-muted);
  text-align: center;
}

.bi-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  margin: 10px 0 18px;
}

.bi-card {
  display: grid;
  gap: 6px;
  min-height: 104px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: inherit;
  text-decoration: none;
}

.bi-card:hover {
  border-color: var(--primary);
}

.bi-card span,
.bi-card small {
  color: var(--muted);
}

.bi-frame-wrap {
  width: 100%;
  height: calc(100vh - 150px);
  min-height: 620px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.bi-frame {
  width: 100%;
  height: 100%;
  border: 0;
}

.bi-page-head {
  width: calc(100% - 28px);
  max-width: none;
  padding-top: var(--space-sm);
}

.bi-page-head h1 {
  font-size: 20px;
}

.bi-viewer {
  width: calc(100% - 28px);
  max-width: none;
  margin: 0 auto var(--space-sm);
}

.inline-form {
  display: inline;
}

.inline-form button {
  vertical-align: middle;
}

.support-mode-toggle {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  white-space: nowrap;
}

.support-mode-toggle.is-active {
  border-color: var(--primary);
  background: rgba(37, 99, 235, 0.10);
  color: var(--primary);
}

.field-inspector-badge {
  display: none;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin-left: 6px;
  padding: 0;
  border: 1px solid var(--primary);
  border-radius: 999px;
  background: #eff6ff;
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  vertical-align: middle;
}

.support-field-mode .field-inspector-badge {
  display: inline-flex;
}

.support-field-mode [data-db-table] {
  outline: 1px dashed rgba(37, 99, 235, 0.35);
  outline-offset: 2px;
}

.field-inspector-popover {
  position: absolute;
  z-index: 1000;
  width: min(340px, calc(100vw - 24px));
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
}

.field-inspector-popover strong {
  display: block;
  margin-bottom: 8px;
}

.field-inspector-popover dl {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 4px 8px;
  margin: 0 0 10px;
}

.field-inspector-popover dt {
  color: var(--muted);
}

.field-inspector-popover dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.field-inspector-sensitive {
  margin: 0 0 8px;
  color: var(--danger);
  font-weight: 700;
}

.field-map-search {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto auto;
  gap: 10px;
  align-items: end;
}

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

@media (max-width: 640px) {
  .assistant-composer { grid-template-columns: 1fr; }
}

@media print {
  :root { --surface-base: #ffffff; }
  body { background: #ffffff; }
  .sidebar,
  .topbar,
  .actions,
  button,
  .button { display: none !important; }
  .main { margin-left: 0; min-height: 0; display: block; }
  .page-head,
  .panel,
  .cards,
  .table-wrap,
  .alert,
  .print-sheet {
    width: 100%;
    margin: 0 0 12px;
    box-shadow: none;
  }
  .panel,
  .print-sheet { border: 0; padding: 0; }
  .document-a4 {
    width: 210mm;
    min-height: 297mm;
    margin: 0;
    padding: 14mm;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
  .doc-footer {
    right: 14mm;
    bottom: 8mm;
    left: 14mm;
  }
  .table { min-width: 0; font-size: 11px; }
  .table th,
  .table td { padding: 5px 6px; }
}
