:root {
  --st-primary: #004659;
  --st-primary-container: #155e75;
  --st-secondary: #006781;
  --st-secondary-soft: #def4ff;
  --st-tertiary: #314156;
  --st-surface: #f7f9fb;
  --st-surface-low: #f2f4f6;
  --st-surface-high: #e6e8ea;
  --st-white: #ffffff;
  --st-ink: #191c1e;
  --st-muted: #5c5f61;
  --st-outline: #bfc8cc;
  --st-outline-soft: #e0e3e5;
  --st-sidebar: 256px;
  --st-header: 56px;
}

html.zms-hd-shell body.zms-stitch-v2 {
  min-height: 100vh;
  background: var(--st-surface) !important;
  color: var(--st-ink);
}

.zms-stitch-v2 #zmsStitchSidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 1650;
  display: flex;
  width: var(--st-sidebar);
  height: 100dvh;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid var(--st-outline);
  background: var(--st-surface-low);
  color: var(--st-tertiary);
}

.zms-stitch-sidebar-brand {
  display: flex;
  min-height: 72px;
  align-items: center;
  gap: 11px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--st-outline-soft);
}

.zms-stitch-sidebar-brand img {
  width: 34px;
  height: 34px;
  border-radius: 8px;
}

.zms-stitch-sidebar-brand span,
.zms-stitch-sidebar-brand strong,
.zms-stitch-sidebar-brand small {
  display: block;
  min-width: 0;
}

.zms-stitch-sidebar-brand strong {
  overflow: hidden;
  color: var(--st-primary);
  font: 700 15px/1.2 var(--zms-font-headline);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.zms-stitch-sidebar-brand small {
  margin-top: 3px;
  color: var(--st-muted);
  font: 500 10px/1.2 var(--zms-font-label);
  letter-spacing: .035em;
  text-transform: uppercase;
}

.zms-stitch-sidebar-action {
  display: flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 12px 16px 8px;
  padding: 0 12px;
  border: 1px solid var(--st-primary);
  border-radius: 6px;
  background: var(--st-primary);
  color: #fff;
  font: 650 12px/1 var(--zms-font-body);
  text-decoration: none;
}

.zms-stitch-sidebar-action:hover {
  border-color: #003544;
  background: #003544;
  color: #fff;
}

.zms-stitch-sidebar-label {
  margin: 13px 18px 7px;
  color: #747779;
  font: 600 9px/1 var(--zms-font-label);
  letter-spacing: .075em;
  text-transform: uppercase;
}

.zms-stitch-sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 2px 12px 16px;
}

.zms-stitch-sidebar-link {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  min-height: 42px;
  align-items: center;
  gap: 9px;
  margin: 2px 0;
  padding: 5px 9px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: #444749;
  font: 580 12px/1.2 var(--zms-font-body);
  text-decoration: none;
}

.zms-stitch-sidebar-link:hover {
  background: #e6eef1;
  color: var(--st-primary);
}

.zms-stitch-sidebar-link.is-active {
  border-color: #b9eaff;
  background: #def4ff !important;
  color: var(--st-primary) !important;
  font-weight: 700;
  box-shadow: inset 3px 0 0 var(--st-secondary) !important;
}

.zms-stitch-sidebar-icon {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 5px;
  background: #e0e3e5;
  color: var(--st-tertiary);
  font: 600 9px/1 var(--zms-font-label);
  text-transform: uppercase;
}

.zms-stitch-sidebar-link.is-active .zms-stitch-sidebar-icon {
  background: var(--st-primary) !important;
  color: #fff !important;
}

.zms-stitch-sidebar-link small {
  color: #747779;
  font: 500 9px/1 var(--zms-font-label);
}

.zms-stitch-sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--st-outline-soft);
}

.zms-stitch-sidebar-footer .zms-stitch-sidebar-link {
  min-height: 38px;
}

.zms-stitch-v2 #zmsGlobalHeader.zms-saas-topbar.zms-hd-header {
  position: sticky;
  top: 0;
  z-index: 1600;
  width: calc(100% - var(--st-sidebar)) !important;
  min-height: 100px;
  margin-left: var(--st-sidebar) !important;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: var(--st-header) 44px;
  padding: 0 20px;
  border-bottom: 1px solid var(--st-outline);
  background: rgba(255, 255, 255, .97);
  backdrop-filter: blur(18px);
}

.zms-stitch-v2 .zms-hd-header .zms-nav-brand-area,
.zms-stitch-v2 .zms-hd-header .zms-nav-primary {
  display: none !important;
}

.zms-stitch-v2 .zms-hd-header .zms-nav-actions {
  grid-column: 1 / -1;
  width: 100%;
  height: var(--st-header);
  justify-content: flex-end;
}

.zms-stitch-v2 .zms-hd-header .zms-nav-search-button {
  width: min(440px, 48vw);
  margin-right: auto;
  border: 1px solid var(--st-outline);
  border-radius: 6px;
  background: var(--st-surface);
}

.zms-stitch-v2 .zms-hd-header .zms-nav-search-button:hover {
  border-color: var(--st-secondary);
  background: #fff;
}

.zms-stitch-v2 .zms-hd-header .zms-nav-create {
  border-radius: 6px;
  background: var(--st-primary);
}

.zms-stitch-v2 .zms-hd-contextbar {
  grid-column: 1 / -1;
  height: 44px;
  margin: 0 -20px;
  padding: 0 20px;
  border-top: 1px solid var(--st-outline-soft);
  background: var(--st-white);
}

.zms-stitch-v2 .zms-hd-breadcrumb a,
.zms-stitch-v2 .zms-hd-breadcrumb span {
  font-size: 11px;
}

.zms-stitch-v2 main.content {
  width: auto !important;
  min-height: calc(100vh - 100px);
  margin-left: var(--st-sidebar) !important;
  padding: 20px !important;
  background: var(--st-surface) !important;
}

/* Keep the Stitch desktop workspace beside the fixed module navigation. The
   high-density base shell uses a more specific zero-margin rule, so the
   desktop adaptation needs an equally specific layout declaration. */
@media (min-width: 861px) {
  html.zms-hd-shell body.zms-stitch-v2 main.content {
    width: calc(100% - var(--st-sidebar)) !important;
    max-width: none !important;
    margin-left: var(--st-sidebar) !important;
  }
}

.zms-stitch-v2 main.content::before {
  content: attr(data-stitch-module) " / " attr(data-stitch-view);
  display: block;
  margin: 0 0 8px;
  color: #747779;
  font: 600 9px/1 var(--zms-font-label);
  letter-spacing: .07em;
  text-transform: uppercase;
}

.zms-stitch-v2 main.content > * {
  max-width: 1480px;
  margin-right: auto;
  margin-left: auto;
}

.zms-stitch-v2 main.content > :where(section, article, div) + :where(section, article, div) {
  margin-top: 14px;
}

.zms-stitch-v2 main.content > section.owner-company-scope {
  padding: 10px 14px !important;
  border-color: var(--st-outline-soft) !important;
  background: var(--st-white) !important;
}

.zms-stitch-v2 .owner-company-scope > form.form-grid {
  display: grid !important;
  grid-template-columns: minmax(240px, 1fr) auto !important;
  align-items: end !important;
  gap: 12px !important;
  margin: 0 !important;
}

.zms-stitch-v2 .owner-company-scope label {
  margin: 0 !important;
  font-size: 10px !important;
}

.zms-stitch-v2 .owner-company-scope select {
  min-height: 36px !important;
  margin-top: 5px !important;
}

.zms-stitch-v2 .owner-company-scope button {
  min-width: 160px !important;
  min-height: 36px !important;
  padding: 0 16px !important;
  background: var(--st-primary) !important;
  box-shadow: none !important;
}

.zms-stitch-v2 main :where(.card, .panel, .widget, .stat-card, .metric-card, .dashboard-card, .content-card, .table-card, .form-card, .settings-card, .kpi-card) {
  border: 1px solid var(--st-outline-soft) !important;
  border-radius: 7px !important;
  background: var(--st-white) !important;
  box-shadow: none !important;
}

.zms-stitch-v2 main :where(.card-header, .panel-header, .widget-header, .table-header, .section-header) {
  min-height: 48px;
  border-bottom: 1px solid var(--st-outline-soft) !important;
  background: var(--st-white) !important;
}

.zms-stitch-v2 main :where(h1, .page-title) {
  font-size: clamp(22px, 2.2vw, 30px);
  line-height: 1.15;
}

.zms-stitch-v2 main :where(h2, .section-title) {
  font-size: 17px;
  line-height: 1.25;
}

.zms-stitch-v2 main table {
  border: 1px solid var(--st-outline-soft);
  border-radius: 7px;
  overflow: hidden;
  font-size: 12px;
}

.zms-stitch-v2 main th {
  height: 38px;
  padding: 8px 10px;
  border-color: var(--st-outline-soft) !important;
  background: var(--st-surface-low) !important;
  color: #5c5f61 !important;
  font: 600 9px/1.2 var(--zms-font-label) !important;
  letter-spacing: .045em;
}

.zms-stitch-v2 main td {
  min-height: 44px;
  padding: 9px 10px;
  border-color: var(--st-outline-soft) !important;
}

.zms-stitch-v2 main tbody tr:hover {
  background: #effbff !important;
}

.zms-stitch-v2 .zms-table-scroll {
  width: 100%;
  overflow-x: auto;
  border-radius: 7px;
  outline: none;
}

.zms-stitch-v2 .zms-table-scroll:focus-visible {
  box-shadow: 0 0 0 3px rgba(0, 103, 129, .2);
}

.zms-stitch-v2 main :where(input:not([type="checkbox"]):not([type="radio"]), select, textarea) {
  min-height: 38px;
  border-color: var(--st-outline) !important;
  border-radius: 5px !important;
  background: var(--st-white) !important;
  font-size: 12px !important;
}

.zms-stitch-v2 main :where(button, .btn, [role="button"]) {
  min-height: 36px;
  border-radius: 5px !important;
  font-size: 11px;
}

.zms-stitch-v2 main :where(.btn-primary, .btn.primary, a.primary, button.primary, button[type="submit"], .action-primary) {
  border-color: var(--st-primary) !important;
  background: var(--st-primary) !important;
  color: #fff !important;
  box-shadow: none !important;
}

.zms-stitch-v2 main :where(.btn-primary, .btn.primary, a.primary, button.primary, button[type="submit"], .action-primary):hover {
  border-color: #003544 !important;
  background: #003544 !important;
}

.zms-stitch-v2 main :where(.zms-overview-icon, .metric-icon, .stat-icon, .kpi-icon) {
  background: var(--st-primary) !important;
  color: #fff !important;
  box-shadow: none !important;
}

.zms-stitch-v2 main a.btn.primary,
.zms-stitch-v2 main button.btn.primary,
.zms-stitch-v2 main .btn.primary,
.zms-stitch-v2 main a.primary,
.zms-stitch-v2 main button.primary {
  border-color: var(--st-primary) !important;
  background: var(--st-primary) !important;
  background-image: none !important;
  color: #fff !important;
  box-shadow: none !important;
}

.zms-stitch-v2 main .zms-overview-icon,
.zms-stitch-v2 main .metric-icon,
.zms-stitch-v2 main .stat-icon,
.zms-stitch-v2 main .kpi-icon {
  background: var(--st-primary) !important;
  background-image: none !important;
  color: #fff !important;
  box-shadow: none !important;
}

.zms-stitch-v2 main :where(.tabs, .tab-list, [role="tablist"]) {
  border-bottom: 1px solid var(--st-outline-soft);
  background: var(--st-white);
}

.zms-stitch-v2 main :where(.tab.active, [role="tab"][aria-selected="true"], .nav-tab.active) {
  border-color: var(--st-secondary) !important;
  color: var(--st-primary) !important;
}

.zms-stitch-v2 main :where(.badge, .status, .pill, .chip, .tag) {
  border-radius: 4px !important;
  font: 600 9px/1.3 var(--zms-font-label) !important;
}

.zms-stitch-v2 main[data-stitch-layout="dashboard"] :where(.stats-grid, .metrics-grid, .kpi-grid, .dashboard-stats) {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.zms-stitch-v2 main[data-stitch-layout="editor"] :where(form, .editor-layout, .form-layout) {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 32%);
  gap: 16px;
}

.zms-stitch-v2 main[data-stitch-layout="analytics"] :where(.chart-grid, .report-grid, .analytics-grid) {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.zms-stitch-mobile-nav {
  display: none;
}

.zms-stitch-mobile-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1640;
  display: none;
  border: 0;
  background: rgba(25, 28, 30, .46);
}

@media (max-width: 1120px) {
  :root { --st-sidebar: 224px; }
  .zms-stitch-v2 main[data-stitch-layout="dashboard"] :where(.stats-grid, .metrics-grid, .kpi-grid, .dashboard-stats) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  :root { --st-sidebar: 256px; }
  .zms-stitch-v2 #zmsStitchSidebar {
    transform: translateX(-102%);
    transition: transform .2s ease;
    box-shadow: 0 18px 55px rgba(25, 28, 30, .2);
  }
  .zms-stitch-v2 #zmsStitchSidebar.is-open { transform: translateX(0); }
  .zms-stitch-v2 .zms-stitch-mobile-backdrop.is-open { display: block; }
  .zms-stitch-v2 #zmsGlobalHeader.zms-saas-topbar.zms-hd-header {
    width: 100% !important;
    margin-left: 0 !important;
    padding-inline: 12px;
  }
  .zms-stitch-v2 main.content {
    margin-left: 0 !important;
    padding: 14px 12px 80px !important;
  }
  .zms-stitch-v2 .zms-hd-header .zms-nav-search-button { width: min(54vw, 340px); }
  .zms-stitch-v2 main[data-stitch-layout="editor"] :where(form, .editor-layout, .form-layout),
  .zms-stitch-v2 main[data-stitch-layout="analytics"] :where(.chart-grid, .report-grid, .analytics-grid) {
    grid-template-columns: 1fr;
  }
  .zms-stitch-v2 .owner-company-scope > form.form-grid {
    grid-template-columns: 1fr !important;
  }
  .zms-stitch-v2 .owner-company-scope button {
    width: 100% !important;
  }
  .zms-stitch-mobile-nav {
    position: fixed;
    inset: auto 0 0;
    z-index: 1590;
    display: grid;
    grid-template-columns: repeat(var(--st-mobile-count, 5), minmax(0, 1fr));
    min-height: 64px;
    padding: 5px max(6px, env(safe-area-inset-right)) max(5px, env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left));
    border-top: 1px solid var(--st-outline);
    background: rgba(255, 255, 255, .98);
    backdrop-filter: blur(16px);
  }
  .zms-stitch-mobile-nav a,
  .zms-stitch-mobile-nav button {
    display: flex;
    min-width: 0;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 3px;
    border: 0;
    background: transparent;
    color: #5c5f61;
    font: 600 9px/1.1 var(--zms-font-label);
    text-decoration: none;
  }
  .zms-stitch-mobile-nav a.is-active { color: var(--st-primary); }
  .zms-stitch-mobile-nav .zms-stitch-sidebar-icon { width: 26px; height: 26px; }
}

@media (max-width: 560px) {
  .zms-stitch-v2 .zms-hd-header .zms-nav-search-button span,
  .zms-stitch-v2 .zms-hd-header .zms-nav-search-button kbd,
  .zms-stitch-v2 .zms-hd-header .zms-hd-create-button { display: none !important; }
  .zms-stitch-v2 .zms-hd-header .zms-nav-search-button { width: 44px; }
  .zms-stitch-v2 main[data-stitch-layout="dashboard"] :where(.stats-grid, .metrics-grid, .kpi-grid, .dashboard-stats) {
    grid-template-columns: 1fr;
  }
}
