/* ─── Modal Overlay ──────────────────────────────────────────────────────── */
#modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(9, 30, 66, 0.54);
  z-index: 1000;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 48px 16px 24px;
  overflow-y: auto;
}
#modal-overlay.visible { display: flex; }

/* ─── Modal Box ──────────────────────────────────────────────────────────── */
.modal {
  background: var(--bg-white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  animation: modalIn .22s ease;
  margin: auto;
  max-height: calc(100vh - 80px);
  overflow: hidden;
}

.modal-wide { max-width: 720px; }
.modal-sm   { max-width: 420px; }

@keyframes modalIn {
  from { opacity: 0; transform: translateY(-12px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ─── Modal Header ───────────────────────────────────────────────────────── */
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 0;
  flex-shrink: 0;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-dark);
}

.modal-subtitle {
  font-size: 13px;
  color: var(--text-light);
  margin-top: 3px;
}

/* ─── Modal Body ─────────────────────────────────────────────────────────── */
.modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1;
}

/* ─── Modal Footer ───────────────────────────────────────────────────────── */
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg-white);
}

.modal-footer-left {
  margin-right: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ─── Wizard Step indicator ──────────────────────────────────────────────── */
.wizard-steps {
  display: flex;
  align-items: center;
  padding: 0 24px;
  margin-top: 16px;
  gap: 0;
}

.wizard-step {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.wizard-step:last-child { flex: 0; }

.step-number {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-light);
  flex-shrink: 0;
  transition: all var(--transition);
}
.wizard-step.active  .step-number { border-color: var(--primary); background: var(--primary); color: #fff; }
.wizard-step.done    .step-number { border-color: var(--success); background: var(--success); color: #fff; }

.step-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-light);
  transition: color var(--transition);
  white-space: nowrap;
}
.wizard-step.active .step-label { color: var(--primary); }
.wizard-step.done   .step-label { color: var(--success); }

.step-connector {
  flex: 1;
  height: 2px;
  background: var(--border);
  margin: 0 8px;
  transition: background var(--transition);
}
.step-connector.done { background: var(--success); }

/* ─── Wizard Panel (single step content area) ────────────────────────────── */
.wizard-panel { display: none; }
.wizard-panel.active { display: block; }

/* ─── Connection test result ─────────────────────────────────────────────── */
.connection-result {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  margin-top: 12px;
}
.connection-result.success {
  background: var(--success-light);
  color: #006644;
  border: 1px solid #79F2C0;
}
.connection-result.error {
  background: var(--danger-light);
  color: var(--danger);
  border: 1px solid #FFBDAD;
}
.connection-result .icon { width: 16px; height: 16px; flex-shrink: 0; }

/* ─── Searchable checkbox list (projects & issues) ───────────────────────── */
.searchable-list {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.searchable-list-header {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-page);
  display: flex;
  align-items: center;
  gap: 8px;
}

.searchable-list-header .icon {
  width: 15px; height: 15px;
  color: var(--text-light);
  flex-shrink: 0;
}

.searchable-list-header input {
  border: none;
  background: transparent;
  outline: none;
  font-size: 14px;
  flex: 1;
  padding: 0;
  color: var(--text-dark);
}
.searchable-list-header input::placeholder { color: var(--text-placeholder); }

.searchable-list-body {
  max-height: 280px;
  overflow-y: auto;
}

.list-item-check {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background var(--transition);
  border-bottom: 1px solid var(--border);
  user-select: none;
}
.list-item-check:last-child { border-bottom: none; }
.list-item-check:hover { background: var(--bg-hover); }
.list-item-check.selected { background: var(--primary-light); }

.list-item-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  accent-color: var(--primary);
  cursor: pointer;
}

.list-item-info { flex: 1; min-width: 0; }
.list-item-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.list-item-sub {
  font-size: 12px;
  color: var(--text-light);
}

.list-loading {
  padding: 20px;
  text-align: center;
  color: var(--text-light);
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.list-empty {
  padding: 24px;
  text-align: center;
  color: var(--text-light);
  font-size: 13px;
}

.selected-count {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  margin-top: 8px;
}

/* ─── Config Modal Tabs ──────────────────────────────────────────────────── */
.modal-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  padding: 0 24px;
  margin-top: 16px;
  overflow-x: auto;
}

.modal-tab-btn {
  padding: 10px 16px;
  border: none;
  background: transparent;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-medium);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  transition: color var(--transition), border-color var(--transition);
}
.modal-tab-btn:hover { color: var(--text-dark); }
.modal-tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 700;
}

.modal-tab-panel { display: none; }
.modal-tab-panel.active { display: block; }

/* ─── Danger zone ────────────────────────────────────────────────────────── */
.danger-zone {
  border: 1px solid #FFBDAD;
  border-radius: var(--radius-md);
  padding: 16px;
  background: var(--danger-light);
}
.danger-zone h4 {
  font-size: 14px;
  font-weight: 700;
  color: var(--danger);
  margin-bottom: 8px;
}
.danger-zone p {
  font-size: 13px;
  color: #5e2318;
  margin-bottom: 12px;
}

/* ─── Templates sidebar ──────────────────────────────────────────────────── */
#templates-panel {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--bg-white);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#templates-panel.collapsed { width: 0; overflow: hidden; }

.templates-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-page);
  flex-shrink: 0;
}

.templates-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-dark);
  display: flex;
  align-items: center;
  gap: 6px;
}
.templates-title .icon { width: 14px; height: 14px; }

.templates-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.template-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 10px 10px 6px;
  background: var(--bg-page);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: grab;
  transition: box-shadow var(--transition), border-color var(--transition);
  user-select: none;
}
.template-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
}
.template-card:active { cursor: grabbing; }
.template-card.dragging { opacity: .55; }

.template-drag-handle {
  color: var(--text-placeholder);
  flex-shrink: 0;
  display: flex;
  align-items: center;
}
.template-drag-handle .icon { width: 14px; height: 14px; }

.template-info { flex: 1; min-width: 0; }
.template-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.template-meta {
  font-size: 11px;
  color: var(--text-light);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.template-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity var(--transition);
}
.template-card:hover .template-actions { opacity: 1; }

.templates-add-btn {
  margin: 8px;
  flex-shrink: 0;
}

/* ─── Confirm dialog ─────────────────────────────────────────────────────── */
.confirm-dialog {
  text-align: center;
  padding: 8px 0;
}
.confirm-dialog p { font-size: 15px; color: var(--text-medium); margin-bottom: 20px; }

/* ─── Stats view ─────────────────────────────────────────────────────────── */
#view-stats { display: none; }
#view-stats.active { display: block; }

.stats-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.stats-period-select {
  display: flex;
  gap: 6px;
  align-items: center;
}

/* Allow dropdowns to overflow the toggle-group border */
.stats-period-select .toggle-group {
  overflow: visible;
}

/* ─── Stats period quick-pick dropdowns ─────────────────────────────────── */
.stat-period-wrap {
  position: relative;
  display: flex;
}

.stat-period-wrap > .toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.stat-period-wrap > .toggle-btn svg {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  opacity: .7;
}

.stat-period-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  padding-top: 6px;  /* invisible bridge over the visual gap */
  background: transparent;
  z-index: 200;
  min-width: 160px;
}

.stat-period-dropdown-inner {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow-x: auto;
  overflow-y: visible;
  padding: 6px 0;
  white-space: nowrap;
}

.stat-period-wrap:hover .stat-period-dropdown,
.stat-period-wrap:focus-within .stat-period-dropdown {
  display: block;
}

.stat-dd-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-medium);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition), color var(--transition);
}
.stat-dd-item:hover { background: var(--primary-light); color: var(--primary); }

.stat-dd-cw {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-light);
  background: var(--bg-page);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 4px;
  margin-right: 4px;
  letter-spacing: .3px;
  vertical-align: middle;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stat-card-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: .5px;
}

.stat-card-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--text-dark);
  line-height: 1;
}

.stat-card-sub {
  font-size: 12px;
  color: var(--text-light);
}

.stat-card.good  .stat-card-value { color: var(--success); }
.stat-card.warn  .stat-card-value { color: var(--warning); }
.stat-card.alert .stat-card-value { color: var(--danger);  }

/* ─── Bar chart ──────────────────────────────────────────────────────────── */
.bar-chart {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 20px;
}

.bar-chart-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 16px;
}

.bar-chart-rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.bar-chart-row {
  display: grid;
  grid-template-columns: 80px 1fr 60px;
  align-items: center;
  gap: 10px;
}

.bar-chart-label {
  font-size: 12px;
  color: var(--text-light);
  text-align: right;
  font-weight: 500;
}

.bar-chart-track {
  height: 20px;
  background: var(--bg-hover);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}

.bar-chart-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--primary);
  transition: width .5s ease;
  min-width: 2px;
}
.bar-chart-fill.full    { background: var(--success); }
.bar-chart-fill.partial { background: var(--primary); }
.bar-chart-fill.over    { background: var(--warning); }
.bar-chart-fill.empty   { background: var(--border); }

.bar-chart-value {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-medium);
  text-align: left;
}

/* Target line on bar charts */
.bar-chart-track::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: rgba(0,82,204,.3);
  /* position set via JS: style="left: X%" */
}

/* ─── Gap list ───────────────────────────────────────────────────────────── */
.gap-list {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 20px;
}

.gap-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-medium);
}
.gap-item:last-child { border-bottom: none; }
.gap-item .icon { width: 14px; height: 14px; color: var(--danger); flex-shrink: 0; }

/* ─── Issue breakdown table ──────────────────────────────────────────────── */
.issue-breakdown {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 20px;
}

.issue-breakdown table {
  width: 100%;
  border-collapse: collapse;
}

.issue-breakdown th {
  padding: 10px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: .4px;
  background: var(--bg-page);
  border-bottom: 1px solid var(--border);
}

.issue-breakdown td {
  padding: 11px 16px;
  font-size: 13px;
  color: var(--text-dark);
  border-bottom: 1px solid var(--border);
}
.issue-breakdown tr:last-child td { border-bottom: none; }
.issue-breakdown tr:hover td { background: var(--bg-hover); }

.pct-bar {
  display: inline-block;
  height: 6px;
  border-radius: 3px;
  background: var(--primary);
  vertical-align: middle;
  margin-right: 6px;
}
