/* ── Variables ──────────────────────────────────────────────────────────── */
:root {
  --primary:        #4F46E5;
  --primary-hover:  #4338CA;
  --primary-light:  #EEF2FF;
  --success:        #10B981;
  --success-light:  #D1FAE5;
  --warning:        #F59E0B;
  --warning-light:  #FEF3C7;
  --danger:         #EF4444;
  --danger-light:   #FEE2E2;
  --gray-50:        #F8FAFC;
  --gray-100:       #F1F5F9;
  --gray-200:       #E2E8F0;
  --gray-300:       #CBD5E1;
  --gray-400:       #94A3B8;
  --gray-500:       #64748B;
  --gray-600:       #475569;
  --gray-700:       #334155;
  --gray-800:       #1E293B;
  --gray-900:       #0F172A;
  --bg:             #F1F5F9;
  --card:           #FFFFFF;
  --border:         #E2E8F0;
  --text:           #1E293B;
  --text-muted:     #64748B;
  --radius:         8px;
  --radius-lg:      12px;
  --shadow-sm:      0 1px 3px rgba(0,0,0,.07);
  --shadow:         0 4px 12px rgba(0,0,0,.08);
  --shadow-lg:      0 8px 24px rgba(0,0,0,.12);
  --header-h:       56px;
}

/* ── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
html { font-size: 14px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font: inherit; }

/* ── Header ─────────────────────────────────────────────────────────────── */
.header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--gray-900);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
}

.header-logo {
  color: #fff;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -.3px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.header-logo span {
  color: var(--primary);
  font-size: 1.3rem;
}

/* ── Header status group (Slack + JIRA) ──────────────────────────────────── */
.header-status-group {
  display: flex;
  align-items: center;
  gap: 10px;
}
.status-divider {
  width: 1px;
  height: 18px;
  background: var(--gray-600);
  flex-shrink: 0;
}
.svc-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .82rem;
  color: var(--gray-300);
}
.svc-icon { display: flex; align-items: center; }
.svc-icon img { width: 16px; height: 16px; object-fit: contain; }
.svc-label { color: var(--gray-400); }
.svc-status.connected  { color: var(--gray-200); }
.svc-status.disconnected { color: var(--gray-500); }
.svc-status a { color: var(--gray-300); font-size: .8rem; opacity: .8; }
.svc-status a:hover { opacity: 1; }

/* Slack button */
.btn-slack {
  background: #4A154B;
  color: #fff;
  border: none;
}
.btn-slack:hover { background: #611f69; }

/* ── Main layout ─────────────────────────────────────────────────────────── */
.main-container {
  margin-top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow: hidden;
  display: grid;
  grid-template-columns: 55% 45%;
  gap: 0;
  transition: grid-template-columns 0.35s ease;
}
.main-container.input-collapsed {
  grid-template-columns: 36px 1fr;
}

/* ── Panels ──────────────────────────────────────────────────────────────── */
.panel {
  padding: 20px;
  overflow-y: auto;
  min-height: 0;   /* grid item must have this to respect parent height */
  box-sizing: border-box;
}
.left-panel {
  border-right: 1px solid var(--border);
  background: var(--bg);
  overflow-x: hidden;
  overflow-y: auto;
  min-width: 0;
  position: relative;
}
.right-panel {
  background: var(--gray-50);
}

/* ── Expand input toggle (visible when left panel is collapsed) ─────────── */
#expand-input-btn {
  display: none;
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  width: 100%;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  align-items: center;
  justify-content: center;
  background: var(--gray-100);
  border: none;
  color: var(--gray-500);
  font-size: .875rem;
  cursor: pointer;
  padding: 0;
  letter-spacing: .08em;
  z-index: 1;
}
#expand-input-btn:hover { background: var(--gray-200); color: var(--text); }
/* When collapsed: show expand button, hide all other left-panel children */
.main-container.input-collapsed #expand-input-btn { display: flex; }
.main-container.input-collapsed .left-panel { padding: 0; }
.main-container.input-collapsed .left-panel > *:not(#expand-input-btn) {
  visibility: hidden;
  pointer-events: none;
}

/* Collapse button — visible when expanded, hidden when collapsed */
#collapse-input-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  top: 8px;
  right: -12px;
  width: 20px;
  height: 40px;
  background: var(--gray-100);
  border: 1px solid var(--border);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--gray-500);
  font-size: 1rem;
  cursor: pointer;
  z-index: 10;
  padding: 0;
}
#collapse-input-btn:hover { background: var(--gray-200); color: var(--text); }
.main-container.input-collapsed #collapse-input-btn { display: none; }

/* ── Comparison cards (Refactor Before/After) ───────────────────────────── */
.comparison-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 12px;
  overflow: hidden;
  background: var(--card);
  box-shadow: var(--shadow-sm);
}
.comparison-card-title {
  background: var(--gray-50);
  border-bottom: 1px solid var(--border);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .875rem;
  font-weight: 600;
  color: var(--gray-700);
  cursor: pointer;
  user-select: none;
}
.comparison-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  max-height: 0;
  overflow: hidden;
  transition: max-height .25s ease-out;
}
.comparison-body.open {
  max-height: 9999px;
  transition: max-height .4s ease-in;
}
.comparison-col {
  padding: 12px 14px;
  font-size: .8125rem;
}
.comparison-before {
  border-right: 1px solid var(--border);
  background: #fafafa;
}
.comparison-after { background: #fff; }
.comparison-col-label {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.comparison-before .comparison-col-label { color: var(--gray-400); }
.comparison-after  .comparison-col-label { color: var(--primary); }
.comparison-field-label {
  font-size: .68rem;
  color: var(--gray-400);
  margin: 8px 0 3px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.comparison-text {
  color: var(--gray-600);
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.55;
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 4px 6px;
  min-height: 36px;
}
.comparison-edit {
  width: 100%;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 4px 6px;
  min-height: 36px;
  max-height: 200px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.55;
  outline: none;
  color: var(--text);
}
.comparison-edit:focus {
  border-color: var(--primary);
  background: var(--primary-light);
}
.comparison-actions {
  margin-top: 10px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
/* Card state variants */
.comparison-card.applied  { border-color: var(--success); }
.comparison-card.applied .comparison-card-title { background: var(--success-light); }
.comparison-card.skipped  { opacity: .45; }
.comparison-card.unmatched { border-color: #ea580c; }
.comparison-card.unmatched .comparison-card-title { background: #fff7ed; }
.comparison-card.pending-create { border-color: var(--primary); }
.comparison-card.pending-create .comparison-card-title { background: var(--primary-light); }

/* Apply preview modal list */
.apply-preview-list {
  margin: 8px 0 0 16px;
  font-size: .8125rem;
  line-height: 1.8;
  color: var(--gray-700);
}

/* Comparison header bar (banner above cards) */
.comparison-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 8px;
  flex-wrap: wrap;
}
.comparison-create-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}
.comparison-proj-select {
  width: 200px;
  font-size: .8rem;
  padding: 4px 8px;
  height: 32px;
}
.unmatched-banner {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: var(--radius);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  color: #92400e;
  font-size: .8125rem;
  flex: 1;
}
.unmatched-banner .unmatched-count { font-weight: 700; }

.panel-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.panel-title small {
  font-size: .75rem;
  font-weight: 400;
  color: var(--text-muted);
}

/* ── Stacked source sections (replaces tabs) ─────────────────────────────── */
.src-section {
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.src-section--last {
  border-bottom: none;
  padding-bottom: 0;
}
.src-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.src-label {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--gray-500);
  margin-bottom: 8px;
  display: block;
}
.src-header .src-label { margin-bottom: 0; }
.src-jira-row {
  display: flex;
  gap: 6px;
  align-items: center;
  flex: 1;
  min-width: 0;
}
.src-jira-row .form-control {
  flex: 1;
  min-width: 0;
}

/* ── Upload zone ─────────────────────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
  background: #fff;
}
.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--primary);
  background: var(--primary-light);
}
.upload-zone .upload-icon { font-size: 2rem; margin-bottom: 8px; }
.upload-zone p { color: var(--gray-500); font-size: .88rem; }
.upload-zone .link {
  color: var(--primary);
  text-decoration: underline;
  cursor: pointer;
}
.upload-zone .hint { font-size: .78rem; color: var(--gray-400); margin-top: 4px; }

/* ── File list ───────────────────────────────────────────────────────────── */
.file-list { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }

.file-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
}
.file-item input[type="checkbox"] { flex-shrink: 0; accent-color: var(--primary); }
.file-icon { font-size: 1.1rem; flex-shrink: 0; }
.file-info { flex: 1; min-width: 0; }
.file-name {
  font-size: .85rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-size { font-size: .75rem; color: var(--text-muted); }
.file-delete {
  background: none;
  border: none;
  color: var(--gray-400);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: .85rem;
  line-height: 1;
  transition: all .15s;
}
.file-delete:hover { color: var(--danger); background: var(--danger-light); }

/* ── Textarea ────────────────────────────────────────────────────────────── */
.textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
  font-size: .88rem;
  resize: vertical;
  min-height: 180px;
  background: var(--card);
  color: var(--text);
  transition: border-color .15s;
}
.textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,.1);
}
.char-count {
  text-align: right;
  font-size: .75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── JIRA sync tab ───────────────────────────────────────────────────────── */
.notice {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: .85rem;
  margin-bottom: 14px;
}
.notice-warning { background: var(--warning-light); color: #92400E; border: 1px solid #FCD34D; }
.notice-error   { background: var(--danger-light);  color: #7F1D1D; border: 1px solid #FCA5A5; }
.notice-info    { background: var(--primary-light);  color: #3730A3; border: 1px solid #A5B4FC; }
.notice .btn-link { color: inherit; font-weight: 600; text-decoration: underline; background: none; border: none; padding: 0; }

.input-group {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.input-group .form-control { flex: 1; }

/* ── JIRA tree ───────────────────────────────────────────────────────────── */
.jira-tree-container {
  min-height: 0;
}

/* ── Slack thread list ───────────────────────────────────────────────────── */
.slack-thread-list { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }

.slack-thread-node {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  overflow: hidden;
}
.slack-thread-header {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  cursor: pointer;
}
.slack-thread-header:hover { background: var(--gray-50); }
.slack-badge {
  font-size: .6rem;
  font-weight: 700;
  background: #4A154B;
  color: #fff;
  border-radius: 3px;
  padding: 1px 5px;
  flex-shrink: 0;
}
.slack-summary {
  flex: 1;
  font-size: .82rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.slack-meta {
  font-size: .72rem;
  color: var(--gray-400);
  white-space: nowrap;
  flex-shrink: 0;
}
.slack-thread-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height .25s ease-out;
  border-top: 0 solid var(--border);
}
.slack-thread-body.open {
  max-height: 600px;
  border-top-width: 1px;
  transition: max-height .4s ease-in;
}
.slack-messages {
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 280px;
  overflow-y: auto;
}
.slack-msg { font-size: .8rem; line-height: 1.5; }
.slack-msg-user { font-weight: 600; color: var(--primary); margin-right: 4px; }
.slack-msg-time { font-size: .72rem; color: var(--gray-400); margin-right: 6px; }
.slack-msg-text { color: var(--gray-700); white-space: pre-wrap; word-break: break-word; }
.jira-tree-container .empty-state {
  text-align: center;
  color: var(--gray-400);
  padding: 24px;
  font-size: .85rem;
}
.tree-select-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  font-size: .8rem;
}
.tree-select-bar button {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 8px;
  color: var(--text-muted);
  transition: all .15s;
}
.tree-select-bar button:hover { border-color: var(--primary); color: var(--primary); }

.tree-node { padding-left: 0; }

.tree-node-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 6px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background .15s;
}
.tree-node-header:hover { background: var(--gray-100); }

.tree-toggle {
  width: 18px; height: 18px;
  border: none;
  background: none;
  font-size: .7rem;
  color: var(--gray-400);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  flex-shrink: 0;
  transition: transform .15s;
}
.tree-toggle:hover { background: var(--gray-200); color: var(--gray-600); }
.tree-toggle.has-children { color: var(--gray-500); }
.tree-toggle.no-children { visibility: hidden; }

input[type="checkbox"].tree-cb {
  accent-color: var(--primary);
  width: 14px; height: 14px;
  flex-shrink: 0;
}

/* Issue type badges */
.issue-type {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: .65rem;
  font-weight: 700;
  width: 20px; height: 20px;
  border-radius: 3px;
  flex-shrink: 0;
  text-transform: uppercase;
}
.issue-type.epic    { background: #DDD6FE; color: #5B21B6; }
.issue-type.story   { background: #BBF7D0; color: #065F46; }
.issue-type.task    { background: #BFDBFE; color: #1D4ED8; }
.issue-type.subtask { background: #E5E7EB; color: #374151; }
.issue-type.bug     { background: #FEE2E2; color: #991B1B; }
.issue-type.other   { background: var(--gray-200); color: var(--gray-600); }

.issue-key {
  font-size: .78rem;
  font-weight: 600;
  color: var(--primary);
  font-family: 'SF Mono', 'Fira Code', monospace;
  white-space: nowrap;
  flex-shrink: 0;
}
.issue-summary {
  flex: 1;
  font-size: .85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Status badges */
.status-badge {
  font-size: .68rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
  white-space: nowrap;
  flex-shrink: 0;
}
.status-badge.todo       { background: var(--gray-200);  color: var(--gray-600); }
.status-badge.inprogress { background: #BFDBFE; color: #1D4ED8; }
.status-badge.done       { background: var(--success-light); color: #065F46; }
.status-badge.review     { background: var(--warning-light); color: #92400E; }
.status-badge.blocked    { background: var(--danger-light);  color: #991B1B; }

.tree-children {
  overflow: hidden;
  max-height: 0;
  padding-left: 24px;
  transition: max-height .25s ease-out;
}
.tree-children.expanded {
  max-height: 9999px;
  transition: max-height .4s ease-in;
}

/* ── Forms ───────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-label {
  display: block;
  font-size: .82rem;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: 5px;
}
.optional { font-weight: 400; color: var(--gray-400); }
.hint { font-size: .75rem; color: var(--text-muted); margin-top: 4px; }

.form-control {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
  font-size: .88rem;
  background: var(--card);
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,.1);
}
.form-control::placeholder { color: var(--gray-400); }
.form-control:disabled { background: var(--gray-100); color: var(--gray-400); }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font: inherit;
  font-size: .85rem;
  font-weight: 500;
  transition: all .15s;
  white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-success  { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: #059669; }
.btn-outline  { background: var(--card); border-color: var(--border); color: var(--gray-600); }
.btn-outline:hover:not(:disabled) { border-color: var(--gray-400); background: var(--gray-50); }
.btn-secondary { background: var(--gray-100); border-color: var(--gray-300); color: var(--gray-700); }
.btn-secondary:hover:not(:disabled) { background: var(--gray-200); }
.btn-warning { background: #fff7ed; border-color: #fed7aa; color: #c2410c; }
.btn-warning:hover:not(:disabled) { background: #ffedd5; }
.btn-sm { padding: 5px 10px; font-size: .8rem; }
.btn-lg { padding: 11px 20px; font-size: .95rem; }

/* ── Mode selector (segmented control) ───────────────────────────────────── */
.mode-selector {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.mode-btn {
  flex: 1;
  background: var(--gray-50);
  border: none;
  border-right: 1px solid var(--border);
  padding: 8px 4px;
  font-size: .85rem;
  color: var(--text-muted);
  transition: background .15s, color .15s;
}
.mode-btn:last-child { border-right: none; }
.mode-btn:hover:not(.active) { background: var(--gray-100); color: var(--text); }
.mode-btn.active {
  background: var(--primary);
  color: #fff;
  font-weight: 600;
}

/* ── Target ticket field required state ──────────────────────────────────── */
.required-star { color: var(--danger); margin-left: 2px; }
.target-ticket-wrap.field-error #target-ticket { border-color: var(--danger); }

/* ── Run button wrapper ───────────────────────────────────────────────────── */
.run-btn-wrap { margin-top: 4px; }

/* ── Analysis options (Use Spec Agent checkbox) ──────────────────────────── */
.analysis-options { margin-bottom: 0; }

/* ── Diff markers ────────────────────────────────────────────────────────── */
.diff-add  { color: #ea580c; font-weight: 500; }
.diff-del  { text-decoration: line-through; color: var(--gray-400); }
.diff-ts   { font-size: .72em; color: var(--gray-400); margin-left: 2px; }
.res-item.update-add    { border-left: 3px solid #ea580c; }
.res-item.update-delete { border-left: 3px solid var(--gray-300); opacity: .65; }
.update-badge {
  display: inline-block; font-size: .7rem; padding: 1px 6px;
  border-radius: 8px; margin-left: 6px; vertical-align: middle;
  font-weight: 600; text-transform: uppercase;
}
.badge-add    { background: #ffedd5; color: #c2410c; }
.badge-update { background: #fbbf24; color: #451a03; }
.badge-delete { background: var(--gray-100); color: var(--gray-500); }
.badge-keep   { background: var(--gray-100); color: var(--gray-400); font-weight: 500; }
.update-summary-banner {
  background: #fff7ed; border: 1px solid #fed7aa; border-radius: var(--radius);
  padding: 10px 14px; margin-bottom: 12px; font-size: .875rem; color: #92400e; line-height: 1.5;
}
.btn-full { width: 100%; justify-content: center; }
.btn-link {
  background: none; border: none; padding: 0;
  color: var(--primary); font: inherit; font-size: inherit;
  text-decoration: underline;
}

/* ── Analysis card ───────────────────────────────────────────────────────── */
.analysis-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

/* ── Progress ────────────────────────────────────────────────────────────── */
.progress-container { margin-top: 14px; }
.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 5px;
}
.progress-label   { font-size: .8rem; color: var(--text-muted); }
.progress-right   { display: flex; align-items: baseline; gap: 8px; }
.progress-elapsed { font-size: .8rem; color: var(--gray-400); font-variant-numeric: tabular-nums; }
.progress-pct     { font-size: .8rem; font-weight: 600; color: var(--primary); min-width: 36px; text-align: right; }
.result-elapsed   { font-size: .75rem; color: var(--gray-400); margin-left: 8px; align-self: center; }
.progress-bar {
  height: 6px;
  background: var(--gray-200);
  border-radius: 3px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--primary);
  border-radius: 3px;
  transition: width 0.4s ease;
}

/* ── Results card ────────────────────────────────────────────────────────── */
.results-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}
.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 8px;
  flex-wrap: wrap;
}
.results-actions { display: flex; gap: 8px; }

/* ── Language tabs ───────────────────────────────────────────────────────── */
.lang-tabs { display: flex; gap: 4px; }
.lang-tab {
  padding: 3px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--gray-600);
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.lang-tab:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }
.lang-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── Translate language selector ─────────────────────────────────────────── */
.translate-langs {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.translate-langs label { font-size: .82rem; color: var(--text-muted); font-weight: 500; }
.lang-toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: .82rem;
  cursor: pointer;
  user-select: none;
  color: var(--gray-700);
}
.lang-toggle input[type="checkbox"] { accent-color: var(--primary); width: 14px; height: 14px; }
.lang-toggle.locked { opacity: .5; cursor: not-allowed; }
.lang-toggle.locked input { cursor: not-allowed; }

/* ── Create JIRA panel ───────────────────────────────────────────────────── */
.create-jira-panel {
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--gray-50);
}
.create-jira-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.create-project-select { flex: 1; min-width: 0; }

/* Searchable project selector */
.project-sel-wrap {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}
.comparison-proj-wrap { width: 210px; flex: unset; }

.project-combobox {
  position: relative;
  flex: 1;
  min-width: 0;
}
.combobox-input { width: 100%; cursor: text; }
.combobox-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0,0,0,.12);
  max-height: 220px;
  overflow-y: auto;
  z-index: 200;
}
.combobox-dropdown.open { display: block; }
.combobox-option {
  padding: 7px 10px;
  font-size: .85rem;
  cursor: pointer;
  color: var(--gray-800);
}
.combobox-option:hover { background: var(--primary-light); color: var(--primary); }
.combobox-empty { color: var(--gray-400); cursor: default; }
.create-status {
  margin-top: 8px;
  font-size: .82rem;
  padding: 7px 10px;
  border-radius: var(--radius);
}
.create-status.success { background: var(--success-light); color: #065F46; }
.create-status.error   { background: var(--danger-light);  color: #991B1B; }

/* ── Collapsible result rows (Epic & Story) ──────────────────────────────── */
#res-items { display: flex; flex-direction: column; gap: 6px; }

.res-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  overflow: hidden;
}
.res-item.epic {
  border-color: #C7D2FE;
  background: var(--primary-light);
}

/* Header row: [badge] [summary ──────] [▶] */
.res-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
}

.res-type-badge {
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
  flex-shrink: 0;
}
.res-type-badge.epic  { background: #DDD6FE; color: #5B21B6; }
.res-type-badge.story { background: #BBF7D0; color: #065F46; }
.res-type-badge.task  { background: #BFDBFE; color: #1D4ED8; }

.res-summary {
  flex: 1;
  font-size: .92rem;
  font-weight: 600;
  color: var(--gray-800);
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 2px 5px;
  line-height: 1.4;
  min-width: 0;
  transition: border-color .15s;
}
.res-item.epic .res-summary { font-size: .98rem; }
.res-summary:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
}

.res-toggle {
  width: 26px; height: 26px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: var(--gray-100);
  color: var(--gray-500);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s, transform .2s;
}
.res-toggle:hover { background: var(--gray-200); color: var(--gray-700); border-color: var(--gray-300); }
.res-toggle.open  { transform: rotate(90deg); color: var(--primary); border-color: var(--primary); background: var(--primary-light); }

/* Collapsible body */
.res-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height .25s ease-out;
}
.res-body.open {
  max-height: 9999px;
  transition: max-height .4s ease-in;
  border-top: 1px solid var(--border);
}
.res-item.epic .res-body.open { border-top-color: #C7D2FE; }

.res-description {
  display: block;
  width: 100%;
  font-size: .85rem;
  color: var(--gray-600);
  white-space: pre-wrap;
  line-height: 1.65;
  padding: 12px 14px;
  border: none;
  background: transparent;
  transition: background .15s;
  min-height: 60px;
}
.res-description:focus {
  outline: 1px solid var(--primary);
  outline-offset: -1px;
  background: #fff;
}
.res-item.epic .res-description:focus { background: #fff; }

/* Platform checkboxes (inside story body) */
.res-platforms {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 14px 12px;
}

/* ── Platform check labels (shared) ─────────────────────────────────────── */
.platforms-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.platform-check {
  display: flex;
  align-items: center;
  gap: 5px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 10px;
  font-size: .78rem;
  font-weight: 500;
  color: var(--gray-600);
  cursor: pointer;
  transition: all .15s;
  user-select: none;
}
.platform-check:hover { border-color: var(--primary); color: var(--primary); }
.platform-check input { display: none; }
.platform-check.checked {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}
.platform-check .dot-plat {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: .7;
}

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; }
.modal-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(2px);
}
.modal-content {
  position: relative;
  background: var(--card);
  border-radius: var(--radius-lg);
  width: 440px;
  max-width: calc(100vw - 32px);
  box-shadow: var(--shadow-lg);
  animation: modal-in .18s ease-out;
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(-16px) scale(.97); }
  to   { opacity: 1; transform: none; }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1rem; font-weight: 600; }
.modal-close {
  background: none; border: none;
  color: var(--gray-400); font-size: 1rem; padding: 2px 6px;
  border-radius: 4px; transition: all .15s;
}
.modal-close:hover { background: var(--gray-100); color: var(--gray-600); }
.modal-body { padding: 18px 20px; }
.modal-footer {
  padding: 12px 20px 18px;
  display: flex; justify-content: flex-end; gap: 8px;
  border-top: 1px solid var(--border);
}

/* ── Utilities ───────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Test Gen results ────────────────────────────────────────────────────── */
.tc-stats {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--gray-50);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
  font-size: 13px;
  font-weight: 600;
}
.tc-stat-total { color: var(--primary); }
.tc-stat-badge {
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
}
.tc-high   { background: var(--danger-light);  color: var(--danger); }
.tc-med    { background: var(--warning-light); color: #B45309; }
.tc-low    { background: var(--success-light); color: var(--success); }
.tc-count-badge {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}
.tc-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-100);
}
.tc-item:last-child { border-bottom: none; }
.tc-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-weight: 600;
  font-size: 13px;
}
.tc-id {
  font-family: monospace;
  font-size: 11px;
  color: var(--primary);
  background: var(--primary-light);
  padding: 1px 6px;
  border-radius: 4px;
  white-space: nowrap;
}
.tc-priority {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
}
.tc-priority.high   { background: var(--danger-light);  color: var(--danger); }
.tc-priority.medium { background: var(--warning-light); color: #B45309; }
.tc-priority.low    { background: var(--success-light); color: var(--success); }
.tc-field {
  font-size: 12px;
  color: var(--text);
  margin-bottom: 4px;
  line-height: 1.5;
}
.tc-field strong { color: var(--text-muted); font-weight: 600; }
.tc-field ol {
  margin: 4px 0 0 18px;
  padding: 0;
}
.tc-field ol li { margin-bottom: 2px; }

/* ── Responsive (basic) ──────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .main-container { grid-template-columns: 1fr; }
  .left-panel { border-right: none; border-bottom: 1px solid var(--border); }
}

/* ── History button ──────────────────────────────────────────────────────── */
.btn-history {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: .8rem;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}
.btn-history:hover { background: var(--bg); color: var(--text); }

/* ── History modal ───────────────────────────────────────────────────────── */
.history-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 1000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 80px;
}
.history-modal-overlay.hidden { display: none; }
.history-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: min(640px, 90vw);
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
  overflow: hidden;
}
.history-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.history-modal-header h3 { margin: 0; font-size: 1rem; }
.history-modal-header button {
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
  padding: 2px 6px;
}
.history-modal-header button:hover { color: var(--text); }
.history-list {
  list-style: none;
  margin: 0;
  padding: 8px 0;
  overflow-y: auto;
}
.history-row {
  display: grid;
  grid-template-columns: 140px 80px 1fr;
  gap: 12px;
  align-items: center;
  padding: 10px 20px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  font-size: .85rem;
  transition: background .12s;
}
.history-row:last-child { border-bottom: none; }
.history-row:hover { background: var(--bg); }
.h-date { color: var(--text-muted); font-size: .78rem; font-variant-numeric: tabular-nums; }
.h-mode {
  text-transform: capitalize;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: .75rem;
  text-align: center;
  color: var(--text-muted);
}
.h-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.history-empty {
  padding: 20px;
  color: var(--text-muted);
  font-size: .85rem;
  text-align: center;
}

/* ── Saved toast ─────────────────────────────────────────────────────────── */
.saved-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #166534;
  color: #fff;
  font-size: .8rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 6px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
  z-index: 2000;
}
.saved-toast.show { opacity: 1; }
