/* Shared Экспертум Про report-template modal */
body.template-modal-open {
  overflow: hidden;
}

#reportTemplateModal {
  --template-modal-paper: #fbfaf7;
  --template-modal-surface: #fff;
  --template-modal-text: #11110f;
  --template-modal-muted: #696762;
  --template-modal-gold: #c9a85f;
  --template-modal-gold-soft: #f2ebdd;
  --template-modal-line: #e7e3db;
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(17, 17, 15, .4);
  overflow-x: hidden;
  box-sizing: border-box;
}

#reportTemplateModal.is-visible {
  display: flex;
  animation: template-modal-fade .18s ease-out;
}

#reportTemplateModal .preview-modal {
  width: min(980px, 100%);
  min-width: 0;
  max-width: 100%;
  max-height: calc(100vh - 40px);
  overflow-x: hidden;
  overflow-y: auto;
  box-sizing: border-box;
  padding: 24px;
  border: 1px solid var(--template-modal-line);
  border-radius: 20px;
  color: var(--template-modal-text);
  background: var(--template-modal-paper);
  box-shadow: 0 24px 72px rgba(49, 43, 31, .16);
  outline: none;
  animation: template-modal-rise .2s ease-out;
}

#reportTemplateModal .modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--template-modal-line);
}

#reportTemplateModal .modal-head h3 {
  margin: 8px 0 6px;
  color: var(--template-modal-text);
  font-size: clamp(23px, 3vw, 30px);
  line-height: 1.18;
  letter-spacing: -.025em;
}

#reportTemplateModal .modal-head p {
  max-width: 650px;
  margin: 0;
  color: var(--template-modal-muted);
  font-size: 14px;
  line-height: 1.55;
}

#reportTemplateModal .badge {
  width: max-content;
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border: 1px solid rgba(201, 168, 95, .32);
  border-radius: 999px;
  color: #715925;
  background: var(--template-modal-gold-soft);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}

#reportTemplateModal .template-modal-close {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  min-height: 42px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid var(--template-modal-line);
  border-radius: 12px;
  color: var(--template-modal-text);
  background: var(--template-modal-surface);
  box-shadow: 0 8px 20px rgba(49, 43, 31, .06);
  cursor: pointer;
  transition: background .18s ease, border-color .18s ease, transform .18s ease;
}

#reportTemplateModal .template-modal-close:hover {
  transform: translateY(-1px);
  border-color: rgba(201, 168, 95, .55);
  background: #fdfbf6;
}

#reportTemplateModal .template-modal-close svg,
#reportTemplateModal .template-modal-back svg,
#reportTemplateModal .template-choice-card__arrow {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#reportTemplateModal .template-modal-toolbar {
  min-height: 44px;
  margin: 14px 0;
  display: flex;
  justify-content: flex-start;
}

#reportTemplateModal .template-modal-back,
#reportTemplateModal > .preview-modal > .actions .btn-secondary {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  border: 1px solid var(--template-modal-line);
  border-radius: 12px;
  color: var(--template-modal-text);
  background: var(--template-modal-surface);
  box-shadow: 0 8px 20px rgba(49, 43, 31, .05);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background .18s ease, border-color .18s ease, transform .18s ease;
}

#reportTemplateModal .template-modal-back:hover,
#reportTemplateModal > .preview-modal > .actions .btn-secondary:hover {
  transform: translateY(-1px);
  border-color: rgba(201, 168, 95, .55);
  background: #fdfbf6;
}

#reportTemplateModal .template-choice-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  min-width: 0;
  width: 100%;
  max-width: 100%;
}

#reportTemplateModal .template-category-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 18px;
}

#reportTemplateModal .template-category-card {
  min-height: 142px;
  padding: 22px;
  grid-template-columns: 52px minmax(0, 1fr) 20px;
  gap: 16px;
}

#reportTemplateModal .template-category-card .template-choice-icon {
  width: 52px;
  height: 52px;
  border-radius: 16px;
}

#reportTemplateModal .template-category-card .template-choice-icon svg {
  width: 26px;
  height: 26px;
}

#reportTemplateModal #reportTemplateGroups.is-transitioning {
  animation: template-modal-content-in .2s ease-out;
}

#reportTemplateModal .template-access-notice {
  min-height:54px;
  margin:16px 0;
  padding:11px 13px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:14px;
  border:1px solid rgba(201,168,95,.28);
  border-radius:14px;
  color:var(--template-modal-muted);
  background:rgba(242,235,221,.58);
  font-size:13px;
  line-height:1.45;
}

#reportTemplateModal .template-access-notice > span { display:grid;gap:2px; }
#reportTemplateModal .template-access-notice strong { color:var(--template-modal-text); }
#reportTemplateModal .template-access-notice small { color:var(--template-modal-muted);font-size:11px; }
#reportTemplateModal .template-access-notice > a:not(.btn) { color:#715925;font-weight:700;white-space:nowrap; }
#reportTemplateModal .template-access-notice.is-error { border-color:rgba(100,116,139,.18);background:rgba(100,116,139,.06); }
#reportTemplateModal .template-access-notice .btn { flex:0 0 auto;white-space:nowrap; }

#reportTemplateModal .template-choice-card {
  width: 100%;
  min-width: 0;
  min-height: 104px;
  padding: 16px;
  border: 1px solid var(--template-modal-line);
  border-radius: 18px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 20px;
  align-items: center;
  gap: 13px;
  box-sizing: border-box;
  overflow: hidden;
  color: var(--template-modal-text);
  background: var(--template-modal-surface);
  box-shadow: 0 8px 24px rgba(49, 43, 31, .05);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

#reportTemplateModal .template-choice-card:hover {
  transform: translateY(-1px);
  border-color: rgba(201, 168, 95, .62);
  background: #fdfbf6;
  box-shadow: 0 12px 30px rgba(49, 43, 31, .08);
}

#reportTemplateModal .template-choice-card:focus-visible,
#reportTemplateModal .template-modal-close:focus-visible,
#reportTemplateModal .template-modal-back:focus-visible {
  outline: 3px solid rgba(201, 168, 95, .28);
  outline-offset: 2px;
}

#reportTemplateModal .template-choice-card.is-disabled {
  opacity: .68;
  cursor: not-allowed;
  filter: grayscale(.25);
}

#reportTemplateModal .template-choice-card.is-disabled:hover {
  transform: none;
  border-color: var(--template-modal-line);
  background: var(--template-modal-surface);
  box-shadow: 0 8px 24px rgba(49, 43, 31, .05);
}

#reportTemplateModal .template-choice-icon {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  color: var(--template-modal-gold);
  background: var(--template-modal-gold-soft);
  overflow: hidden;
}

#reportTemplateModal .template-choice-icon svg {
  display: block;
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#reportTemplateModal .template-choice-copy {
  display: block;
  min-width: 0;
  max-width: 100%;
}

#reportTemplateModal .template-choice-title {
  display: block;
  margin: 0 0 6px;
  color: var(--template-modal-text);
  font-size: 17px;
  font-weight: 800;
  line-height: 1.25;
  white-space: normal;
  overflow-wrap: anywhere;
}

#reportTemplateModal .template-choice-desc {
  display: block;
  color: var(--template-modal-muted);
  font-size: 13px;
  line-height: 1.45;
  white-space: normal;
  overflow-wrap: anywhere;
}

#reportTemplateModal .template-choice-card__meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  width: 20px;
  min-width: 20px;
  color: var(--template-modal-gold);
}

#reportTemplateModal .template-choice-card__arrow {
  display: block;
  flex: 0 0 auto;
}

#reportTemplateModal .template-choice-status {
  width: max-content;
  min-height: 26px;
  padding: 4px 10px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  color: #715925;
  background: var(--template-modal-gold-soft);
  font-size: 12px;
  font-weight: 800;
}

#reportTemplateModal .template-choice-status.soon {
  color: #64748b;
  background: rgba(100, 116, 139, .12);
}

#reportTemplateModal .template-choice-status.beta {
  color: #b45f05;
  background: rgba(255, 159, 47, .13);
}

#reportTemplateModal .template-choice-status.unavailable {
  margin-top:8px;
  color:#475569;
  background:rgba(100,116,139,.12);
  text-transform:none;
}

#reportTemplateModal > .preview-modal > .actions {
  margin-top: 14px !important;
  padding-top: 14px;
  display: flex;
  gap: 10px;
  border-top: 1px solid var(--template-modal-line);
}

@keyframes template-modal-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes template-modal-rise {
  from { opacity: 0; transform: translateY(8px) scale(.99); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes template-modal-content-in {
  from { opacity: 0; transform: translateX(8px); }
  to { opacity: 1; transform: translateX(0); }
}

@media (max-width: 720px) {
  #reportTemplateModal { padding: 10px; }
  #reportTemplateModal .preview-modal { max-height: calc(100vh - 20px); padding: 18px; border-radius: 17px; }
  #reportTemplateModal .template-choice-grid { grid-template-columns: 1fr; }
  #reportTemplateModal .template-choice-card { min-height: 96px; padding: 14px; }
  #reportTemplateModal .template-category-grid { grid-template-columns: minmax(0, 1fr); }
  #reportTemplateModal .template-category-card { min-height: 112px; }
  #reportTemplateModal .template-access-notice { align-items:stretch;flex-direction:column; }
  #reportTemplateModal .template-access-notice .btn { width:100%; }
}
#reportTemplateModal #reportTemplateGroups,
#reportTemplateModal .report-template-group {
  min-width: 0;
  max-width: 100%;
}

#reportTemplateModal .report-template-group {
  margin-top: 18px;
}

#reportTemplateModal .report-template-group + .report-template-group {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border, #d8dee8);
}

#reportTemplateModal .report-template-group h4 {
  margin: 0 0 12px;
  font-size: 18px;
}

@media (max-width: 1024px) {
  #reportTemplateModal .template-choice-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  #reportTemplateModal .template-choice-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 420px) {
  #reportTemplateModal { padding: 6px; }
  #reportTemplateModal .preview-modal { padding: 14px; max-height: calc(100vh - 12px); }
  #reportTemplateModal .modal-head { gap: 12px; }
  #reportTemplateModal .template-choice-card { grid-template-columns: 40px minmax(0, 1fr) 18px; gap: 10px; }
  #reportTemplateModal .template-choice-icon { width: 40px; height: 40px; }
}
