:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #18212f;
  --muted: #667085;
  --line: #d9dee7;
  --blue: #2557d6;
  --blue-dark: #1f46a8;
  --green: #147a43;
  --yellow: #8a6500;
  --red: #b42318;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.4 "Segoe UI", Arial, sans-serif;
  display: flex;
  flex-direction: column;
}

#appRoot {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 10px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.topbar-logo {
  height: 52px;
  width: auto;
  max-width: 280px;
  object-fit: contain;
  flex-shrink: 0;
}

.topbar-brand h1 {
  font-size: 20px;
  white-space: nowrap;
}

h1, h2, h3, p {
  margin: 0;
}

h1 {
  font-size: 22px;
  font-weight: 700;
}

h2 {
  font-size: 20px;
}

h3 {
  font-size: 13px;
  margin-bottom: 8px;
  color: var(--muted);
  text-transform: uppercase;
}

#folderLabel,
#modalMeta {
  margin: 0;
  color: var(--muted);
}

.session-status {
  flex-shrink: 0;
  min-width: 9rem;
  font-size: 13px;
  white-space: nowrap;
}

main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 18px 24px 24px;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 6px;
  padding: 8px 12px;
  cursor: pointer;
}

button:hover {
  border-color: #aab3c2;
}

button.primary {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

button.primary:hover {
  background: var(--blue-dark);
}

button:disabled {
  opacity: .55;
  cursor: not-allowed;
}

.actions,
.controls,
.modal-actions,
.preview-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.controls {
  margin-bottom: 14px;
}

#searchInput {
  flex: 1;
}

input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.stat strong {
  display: block;
  font-size: 22px;
}

.stat span {
  color: var(--muted);
}

.loaded-files {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 14px;
}

.loaded-files-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.loaded-files-head h2 {
  font-size: 14px;
  font-weight: 600;
  text-transform: none;
  color: var(--ink);
}

.loaded-files-count {
  color: var(--muted);
  font-size: 12px;
}

.loaded-files-list {
  margin: 0;
  padding: 0;
  list-style: none;
  max-height: 120px;
  overflow-y: auto;
  display: grid;
  gap: 4px;
}

.loaded-files-list li {
  font-size: 13px;
  padding: 4px 8px;
  border-radius: 4px;
  background: var(--bg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.table-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px 10px;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eef2f7;
  text-align: left;
  font-size: 12px;
  color: #3d4757;
}

th:nth-child(1),
td:nth-child(1) {
  width: 34px;
  max-width: 34px;
}

th:nth-child(2),
td:nth-child(2) {
  width: 58px;
  max-width: 58px;
}

th:nth-child(3),
td:nth-child(3) {
  width: 92px;
  min-width: 92px;
}

th:nth-child(6),
td:nth-child(6) {
  width: 260px;
  max-width: 260px;
}

th:nth-child(7),
td:nth-child(7) {
  width: 58px;
  max-width: 58px;
  text-align: center;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover {
  background: #f3f6fb;
}

.file-cell {
  color: #98a2b3;
  text-align: center;
  font-size: 12px;
  white-space: nowrap;
  vertical-align: middle;
}

.string-cell {
  white-space: nowrap;
  overflow: visible;
  color: #344054;
  font-variant-numeric: tabular-nums;
  vertical-align: middle;
}

.text-cell {
  max-width: 460px;
  white-space: normal;
  overflow: hidden;
  overflow-wrap: anywhere;
  word-break: normal;
  line-height: 1.35;
  vertical-align: top;
}

.issues-cell {
  vertical-align: middle;
}

.issues-stack {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
}

.issue-tag {
  display: inline-flex;
  align-items: center;
  border: 1px solid #d5def0;
  background: #eef4ff;
  color: #244f9e;
  border-radius: 999px;
  padding: 2px 7px;
  font-size: 12px;
  line-height: 1.25;
  cursor: pointer;
}

.issue-tag:hover {
  border-color: #9db7ee;
  background: #dfeaff;
}

.issue-tag.clean {
  background: #eef2f7;
  border-color: #e4e7ec;
  color: var(--muted);
  cursor: default;
}

.status-cell {
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  vertical-align: middle;
}

.status-cell.needs-review {
  color: var(--yellow);
}

.status-cell.complete {
  color: var(--green);
}

.status-cell.clean {
  color: var(--muted);
}

.status-cell.linguist-review {
  color: var(--red);
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 30px;
}

.pill {
  display: inline-block;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
  background: #eef2f7;
}

.pill.good {
  color: var(--green);
  background: #e8f5ee;
}

.pill.warn {
  color: var(--yellow);
  background: #fff6d8;
}

.pill.reviewed {
  color: var(--blue);
  background: #e8efff;
}

.export-complete-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 40, .52);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 1100;
}

.export-complete-card {
  width: min(520px, 92vw);
  background: var(--panel);
  border-radius: 10px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .25);
  padding: 28px 32px;
}

.export-complete-card h2 {
  font-size: 20px;
  margin-bottom: 12px;
}

.export-complete-intro {
  margin: 0 0 16px;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
}

.export-complete-breakdown {
  list-style: none;
  margin: 0 0 24px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.export-complete-breakdown li {
  font-size: 15px;
  line-height: 1.4;
}

.export-complete-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.export-progress-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 40, .52);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 1100;
}

.export-progress-card {
  width: min(960px, 96vw);
  background: var(--panel);
  border-radius: 10px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .25);
  padding: 24px 28px;
}

.export-progress-card h2 {
  font-size: 18px;
  margin-bottom: 8px;
}

.export-progress-card p {
  color: var(--muted);
}

#exportProgressMessage {
  white-space: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}

.export-progress-track {
  margin: 18px 0 10px;
  height: 12px;
  border-radius: 999px;
  background: #e8edf5;
  overflow: hidden;
}

.export-progress-bar {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--blue), #4f7df3);
  transition: width .25s ease;
}

.export-progress-percent {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  text-align: right;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 40, .52);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 1000;
}

.hidden {
  display: none !important;
}

.modal {
  width: min(1540px, 98vw);
  max-height: 96vh;
  overflow: auto;
  background: var(--panel);
  border-radius: 10px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .25);
  position: relative;
  z-index: 1001;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.icon-btn {
  width: 34px;
  height: 34px;
  padding: 0;
}

.context-grid,
.review-grid {
  display: grid;
  gap: 12px;
  padding: 16px 20px;
}

.context-grid {
  grid-template-columns: minmax(0, 1fr);
}

.context-grid article,
.review-grid > div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.source-prepped-card {
  background: linear-gradient(180deg, #ffffff, #fbfcff);
}

.comparison-stack {
  display: grid;
  gap: 0;
}

.comparison-row {
  display: grid;
  grid-template-columns: 142px minmax(0, 1fr);
  gap: 14px;
  padding: 10px 0;
  border-top: 1px solid #e4e9f2;
}

.comparison-row:first-child {
  padding-top: 0;
  border-top: 0;
}

.comparison-row:last-child {
  padding-bottom: 0;
}

.comparison-label {
  color: #344054;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.32;
}

.info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border: 1px solid #b8c2d3;
  border-radius: 50%;
  color: #475467;
  background: #f8fafc;
  font-size: 12px;
  font-weight: 700;
  cursor: help;
}

.comparison-text,
.context-grid p {
  white-space: pre-wrap;
  max-height: none;
  overflow: visible;
  font-size: 12px;
  line-height: 1.32;
  overflow-wrap: anywhere;
}

.comparison-text {
  color: #253044;
}

.comparison-text .source-change,
.comparison-text .prepped-change {
  border-radius: 4px;
  padding: 1px 2px;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.source-diff-text .source-change,
.original-translation-diff-text .source-change {
  color: #9c0006;
  background: #ffd9d9;
  text-decoration: line-through;
}

.prepped-diff-text .prepped-change,
.fixed-translation-diff-text .prepped-change {
  color: #006100;
  background: #d9f2df;
}

.review-grid {
  grid-template-columns: 1.15fr .85fr;
  padding-top: 0;
}

.fixes-list {
  display: grid;
  gap: 10px;
}

.fix-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.fix-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.fix-card label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.fix-choice-row {
  display: inline-grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  position: relative;
  width: 680px;
  max-width: 100%;
  margin: 8px 0 10px;
  padding: 3px;
  overflow: hidden;
  border: 1px solid #ccd4df;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffffff, #f4f6fa);
  box-shadow: inset 0 1px 2px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
}

.fix-choice-row::before {
  content: "";
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 3px;
  width: calc((100% - 6px) / 4);
  border-radius: 999px;
  background-color: #fff1b8;
  box-shadow: 0 1px 4px rgba(16, 24, 40, 0.16);
  transform: translateX(0);
  transition:
    transform 180ms ease,
    background-color 180ms ease,
    box-shadow 180ms ease;
  z-index: 0;
}

.choice-pill {
  min-width: 0;
  position: relative;
  z-index: 1;
  justify-content: center;
  padding: 6px 12px;
  background: transparent;
  cursor: pointer;
  user-select: none;
  color: #475467;
  transition: color 160ms ease;
  white-space: nowrap;
}

.linguist-choice {
  padding-inline: 10px 12px;
}

.choice-pill + .choice-pill::before {
  content: "";
  position: absolute;
  left: 0;
  top: 20%;
  bottom: 20%;
  width: 1px;
  background: rgba(102, 112, 133, 0.22);
  transition: opacity 160ms ease;
}

.choice-pill input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.choice-pill:has(input:focus-visible) {
  outline: 2px solid #8fb7ee;
  outline-offset: -2px;
}

.fix-choice-row:has(.unreviewed-choice input:checked)::before {
  background-color: #fff1b8;
  transform: translateX(0);
}

.fix-choice-row:has(.ignore-choice input:checked)::before {
  background-color: #e9edf3;
  transform: translateX(100%);
}

.fix-choice-row:has(.apply-choice input:checked)::before {
  background-color: #dff3e7;
  transform: translateX(200%);
}

.fix-choice-row:has(.linguist-choice input:checked)::before {
  background-color: #ffd9d9;
  transform: translateX(300%);
}

.fix-choice-row:has(.unreviewed-choice input:checked) .unreviewed-choice,
.fix-choice-row:has(.ignore-choice input:checked) .ignore-choice,
.fix-choice-row:has(.apply-choice input:checked) .apply-choice,
.fix-choice-row:has(.linguist-choice input:checked) .linguist-choice {
  font-weight: 700;
}

.fix-choice-row:has(.unreviewed-choice input:checked) .unreviewed-choice {
  color: var(--yellow);
}

.fix-choice-row:has(.ignore-choice input:checked) .ignore-choice {
  color: #344054;
}

.fix-choice-row:has(.apply-choice input:checked) .apply-choice {
  color: var(--green);
}

.fix-choice-row:has(.linguist-choice input:checked) .linguist-choice {
  color: var(--red);
}

.fix-choice-row:has(.unreviewed-choice input:checked) .unreviewed-choice + .choice-pill::before,
.fix-choice-row:has(.ignore-choice input:checked) .ignore-choice::before,
.fix-choice-row:has(.ignore-choice input:checked) .ignore-choice + .choice-pill::before,
.fix-choice-row:has(.apply-choice input:checked) .apply-choice::before,
.fix-choice-row:has(.linguist-choice input:checked) .linguist-choice::before {
  opacity: 0;
}

.fix-card p {
  color: #344054;
  white-space: pre-wrap;
}

.diff {
  margin-top: 8px;
  padding: 8px;
  border-radius: 6px;
  background: #f8fafc;
  color: #344054;
  white-space: pre-wrap;
}

.ins {
  color: #006100;
  background: #e8f5ee;
}

.diff .crossout {
  color: #9c0006;
  background: #fce4e4;
  text-decoration: line-through;
}

.diff .new {
  color: #006100;
  background: #e8f5ee;
}

.table-diff {
  white-space: normal;
}

.del {
  color: #9c0006;
  background: #fce4e4;
  text-decoration: line-through;
}

#finalText {
  width: 100%;
  min-height: 260px;
  resize: vertical;
  line-height: 1.5;
}

.conflict {
  color: #fff;
  background: var(--red);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
}

.conflict-message {
  min-height: 20px;
  margin-bottom: 8px;
  color: var(--red);
}

.modal-actions {
  justify-content: flex-end;
  margin-top: 12px;
}

@media (max-width: 980px) {
  .context-grid,
  .review-grid {
    grid-template-columns: 1fr;
  }

  .comparison-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}
