:root {
  --idsa-container-max: 1200px;
}

.idsa-page {
  padding: 0;
  margin: 0;
  min-width: 0;
}

.idsa-container {
  width: 100%;
  max-width: var(--idsa-container-max);
  margin: 0 auto;
  padding: var(--sp-4, 16px);
  box-sizing: border-box;
}

/* Common rule: allow full width inside panel work area where needed */
.idsa-work-area-full .idsa-container {
  max-width: none;
  width: 100%;
}

.idsa-section {
  background: var(--surface, #fff);
  border: 1px solid var(--border, #dbe6ff);
  border-radius: var(--idsa-radius, 12px);
  padding: var(--sp-4, 16px);
  margin-bottom: var(--sp-4, 16px);
  min-width: 0;
}

.idsa-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--sp-3, 12px);
  min-width: 0;
}

.idsa-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--sp-3, 12px);
  min-width: 0;
}

.idsa-table-scroll {
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}

.idsa-table-scroll > table {
  min-width: 640px;
}

/* One-scroll safety: keep horizontal overflow closed globally */
html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

/* Admin shell: lock page and scroll only in work area */
body.idsa-admin-root.idsa-shell-lock {
  overflow: hidden;
}

body.idsa-admin-root .admin-main,
body.idsa-admin-root .admin-content,
body.idsa-admin-root #admin-content {
  min-height: 0;
}

body.idsa-admin-root .admin-content {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

/* CRM shell: lock page and scroll only in main/work area */
body.idsa-crm-root.idsa-shell-lock {
  overflow: hidden;
}

body.idsa-crm-root .uish-main,
body.idsa-crm-root .uish-work,
body.idsa-crm-root .uish-workbody {
  min-width: 0;
  min-height: 0;
}

body.idsa-crm-root .uish-main,
body.idsa-crm-root .uish-work {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

/* User shell: keep shell static and scroll in work area only */
body.idsa-user-root.idsa-shell-lock {
  overflow: hidden;
}

body.idsa-user-root .idsa-shell,
body.idsa-user-root .idsa-main,
body.idsa-user-root .idsa-work,
body.idsa-user-root .idsa-work-inner {
  min-width: 0;
  min-height: 0;
}

body.idsa-user-root .idsa-work {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

/* Content safety for long text */
.idsa-page,
.idsa-container,
.idsa-section {
  overflow-wrap: anywhere;
}

/* Universal image safety (panel + public content) */
.idsa-container img,
.idsa-section img,
.idsa-work img {
  max-width: 100%;
  height: auto;
}

.idsa-img-auto,
.img-auto {
  display: block;
  margin-inline: auto;
  object-fit: contain;
}

/* Shared media wrappers to keep visual cards aligned across pages */
.idsa-media-frame,
.idsa-image-frame,
.idsa-thumb-frame {
  width: 100%;
  overflow: hidden;
  border-radius: var(--idsa-radius, 12px);
}

.idsa-media-frame img,
.idsa-image-frame img,
.idsa-thumb-frame img {
  width: 100%;
  height: auto;
  display: block;
  margin-inline: auto;
}

/* Topbar shells keep safe box model so auto margins work predictably */
.idsa-topbar,
.uish-topbar,
.topbar {
  box-sizing: border-box;
}

/* Inline-CSS debt cleanup utilities (safe, additive) */
.idsa-u-m0 { margin: 0 !important; }
.idsa-u-m0b10 { margin: 0 0 10px !important; }
.idsa-u-m0b10x { margin: 0 0 10px 0 !important; }
.idsa-u-m0b8 { margin: 0 0 8px !important; }
.idsa-u-m12b8 { margin: 12px 0 8px !important; }
.idsa-u-my10b12 { margin: 10px 0 12px !important; }
.idsa-u-mt0 { margin-top: 0 !important; }
.idsa-u-mt4 { margin-top: 4px !important; }
.idsa-u-mt6 { margin-top: 6px !important; }
.idsa-u-mt8 { margin-top: 8px !important; }
.idsa-u-mt10 { margin-top: 10px !important; }
.idsa-u-mt12 { margin-top: 12px !important; }
.idsa-u-mt14 { margin-top: 14px !important; }
.idsa-u-mb10 { margin-bottom: 10px !important; }
.idsa-u-mb12 { margin-bottom: 12px !important; }
.idsa-u-fs24 { font-size: 24px !important; }
.idsa-u-span-full { grid-column: 1 / -1 !important; }

@media (max-width: 768px) {
  .idsa-container {
    padding: var(--sp-3, 12px);
  }

  .idsa-grid,
  .idsa-form-grid {
    grid-template-columns: 1fr;
  }
}
