:root{
  --bg: #1c2329;
  --panel: #1e3044;
  --panel2:#1e3044;
  --text:#f0e1e1;
  --muted:#9fb0c3;
  --border:rgba(255,255,255,.08);
  --brand:#ff6642;
  --danger:#ff4d4d;
  --shadow: 0 16px 40px rgba(0,0,0,.45);
  --radius: 18px;
  --radius2: 14px;
  --pad: 18px;
}

[data-theme="light"]{
  --bg:#f6f7fb;
  --panel:#ffffff;
  --panel2:#ffffff;
  --text:#0f172a;
  --muted:#475569;
  --border:#e5e7eb;
  --brand:#0ea5e9;
  --danger:#e11d48;
  --shadow: 0 16px 40px rgba(2,6,23,.12);
}

*{ box-sizing:border-box; }
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial;
  background: radial-gradient(1200px 800px at 10% 10%, rgba(94,234,212,.12), transparent 55%),
              radial-gradient(1000px 700px at 90% 20%, rgba(14,165,233,.14), transparent 55%),
              var(--bg);
  color:var(--text);
}

.app{
  display:grid;
  grid-template-columns: 280px 1fr;
  min-height:100vh;
}

.sidebar{
  position:sticky;
  top:0;
  height:100vh;
  padding:18px;
  border-right:1px solid var(--border);
  background: linear-gradient(180deg, rgba(17,24,39,.65), rgba(17,24,39,.35));
  backdrop-filter: blur(10px);
}

.brand{
  display:flex;
  gap:12px;
  align-items:center;
  padding:12px;
  border:1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255,255,255,.03);
}
.brandMark{
  width:42px;height:42px;
  border-radius: 14px;
  display:flex;align-items:center;justify-content:center;
  font-weight:800;
  color: #001018;
  background: linear-gradient(135deg, var(--brand), rgba(255,255,255,.85));
}
.brandName{ font-weight:800; letter-spacing:.2px; }
.brandSub{ font-size:12px; color:var(--muted); margin-top:2px; }

.nav{
  margin-top:14px;
  display:flex;
  flex-direction:column;
  gap:8px;
}
.navItem{
  width:100%;
  display:flex;
  gap:10px;
  align-items:center;
  padding:12px 12px;
  border-radius: 14px;
  border:1px solid var(--border);
  background: rgba(255,255,255,.03);
  color:var(--text);
  cursor:pointer;
  transition: transform .08s ease, background .12s ease, border-color .12s ease;
}
.navItem:hover{ transform: translateY(-1px); background: rgba(255,255,255,.05); }
.navItem.active{
  border-color: rgba(94,234,212,.35);
  box-shadow: 0 0 0 3px rgba(94,234,212,.10);
}
.navDot{
  width:10px;height:10px;border-radius:10px;
  background: rgba(148,163,184,.6);
}
.navItem.active .navDot{ background: var(--brand); }

.sidebarFooter{
  position:absolute;
  left:18px; right:18px; bottom:18px;
  display:flex;
  gap:10px;
}
.ghostBtn{
  flex:1;
  padding:10px 12px;
  border-radius: 14px;
  border:1px solid var(--border);
  background: rgba(255,255,255,.03);
  color:var(--text);
  cursor:pointer;
}
.ghostBtn:hover{ background: rgba(255,255,255,.06); }
.ghostBtn.danger{ color: var(--danger); }

.main {
  min-width: 0;
}

.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:12px 14px;
  border-radius: var(--radius);
  border:1px solid var(--border);
  background: rgba(255,255,255,.03);
  backdrop-filter: blur(10px);
}

.pageTitle{ font-size:18px; font-weight:800; }
.pageHint{ font-size:12px; color:var(--muted); margin-top:2px; }

.topbarRight{ display:flex; align-items:center; gap:10px; }

.pill{
  display:flex; gap:8px; align-items:center;
  padding:8px 10px;
  border-radius: 999px;
  border:1px solid var(--border);
  background: rgba(255,255,255,.03);
  font-size:12px;
  color:var(--muted);
}
.pillDot{ width:10px;height:10px;border-radius:10px;background: var(--brand); }

.route{ display:none; margin-top:14px; }
.route.active{ display:block; }

.card{
  border:1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255,255,255,.03);
  box-shadow: var(--shadow);
  padding: var(--pad);
}
.cardHeader{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.cardHeader > .row {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.cardHeader .input {
  width: min(360px, 100%);
}

.cardTitle{ font-size:15px; font-weight:800; }
.cardSub{ font-size:12px; color:var(--muted); margin-top:2px; }

/* Make cards and route contents shrink correctly */
.route,
.card,
.grid2,
.tableWrap,
.miniTableWrap {
  min-width: 0;
}

.grid2{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:14px;
}

.row{ display:flex; gap:10px; align-items:center; }
.right{ text-align:right; }
.spacer{ flex:1; }

.btn, .btnPrimary, .btnWide{
  border-radius: 14px;
  border:1px solid var(--border);
  background: rgba(255,255,255,.03);
  color: var(--text);
  padding:10px 12px;
  cursor:pointer;
}
.btn:hover, .btnPrimary:hover, .btnWide:hover{ background: rgba(255,255,255,.06); }
.btnPrimary{
  border-color: rgba(94,234,212,.30);
  box-shadow: 0 0 0 3px rgba(94,234,212,.10);
}
.btn.danger{ color: var(--danger); }
.btnWide{
  width:100%;
  text-align:left;
  padding:12px 12px;
}

.iconBtn{
  border-radius: 12px;
  border:1px solid var(--border);
  background: rgba(255,255,255,.03);
  color: var(--text);
  padding:10px 12px;
  cursor:pointer;
}
.iconBtn:hover{ background: rgba(255,255,255,.06); }

.input:focus{
  border-color: rgba(94,234,212,.35);
  box-shadow: 0 0 0 3px rgba(94,234,212,.10);
}

.small{ font-size:12px; }
.muted{ color: var(--muted); }
.mono{ font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New"; }

.divider{
  height:1px;
  background: var(--border);
  margin: 14px 0;
}

.statsRow{
  display:grid;
  grid-template-columns: repeat(4, 1fr);
  gap:12px;
}
.stat{
  padding:12px;
  border:1px solid var(--border);
  border-radius: var(--radius2);
  background: rgba(255,255,255,.03);
}
.statLabel{ font-size:12px; color:var(--muted); }
.statValue{ font-size:24px; font-weight:900; margin-top:6px; }

.kv{
  display:grid;
  grid-template-columns: 140px 1fr;
  gap:10px 12px;
  align-items:center;
}
.k{ color:var(--muted); font-size:12px; }
.v{ font-size:13px; }

.tableWrap,
.miniTableWrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
}

.table{
  width:100%;
  border-collapse: collapse;
  min-width: 780px;
}
.table th, .table td{
  padding:12px;
  border-bottom:1px solid var(--border);
  font-size:13px;
}
.table th{ color:var(--muted); text-align:left; font-weight:700; }
.table tr:hover td{ background: rgba(255,255,255,.03); }

.table.mini{ min-width: 520px; }

.actions{ display:flex; flex-direction:column; gap:10px; }

.note{
  font-size:13px;
  color: var(--muted);
  line-height:1.45;
}

.integrationList{
  display:flex;
  flex-direction:column;
  gap:10px;
}
.integrationItem{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px;
  padding:12px;
  border:1px solid var(--border);
  border-radius: var(--radius2);
  background: rgba(255,255,255,.03);
}
.integrationName{ font-weight:800; }
.integrationMeta{ font-size:12px; color: var(--muted); margin-top:2px; }

.formGrid{
  display:grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap:10px 12px;
  align-items:center;
}

.formGrid .input{
  width: 100%;
}

.label{ font-size:12px; color: var(--muted); }

.issueList{
  display:flex;
  flex-direction:column;
  gap:10px;
}
.issueCard{
  border:1px solid var(--border);
  border-radius: var(--radius2);
  background: rgba(255,255,255,.03);
  padding:12px;
}
.issueTop{
  display:flex;
  justify-content:space-between;
  gap:10px;
}
.issueTitle{ font-weight:900; }
.issueMeta{ font-size:12px; color:var(--muted); margin-top:4px; }
.issueMsg{ margin-top:10px; font-size:13px; line-height:1.45; }
.issueActions{ margin-top:10px; display:flex; gap:10px; align-items:center; }
.textarea{
  width:100%;
  min-height: 90px;
  resize: vertical;
  border-radius: 14px;
  border:1px solid var(--border);
  background: rgba(255,255,255,.03);
  color: var(--text);
  padding:10px 12px;
  outline:none;
}

.modalOverlay{
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0,0,0,0.55);
}

/* Key fix: cap height + make modal body scroll */
.modal{
  position: fixed;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  left: 50%;
  top: 16px;
  transform: translateX(-50%);
  width: min(1180px, calc(100vw - 24px));
  max-height: calc(100vh - 32px);
  z-index: 1001;

  display: flex;
  flex-direction: column;
  overflow: hidden; /* keeps header/footer visible */
}

/* Builder: make Add Columns thinner and Columns wider */
#builderModal .grid2{
  grid-template-columns: 360px 1fr; /* left thin, right wide */
}

#builderPhasesHost .formGrid{
  grid-template-columns: 1fr; /* stack label + control */
}

#builderPhasesHost .row{
  flex-wrap: wrap;
}
#builderPhasesHost .row .input{
  width: 100%;
  min-width: 0;
}

/* ✅ Milestone rows: input + remove button wrap nicely */
.gs-ms-edit-row{
  display:flex;
  gap:8px;
  align-items:center;
  flex-wrap:wrap;
}
.gs-ms-edit-row .input{
  flex: 1 1 260px;
  width: auto;
  min-width: 0;
}

/* Builder editor UI */
.builderFieldCard{
  border:1px solid var(--border);
  border-radius: 14px;
  background: rgba(255,255,255,.03);
  padding: 12px;
  margin-bottom: 10px;
}

.builderFieldTop{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
  margin-bottom:10px;
}

.builderBadge{
  font-size:12px;
  color: var(--muted);
  border:1px solid var(--border);
  border-radius: 999px;
  padding: 6px 10px;
  background: rgba(255,255,255,.03);
}

.builderGrid{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:10px;
  align-items:end;
}

.builderGrid .input{
  width: 100%;
}

.builderRow{
  display:flex;
  gap:10px;
  align-items:center;
  flex-wrap: wrap;
}

.builderOptRow{
  display:grid;
  grid-template-columns: 1fr 120px 88px;
  gap:10px;
  align-items:center;
  margin-top: 8px;
}

.builderOptRow input[type="color"]{
  width: 100%;
  height: 44px;
  border-radius: 12px;
  border:1px solid var(--border);
  background: transparent;
  padding: 4px;
}

.modalHeader,
.modalFooter{
  flex: 0 0 auto;
  background: rgba(0,0,0,.12);
}

.modalBody{
  flex: 1 1 auto;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

/* Small screens */
@media (max-width: 600px){
  .modal{
    top: 12px;
    max-height: calc(100vh - 24px);
  }
}
.modalHeader, .modalFooter{
  padding:14px 16px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  border-bottom:1px solid var(--border);
}
.modalFooter{ border-bottom:none; border-top:1px solid var(--border); }
.modalTitle{ font-weight:900; }
.modalSub{ font-size:12px; color:var(--muted); margin-top:2px; }

.toast{
  position:fixed;
  left:50%;
  bottom:18px;
  transform: translateX(-50%);
  padding:12px 14px;
  border-radius: 999px;
  border:1px solid var(--border);
  background: rgba(17,24,39,.92);
  color: var(--text);
  box-shadow: var(--shadow);
  z-index:80;
  font-size:13px;
}

.hidden{ display:none !important; }

.mobileOnly{ display:none; }

@media (max-width: 980px){
  #builderModal .grid2{ grid-template-columns: 1fr; }
  .builderGrid{ grid-template-columns: 1fr; }
  .builderOptRow{ grid-template-columns: 1fr; }
  .grid2{ grid-template-columns: 1fr; }
  .statsRow{ grid-template-columns: 1fr 1fr; }
  .app{ grid-template-columns: 1fr; }
  .sidebar{
    position:fixed;
    left:-310px;
    width:280px;
    transition: left .18s ease;
    z-index:40;
  }
  .sidebar.open{ left:0; }
  .mobileOnly{ display:inline-flex; }
}

/* ✅ Builder Columns panel: prevent horizontal overflow */
#builderFieldsHost{
  overflow-x: hidden;
}

#builderFieldsHost .formGrid .input {
  max-width: 260px;
}

/* ✅ In the builder, inputs should fill their grid cell (not force 320px width) */
#builderModal #builderFieldsHost .input{
  width: 100%;
}

/* ✅ Dropdown option row uses builderOptRow; ensure it never overflows */
#builderModal .builderOptRow{
  grid-template-columns: minmax(0, 1fr) 120px 88px;
}

/* ✅ Make field cards inside Columns panel fit nicely */
#builderModal #builderFieldsHost .card{
  min-width: 0;
}
#builderModal #builderFieldsHost .formGrid{
  grid-template-columns: 120px minmax(0, 1fr);
}

.admin-files-settings { margin-top: 16px; padding: 14px; border: 1px solid rgba(0,0,0,.12); border-radius: 14px; background: rgba(255,255,255,.7); }
.admin-files-settings__title { font-weight: 900; font-size: 14px; }
.admin-files-settings__sub { opacity: .7; font-weight: 700; font-size: 12px; margin-top: 4px; }

.gs-files-settings-editor { margin-top: 10px; display: grid; gap: 12px; }
.gsfs-label { display:flex; align-items:center; justify-content: space-between; gap: 10px; font-weight: 900; }
.gsfs-grid { display:grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.gsfs-col { display:grid; gap: 6px; }
.gsfs-h { font-weight: 900; }
.gsfs-sub { opacity: .7; font-weight: 700; font-size: 12px; }
.gsfs-ta { width: 100%; border: 1px solid rgba(0,0,0,.12); border-radius: 12px; padding: 10px 12px; font-weight: 800; }
.gsfs-actions { display:flex; align-items:center; justify-content: space-between; gap: 10px; }
.gsfs-btn { padding: 10px 12px; border-radius: 12px; border: 1px solid rgba(0,0,0,.12); background: white; font-weight: 900; cursor:pointer; }
.gsfs-muted { opacity: .7; font-weight: 800; font-size: 12px; }

.gs-builder-addbar .cardHeader { margin-bottom: 12px; }
.gs-addbar-actions{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
}
.gs-addbtn{
  width:auto;
  text-align:left;
  white-space:nowrap;
  padding:10px 12px;
  border-radius: 14px;
}

/* Make <details> look like a normal card */
.gs-advanced-summary{
  list-style:none;
  cursor:pointer;
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
}
.gs-advanced-summary::-webkit-details-marker{ display:none; }

/* ===== Record Details Builder: thinner Available Tabs, wider Active Tabs ===== */
.gs-details-tabs-grid{
  grid-template-columns: 280px minmax(0, 1fr);
  gap:14px;
}
@media (max-width: 980px){
  .gs-details-tabs-grid{ grid-template-columns: 1fr; }
}

@media (max-width: 900px) { .gsfs-grid { grid-template-columns: 1fr; } }

/* Mobile-friendly tables */
@media (max-width: 760px) {
  .main {
    padding: 12px;
  }

  .card {
    padding: 14px;
    border-radius: 16px;
  }

  .cardHeader {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .cardHeader > .row {
    width: 100%;
    justify-content: stretch;
  }

  .cardHeader > .row .input,
  .cardHeader > .row .btn,
  .cardHeader > .row .btnPrimary {
    width: 100%;
  }

  .table {
    min-width: 680px;
  }

  .integrationItem {
    display: grid;
    grid-template-columns: 1fr;
  }

  .integrationItem .row {
    width: 100%;
    flex-wrap: wrap;
  }

  .integrationItem .row .btn {
    flex: 1 1 140px;
  }

  .formGrid {
    grid-template-columns: 1fr;
  }
}

/* =========================================================
   TABLE BUILDER MODAL: fit better on laptop
========================================================= */

#builderModal {
  width: min(1500px, calc(100vw - 18px)) !important;
  max-width: none !important;
  top: 10px;
  max-height: calc(100vh - 20px);
}

#builderModal .modalBody {
  padding: 14px 18px;
}

/* Make Add Columns compact */
#builderModal .gs-builder-addbar {
  padding: 14px 18px;
}

#builderModal .gs-builder-addbar .cardHeader {
  margin-bottom: 10px;
}

#builderModal .gs-builder-addbar .cardTitle {
  font-size: 14px;
}

#builderModal .gs-builder-addbar .cardSub {
  font-size: 12px;
}

/* Add column buttons should wrap tightly */
#builderModal .gs-addbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

#builderModal .gs-addbtn {
  padding: 8px 11px;
  border-radius: 12px;
  font-size: 13px;
  white-space: nowrap;
}

/* Put table name + default checkbox side-by-side on laptop */
#builderModal .gs-builder-addbar .formGrid {
  grid-template-columns: 110px minmax(260px, 1fr) 170px auto;
  gap: 10px 12px;
  align-items: center;
}

#builderModal .gs-builder-addbar .formGrid .label:nth-of-type(2) {
  justify-self: end;
}

#builderModal .gs-builder-addbar .divider {
  margin: 12px 0;
}

/* Keep preview visible and reduce vertical waste */
#builderModal .modalBody > .divider:first-of-type {
  margin: 12px 0;
}

#builderModal .modalBody > .card:nth-of-type(2) {
  padding: 14px;
}

#builderModal .modalBody > .card:nth-of-type(2) .cardHeader {
  margin-bottom: 10px;
}

/* The preview should not force the modal to become too tall */
#builderModal .tableWrap {
  max-height: 320px;
  overflow: auto;
}

/* Record Details section can live below the main editor */
#builderModal .gs-details-modal-editor-card {
  margin-top: 14px !important;
}

/* Laptop/tablet builder layout */
@media (max-width: 1100px) {
  #builderModal .gs-builder-addbar .formGrid {
    grid-template-columns: 1fr;
  }

  #builderModal .gs-builder-addbar .formGrid .label:nth-of-type(2) {
    justify-self: start;
  }
}

/* Mobile builder */
@media (max-width: 700px) {
  #builderModal {
    width: calc(100vw - 10px) !important;
    top: 5px;
    max-height: calc(100vh - 10px);
    border-radius: 18px;
  }

  #builderModal .modalBody {
    padding: 12px;
  }

  #builderModal .modalHeader,
  #builderModal .modalFooter {
    padding: 12px;
  }

  #builderModal .gs-addbtn {
    flex: 1 1 100%;
    justify-content: flex-start;
  }

  #builderModal .tableWrap {
    max-height: 280px;
  }
}

/* =========================================================
   BUILDER PREVIEW: make it match Dashboard Table View
========================================================= */

#builderPreviewTable {
  width: 95%;
  min-width: 780px;
  margin: 0 auto;
  border-collapse: collapse;
  table-layout: fixed;
  background: #ffffff;
  color: #0f172a;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.10);
}

#builderPreviewTable th,
#builderPreviewTable td {
  height: 48px;
  padding: 0 12px !important;
  border-bottom: 1px solid #dddddd;
  vertical-align: middle;
  text-align: left;
  font-size: 14px;
}

#builderPreviewTable th {
  background: #62ad78;
  color: #ffffff;
  font-weight: 700;
}

#builderPreviewTable tbody tr:nth-child(even) {
  background: #f9f9f9;
}

#builderPreviewTable tbody tr:hover {
  background: #c0d8f0;
  cursor: pointer;
}

#builderPreviewTable .gsThInner {
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

#builderPreviewTable .gsThLabel {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#builderPreviewTable .gsColMenuBtn {
  color: #ffffff;
}

#builderPreviewTable .cellContactName {
  font-weight: 800;
  line-height: 1.15;
}

#builderPreviewTable .cellContactSub {
  color: rgba(15, 23, 42, 0.65);
  font-size: 12px;
  margin-top: 2px;
}

#builderPreviewTable .builderPreviewText {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#builderPreviewTable .gsDdPill {
  width: 100%;
  min-height: 48px;
  border-radius: 0;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* =========================================================
   Hide Slug column in Admin Tables & Fields list
   Keeps the slug in the data/JS for later, but removes it
   from the visible admin table for now.
========================================================= */

#tablesTable th:nth-child(2),
#tablesTable td:nth-child(2) {
  display: none;
}

/* Since Slug is hidden, the table does not need to be as wide */
#tablesTable {
  min-width: 620px;
}

@media (max-width: 760px) {
  #tablesTable {
    min-width: 560px;
  }
}

/* =========================================================
   Table Builder compact top layout
   Moves table settings beside Dashboard Preview title
========================================================= */

#builderModal .gs-builder-addbar {
  padding: 12px 18px;
}

#builderModal .gs-builder-topline {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}

#builderModal .gs-builder-addbar .cardTitle {
  font-size: 14px;
}

#builderModal .gs-builder-addbar .cardSub {
  font-size: 12px;
}

#builderModal .gs-addbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-start;
}

#builderModal .gs-addbtn {
  padding: 8px 11px;
  border-radius: 12px;
  font-size: 13px;
  white-space: nowrap;
}

/* Dashboard preview header now includes table settings */
#builderModal .gs-dashboard-preview-card {
  padding: 14px 18px;
}

#builderModal .gs-preview-header {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(360px, 620px);
  gap: 16px;
  align-items: end;
  margin-bottom: 12px;
}

#builderModal .gs-preview-settings {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 12px;
  align-items: end;
}

#builderModal .gs-preview-field {
  display: grid;
  gap: 6px;
}

#builderModal .gs-preview-field span,
#builderModal .gs-preview-check span {
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
}

#builderModal .gs-preview-field .input {
  width: 100%;
  height: 42px;
}

#builderModal .gs-preview-check {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  padding: 0 4px;
}

/* Give the preview more visible room */
#builderModal .gs-dashboard-preview-card .tableWrap {
  max-height: 380px;
}

/* Reduce wasted divider space inside the modal */
#builderModal .modalBody > .divider {
  margin: 10px 0;
}

/* Laptop / narrower screens */
@media (max-width: 1150px) {
  #builderModal .gs-builder-topline {
    grid-template-columns: 1fr;
  }

  #builderModal .gs-preview-header {
    grid-template-columns: 1fr;
    align-items: start;
  }

  #builderModal .gs-preview-settings {
    grid-template-columns: 1fr auto;
  }
}

/* Mobile */
@media (max-width: 700px) {
  #builderModal .gs-preview-settings {
    grid-template-columns: 1fr;
  }

  #builderModal .gs-preview-check {
    justify-content: flex-start;
  }

  #builderModal .gs-addbtn {
    flex: 1 1 100%;
  }
}

/* =========================================================
   Spreadsheet Import Preview Editor — Dashboard-style table
   + solid column editor popover
========================================================= */

/* Wider import modal so the dashboard-style preview has room */
#spreadsheetImportModal {
  max-width: 1220px !important;
}

/* Preview host spacing */
#spreadsheetImportPreview {
  display: grid;
  gap: 14px;
}

/* Summary cards */
.gs-import-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.gs-import-summary-card {
  border: 1px solid var(--gs-border, rgba(28, 35, 41, 0.14));
  background: var(--gs-card-bg, #ffffff);
  color: var(--gs-text, #1c2329);
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 8px 18px rgba(28, 35, 41, 0.08);
}

.gs-import-summary-card strong {
  display: block;
  margin-top: 4px;
  font-size: 18px;
}

.gs-import-map-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* Make the import preview use the same visual foundation as dashboard tables */
.gs-import-dashboard-preview,
.gs-import-preview-table-wrap {
  width: 100%;
  overflow-x: auto !important;
  overflow-y: visible !important;
  padding-bottom: 8px;
  border-radius: 14px;
}

.gs-import-dashboard-preview table,
.gs-import-preview-table {
  width: 100% !important;
  min-width: 1080px;
  table-layout: fixed !important;
  margin: 0 auto;
  border-collapse: collapse;
  background: var(--gs-card-bg, #ffffff);
  color: var(--gs-text, #1c2329);
  box-shadow: var(--gs-shadow, 0 12px 30px rgba(28, 35, 41, 0.12));
  border: 1px solid var(--gs-border, rgba(28, 35, 41, 0.14));
  border-radius: 14px;
  overflow: hidden;
}

.gs-import-dashboard-preview th,
.gs-import-dashboard-preview td,
.gs-import-preview-table th,
.gs-import-preview-table td {
  text-align: left;
  vertical-align: middle !important;
  border-bottom: 1px solid var(--gs-border, rgba(28, 35, 41, 0.14));
  padding: 12px 14px !important;
  margin: 0;
  line-height: 1.15;
  overflow: hidden;
}

.gs-import-dashboard-preview th,
.gs-import-preview-table th {
  background: var(--gs-charcoal, #1c2329) !important;
  color: var(--gs-text-white, #ffffff) !important;
  border-bottom: 2px solid var(--gs-coral, #ff6642) !important;
  height: 58px;
  min-height: 58px;
  white-space: nowrap;
  word-break: normal;
  overflow: hidden;
  font-weight: 800;
  font-size: 15px;
  cursor: grab;
  user-select: none;
}

.gs-import-dashboard-preview td,
.gs-import-preview-table td {
  background: var(--gs-card-bg, #ffffff);
  min-height: 56px;
  height: auto !important;
  font-size: 14px;
}

.gs-import-dashboard-preview tbody tr:nth-child(even) td,
.gs-import-preview-table tbody tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.68);
}

.gs-import-dashboard-preview tbody tr:hover td,
.gs-import-preview-table tbody tr:hover td {
  background: rgba(255, 102, 66, 0.08);
}

/* Column header inner layout */
.gs-import-th-inner {
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.gs-import-th-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.gs-import-th-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 800;
}

.gs-import-th-meta {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  font-weight: 600;
  opacity: 0.82;
}

/* Column menu button inside import preview header */
.gs-import-col-menu-btn,
.gs-import-preview-table .gsColMenuBtn {
  appearance: none;
  width: 28px;
  height: 28px;
  min-width: 28px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
}

.gs-import-col-menu-btn:hover,
.gs-import-preview-table .gsColMenuBtn:hover {
  background: rgba(255, 102, 66, 0.42);
  border-color: rgba(255, 102, 66, 0.75);
}

/* Drag feedback */
.gs-import-edit-th.dragging {
  opacity: 0.65;
}

.gs-import-edit-th.drag-over {
  outline: 3px solid rgba(255, 102, 66, 0.75);
  outline-offset: -3px;
}

/* Dashboard-like column sizing for import preview */
.gs-import-preview-table th.gs-col-contact,
.gs-import-preview-table td.gs-col-contact {
  width: 145px !important;
  min-width: 145px !important;
  max-width: 145px !important;
}

.gs-import-preview-table th.gs-col-address,
.gs-import-preview-table td.gs-col-address {
  width: 210px !important;
  min-width: 210px !important;
  max-width: 210px !important;
}

.gs-import-preview-table th.gs-col-dropdown,
.gs-import-preview-table td.gs-col-dropdown {
  width: 220px !important;
  min-width: 220px !important;
  max-width: 220px !important;
}

.gs-import-preview-table th.gs-col-email-status,
.gs-import-preview-table td.gs-col-email-status,
.gs-import-preview-table th.gs-col-email-followup,
.gs-import-preview-table td.gs-col-email-followup {
  width: 115px !important;
  min-width: 115px !important;
  max-width: 115px !important;
  text-align: center;
}

.gs-import-preview-table th.gs-col-email-date,
.gs-import-preview-table td.gs-col-email-date {
  width: 175px !important;
  min-width: 175px !important;
  max-width: 175px !important;
  white-space: nowrap;
}

/* Cell rendering */
.gs-import-cell-main {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gs-import-cell-wrap {
  display: block;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: normal;
  line-height: 1.1 !important;
}

.gs-import-dd-preview {
  width: 100%;
  min-height: 34px;
  padding: 5px 10px;
  border-radius: 7px;
  color: #ffffff;
  background: #64748b;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Contact preview: match dashboard contact feel */
.gs-import-preview-table .cellContact,
.gs-import-preview-table .contact-cell {
  display: grid;
  align-content: center;
  gap: 5px;
  min-width: 92px;
  max-width: 150px;
  line-height: 1.1;
}

.gs-import-preview-table .cellContactName,
.gs-import-preview-table .contact-name {
  font-weight: 800;
  line-height: 1.1;
  white-space: normal;
  overflow-wrap: anywhere;
  color: var(--gs-charcoal, #1c2329);
}

.gs-import-preview-table .cellContactSub,
.gs-import-preview-table .contact-info {
  font-size: 12px;
  line-height: 1.15;
  color: rgba(28, 35, 41, 0.68);
}

/* SOLID column editor popover */
.gs-import-col-popover,
body > .gs-import-col-popover,
.gsColPopover.gs-import-col-popover {
  position: absolute;
  z-index: 999999 !important;
  width: min(360px, calc(100vw - 24px));
  max-height: min(620px, calc(100vh - 28px));
  overflow: auto;

  background: #ffffff !important;
  color: #1c2329 !important;
  border: 1px solid rgba(28, 35, 41, 0.18) !important;
  border-radius: 16px !important;
  box-shadow:
    0 24px 70px rgba(0, 0, 0, 0.35),
    0 0 0 1px rgba(255, 255, 255, 0.72) inset !important;

  padding: 0 !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

/* Popover content */
.gs-import-col-popover .gsPopHeader {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #ffffff !important;
  color: #1c2329 !important;
  border-bottom: 1px solid rgba(28, 35, 41, 0.12);
  padding: 14px 14px 12px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.gs-import-col-popover .gsPopTitle {
  color: #1c2329 !important;
  font-size: 15px;
  font-weight: 900;
}

.gs-import-col-popover .muted,
.gs-import-col-popover .small {
  color: rgba(28, 35, 41, 0.68) !important;
}

.gs-import-col-popover .gsPopClose {
  appearance: none;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 1px solid rgba(28, 35, 41, 0.14);
  background: rgba(28, 35, 41, 0.05);
  color: #1c2329;
  cursor: pointer;
  font-weight: 900;
  line-height: 1;
}

.gs-import-col-popover .gsPopClose:hover {
  background: rgba(255, 102, 66, 0.14);
  border-color: rgba(255, 102, 66, 0.45);
}

.gs-import-col-popover .gsPopSection {
  padding: 14px;
  border-bottom: 1px solid rgba(28, 35, 41, 0.10);
  display: grid;
  gap: 12px;
}

.gs-import-col-popover .gsPopFooter {
  padding: 14px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: #ffffff !important;
}

.gs-import-col-popover .gsPopField {
  display: grid;
  gap: 6px;
}

.gs-import-col-popover .gsPopLabel {
  color: rgba(28, 35, 41, 0.72);
  font-size: 12px;
  font-weight: 800;
}

.gs-import-col-popover .input,
.gs-import-col-popover select,
.gs-import-col-popover textarea {
  width: 100%;
  border: 1px solid rgba(28, 35, 41, 0.16) !important;
  border-radius: 12px !important;
  background: #ffffff !important;
  color: #1c2329 !important;
  padding: 10px 11px !important;
  outline: none;
  box-shadow: none !important;
}

.gs-import-col-popover .input:focus,
.gs-import-col-popover select:focus,
.gs-import-col-popover textarea:focus {
  border-color: rgba(255, 102, 66, 0.55) !important;
  box-shadow: 0 0 0 3px rgba(255, 102, 66, 0.14) !important;
}

.gs-import-options-textarea {
  width: 100%;
  min-height: 110px;
  resize: vertical;
  font-family: inherit;
  line-height: 1.25;
}

.gs-import-pop-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.gs-import-col-popover .btn {
  background: #ffffff !important;
  color: #1c2329 !important;
  border: 1px solid rgba(28, 35, 41, 0.16) !important;
  box-shadow: none !important;
}

.gs-import-col-popover .btn:hover {
  background: rgba(255, 102, 66, 0.10) !important;
  border-color: rgba(255, 102, 66, 0.38) !important;
}

.gs-import-col-popover .btn.danger {
  color: #b91c1c !important;
  border-color: rgba(185, 28, 28, 0.28) !important;
}

.gs-import-col-popover .btn.danger:hover {
  background: rgba(185, 28, 28, 0.08) !important;
}

@media (max-width: 760px) {
  .gs-import-summary {
    grid-template-columns: 1fr;
  }

  .gs-import-map-header {
    align-items: stretch;
    flex-direction: column;
  }

  .gs-import-map-header .btn {
    width: 100%;
  }

  .gs-import-pop-actions {
    grid-template-columns: 1fr;
  }

  .gs-import-dashboard-preview table,
  .gs-import-preview-table {
    min-width: 920px;
  }
}

/* =========================================================
   Spreadsheet import preview: prevent squeezed headers
========================================================= */

.gs-import-preview-table-wrap {
  overflow-x: auto !important;
  overflow-y: visible !important;
  -webkit-overflow-scrolling: touch;
}

.gs-import-preview-table th,
.gs-import-preview-table td {
  overflow: hidden;
}

/* Keep header content readable */
.gs-import-th-inner {
  min-height: 44px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.gs-import-th-copy {
  min-width: 0;
  flex: 1 1 auto;
  display: grid;
  gap: 3px;
}

.gs-import-th-label {
  display: block;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  line-height: 1.05;
  font-size: 15px;
  font-weight: 800;
}

.gs-import-th-meta {
  display: block;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  line-height: 1.05;
  font-size: 11px;
  font-weight: 700;
  opacity: 0.9;
}

/* Keep menu button compact so it doesn't steal header width */
.gs-import-col-menu-btn,
.gs-import-preview-table .gsColMenuBtn {
  width: 26px;
  height: 26px;
  min-width: 26px;
  flex: 0 0 26px;
  margin-top: 1px;
}

/* A bit more room for header cells */
.gs-import-preview-table th {
  height: auto !important;
  min-height: 72px !important;
  vertical-align: top !important;
  padding-top: 10px !important;
  padding-bottom: 10px !important;
}

/* Make small default text cells feel less cramped */
.gs-import-preview-table td {
  white-space: nowrap;
  text-overflow: ellipsis;
}

.gs-import-preview-table td.gs-col-address,
.gs-import-preview-table td.gs-col-address > * {
  white-space: normal !important;
}

/* =========================================================
   ADMIN LAYOUT — COMPACT SIDEBAR + RESPONSIVE INTEGRATIONS
   Paste at the very bottom of admin_v2.css
========================================================= */

/* -----------------------------
   Narrower desktop sidebar
----------------------------- */

.app {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 14px;
  border-right: 1px solid var(--border);
  background:
    linear-gradient(
      180deg,
      rgba(17, 24, 39, 0.65),
      rgba(17, 24, 39, 0.35)
    );
  backdrop-filter: blur(10px);
}

.sidebar .brand {
  gap: 10px;
  padding: 10px;
}

.sidebar .brandText {
  min-width: 0;
}

.sidebar .brandName,
.sidebar .brandSub {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar .nav {
  margin-top: 12px;
  gap: 7px;
}

.sidebar .navItem {
  gap: 9px;
  padding: 11px 10px;
}

.sidebarFooter {
  left: 14px;
  right: 14px;
  bottom: 14px;
}


/* -----------------------------
   Integrations-page card layout
----------------------------- */

.route[data-route="integrations"] > .grid2 {
  display: grid;
  grid-template-columns:
    minmax(390px, 0.8fr)
    minmax(650px, 1.35fr);
  gap: 18px;
  align-items: start;
}

/*
  First card is the general Integrations card.
  Keep it across the entire page.
*/
.route[data-route="integrations"]
  > .grid2
  > .card:first-child {
  grid-column: 1 / -1;
}

/* Make sure every card is allowed to shrink properly */
.route[data-route="integrations"] .card,
.route[data-route="integrations"] .formGrid,
.route[data-route="integrations"] .row {
  min-width: 0;
}


/* -----------------------------
   Compact form label spacing
----------------------------- */

.route[data-route="integrations"] .formGrid {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  column-gap: 14px;
  row-gap: 12px;
  align-items: center;
}

.route[data-route="integrations"] .formGrid > .label {
  justify-self: start;
  width: auto;
  margin: 0;
}

/*
  Override any fixed input widths from another stylesheet.
*/
.route[data-route="integrations"] .formGrid > .input,
.route[data-route="integrations"] .formGrid > input:not([type="hidden"]),
.route[data-route="integrations"] .formGrid > select,
.route[data-route="integrations"] .formGrid > textarea {
  width: 100% !important;
  min-width: 0;
  max-width: none !important;
}

.route[data-route="integrations"] .formGrid > textarea.input {
  resize: vertical;
}

.route[data-route="integrations"] .formGrid > .row {
  width: 100%;
  flex-wrap: wrap;
  justify-content: flex-start;
}


/* -----------------------------
   Stack cards when space is tight
----------------------------- */

@media (max-width: 1500px) {
  .route[data-route="integrations"] > .grid2 {
    grid-template-columns: minmax(0, 1fr);
  }

  .route[data-route="integrations"]
    > .grid2
    > .card:first-child {
    grid-column: auto;
  }
}


/* -----------------------------
   Existing mobile sidebar behavior
----------------------------- */

@media (max-width: 980px) {
  .app {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    position: fixed;
    left: -310px;
    top: 0;
    width: 280px;
    height: 100vh;
    padding: 18px;
    transition: left 0.18s ease;
    z-index: 40;
  }

  .sidebar.open {
    left: 0;
  }

  .sidebarFooter {
    left: 18px;
    right: 18px;
    bottom: 18px;
  }
}


/* -----------------------------
   Stack labels above controls
   on small screens
----------------------------- */

@media (max-width: 760px) {
  .route[data-route="integrations"] .formGrid {
    grid-template-columns: minmax(0, 1fr);
    row-gap: 8px;
  }

  .route[data-route="integrations"] .formGrid > .label {
    margin-top: 6px;
    margin-bottom: -2px;
  }

  /*
    Removes the empty spacer divs used by the desktop
    two-column form layout.
  */
  .route[data-route="integrations"]
    .formGrid
    > div:empty {
    display: none;
  }

  .route[data-route="integrations"] .formGrid > .row {
    margin-top: 6px;
  }

  .route[data-route="integrations"]
    .formGrid
    > .row
    > button {
    flex: 1 1 160px;
  }
}

/* =========================================================
   SHARED EMAIL ACCOUNT — SIGNATURE EDITOR
========================================================= */

.gs-email-signature-editor {
  grid-column: 1 / -1;
  min-width: 0;
  margin-top: 8px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.035);
}

.gs-email-signature-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.gs-signature-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.gs-email-signature-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(300px, 0.9fr);
  gap: 18px;
  align-items: start;
}

.gs-email-signature-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  min-width: 0;
}

.gs-signature-field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.gs-signature-field > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.gs-signature-field-wide {
  grid-column: 1 / -1;
}

.gs-signature-field small {
  line-height: 1.35;
}

.gs-signature-color {
  width: 100% !important;
  min-height: 42px;
  padding: 4px !important;
  cursor: pointer;
}

.gs-signature-options {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 18px;
  padding: 10px 0 2px;
}

.gs-signature-options label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 13px;
}

.gs-email-signature-preview-shell {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  background: #ffffff;
}

.gs-email-signature-preview-title {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(28, 35, 41, 0.12);
  background: #f7f9fb;
  color: #1c2329;
  font-size: 12px;
  font-weight: 800;
}

.gs-email-signature-preview {
  min-height: 250px;
  padding: 22px;
  overflow-x: auto;
  background: #ffffff;
  color: #1c2329;
}

.gs-email-signature-preview img {
  max-width: 100%;
  height: auto;
}

.gs-email-signature-preview-empty {
  display: grid;
  min-height: 200px;
  place-items: center;
  color: rgba(28, 35, 41, 0.55);
  font-size: 13px;
  text-align: center;
}

@media (max-width: 1100px) {
  .gs-email-signature-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .gs-email-signature-preview-shell {
    max-width: 720px;
  }
}

@media (max-width: 700px) {
  .gs-email-signature-editor {
    padding: 13px;
  }

  .gs-email-signature-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  .gs-email-signature-fields {
    grid-template-columns: minmax(0, 1fr);
  }

  .gs-signature-field-wide {
    grid-column: auto;
  }

  .gs-signature-options {
    display: grid;
    gap: 10px;
  }

  .gs-email-signature-preview {
    padding: 16px;
  }
}

/* =========================================================
   CRM SHARED EMAIL ACCOUNT — CLEAN FORM LAYOUT
========================================================= */

.gs-shared-email-form {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.gs-mail-section {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
}

.gs-mail-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.gs-mail-section-title {
  color: var(--text);
  font-size: 14px;
  font-weight: 900;
}

.gs-mail-section-sub {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.gs-mail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 16px;
  min-width: 0;
}

.gs-mail-grid-tight {
  gap: 12px;
}

.gs-mail-field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.gs-mail-field > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.gs-mail-field > span b {
  color: var(--gs-coral, #ff6642);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.gs-mail-field small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.gs-mail-field-wide {
  grid-column: 1 / -1;
}

.gs-shared-email-form .input {
  width: 100% !important;
  min-width: 0;
  min-height: 46px;
  border-radius: 14px;
}

.gs-mail-check {
  display: inline-flex;
  align-items: flex-start;
  gap: 9px;
  margin-top: 14px;
  color: var(--text);
  font-size: 13px;
  line-height: 1.35;
}

.gs-mail-check input {
  margin-top: 2px;
}

.gs-mail-advanced {
  padding: 0;
  overflow: hidden;
}

.gs-mail-advanced summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  cursor: pointer;
  list-style: none;
}

.gs-mail-advanced summary::-webkit-details-marker {
  display: none;
}

.gs-mail-chevron {
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  transition: transform 0.15s ease;
}

.gs-mail-advanced[open] .gs-mail-chevron {
  transform: rotate(180deg);
}

.gs-mail-preset-row {
  padding: 0 16px 14px;
  max-width: 520px;
}

.gs-mail-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 0 16px 16px;
}

.gs-mail-subsection {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.035);
}

.gs-mail-subsection-title {
  margin-bottom: 12px;
  color: var(--text);
  font-size: 13px;
  font-weight: 900;
}

.gs-mail-actions-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.gs-mail-actions-section .gs-mail-check {
  margin-top: 0;
}

.gs-mail-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

@media (max-width: 1200px) {
  .gs-mail-columns {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 760px) {
  .gs-mail-section {
    padding: 13px;
  }

  .gs-mail-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .gs-mail-field-wide {
    grid-column: auto;
  }

  .gs-mail-advanced summary {
    padding: 13px;
  }

  .gs-mail-preset-row,
  .gs-mail-columns {
    padding-left: 13px;
    padding-right: 13px;
  }

  .gs-mail-actions-section {
    align-items: stretch;
  }

  .gs-mail-actions {
    width: 100%;
    justify-content: stretch;
  }

  .gs-mail-actions .btn,
  .gs-mail-actions .btnPrimary {
    flex: 1 1 160px;
  }
}

/* =========================================================
   CRM SHARED EMAIL ACCOUNT — FULL WIDTH + SIDE PANEL
========================================================= */

.route[data-route="integrations"] .gs-shared-email-card {
  grid-column: 1 / -1;
}

.gs-shared-email-account-layout {
  display: grid;
  grid-template-columns: minmax(720px, 1fr) minmax(330px, 430px);
  gap: 18px;
  align-items: start;
  min-width: 0;
}

.gs-shared-email-form-panel,
.gs-connected-email-panel,
.gs-email-template-section {
  min-width: 0;
}

.gs-panel-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.gs-panel-title {
  color: var(--text);
  font-size: 14px;
  font-weight: 900;
}

.gs-panel-sub {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.gs-connected-email-panel {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
}

.gs-connected-email-table-wrap {
  max-height: 520px;
  overflow: auto;
}

.gs-connected-email-table {
  min-width: 620px;
}

.gs-connected-email-table th,
.gs-connected-email-table td {
  white-space: nowrap;
}

/*
  Force SMTP and IMAP to remain side-by-side while there is
  reasonable space. This overrides the earlier 1200px stacking rule.
*/
.gs-shared-email-card .gs-mail-columns {
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
}

.gs-shared-email-card .gs-mail-subsection {
  min-width: 0;
}

.gs-shared-email-card .gs-mail-grid-tight {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.gs-shared-email-card .gs-mail-field-wide {
  grid-column: 1 / -1;
}

.gs-email-template-section {
  margin-top: 2px;
}

.gs-email-template-grid {
  grid-template-columns: 150px minmax(0, 1fr);
}

/* Medium screens: keep the connected list below the form */
@media (max-width: 1180px) {
  .gs-shared-email-account-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .gs-connected-email-table-wrap {
    max-height: none;
  }
}

/* Smaller screens: stack SMTP and IMAP */
@media (max-width: 860px) {
  .gs-shared-email-card .gs-mail-columns {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .gs-shared-email-card .gs-mail-grid-tight {
    grid-template-columns: minmax(0, 1fr);
  }

  .gs-email-template-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* =========================================================
   Spreadsheet import row cleanup
========================================================= */

.gs-import-skip-row-control {
  display: grid;
  grid-template-columns: minmax(90px, 130px) minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

#spreadsheetImportSkipRows {
  width: 100%;
}

.gs-import-summary {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.gs-import-preview-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.gs-import-row-action-col {
  width: 104px;
}

.gs-import-row-action-th,
.gs-import-row-action-cell {
  position: sticky;
  left: 0;
  z-index: 3;
  width: 104px;
  min-width: 104px;
  max-width: 104px;
}

.gs-import-row-action-th {
  background: var(--gs-charcoal, #1c2329) !important;
  color: var(--gs-text-white, #ffffff) !important;
  text-align: center !important;
}

.gs-import-row-action-cell {
  background: var(--gs-card-bg, #ffffff) !important;
  border-right: 1px solid var(--gs-border, rgba(28, 35, 41, 0.14));
  text-align: center !important;
}

.gs-import-row-number {
  display: block;
  color: var(--gs-muted, rgba(28, 35, 41, 0.68));
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 6px;
  white-space: nowrap;
}

.gs-import-remove-row-btn {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(185, 28, 28, 0.28);
  border-radius: 10px;
  background: rgba(185, 28, 28, 0.06);
  color: #b91c1c;
  cursor: pointer;
  font-weight: 900;
}

.gs-import-remove-row-btn:hover {
  background: rgba(185, 28, 28, 0.13);
  border-color: rgba(185, 28, 28, 0.48);
}

@media (max-width: 760px) {
  .gs-import-skip-row-control {
    grid-template-columns: 1fr;
  }

  .gs-import-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .gs-import-preview-actions,
  .gs-import-preview-actions .btn {
    width: 100%;
  }
}

/* =========================================================
   Spreadsheet import preview — dashboard-like horizontal table
========================================================= */

.gs-import-preview-table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto !important;
  overflow-y: visible !important;
  padding-bottom: 10px;
}

.gs-import-th-inner {
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.gs-import-th-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.gs-import-th-label {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.15;
}

.gs-import-th-meta {
  display: block;
  max-width: 100%;
  color: rgba(255, 255, 255, 0.78);
  font-size: 12px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.15;
}

.gs-import-col-menu-btn,
.gs-import-preview-table .gsColMenuBtn {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 999px;
}

.gs-import-dashboard-preview td,
.gs-import-preview-table td {
  height: 48px;
  white-space: nowrap;
}

.gs-import-cell-main,
.gs-import-cell-wrap,
.gs-import-dd-preview {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* =========================================================
   GOODSTREAM ADMIN VISUAL ALIGNMENT
   Solid surfaces, sharper borders, clearer section hierarchy
   Paste at the very bottom of admin_v2.css
========================================================= */

:root {
  --bg: var(--gs-page-bg, #e1e9f0);
  --panel: var(--gs-card-bg, #ffffff);
  --panel2: var(--gs-panel-bg, #ffffff);
  --text: var(--gs-text, #1c2329);
  --muted: var(--gs-muted, rgba(28, 35, 41, 0.68));
  --border: var(--gs-border, rgba(28, 35, 41, 0.16));
  --brand: var(--gs-coral, #ff6642);
  --shadow: 0 8px 22px rgba(28, 35, 41, 0.10);
  --radius: 14px;
  --radius2: 10px;
}

[data-theme="dark"] {
  --bg: #131a20;
  --panel: #1c2732;
  --panel2: #223140;
  --text: #f4f7fa;
  --muted: #aebdca;
  --border: rgba(225, 233, 240, 0.18);
  --shadow: 0 10px 26px rgba(0, 0, 0, 0.28);
}

/* Remove the glass/gradient treatment from the admin page. */
body {
  background: var(--bg) !important;
  color: var(--text);
}

.app {
  min-height: calc(100vh - 72px);
  background: var(--bg);
}

.sidebar {
  top: 72px;
  height: calc(100vh - 72px);
  border-right: 1px solid var(--border);
  background: var(--gs-navy, #1e3044) !important;
  box-shadow: 4px 0 14px rgba(28, 35, 41, 0.08);
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

.sidebar .brand {
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.07);
  box-shadow: none;
}

.sidebar .brandMark {
  color: #ffffff;
  background: var(--gs-coral, #ff6642) !important;
  border-radius: 10px;
  box-shadow: none;
}

.sidebar .brandName,
.sidebar .navItem {
  color: #ffffff;
}

.sidebar .brandSub,
.sidebar .sidebarFooter,
.sidebar .sidebarFooter .muted {
  color: rgba(255, 255, 255, 0.68) !important;
}

.sidebar .navItem {
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  box-shadow: none;
  transform: none;
}

.sidebar .navItem:hover {
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.08);
  transform: none;
}

.sidebar .navItem.active {
  border-color: rgba(255, 102, 66, 0.55);
  background: rgba(255, 102, 66, 0.18);
  box-shadow: inset 3px 0 0 var(--gs-coral, #ff6642);
}

.sidebar .navDot {
  background: rgba(255, 255, 255, 0.42);
}

.sidebar .navItem.active .navDot {
  background: var(--gs-coral, #ff6642);
}

.main {
  padding: 22px;
  background: var(--bg);
}

.route {
  margin-top: 0;
}

/* Main content cards should read as distinct white panels. */
.card {
  border: 1px solid var(--border) !important;
  border-radius: var(--radius);
  background: var(--panel) !important;
  box-shadow: var(--shadow);
}

.card + .card,
.route > .card + .card {
  margin-top: 18px;
}

.cardHeader {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.cardTitle {
  color: var(--text);
  font-size: 16px;
  font-weight: 850;
}

.cardSub,
.note,
.muted,
.label,
.statLabel,
.k,
.modalSub {
  color: var(--muted) !important;
}

.divider {
  background: var(--border);
}

/* Make nested sections visibly separate from their parent card. */
.stat,
.integrationItem,
.issueCard,
.builderFieldCard,
.gs-mail-section,
.gs-mail-subsection,
.gs-connected-email-panel,
.gs-shared-email-form-panel,
.gs-signature-manager-shell,
.gs-signature-sidebar,
.gs-signature-editor-panel,
.admin-files-settings,
.gs-import-summary-card {
  border: 1px solid var(--border) !important;
  background: var(--panel2) !important;
  box-shadow: none !important;
}

.stat,
.integrationItem,
.issueCard,
.builderFieldCard,
.gs-mail-section,
.gs-mail-subsection,
.admin-files-settings,
.gs-import-summary-card {
  border-radius: var(--radius2);
}

.statValue {
  color: var(--gs-navy, #1e3044);
}

[data-theme="dark"] .statValue {
  color: var(--text);
}

/* Inputs use solid fields and stronger outlines. */
.input,
.textarea,
select.input,
textarea.input {
  border: 1px solid rgba(28, 35, 41, 0.22) !important;
  border-radius: 9px;
  background: #ffffff !important;
  color: #1c2329 !important;
  box-shadow: none !important;
}

[data-theme="dark"] .input,
[data-theme="dark"] .textarea,
[data-theme="dark"] select.input,
[data-theme="dark"] textarea.input {
  border-color: rgba(225, 233, 240, 0.24) !important;
  background: #17222c !important;
  color: #f4f7fa !important;
}

.input:focus,
.textarea:focus,
select.input:focus,
textarea.input:focus {
  border-color: var(--gs-coral, #ff6642) !important;
  box-shadow: 0 0 0 3px rgba(255, 102, 66, 0.14) !important;
}

/* Buttons now follow the dashboard's charcoal/coral language. */
.btn,
.btnWide,
.iconBtn,
.ghostBtn {
  border: 1px solid rgba(28, 35, 41, 0.18);
  border-radius: 9px;
  background: #ffffff;
  color: var(--gs-charcoal, #1c2329);
  box-shadow: none;
}

.btn:hover,
.btnWide:hover,
.iconBtn:hover,
.ghostBtn:hover {
  border-color: rgba(255, 102, 66, 0.48);
  background: rgba(255, 102, 66, 0.08);
}

.btnPrimary {
  border: 1px solid var(--gs-navy, #1e3044);
  border-radius: 9px;
  background: var(--gs-navy, #1e3044);
  color: #ffffff;
  box-shadow: none;
}

.btnPrimary:hover {
  border-color: var(--gs-coral, #ff6642);
  background: var(--gs-coral, #ff6642);
}

[data-theme="dark"] .btn,
[data-theme="dark"] .btnWide,
[data-theme="dark"] .iconBtn,
[data-theme="dark"] .ghostBtn {
  border-color: rgba(225, 233, 240, 0.18);
  background: #223140;
  color: #f4f7fa;
}

/* Tables receive a complete frame, solid header, and row separation. */
.tableWrap,
.miniTableWrap,
.gs-connected-email-table-wrap {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  overflow: auto;
}

.table {
  border-collapse: separate;
  border-spacing: 0;
  background: var(--panel);
}

.table th {
  border-bottom: 2px solid var(--gs-coral, #ff6642) !important;
  background: var(--gs-navy, #1e3044);
  color: #ffffff !important;
  font-weight: 800;
}

.table th:first-child {
  border-top-left-radius: 9px;
}

.table th:last-child {
  border-top-right-radius: 9px;
}

.table td {
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

.table tbody tr:nth-child(even) td {
  background: rgba(225, 233, 240, 0.34);
}

.table tbody tr:hover td {
  background: rgba(255, 102, 66, 0.08);
}

[data-theme="dark"] .table tbody tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.025);
}

/* Modal surfaces should be opaque and clearly framed. */
.modalOverlay {
  background: rgba(10, 16, 22, 0.68);
  backdrop-filter: none;
}

.modal {
  border: 1px solid var(--border);
  background: var(--panel) !important;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
}

.modalHeader,
.modalFooter {
  background: var(--panel2) !important;
}

/* Signature manager: remove translucent panels. */
.gs-signature-manager-shell {
  overflow: hidden;
}

.gs-signature-sidebar {
  border-right: 1px solid var(--border) !important;
}

.gs-signature-list-item:hover {
  background: rgba(255, 102, 66, 0.07);
}

.gs-signature-list-item.active {
  border-color: rgba(255, 102, 66, 0.55);
  background: rgba(255, 102, 66, 0.10);
}

/* Keep the layout practical below the fixed Goodstream header. */
@media (max-width: 980px) {
  .sidebar {
    top: 0;
    height: 100vh;
  }

  .main {
    padding: 16px;
  }
}

@media (max-width: 760px) {
  .main {
    padding: 12px;
  }

  .card {
    border-radius: 12px;
  }
}

/* =========================================================
   EXCEL / SPREADSHEET IMPORT
========================================================= */

#spreadsheetImportModal.gs-excel-import-modal {
  width: min(1520px, calc(100vw - 18px));
  max-width: none !important;
  top: 9px;
  max-height: calc(100vh - 18px);
}

.gs-excel-import-body {
  padding: 16px 18px;
}

.gs-excel-import-layout {
  display: grid;
  grid-template-columns: minmax(300px, 0.85fr) minmax(420px, 1.15fr);
  gap: 16px;
  align-items: stretch;
}

.gs-excel-import-settings,
.gs-excel-import-snapshot,
.gs-excel-import-table-section {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--panel);
}

.gs-excel-import-settings,
.gs-excel-import-snapshot {
  padding: 16px;
}

.gs-excel-import-settings {
  align-self: stretch;
}

.gs-excel-import-snapshot {
  overflow: hidden;
}

.gs-excel-import-table-section {
  margin-top: 16px;
  padding: 16px;
}

.gs-excel-import-table-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.gs-excel-import-panel-heading {
  margin-bottom: 16px;
}

.gs-excel-import-fields {
  display: grid;
  gap: 13px;
}

.gs-excel-import-field {
  display: grid;
  gap: 6px;
}

.gs-excel-import-field > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.gs-excel-import-field small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.gs-excel-import-field .input {
  width: 100%;
  min-width: 0;
}

.gs-excel-import-options {
  display: grid;
  gap: 10px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.gs-excel-import-check {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  cursor: pointer;
}

.gs-excel-import-check input {
  margin-top: 3px;
}

.gs-excel-import-check span {
  display: grid;
  gap: 3px;
  color: var(--text);
  font-size: 13px;
}

.gs-excel-import-check small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.35;
}

.gs-excel-import-settings .gs-import-status {
  margin: 16px 0 0;
}

.gs-import-empty-preview {
  min-height: 420px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: 14px;
  color: var(--muted);
  padding: 24px;
}

.gs-import-preview-topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.gs-import-preview-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.gs-import-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(110px, 1fr));
  gap: 10px;
}

.gs-import-summary-card {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.025);
  padding: 10px 12px;
  box-shadow: none;
}

.gs-import-summary-card span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.gs-import-summary-card strong {
  display: block;
  margin-top: 4px;
  color: var(--text);
  font-size: 17px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gs-import-preview-table-wrap {
  width: 100%;
  max-width: 100%;
  overflow: auto !important;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #ffffff;
}

.gs-import-preview-table {
  table-layout: fixed;
  border-collapse: collapse;
  background: #ffffff;
  color: #1c2329;
}

.gs-import-preview-table th,
.gs-import-preview-table td {
  padding: 11px 12px;
  border-right: 1px solid rgba(28, 35, 41, 0.09);
  border-bottom: 1px solid rgba(28, 35, 41, 0.12);
  vertical-align: middle;
  text-align: left;
  overflow: hidden;
}

.gs-import-preview-table th {
  position: relative;
  height: 74px;
  background: var(--gs-charcoal, #1c2329);
  color: #ffffff;
  font-size: 13px;
  font-weight: 800;
  cursor: grab;
  user-select: none;
  border-bottom: 2px solid var(--gs-coral, #ff6642);
}

.gs-import-preview-table th:active {
  cursor: grabbing;
}

.gs-import-preview-table tbody tr:nth-child(even) td {
  background: #f8fafc;
}

.gs-import-preview-table tbody tr:hover td {
  background: rgba(255, 102, 66, 0.08);
}

.gs-import-th-inner {
  min-width: 0;
  min-height: 48px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.gs-import-th-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.gs-import-inline-label,
.gs-import-inline-type {
  appearance: none;
  width: fit-content;
  max-width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.gs-import-inline-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font: inherit;
  font-size: 14px;
  font-weight: 900;
}

.gs-import-inline-label:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.gs-import-inline-type {
  color: rgba(255, 255, 255, 0.9);
  font-size: 11px;
  font-weight: 800;
}

.gs-import-inline-type::after {
  content: " ▾";
  opacity: 0.72;
}

.gs-import-inline-type:hover {
  color: #ffffff;
}

.gs-import-source-label {
  display: block;
  max-width: 100%;
  overflow: hidden;
  color: rgba(255, 255, 255, 0.62);
  font-size: 9px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gs-import-inline-input,
.gs-import-inline-select {
  width: 100%;
  min-width: 90px;
  height: 30px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 7px;
  background: #ffffff;
  color: #1c2329;
  padding: 4px 7px;
  outline: none;
  font-size: 12px;
}

/*
 * Plain ellipsis:
 * no circle, no permanent button, only visible on column hover.
 */
.gs-import-col-menu-btn {
  appearance: none;
  flex: 0 0 auto;
  opacity: 0;
  pointer-events: none;
  width: auto;
  min-width: 0;
  height: auto;
  margin: -3px -3px 0 0;
  padding: 1px 4px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: #ffffff;
  cursor: pointer;
  font-size: 19px;
  font-weight: 900;
  line-height: 1;
  transition:
    opacity 0.12s ease,
    background 0.12s ease;
}

.gs-import-edit-th:hover .gs-import-col-menu-btn,
.gs-import-col-menu-btn:focus-visible {
  opacity: 1;
  pointer-events: auto;
}

.gs-import-col-menu-btn:hover {
  background: rgba(255, 255, 255, 0.14);
}

.gs-import-edit-th.dragging {
  opacity: 0.55;
}

.gs-import-edit-th.drag-over {
  box-shadow: inset 4px 0 0 var(--gs-coral, #ff6642);
}

.gs-import-row-action-th,
.gs-import-row-action-cell {
  width: 96px;
}

.gs-import-row-action-cell {
  background: #f8fafc;
  color: rgba(28, 35, 41, 0.7);
  font-size: 11px;
  font-weight: 700;
}

.gs-import-row-action-cell span {
  display: block;
  margin-bottom: 6px;
  white-space: nowrap;
}

.gs-import-row-action-cell button {
  appearance: none;
  width: 27px;
  height: 27px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(185, 28, 28, 0.25);
  border-radius: 8px;
  background: rgba(185, 28, 28, 0.06);
  color: #b91c1c;
  cursor: pointer;
  font-weight: 900;
}

.gs-import-row-action-cell button:hover {
  background: rgba(185, 28, 28, 0.13);
}

.gs-import-cell-main {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gs-import-preview-table .cellContact {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.gs-import-preview-table .cellContactName {
  overflow: hidden;
  color: #1c2329;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gs-import-preview-table .cellContactSub {
  overflow: hidden;
  color: rgba(28, 35, 41, 0.65);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gs-import-dd-preview {
  min-height: 30px;
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 5px 9px;
  border-radius: 7px;
  background: #64748b;
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Column options dropdown */
.gs-import-column-menu {
  position: absolute;
  z-index: 999999;
  width: min(320px, calc(100vw - 20px));
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(28, 35, 41, 0.18);
  border-radius: 14px;
  background: #ffffff;
  color: #1c2329;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.3);
}

.gs-import-column-menu-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.gs-import-column-menu-head strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gs-import-column-menu-head button {
  appearance: none;
  border: 0;
  background: transparent;
  color: #1c2329;
  cursor: pointer;
}

.gs-import-column-menu label {
  display: grid;
  gap: 6px;
}

.gs-import-column-menu label > span {
  color: rgba(28, 35, 41, 0.68);
  font-size: 11px;
  font-weight: 800;
}

.gs-import-column-menu .input {
  width: 100%;
  background: #ffffff;
  color: #1c2329;
  border-color: rgba(28, 35, 41, 0.16);
}

.gs-import-column-menu textarea {
  resize: vertical;
}

.gs-import-column-menu small,
.gs-import-menu-note {
  color: rgba(28, 35, 41, 0.62);
  font-size: 11px;
  line-height: 1.4;
}

.gs-import-column-menu .btn.danger {
  justify-self: stretch;
  color: #b91c1c;
  border-color: rgba(185, 28, 28, 0.24);
}

/* =========================================================
   Spreadsheet header-row controls
========================================================= */

.gs-import-header-row-controls {
  display: grid;
  grid-template-columns: minmax(100px, 130px) minmax(0, 1fr);
  gap: 10px;
  align-items: end;
}

.gs-import-header-row-controls label {
  display: grid;
  gap: 6px;
}

.gs-import-header-row-controls .btn {
  min-height: 42px;
  width: 100%;
}

.gs-import-header-row-controls .btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

/* =========================================================
   Spreadsheet snapshot summary
========================================================= */

.gs-import-snapshot-content {
  display: grid;
  gap: 14px;
}

.gs-import-empty-snapshot {
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  border: 1px dashed var(--border);
  border-radius: 14px;
  color: var(--muted);
  text-align: center;
}

.gs-import-contact-preview-state {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
}

.gs-import-contact-preview-state-copy {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.gs-import-contact-preview-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.gs-import-contact-preview-state-copy strong {
  color: var(--text);
  font-size: 14px;
}

.gs-import-contact-preview-state-copy small {
  max-width: 520px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.gs-import-contact-preview-badge {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
}

.gs-import-contact-preview-badge.combined {
  background: rgba(34, 197, 94, 0.14);
  color: #15803d;
}

.gs-import-contact-preview-badge.separate {
  background: rgba(28, 35, 41, 0.08);
  color: var(--muted);
}

.gs-import-snapshot-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* =========================================================
   Import preview dashboard-style Contact cell
========================================================= */

.gs-import-preview-table .gs-import-dashboard-contact {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  display: grid;
  align-content: center;
  gap: 5px;
}

.gs-import-preview-table .gs-import-dashboard-contact .contact-name {
  max-width: 100%;
  overflow: hidden;
  color: #1c2329;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gs-import-preview-table .gs-import-dashboard-contact .contact-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.gs-import-preview-table .gs-import-dashboard-contact .contact-icon-btn {
  width: 24px;
  height: 24px;
  min-width: 24px;
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid rgba(28, 35, 41, 0.16);
  border-radius: 999px;
  background: rgba(28, 35, 41, 0.05);
  color: #1c2329;
  font-size: 12px;
  line-height: 1;
}

.gs-import-preview-footnote {
  margin-top: 10px;
}

@media (max-width: 1050px) {
  .gs-excel-import-layout {
    grid-template-columns: 1fr;
  }

  .gs-excel-import-settings,
  .gs-excel-import-snapshot {
    width: 100%;
  }

  .gs-import-empty-snapshot {
    min-height: 160px;
  }

  .gs-import-empty-preview {
    min-height: 280px;
  }
}

@media (max-width: 720px) {
  #spreadsheetImportModal.gs-excel-import-modal {
    width: calc(100vw - 10px);
    top: 5px;
    max-height: calc(100vh - 10px);
  }

  .gs-excel-import-body {
    padding: 10px;
  }

  .gs-excel-import-settings {
    display: block;
  }

  .gs-excel-import-options {
    margin-bottom: 14px;
  }

  .gs-import-preview-topbar {
    display: grid;
  }

  .gs-import-preview-actions,
  .gs-import-preview-actions .btn {
    width: 100%;
  }

  .gs-import-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .gs-import-header-row-controls {
    grid-template-columns: 1fr;
  }

  .gs-import-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .gs-import-contact-preview-state {
    align-items: flex-start;
    flex-direction: column;
  }

  .gs-import-snapshot-actions,
  .gs-import-snapshot-actions .btn {
    width: 100%;
  }
}

/* =========================================================
   COMPACT SPREADSHEET IMPORT WORKSPACE
   Main table controls directly above preview
========================================================= */

#spreadsheetImportModal.gs-excel-import-modal {
  width: min(1540px, calc(100vw - 16px));
  top: 8px;
  max-height: calc(100vh - 16px);
}

#spreadsheetImportModal .modalHeader,
#spreadsheetImportModal .modalFooter {
  padding: 10px 14px;
}

#spreadsheetImportModal .gs-excel-import-body {
  padding: 10px 14px 14px;
}

/*
 * Keep the upload/settings and snapshot panels short.
 * Their content determines their height instead of forcing
 * both sides to stretch to the tallest panel.
 */
#spreadsheetImportModal .gs-excel-import-layout {
  grid-template-columns:
    minmax(310px, 0.9fr)
    minmax(420px, 1.1fr);
  gap: 12px;
  align-items: start;
}

#spreadsheetImportModal .gs-excel-import-settings,
#spreadsheetImportModal .gs-excel-import-snapshot {
  align-self: start;
  padding: 12px 14px;
}

#spreadsheetImportModal .gs-excel-import-panel-heading {
  margin-bottom: 10px;
}

#spreadsheetImportModal .gs-excel-import-fields {
  gap: 9px;
}

/*
 * Inputs in the upper settings area no longer consume
 * the full width of the entire panel.
 */
#spreadsheetImportModal
  .gs-excel-import-settings
  #spreadsheetImportTableName {
  width: min(100%, 300px);
}

#spreadsheetImportModal
  .gs-excel-import-settings
  #spreadsheetImportSheet {
  width: min(100%, 280px);
}

/* Snapshot cards use the available horizontal space. */
#spreadsheetImportModal
  #spreadsheetImportSnapshot
  .gs-import-summary {
  grid-template-columns:
    repeat(4, minmax(95px, 1fr));
  gap: 8px;
}

#spreadsheetImportModal
  #spreadsheetImportSnapshot
  .gs-import-summary-card {
  min-height: 72px;
  padding: 9px 10px;
  box-shadow: none;
}

#spreadsheetImportModal
  #spreadsheetImportSnapshot
  .gs-import-summary-card span {
  font-size: 10px;
}

#spreadsheetImportModal
  #spreadsheetImportSnapshot
  .gs-import-summary-card strong {
  margin-top: 3px;
  font-size: 15px;
}

#spreadsheetImportModal
  .gs-import-contact-preview-state {
  margin-top: 8px;
  padding: 9px 10px;
}

#spreadsheetImportModal
  .gs-import-snapshot-actions {
  margin-top: 8px;
}

/* Remove the large empty-state height before a file is loaded. */
#spreadsheetImportModal
  .gs-import-empty-snapshot {
  min-height: 94px;
  padding: 14px;
}

#spreadsheetImportModal
  .gs-import-empty-preview {
  min-height: 140px;
  padding: 18px;
}

/* Preview section begins closer to the upper panels. */
#spreadsheetImportModal
  .gs-excel-import-table-section {
  margin-top: 12px;
  padding: 12px 14px 14px;
}

#spreadsheetImportModal
  .gs-excel-import-table-heading {
  margin-bottom: 8px;
}

/* =========================================================
   CONTROLS DIRECTLY ABOVE THE TABLE
========================================================= */

#spreadsheetImportModal
  .gs-import-preview-controls {
  display: grid;
  grid-template-columns:
    220px
    minmax(260px, 360px)
    minmax(300px, 430px);
  gap: 12px;
  align-items: end;
  justify-content: start;
  margin-bottom: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel2);
}

/* =========================================================
   TABLE NAME: compact field
========================================================= */

#spreadsheetImportModal
  .gs-import-table-name-control {
  width: 220px;
  max-width: 220px;
}

#spreadsheetImportModal
  #spreadsheetImportTableName {
  width: 220px !important;
  max-width: 220px !important;
}

/*
 * Change both 220px values above to your preferred width.
 * For example:
 *
 * 180px = very compact
 * 220px = compact default
 * 260px = slightly wider
 */


/* =========================================================
   CHECKBOXES BESIDE TABLE NAME
========================================================= */

#spreadsheetImportModal
  .gs-import-preview-checkboxes {
  min-height: 36px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 18px;
  padding: 0 4px;
}

#spreadsheetImportModal
  .gs-import-preview-checkboxes
  .gs-import-check,
#spreadsheetImportModal
  .gs-import-preview-checkboxes
  label {
  width: auto;
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  cursor: pointer;
}

#spreadsheetImportModal
  .gs-import-preview-checkboxes
  input[type="checkbox"] {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  margin: 0;
}


/* =========================================================
   SHEET DIRECTLY BELOW SPREADSHEET FILE
========================================================= */

#spreadsheetImportModal
  .gs-import-file-control {
  margin-bottom: 9px;
}

#spreadsheetImportModal
  .gs-import-sheet-control {
  margin-top: 0;
  margin-bottom: 9px;
}

#spreadsheetImportModal
  .gs-import-sheet-control
  #spreadsheetImportSheet {
  width: min(100%, 280px) !important;
  max-width: 280px !important;
}

#spreadsheetImportModal
  .gs-import-preview-controls
  label,
#spreadsheetImportModal
  .gs-import-preview-control {
  min-width: 0;
  display: grid;
  gap: 5px;
}

#spreadsheetImportModal
  .gs-import-preview-controls
  label > span,
#spreadsheetImportModal
  .gs-import-preview-controls
  label > .label,
#spreadsheetImportModal
  .gs-import-preview-control > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

#spreadsheetImportModal
  .gs-import-preview-controls
  .input,
#spreadsheetImportModal
  .gs-import-preview-controls
  select {
  width: 100%;
  min-width: 0;
  height: 36px;
  padding: 6px 9px;
  border-radius: 9px;
  font-size: 12px;
}

/*
 * Header-row input and "Use row..." button share one compact row.
 */
#spreadsheetImportModal
  .gs-import-preview-controls
  .gs-import-header-row-controls {
  display: grid;
  grid-template-columns: 90px minmax(150px, 1fr);
  gap: 8px;
  align-items: end;
}

#spreadsheetImportModal
  .gs-import-preview-controls
  .gs-import-header-row-controls
  .btn,
#spreadsheetImportModal
  .gs-import-preview-promote
  .btn {
  width: 100%;
  min-height: 36px;
  padding: 7px 9px;
  border-radius: 9px;
  font-size: 12px;
}

#spreadsheetImportModal
  .gs-import-preview-promote {
  align-self: end;
}

/* =========================================================
   SMALL ROW-ACTION COLUMN
========================================================= */

#spreadsheetImportModal
  .gs-import-preview-table
  .gs-import-row-action-th,
#spreadsheetImportModal
  .gs-import-preview-table
  .gs-import-row-action-cell {
  width: 48px !important;
  min-width: 48px !important;
  max-width: 48px !important;
  padding: 5px !important;
  text-align: center !important;
}

#spreadsheetImportModal
  .gs-import-preview-table
  .gs-import-row-action-th {
  cursor: default;
}

#spreadsheetImportModal
  .gs-import-preview-table
  .gs-import-row-action-cell
  span {
  display: none;
}

#spreadsheetImportModal
  .gs-import-preview-table
  .gs-import-remove-row-btn,
#spreadsheetImportModal
  .gs-import-preview-table
  .gs-import-row-action-cell
  button {
  appearance: none;
  width: 19px;
  min-width: 19px;
  height: 19px;
  margin: 0 auto;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(185, 28, 28, 0.24);
  border-radius: 5px;
  background: rgba(185, 28, 28, 0.06);
  color: #b91c1c;
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
}

#spreadsheetImportModal
  .gs-import-preview-table
  .gs-import-remove-row-btn:hover,
#spreadsheetImportModal
  .gs-import-preview-table
  .gs-import-row-action-cell
  button:hover {
  border-color: rgba(185, 28, 28, 0.45);
  background: rgba(185, 28, 28, 0.13);
}

/*
 * Slightly shorter table headers so more rows remain visible
 * on an ordinary laptop screen.
 */
#spreadsheetImportModal
  .gs-import-preview-table
  th {
  min-height: 60px !important;
  padding: 8px 10px !important;
}

#spreadsheetImportModal
  .gs-import-preview-table
  td {
  height: 42px;
  padding: 7px 10px !important;
}

/* Never visibly expose Goodstream's internal table slug. */
#spreadsheetImportModal
  .gs-import-source-label[data-source="table_slug"],
#spreadsheetImportModal
  [data-field-key="table_slug"] {
  display: none !important;
}

@media (max-width: 1100px) {
  #spreadsheetImportModal
    .gs-import-preview-controls {
    grid-template-columns:
      200px
      minmax(240px, 1fr);
  }

  #spreadsheetImportModal
    .gs-import-preview-header-control,
  #spreadsheetImportModal
    .gs-import-preview-promote {
    grid-column: 1 / -1;
  }

  #spreadsheetImportModal
    .gs-import-table-name-control,
  #spreadsheetImportModal
    #spreadsheetImportTableName {
    width: 200px !important;
    max-width: 200px !important;
  }
}

@media (max-width: 760px) {
  #spreadsheetImportModal
    .gs-import-preview-controls {
    grid-template-columns: 1fr;
  }

  #spreadsheetImportModal
    .gs-import-preview-header-control,
  #spreadsheetImportModal
    .gs-import-preview-promote {
    grid-column: auto;
  }

  #spreadsheetImportModal
    .gs-import-table-name-control,
  #spreadsheetImportModal
    #spreadsheetImportTableName {
    width: 100% !important;
    max-width: none !important;
  }

  #spreadsheetImportModal
    .gs-import-preview-checkboxes {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
    padding: 2px 0;
  }
}