@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
  --ink: #0f172a;
  --ink-soft: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --surface: #f1f5f9;
  --surface-2: #e2e8f0;
  --panel: #ffffff;
  --navy: #0b1220;
  --navy-mid: #111827;
  --navy-soft: #1e293b;
  --accent: #0d9488;
  --accent-hover: #0f766e;
  --accent-soft: rgba(13, 148, 136, 0.12);
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --success: #059669;
  --warning: #d97706;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 10px 30px rgba(15, 23, 42, 0.08);
  --radius: 14px;
  --radius-sm: 10px;
  --sidebar-w: 272px;
  --nav-h: 64px;
  --font-ui: "Plus Jakarta Sans", system-ui, sans-serif;
}

*,
*::before,
*::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

#body {
  margin: 0;
  min-height: 100vh;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 14.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ========== Market-standard SaaS shell ========== */
.app-shell {
  min-height: 100vh;
  width: 100%;
  display: flex;
  background: var(--surface);
  overflow-x: hidden;
}

.app-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--navy);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 1rem 0.85rem 1.25rem;
  z-index: 200;
  border-right: 1px solid rgba(255,255,255,0.06);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.35rem 0.55rem 1.1rem;
  cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 0.85rem;
}

.sidebar-brand img {
  height: 36px;
  width: auto;
  border-radius: 8px;
  background: #fff;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(145deg, var(--accent) 0%, #115e59 100%);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 0.95rem;
  flex-shrink: 0;
}

.sidebar-brand strong {
  display: block;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.sidebar-brand span {
  display: block;
  font-size: 0.7rem;
  color: rgba(255,255,255,0.5);
  font-weight: 500;
}

.sidebar-label {
  padding: 0.55rem 0.75rem 0.4rem;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.38);
}

.sidebar-nav {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.7rem 0.8rem;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.72);
  font-size: 0.9rem;
  font-weight: 550;
  transition: background 0.15s ease, color 0.15s ease;
}

.sidebar-nav a:hover {
  background: rgba(255,255,255,0.06);
  color: #fff;
}

.sidebar-nav a.active {
  background: rgba(13, 148, 136, 0.22);
  color: #fff;
  box-shadow: inset 3px 0 0 var(--accent);
}

.sidebar-nav .fa-solid {
  width: 1.1rem;
  text-align: center;
  opacity: 0.9;
  font-size: 0.9rem;
}

.sidebar-divider {
  height: 1px;
  background: rgba(255,255,255,0.08);
  margin: 0.75rem 0.4rem;
}

.sidebar-cta {
  margin-top: auto;
  padding: 0.9rem;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
}

.sidebar-cta p {
  margin: 0 0 0.7rem;
  font-size: 0.78rem;
  color: rgba(255,255,255,0.62);
  line-height: 1.4;
}

.sidebar-cta .btn-app { width: 100%; height: 38px; font-size: 0.8rem; }

.app-frame {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  width: calc(100% - var(--sidebar-w));
  max-width: calc(100% - var(--sidebar-w));
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-nav,
.app-topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-h);
  width: 100%;
  background: rgba(255,255,255,0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.app-nav-inner,
.app-topbar-inner {
  height: 100%;
  width: 100%;
  max-width: none;
  padding: 0 clamp(1rem, 2vw, 2rem);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.topbar-title {
  min-width: 0;
}

.topbar-title h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-title p {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-nav-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-shrink: 0;
}

.app-content {
  flex: 1;
  width: 100%;
  max-width: none;
  padding: 1.35rem clamp(1rem, 2vw, 2rem) 2rem;
  min-width: 0;
}

.app-main,
.main-ground,
.page-stack {
  width: 100%;
  max-width: none;
  min-width: 0;
}

.app-body { display: contents; }

.page-stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.brand { display: none; } /* brand lives in sidebar for admin shell */

/* Client / public pages keep top brand visible */
.public-page .brand,
.ty-page .brand {
  display: flex !important;
}

.public-page .app-nav-inner,
.ty-page .app-nav-inner {
  max-width: none;
  width: 100%;
}

.btn-app {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  height: 40px;
  padding: 0 1rem;
  border: 0;
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: 0.845rem;
  font-weight: 650;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.btn-app:active { transform: translateY(1px); }
.btn-app-primary { background: var(--accent); color: #fff; }
.btn-app-primary:hover { background: var(--accent-hover); color: #fff; }
.btn-app-secondary { background: var(--surface-2); color: var(--ink); }
.btn-app-secondary:hover { background: var(--line); color: var(--ink); }
.btn-app-ghost { background: transparent; color: var(--ink-soft); border: 1px solid var(--line); }
.btn-app-ghost:hover { background: var(--surface); color: var(--ink); }
.btn-app-danger { background: var(--danger-soft); color: var(--danger); }
.btn-app-danger:hover { background: #fee2e2; color: var(--danger); }
.btn-app-dark { background: var(--navy); color: #fff; }
.btn-app-danger:disabled { opacity: 0.45; cursor: not-allowed; }

.labelHeader,
.page-header {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
}

.labelHeader h2,
.page-header h2 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 750;
  color: var(--ink);
  letter-spacing: -0.025em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.page-header p {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.PageFormBox,
.page-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.infoLabelBox,
.page-hint {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  color: var(--ink-soft);
  font-size: 0.875rem;
}
.infoLabelBox p, .page-hint p { margin: 0; }
.infoLabelBox.bg-dark,
.section-banner {
  background: var(--navy) !important;
  color: #fff !important;
  border-color: transparent !important;
}
.section-banner p { color: #fff; font-weight: 600; }

/* Stats / dashboard */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.9rem;
}
.stat-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.15rem;
  box-shadow: var(--shadow-sm);
}
.stat-card .stat-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 0.35rem;
}
.stat-card .stat-value {
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--ink);
  line-height: 1.1;
}
.stat-card .stat-meta {
  margin-top: 0.35rem;
  font-size: 0.78rem;
  color: var(--muted);
}

/* List rows */
.addedTemplatesLis,
.item-row {
  height: auto !important;
  background: #fff !important;
  border: 1px solid var(--line) !important;
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.addedTemplatesLis:hover,
.item-row:hover {
  border-color: var(--line-strong) !important;
  box-shadow: var(--shadow-sm);
}
.addedTemplatesLis .row,
.item-row-inner {
  display: flex;
  align-items: center;
  margin: 0;
  min-height: 84px;
}
.addedTemplatesLis1,
.item-thumb {
  height: auto !important;
  width: 72px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  padding: 0.75rem;
  background: transparent !important;
}
.item-icon {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 1.05rem;
}
.addedTemplatesLis2,
.item-body {
  height: auto !important;
  flex: 1;
  min-width: 0;
  padding: 0.85rem 0.5rem !important;
}
.addedTemplatesLis2 h2,
.item-body h2 {
  font-size: 0.98rem !important;
  font-weight: 700;
  color: var(--ink) !important;
  margin: 0 0 0.3rem !important;
}
.addedTemplatesLis2 h2 a,
.item-body h2 a { color: inherit; }
.addedTemplatesLis2 .infoLabelBox {
  margin: 0 !important;
  padding: 0.35rem 0.6rem;
  display: inline-flex;
}
.addedTemplatesLis3,
.item-actions {
  height: auto !important;
  min-height: 84px;
  min-width: 140px;
  display: flex !important;
  flex-direction: row;
  align-items: center;
  justify-content: flex-end;
  gap: 0.4rem;
  padding: 0.75rem 1rem;
  background: transparent !important;
}
.addedTemplatesLis3 button,
.item-actions button,
.item-actions .btn-app {
  height: 36px;
  padding: 0 0.8rem;
  border: 0;
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: 0.78rem;
  font-weight: 650;
  background: var(--accent);
  color: #fff;
  white-space: nowrap;
}
.addedTemplatesLis3 button.bg-danger,
.item-actions button.bg-danger,
.addedTemplatesLis3 button.btn-icon-danger,
.item-actions button.btn-icon-danger {
  background: var(--danger-soft) !important;
  color: var(--danger) !important;
  border: 1px solid #fecaca !important;
}

.addedTemplatesLis3 button.btn-icon-danger .fa-trash,
.item-actions button.btn-icon-danger .fa-trash,
.btn-app-danger .fa-trash {
  color: var(--danger) !important;
}

/* Forms */
.PageFormBox form, .page-panel form { font-family: var(--font-ui); font-size: 0.9rem; }
.PageFormBox label, .page-panel label, .form-label {
  font-weight: 650;
  color: var(--ink-soft);
  font-size: 0.8rem;
  margin-bottom: 0.35rem;
}
.PageFormBox .form-control,
.PageFormBox .form-select,
.page-panel .form-control,
.page-panel .form-select {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm) !important;
  background: #fff !important;
  min-height: 42px;
  font-size: 0.9rem;
  color: var(--ink);
  box-shadow: none !important;
}
.PageFormBox .form-control:focus,
.PageFormBox .form-select:focus,
.page-panel .form-control:focus,
.page-panel .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft) !important;
}
.PageFormBox button.btn,
.page-panel button.btn-primary {
  height: 42px;
  background: var(--accent) !important;
  border: 0 !important;
  border-radius: var(--radius-sm) !important;
  float: none;
  font-weight: 650;
  padding: 0 1.15rem;
}
.req { color: #dc2626; }
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
  margin-top: 0.5rem;
}

.nav-tabs { border-bottom: 1px solid var(--line); gap: 0.25rem; }
.nav-tabs .nav-link {
  border: 0 !important;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0 !important;
  background: transparent !important;
  color: var(--muted) !important;
  font-weight: 650;
  font-size: 0.875rem;
  padding: 0.7rem 1rem;
}
.nav-tabs .nav-link.active {
  color: var(--ink) !important;
  box-shadow: inset 0 -2px 0 var(--accent);
}
.nav-tabs .badge { font-weight: 650; font-size: 0.7rem; }

.table { margin-bottom: 0; font-size: 0.9rem; }
.table thead th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 700;
  background: var(--surface);
}
.table tbody td {
  vertical-align: middle;
  color: var(--ink-soft);
  padding: 0.85rem 0.75rem;
}
.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.empty-state i { font-size: 1.75rem; margin-bottom: 0.75rem; color: var(--line-strong); }

/* Preview / client */
.navBoc {
  position: sticky; top: 0; z-index: 100; height: var(--nav-h);
  background: rgba(255,255,255,0.92); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.navBocOption { height: var(--nav-h); display: flex; align-items: center; }
.navBocOption h1 { margin: 0; font-size: 1.1rem; font-weight: 700; color: var(--ink); }
.navBocOptionBtn { height: var(--nav-h); display: flex; align-items: center; justify-content: flex-end; gap: 0.5rem; }
.navBocOptionBtn button {
  height: 40px; background: var(--accent); border: 0; border-radius: var(--radius-sm);
  color: #fff; font-weight: 650; padding: 0 1rem;
}
.contPreviewPage {
  background: var(--panel);
  border: 1px solid var(--line) !important;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.contLabel {
  height: auto !important; min-height: 64px;
  background: var(--navy) !important; padding: 0.75rem 1rem;
}
.contLabel1, .contLabel2 { height: auto !important; min-height: 48px; display: flex; align-items: center; }
.contLabel1 h2 { margin: 0; font-size: 1.05rem; color: #fff; font-weight: 700; }
.contLabel2 { justify-content: flex-end; gap: 0.5rem; flex-wrap: wrap; }
.contLabel2 button { height: 38px; border-radius: var(--radius-sm); font-weight: 650; font-size: 0.85rem; }
.contContentBox {
  height: 75vh; overflow: auto; background: #fff !important;
  border: 1px solid var(--line) !important; border-radius: var(--radius-sm) !important; padding: 1.5rem !important;
}
.contLabel1_pre {
  background: var(--navy) !important; border-bottom: 3px solid var(--accent) !important;
  border-radius: var(--radius) var(--radius) 0 0;
}
.contLabel1_pre h2 {
  font-size: 0.92rem; height: 52px; display: flex; align-items: center;
  color: #fff; margin: 0; padding: 0 1rem; font-weight: 650;
}
.allDetailsBox h3 {
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--muted); font-weight: 700; margin: 0;
}
.allDetailsBox p { font-size: 0.9rem; color: var(--ink); font-weight: 550; margin: 0.15rem 0 0.85rem; }
.contLabel1_preSig {
  height: 48px; display: grid; place-items: center; background: var(--accent);
  cursor: pointer; border-radius: 0 0 var(--radius) var(--radius);
}
.contLabel1_preSig:hover { background: var(--accent-hover); }
.contLabel1_preSig h2 { font-size: 0.92rem; margin: 0; color: #fff; font-weight: 650; }
.rightPreviewBox .border.bg-white {
  border-radius: var(--radius) !important; border-color: var(--line) !important;
  overflow: hidden; box-shadow: var(--shadow-sm);
}
#generate-pdf-btn {
  width: 100%; height: 42px; background: var(--accent); border: 0;
  border-radius: var(--radius-sm); color: #fff; font-weight: 650;
}

.footeRbOX, .app-footer {
  margin-top: auto;
  width: 100%;
  min-height: 52px;
  background: transparent;
  border-top: 1px solid var(--line);
  display: grid;
  place-items: center;
  padding: 0.85rem clamp(1rem, 2vw, 2rem);
}
.footeRbOX p, .app-footer p { margin: 0; color: var(--muted); font-size: 0.78rem; }
.footeRbOX .text-primary, .app-footer a { color: var(--accent) !important; font-weight: 650; }

.sidebar { height: auto; background: transparent; }
.underDocs { background: transparent; }
.underDocs ul { list-style: none; margin: 0; padding: 0; }
.tabOPtion {
  width: 100%; height: auto; min-height: 40px; background: transparent;
  display: flex; align-items: center; border-bottom: 0;
}

/* Quill */
.quill-wrap {
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  overflow: hidden; background: #fff;
}
.quill-wrap .ql-toolbar.ql-snow {
  border: 0; border-bottom: 1px solid var(--line); background: var(--surface); font-family: var(--font-ui);
}
.quill-wrap .ql-container.ql-snow { border: 0; font-family: var(--font-ui); font-size: 0.95rem; }
.quill-wrap .ql-editor { min-height: 200px; }

.settings-preview-img {
  max-width: 220px; max-height: 100px; object-fit: contain;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; padding: 0.5rem;
}
.sig-canvas-box {
  border: 1px dashed var(--line-strong); border-radius: var(--radius-sm);
  background: #fff; overflow: hidden;
}
.sig-canvas-box canvas { display: block; width: 100%; max-width: 100%; height: auto; touch-action: none; cursor: crosshair; }
.sig-error { display: none; color: var(--danger); font-size: 0.85rem; font-weight: 650; margin-top: 0.5rem; }
.sig-error.show { display: block; }

/* Bulk toolbar */
.bulk-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  flex-wrap: wrap; padding: 0.75rem 0.85rem; margin-bottom: 0.85rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.bulk-toolbar-left, .bulk-toolbar-right { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.bulk-check-all {
  display: inline-flex; align-items: center; gap: 0.45rem; margin: 0;
  font-weight: 650; font-size: 0.875rem; color: var(--ink-soft); cursor: pointer;
}
.bulk-count { font-size: 0.8rem; color: var(--muted); font-weight: 650; }
.bulk-search { position: relative; min-width: 220px; }
.bulk-search i {
  position: absolute; left: 0.75rem; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: 0.8rem;
}
.bulk-search .form-control { padding-left: 2rem; height: 38px; border-radius: var(--radius-sm); }
.item-check { display: grid; place-items: center; padding-left: 0.85rem; }
.item-check .form-check-input { width: 1.15rem; height: 1.15rem; cursor: pointer; margin: 0; }
.item-row.is-selected { border-color: var(--accent) !important; background: var(--accent-soft) !important; }
.status-pill {
  display: inline-flex; align-items: center; padding: 0.15rem 0.55rem; border-radius: 999px;
  background: var(--surface-2); color: var(--ink-soft); font-size: 0.7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.03em;
}
.status-pill.is-signed { background: rgba(5, 150, 105, 0.12); color: var(--success); }
.status-pill.is-draft { background: rgba(15, 23, 42, 0.06); color: var(--navy); }

.mobile-nav-toggle {
  display: none;
  width: 40px; height: 40px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: #fff; color: var(--ink); align-items: center; justify-content: center;
  flex-shrink: 0;
}

.sidebar-overlay {
  display: none;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.PageFormBox,
.page-panel,
.labelHeader,
.page-header {
  width: 100%;
  max-width: 100%;
}

/* Large / ultra-wide: fill available space, no empty right gutter */
@media (min-width: 1400px) {
  .app-nav-inner,
  .app-topbar-inner,
  .app-content {
    padding-left: clamp(1.5rem, 2.5vw, 2.75rem);
    padding-right: clamp(1.5rem, 2.5vw, 2.75rem);
  }

  .stat-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (min-width: 1600px) {
  .stat-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* Tablet landscape / small desktop */
@media (max-width: 1199.98px) {
  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .item-actions,
  .addedTemplatesLis3 {
    flex-wrap: wrap;
  }
}

/* Tablet / mobile: collapsible sidebar */
@media (max-width: 991.98px) {
  :root {
    --sidebar-w: 272px;
  }

  .app-sidebar {
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow-md);
  }

  .app-shell.sidebar-open .app-sidebar {
    transform: translateX(0);
  }

  .app-frame {
    margin-left: 0;
    width: 100%;
    max-width: 100%;
  }

  .mobile-nav-toggle {
    display: inline-flex;
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 150;
  }

  .app-shell.sidebar-open .sidebar-overlay {
    display: block;
  }

  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .page-header,
  .labelHeader {
    flex-direction: column;
    align-items: flex-start;
  }

  .bulk-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .bulk-toolbar-left,
  .bulk-toolbar-right {
    width: 100%;
    justify-content: space-between;
  }

  .bulk-search {
    flex: 1;
    min-width: 0;
    width: 100%;
  }

  .addedTemplatesLis .row,
  .item-row-inner {
    flex-wrap: wrap;
  }

  .addedTemplatesLis3,
  .item-actions {
    width: 100%;
    min-width: 0;
    min-height: auto;
    justify-content: stretch;
    border-top: 1px solid var(--line);
    padding: 0.65rem 0.85rem;
  }

  .addedTemplatesLis3 button,
  .item-actions button {
    flex: 1;
  }

  .contLabel2 {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .contContentBox {
    height: 60vh;
  }
}

/* Phones */
@media (max-width: 575.98px) {
  .stat-grid {
    grid-template-columns: 1fr;
  }

  .app-content {
    padding: 0.85rem 0.85rem 1.5rem;
  }

  .app-nav-inner,
  .app-topbar-inner {
    padding: 0 0.85rem;
  }

  .topbar-title p {
    display: none;
  }

  .app-nav-actions .btn-app-ghost span,
  .app-nav-actions .btn-app-primary {
    font-size: 0.78rem;
  }

  .app-nav-actions .btn-app-ghost span {
    display: none;
  }

  .page-header h2,
  .labelHeader h2 {
    font-size: 1.05rem;
  }

  .item-thumb,
  .addedTemplatesLis1 {
    width: 56px;
  }

  .bulk-toolbar-right {
    flex-direction: column;
    align-items: stretch;
  }

  .bulk-toolbar-right .btn-app {
    width: 100%;
  }

  .sig-canvas-box canvas {
    width: 100% !important;
    height: auto !important;
  }
}

/* Very small phones */
@media (max-width: 380px) {
  .app-nav-actions .btn-app-primary {
    padding: 0 0.7rem;
  }
}

/* ========== Global responsive hardening ========== */
html, body, #body {
  max-width: 100%;
  overflow-x: hidden;
}

img, video, canvas, svg {
  max-width: 100%;
  height: auto;
}

.row {
  --bs-gutter-x: 1rem;
}

.quill-wrap {
  max-width: 100%;
}

.quill-wrap .ql-toolbar.ql-snow {
  flex-wrap: wrap;
  white-space: normal;
}

.quill-wrap .ql-editor {
  word-break: break-word;
  overflow-wrap: anywhere;
}

.settings-tabs,
.nav-tabs {
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.settings-tabs .nav-item,
.nav-tabs .nav-item {
  flex: 0 0 auto;
}

.form-actions {
  flex-wrap: wrap;
}

.contContentBox,
.contPreviewPage,
.page-panel,
.PageFormBox {
  max-width: 100%;
  overflow-x: auto;
}

.contContentBox * {
  max-width: 100%;
}

.contContentBox img,
.contContentBox table {
  max-width: 100% !important;
  height: auto !important;
}

.public-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
}

.public-page .public-body {
  flex: 1;
  width: 100%;
  padding: 1rem clamp(0.85rem, 2vw, 1.75rem) 1.75rem;
}

.public-page .rightPreviewBox {
  margin-top: 0.5rem;
}

@media (max-width: 991.98px) {
  .public-page .contContentBox {
    height: 55vh;
    min-height: 280px;
  }

  .public-page .app-nav-actions .btn-app span {
    display: none;
  }

  .form-actions {
    flex-direction: column;
  }

  .form-actions .btn,
  .form-actions .btn-app {
    width: 100%;
  }

  .page-header .d-flex,
  .labelHeader .d-flex {
    width: 100%;
    flex-wrap: wrap;
  }

  .page-header .btn-app,
  .labelHeader .btn-app {
    flex: 1 1 auto;
  }
}

@media (max-width: 767.98px) {
  .create-load-row .col-md-2,
  .create-load-row .col-md-10 {
    width: 100%;
  }

  .modal-dialog {
    margin: 0.5rem;
    max-width: calc(100% - 1rem);
  }

  .sig-canvas-box {
    margin: 0 -0.15rem;
  }

  #confirmTable th:nth-child(5),
  #confirmTable td:nth-child(5) {
    display: none;
  }
}

@media (max-width: 575.98px) {
  .app-nav-actions .btn-app-primary {
    padding: 0 0.85rem;
  }

  .app-nav-actions .btn-app-ghost {
    display: none;
  }

  .infoLabelBox {
    font-size: 0.8rem;
  }

  .item-body h2,
  .addedTemplatesLis2 h2 {
    font-size: 0.92rem !important;
  }

  .status-pill {
    font-size: 0.65rem;
  }

  .public-page .brand-text span {
    display: none;
  }

  .public-page .contContentBox {
    height: 50vh;
    padding: 1rem !important;
    font-size: 0.9rem;
  }
}

@media (min-width: 992px) {
  .public-page .rightPreviewBox {
    position: sticky;
    top: calc(var(--nav-h) + 1rem);
  }
}
