:root {
  --bg: #061326;
  --panel: rgba(9, 27, 54, 0.84);
  --panel-soft: rgba(15, 44, 82, 0.64);
  --ink: #edf7ff;
  --muted: #9fb3ca;
  --line: rgba(156, 190, 220, 0.22);
  --border: rgba(156, 190, 220, 0.22);
  --accent: #4da3ff;
  --accent-2: #2f6fd6;
  --warning: #f5c76b;
  --green: rgba(61, 214, 143, 0.18);
  --yellow: rgba(245, 199, 107, 0.2);
  --red: rgba(255, 103, 128, 0.18);
  --blue: rgba(77, 163, 255, 0.2);
  --violet: rgba(97, 139, 255, 0.18);
  --gray: rgba(159, 179, 202, 0.16);
  --danger: #ff7890;
  --success: #5ee0a4;
  --glow: 0 18px 42px rgba(0, 0, 0, 0.26);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: linear-gradient(145deg, #040d1d 0%, #071b38 48%, #0f3566 100%);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 360px;
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: #eef2ee;
  padding: 20px;
  min-height: 0;
  overflow-y: auto;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 28px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.brand h1,
.topbar h2,
.content-band h3,
.mapping-section h3,
.export-panel h3 {
  margin: 0;
}

.brand p,
.eyebrow,
.content-band p,
.drop-zone p {
  margin: 4px 0 0;
  color: var(--muted);
}

.eyebrow {
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0;
  font-weight: 700;
}

.nav {
  display: grid;
  gap: 6px;
  margin-bottom: 28px;
}

.nav-item,
.button,
.icon-button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 8px;
  cursor: pointer;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  padding: 11px 12px;
}

.nav-item span {
  display: inline-grid;
  place-items: center;
  width: 28px;
  min-width: 28px;
  height: 24px;
  border-radius: 6px;
  background: #eef2ee;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.nav-item.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.nav-item.active span {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.side-panel {
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.side-panel h2 {
  margin: 0 0 12px;
  font-size: 15px;
}

.language-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.language-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 5px 9px;
  color: var(--ink);
}

.language-pills-divider {
  flex-basis: 100%;
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.language-pill.master-only-language {
  border-style: dashed;
  border-color: rgba(139, 177, 207, 0.32);
  background: rgba(119, 154, 188, 0.08);
  color: rgba(214, 229, 242, 0.62);
  cursor: default;
}

.review-family-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  max-width: 100%;
  margin-top: 10px;
  padding: 7px 10px;
  border: 1px solid rgba(77, 163, 255, 0.42);
  border-radius: 8px;
  background: rgba(77, 163, 255, 0.1);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.review-family-badge strong {
  color: var(--ink);
  font-size: 13px;
}

.main {
  min-width: 0;
  padding: 22px;
  min-height: 0;
  overflow-y: auto;
}

.topbar,
.section-head,
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar {
  margin-bottom: 18px;
}

.top-actions,
.toolbar {
  display: flex;
}

.top-actions {
  align-items: center;
  gap: 8px;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.status-chip.stable {
  border-color: #b8d9c8;
  background: #e9f6ef;
  color: #17633f;
}

.button {
  min-height: 38px;
  padding: 0 14px;
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 700;
}

.button.secondary {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}

.button.compact {
  min-height: 34px;
  padding: 0 10px;
  font-size: 13px;
}

.publish-button {
  margin-left: auto;
}

.select-ghost-red {
  background: transparent !important;
  color: #d32f2f !important;
  border: 1px solid #d32f2f !important;
  font-weight: 600;
}
.select-ghost-red option {
  color: var(--ink);
}

.icon-button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  font-size: 20px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.hidden {
  display: none !important;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.metric,
.content-band,
.mapping-section,
.export-panel,
.drop-zone,
.master-grid > div {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric {
  padding: 16px;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin-top: 6px;
  font-size: 30px;
}

.metric-accent {
  border-color: #b9d8d5;
  background: #eef8f6;
}

.workflow-board {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(360px, 0.9fr);
  gap: 14px;
  margin-top: 14px;
}

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

.workflow-panel h3 {
  margin: 4px 0 6px;
  font-size: 22px;
}

.workflow-panel p {
  margin: 0;
  color: var(--muted);
}

.workflow-panel-muted {
  background: var(--panel-soft);
}

.section-kicker {
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.workflow-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.workflow-steps {
  display: grid;
  gap: 10px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.workflow-steps li {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.workflow-steps strong {
  color: var(--ink);
}

.workflow-steps span {
  color: var(--muted);
  font-size: 13px;
}

.content-band {
  margin-top: 14px;
  padding: 18px;
}

.system-band {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.schema-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.schema-strip span {
  padding: 7px 10px;
  border-radius: 6px;
  background: #eef6f4;
  color: var(--accent);
  font-weight: 700;
  font-size: 13px;
}

.import-layout {
  display: grid;
  gap: 14px;
}

.import-steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.import-step {
  min-height: 72px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.import-step strong,
.import-step span {
  display: block;
}

.import-step strong {
  font-size: 13px;
}

.import-step span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.import-step.active {
  border-color: #b9d8d5;
  background: #eef8f6;
}

.import-step.done {
  border-color: #b8d9c8;
  background: #e9f6ef;
}

.import-step.blocked {
  border-color: #efc2c2;
  background: #fff4f4;
}

.drop-zone {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
}

.drop-zone input {
  max-width: 280px;
}

.import-drop-zone {
  min-height: 104px;
}

.mapping-section,
.export-panel {
  padding: 18px;
}

.mapping-table {
  overflow: auto;
  margin-top: 14px;
}

.mapping-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 0;
}

.mapping-summary span,
.mapping-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.mapping-chip.good {
  border-color: #b8d9c8;
  background: #e9f6ef;
  color: #17633f;
}

.mapping-chip.warn {
  border-color: #ead39d;
  background: #fff8e5;
  color: #87530d;
}

.mapping-chip.bad {
  border-color: #efc2c2;
  background: #fff4f4;
  color: #9f1d1d;
}

.validation-panel {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid #efc2c2;
  border-radius: 8px;
  background: #fff4f4;
  color: #7f1d1d;
}

.validation-panel ul {
  margin: 6px 0 0;
  padding-left: 18px;
}

.mapping-status {
  display: inline-flex;
  width: fit-content;
  margin-top: 5px;
  padding: 2px 6px;
  border-radius: 6px;
  background: #eef2ee;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.mapping-status.auto_mapped {
  background: #e9f6ef;
  color: #17633f;
}

.mapping-status.unresolved {
  background: #fff4f4;
  color: #9f1d1d;
}

.mapping-status.user_mapped,
.mapping-status.new_language {
  background: #e0f2fe;
  color: #075985;
}

.mapping-row-error {
  background: #fff8f8;
}

.header-tools {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.header-tools.hidden {
  display: none;
}

.header-tools label {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-weight: 700;
}

.file-preview {
  max-height: 180px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.file-preview table {
  min-width: 640px;
}

.file-preview td {
  color: var(--muted);
  white-space: nowrap;
}

.file-preview tr.selected-preview-row {
  background: #eef6f4;
}

.empty-state {
  color: var(--muted);
  padding: 18px 0;
}

.input {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 0 10px;
}

#searchInput {
  min-width: 280px;
}

.toolbar {
  justify-content: flex-start;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.workbar {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.workbar-row {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
}

.master-copy-row {
  align-items: center;
  padding-top: 2px;
}

.master-new-row-panel {
  align-items: end;
  padding-top: 2px;
}

.master-new-row-panel .tool-field-wide {
  min-width: 320px;
}

.copy-hint {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.tool-field {
  display: grid;
  gap: 5px;
  min-width: 170px;
}

.tool-field > span,
.inline-label,
.draft-filter {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.tool-field-wide {
  flex: 1 1 300px;
  min-width: 260px;
}

.inline-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.inline-controls .input {
  min-width: 180px;
}

.inline-label,
.draft-filter {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
}

.bulk-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.pager-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 12px;
}

.pager-controls,
.draft-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.push-right {
  margin-left: auto;
}

.master-head {
  margin-bottom: 12px;
}

.draft-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.column-scope {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.column-scope .language-toggles {
  flex: 1;
}

.master-order-pill {
  position: relative;
  align-items: center;
  gap: 6px;
  cursor: grab;
  user-select: none;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease, opacity 0.12s ease;
}

.master-order-pill:active {
  cursor: grabbing;
}

.master-order-pill.dragging {
  opacity: 0.55;
  transform: scale(0.98);
}

.master-order-pill.drag-over {
  border-color: rgba(61, 214, 143, 0.9);
  background: rgba(61, 214, 143, 0.16);
  box-shadow: inset 0 0 0 1px rgba(61, 214, 143, 0.35);
}

.language-move-btn {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 1px solid rgba(77, 163, 255, 0.34);
  border-radius: 6px;
  background: rgba(77, 163, 255, 0.09);
  color: #dffffb;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
}

.language-move-btn:hover {
  background: rgba(77, 163, 255, 0.2);
  border-color: rgba(77, 163, 255, 0.7);
}

.table-shell {
  overflow: auto;
  max-height: calc(100vh - 160px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.master-table-shell {
  max-height: calc(100vh - 250px);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 9px 10px;
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f9faf7;
  font-weight: 800;
}

.sticky-col {
  position: sticky;
  left: 0;
  z-index: 3;
  background: inherit;
}

tr {
  background: #fff;
}

tr:hover {
  background: #f8fbf8;
}

.status {
  display: inline-flex;
  padding: 4px 7px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 12px;
}

.review-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 5px;
}

.status.exact_match {
  background: var(--green);
}

.status.different_from_master,
.status.source_match_different_id,
.status.conflict {
  background: var(--yellow);
}

.status.ai_translated {
  background: #f3e8ff;
  color: #6f42c1;
  border: 1px solid #6f42c1;
}

.status.new_string {
  background: var(--red);
}

.status.missing_in_import {
  background: var(--blue);
}

.status.missing_in_master {
  background: var(--gray);
}

.status.pending {
  background: #f8fafc;
  color: var(--muted);
}

.status.staged {
  background: #e0f2fe;
  color: #075985;
}

.status.saved,
.status.approved {
  background: #e9f6ef;
  color: #17633f;
}

.detail-panel {
  border-left: 1px solid var(--line);
  background: #fff;
  padding: 18px;
  min-height: 0;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.close-button {
  margin-left: auto;
}

.detail-content h3 {
  margin-top: 8px;
}

.detail-content {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  padding-right: 4px;
}

.translation-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  margin: 10px 0;
}

.translation-card textarea {
  width: 100%;
  min-height: 70px;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  resize: vertical;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.mini-button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 6px 9px;
  cursor: pointer;
}

.master-grid {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 14px;
  margin-top: 14px;
}

.master-grid > div {
  padding: 16px;
}

.list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.list-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.list-item small {
  display: block;
  color: var(--muted);
  margin-top: 4px;
}

.export-options {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin: 14px 0;
}

.batch-error-log {
  max-height: 92px;
  overflow: auto;
  margin-bottom: 12px;
  padding: 8px 10px;
  border: 1px solid #efc2c2;
  border-radius: 8px;
  background: #fff4f4;
  color: #7f1d1d;
  font-size: 12px;
  line-height: 1.4;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .detail-panel {
    grid-column: 1 / -1;
    border-left: 0;
    border-top: 1px solid var(--line);
    height: auto;
    max-height: 42vh;
  }

  .metrics-grid,
  .master-grid,
  .workflow-board,
  .import-steps {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .workflow-board {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .app-shell {
    display: block;
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .sidebar,
  .main,
  .detail-panel {
    padding: 14px;
    height: auto;
    max-height: none;
    overflow: visible;
  }

  .detail-content {
    overflow: visible;
  }

  .metrics-grid,
  .master-grid,
  .workflow-board,
  .import-steps {
    grid-template-columns: 1fr;
  }

  .system-band,
  .topbar,
  .drop-zone {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions {
    justify-content: space-between;
    padding-right: 0;
  }

  .workflow-steps li {
    grid-template-columns: 1fr;
  }

  .workbar-row,
  .pager-row,
  .column-scope {
    align-items: stretch;
    flex-direction: column;
  }

  .tool-field,
  .tool-field-wide,
  .inline-controls .input {
    min-width: 100%;
  }

  .inline-controls,
  .bulk-actions,
  .pager-controls,
  .draft-actions {
    flex-wrap: wrap;
  }

  .publish-button,
  .push-right {
    margin-left: 0;
  }

  #searchInput {
    min-width: 100%;
  }

  .ai-chat-toggle {
    position: static;
    display: inline-flex;
    margin: 10px 0 0 14px;
    padding: 9px 11px;
    font-size: 13px;
  }

  #aiBatchToggle {
    bottom: auto !important;
  }

  .ai-chat-panel {
    left: 14px;
    right: 14px;
    width: auto !important;
  }
}

/* Spinner Overlay */
.global-spinner {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(2px);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  transition: opacity 0.3s ease;
}

.global-spinner.hidden {
  display: none;
  opacity: 0;
  pointer-events: none;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid var(--line);
  border-top: 4px solid var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 16px;
}

.spinner-text {
  color: var(--ink);
  font-weight: 700;
  font-size: 16px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* AI Chat UI */
.ai-chat-toggle {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--accent);
  color: white;
  padding: 12px 20px;
  border-radius: 30px;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 1000;
  transition: transform 0.2s, background 0.2s;
}

.ai-chat-toggle:hover {
  transform: scale(1.05);
  background: var(--accent-2);
}

.ai-chat-panel {
  position: fixed;
  bottom: 80px;
  right: 20px;
  width: 400px;
  height: 600px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: transform 0.3s ease, opacity 0.3s ease;
  overflow: hidden;
  border: 1px solid var(--line);
}

.ai-chat-panel.hidden {
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
}

.ai-chat-header {
  background: var(--accent);
  color: white;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ai-chat-header h4 {
  margin: 0;
  font-size: 16px;
}

.ai-chat-history {
  flex-grow: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f8fbf8;
}

.chat-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.4;
}

.chat-msg.ai {
  background: white;
  border: 1px solid var(--line);
  align-self: flex-start;
  border-bottom-left-radius: 2px;
}

.chat-msg.user {
  background: var(--accent);
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 2px;
}

.ai-chat-input-area {
  padding: 12px;
  background: white;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 8px;
}

.ai-chat-input-area textarea {
  flex-grow: 1;
  min-height: 40px;
  max-height: 120px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  resize: none;
  font-family: inherit;
}

.language-pill.hidden-lang {
  opacity: 0.4;
  filter: grayscale(100%);
  background: #eee;
  border-color: #ccc;
}
/* Custom Modal */
.custom-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  transition: opacity 0.2s ease;
}
.custom-modal-overlay.hidden {
  opacity: 0;
  pointer-events: none;
  display: flex;
}
.custom-modal {
  background: white;
  border-radius: 12px;
  padding: 24px;
  max-width: 500px;
  width: 90%;
  box-shadow: 0 10px 25px rgba(0,0,0,0.15);
  transform: translateY(0);
  transition: transform 0.2s ease;
}
.custom-modal-overlay.hidden .custom-modal {
  transform: translateY(20px);
}
.custom-modal h3 {
  margin: 0 0 12px 0;
  font-size: 1.25rem;
  color: var(--text);
}
.custom-modal p {
  margin: 0 0 24px 0;
  color: var(--text-light);
  line-height: 1.5;
}
.custom-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}
.custom-modal-actions .hidden {
  display: none;
}


tr.selected { background-color: rgba(66, 133, 244, 0.1) !important; }
tr.selected td { background-color: rgba(66, 133, 244, 0.05) !important; border-top: 1px solid rgba(66, 133, 244, 0.3) !important; border-bottom: 1px solid rgba(66, 133, 244, 0.3) !important; }

.import-compare-col, .master-compare-col { cursor: pointer; user-select: none; }
.import-compare-col:hover, .master-compare-col:hover { background-color: rgba(0, 0, 0, 0.05) !important; }

/* V2 Midnight Theme */
body {
  scrollbar-color: rgba(77, 163, 255, 0.45) rgba(7, 20, 35, 0.65);
}

.app-shell {
  background: linear-gradient(145deg, rgba(6, 17, 31, 0.98), rgba(9, 40, 82, 0.96));
}

.sidebar,
.detail-panel,
.metric,
.content-band,
.mapping-section,
.export-panel,
.drop-zone,
.workflow-panel,
.workbar,
.import-step,
.table-shell,
.master-grid > div,
.ai-chat-panel,
.custom-modal,
.file-preview,
.bulk-actions,
.language-pill,
.translation-card,
.list-item {
  background: var(--panel);
  border-color: var(--line);
  box-shadow: var(--glow);
  backdrop-filter: blur(14px);
}

.sidebar {
  background: rgba(4, 15, 31, 0.92);
}

.main {
  background: transparent;
}

.brand-mark {
  background: linear-gradient(135deg, rgba(77, 163, 255, 0.95), rgba(47, 111, 214, 0.88));
  color: #06111f;
  box-shadow: 0 10px 28px rgba(77, 163, 255, 0.2);
}

.brand h1,
.topbar h2,
.workflow-panel h3,
.content-band h3,
.mapping-section h3,
.export-panel h3,
.detail-content h3,
.custom-modal h3 {
  color: var(--ink);
}

.brand p,
.eyebrow,
.content-band p,
.drop-zone p,
.workflow-panel p,
.workflow-steps span,
.metric span,
.tool-field > span,
.inline-label,
.draft-filter,
.empty-state,
.file-preview td,
.custom-modal p,
.list-item small {
  color: var(--muted);
}

.section-kicker {
  color: var(--accent);
}

.nav-item,
.button,
.icon-button,
.mini-button {
  background: rgba(255, 255, 255, 0.045);
  border-color: rgba(156, 190, 220, 0.28);
  color: var(--ink);
  box-shadow: none;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease, color 0.18s ease;
}

.button {
  background: rgba(77, 163, 255, 0.16);
  border-color: rgba(77, 163, 255, 0.5);
  color: #ecfffd;
}

.button.secondary,
.mini-button {
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
}

.button:hover,
.icon-button:hover,
.mini-button:hover,
.nav-item:hover {
  background: rgba(77, 163, 255, 0.19);
  border-color: rgba(77, 163, 255, 0.72);
  transform: translateY(-1px);
}

.button:disabled,
.icon-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.publish-button {
  background: rgba(47, 111, 214, 0.2);
  border-color: rgba(77, 163, 255, 0.52);
}

.nav-item span {
  background: rgba(255, 255, 255, 0.07);
  color: var(--muted);
}

.nav-item.active {
  background: rgba(77, 163, 255, 0.17);
  border-color: rgba(77, 163, 255, 0.7);
  color: #ecfffd;
}

.nav-item.active span {
  background: rgba(77, 163, 255, 0.22);
  color: #ecfffd;
}

.status-chip {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--line);
  color: var(--muted);
}

.status-chip.stable,
.metric-accent {
  background: rgba(77, 163, 255, 0.12);
  border-color: rgba(77, 163, 255, 0.42);
  color: #dffffb;
}

.workflow-panel-muted,
.workbar,
.panel-soft,
.file-preview,
.table-shell {
  background: var(--panel-soft);
}

.workflow-steps li,
.mapping-chip,
.mapping-summary span,
.schema-strip span,
.bulk-actions,
.language-pill,
.list-item {
  background: rgba(255, 255, 255, 0.045);
  border-color: rgba(156, 190, 220, 0.22);
  color: var(--ink);
}

.schema-strip span {
  color: #c9fff9;
}

.input,
textarea,
select {
  background: rgba(4, 13, 24, 0.52);
  border-color: rgba(156, 190, 220, 0.28);
  color: var(--ink);
}

.input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: rgba(77, 163, 255, 0.72);
  box-shadow: 0 0 0 3px rgba(77, 163, 255, 0.13);
}

option {
  background: #0b1f35;
  color: var(--ink);
}

.mapping-chip.good,
.import-step.done,
.status.saved,
.status.approved,
.status.exact_match,
.mini-status.ok {
  background: rgba(61, 214, 143, 0.15);
  border-color: rgba(61, 214, 143, 0.42);
  color: #bff8da;
}

.mapping-chip.warn,
.import-step.active,
.status.different_from_master,
.status.source_match_different_id,
.status.conflict,
.mini-status.warn {
  background: rgba(245, 199, 107, 0.16);
  border-color: rgba(245, 199, 107, 0.42);
  color: #ffe4a4;
}

.mapping-chip.bad,
.import-step.blocked,
.status.new_string,
.mini-status.new-id,
.id-status-badge.new-id,
.mini-status.bad,
.select-ghost-red {
  background: rgba(255, 103, 128, 0.13) !important;
  border-color: rgba(255, 103, 128, 0.48) !important;
  color: #ffc3cf !important;
}

.status.ai_translated,
.mini-status.ai {
  background: rgba(47, 111, 214, 0.18);
  border-color: rgba(77, 163, 255, 0.48);
  color: #ddd2ff;
}

.status.missing_in_import,
.status.staged,
.mini-status.staged {
  background: rgba(91, 168, 255, 0.15);
  border-color: rgba(91, 168, 255, 0.42);
  color: #cbe5ff;
}

.status.missing_in_master,
.status.pending,
.mini-status.neutral {
  background: rgba(159, 179, 202, 0.13);
  border-color: rgba(159, 179, 202, 0.3);
  color: #d8e3ef;
}

.mini-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 22px;
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  font-size: 11px;
  line-height: 1.2;
}

.id-status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  margin-left: 8px;
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 11px;
  font-weight: 900;
  line-height: 1.2;
  white-space: nowrap;
}

.review-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin: 0 0 12px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted);
  font-size: 12px;
}

.review-legend > span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.review-legend .legend-title {
  color: var(--ink);
  font-weight: 800;
}

.review-legend .mini-status {
  cursor: default;
}

.table-shell {
  border-color: var(--line);
}

table,
tr,
.sticky-col {
  background: transparent;
}

th,
td {
  border-bottom-color: rgba(156, 190, 220, 0.16);
}

th {
  background: rgba(8, 23, 39, 0.96);
  color: #dceeff;
}

tr:hover,
tr.selected,
tr.selected td,
.import-compare-col:hover,
.master-compare-col:hover {
  background-color: rgba(77, 163, 255, 0.08) !important;
}

.master-compare-head {
  background: rgba(91, 168, 255, 0.08) !important;
  border-left: 1px dashed rgba(91, 168, 255, 0.42) !important;
}

.master-compare-cell {
  cursor: pointer;
  background-color: rgba(91, 168, 255, 0.06) !important;
  border-left: 1px dashed rgba(91, 168, 255, 0.35) !important;
  color: #cfe2f6 !important;
  font-size: 13px;
}

.muted-text {
  color: var(--muted);
}

.table-note {
  text-align: center;
  padding: 20px;
  font-weight: 700;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  border-top: 1px solid var(--line);
}

.translation-card textarea,
.ai-chat-input-area textarea {
  background: rgba(4, 13, 24, 0.62);
  color: var(--ink);
}

.global-spinner {
  background: rgba(4, 13, 24, 0.72);
  backdrop-filter: blur(7px);
}

.spinner {
  border-color: rgba(156, 190, 220, 0.22);
  border-top-color: var(--accent);
}

.spinner-text {
  color: var(--ink);
}

#spinnerProgressBar,
#batchAiProgressBar {
  background: linear-gradient(90deg, var(--accent), var(--accent-2)) !important;
}

.batch-lang-cell {
  width: 15%;
  padding: 8px 10px;
  border-right: 1px solid var(--line);
  font-weight: 600;
}

.batch-stat-bar {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  opacity: 0.18;
  transition: width 0.3s ease;
}

.ai-chat-toggle {
  background: rgba(77, 163, 255, 0.18) !important;
  border: 1px solid rgba(77, 163, 255, 0.55);
  color: #ecfffd;
  border-radius: 8px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.24);
}

.ai-chat-toggle:hover {
  background: rgba(47, 111, 214, 0.22) !important;
}

.ai-chat-panel {
  background: rgba(8, 23, 39, 0.96) !important;
  border-color: var(--line);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.42);
}

.ai-chat-header,
#aiBatchPanel .ai-chat-header {
  background: rgba(77, 163, 255, 0.15) !important;
  color: var(--ink);
  border-bottom: 1px solid var(--line);
}

.ai-chat-history,
.ai-chat-input-area,
#aiChatPanel > div[style],
#aiBatchPanel > div[style],
#batchAiProgressContainer > div[style*="border"] {
  background: rgba(4, 13, 24, 0.42) !important;
  border-color: var(--line) !important;
  color: var(--ink) !important;
}

.chat-msg.ai {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--line);
}

.chat-msg.user {
  background: rgba(77, 163, 255, 0.18);
  color: #ecfffd;
}

.batch-error-log,
.validation-panel {
  background: rgba(255, 103, 128, 0.12);
  border-color: rgba(255, 103, 128, 0.42);
  color: #ffc3cf;
}

.custom-modal-overlay {
  background: rgba(1, 8, 15, 0.72);
}

.custom-modal {
  background: rgba(9, 25, 42, 0.98);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.source-match-banner {
  background: rgba(245, 199, 107, 0.14) !important;
  border-left-color: rgba(245, 199, 107, 0.65) !important;
  color: #ffe4a4;
}

.language-pill.hidden-lang {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(156, 190, 220, 0.16);
  opacity: 0.46;
  filter: none;
}

.export-group-label {
  margin: 12px 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.export-language-pill {
  border-color: rgba(61, 214, 143, 0.42);
}

.export-options p,
#addLanguageModal p,
#batchAiProgressText,
#batchAiTokenText,
#batchAiCurrentAction {
  color: var(--muted) !important;
}

#batchAiStopBtn {
  color: var(--danger) !important;
}

#batchAiProgressContainer table,
#batchAiProgressContainer thead,
#batchAiProgressContainer tr,
#batchAiProgressContainer th,
#batchAiProgressContainer td {
  background: transparent !important;
  border-color: var(--line) !important;
  color: var(--ink) !important;
}

#batchAiProgressContainer thead {
  background: rgba(8, 23, 39, 0.84) !important;
}

hr {
  border-top-color: var(--line) !important;
}

@media (max-width: 760px) {
  .top-actions {
    padding-right: 0;
  }

  .ai-chat-toggle {
    position: static !important;
    display: inline-flex;
    margin: 10px 0 0 14px;
    padding: 9px 11px;
    font-size: 13px;
    transform: none !important;
  }

  #aiBatchToggle {
    bottom: auto !important;
  }

  .ai-chat-panel {
    left: 14px;
    right: 14px;
    width: auto !important;
  }
}

/* Dark cleanup for native and validation surfaces */
input[type="file"] {
  color: var(--muted);
}

input[type="file"]::file-selector-button {
  min-height: 30px;
  margin-right: 10px;
  border: 1px solid rgba(77, 163, 255, 0.42);
  border-radius: 6px;
  background: rgba(77, 163, 255, 0.12);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

input[type="checkbox"] {
  accent-color: var(--accent);
}

.mapping-row-error,
.mapping-row-error td {
  background: rgba(255, 103, 128, 0.09) !important;
  color: var(--ink) !important;
}

.mapping-row-error:hover,
.mapping-row-error:hover td {
  background: rgba(255, 103, 128, 0.14) !important;
}

.mapping-row-error .mapping-status.unresolved {
  background: rgba(255, 103, 128, 0.16) !important;
  border: 1px solid rgba(255, 103, 128, 0.42);
  color: #ffc3cf !important;
}

.mapping-table select:disabled,
.input:disabled,
select:disabled,
button:disabled {
  background: rgba(255, 255, 255, 0.035) !important;
  border-color: rgba(156, 190, 220, 0.18) !important;
  color: rgba(237, 247, 255, 0.46) !important;
}

.language-pill[style*="#f1f3f4"],
.language-pill[style*="var(--primary)"] {
  background: rgba(255, 255, 255, 0.045) !important;
  border-color: rgba(156, 190, 220, 0.22) !important;
  color: var(--ink) !important;
}

.master-fill-coverage {
  min-height: 30px;
  margin-top: 8px;
  padding: 7px 9px;
  border: 1px solid rgba(77, 163, 255, 0.28);
  border-radius: 8px;
  background: rgba(77, 163, 255, 0.08);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
}

.master-fill-coverage strong {
  color: var(--ink);
}

.master-fill-coverage span {
  display: inline-block;
  margin-left: 6px;
  color: #c9fff9;
  font-weight: 800;
}

.coverage-summary {
  margin-bottom: 6px;
}

.coverage-table-wrap {
  overflow-x: auto;
  padding-bottom: 2px;
}

.coverage-table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

.coverage-table th,
.coverage-table td {
  padding: 4px 7px;
  border: 1px solid rgba(156, 190, 220, 0.16);
  text-align: center;
  white-space: nowrap;
}

.coverage-table th {
  position: sticky;
  left: 0;
  z-index: 1;
  background: rgba(5, 18, 31, 0.95);
  color: var(--muted);
  text-align: left;
}

.coverage-table td {
  color: #c9fff9;
  font-weight: 900;
}

#useMasterDeviationsBtn {
  background: rgba(61, 214, 143, 0.16);
  border-color: rgba(61, 214, 143, 0.58);
  color: #d9ffef;
}

#useMasterDeviationsBtn:hover {
  background: rgba(61, 214, 143, 0.24);
  border-color: rgba(61, 214, 143, 0.78);
}

#confirmNewBtn {
  background: rgba(245, 199, 107, 0.12);
  border-color: rgba(245, 199, 107, 0.42);
  color: #ffe3a0;
  max-width: 260px;
  white-space: normal;
  line-height: 1.2;
}

#confirmNewBtn:hover {
  background: rgba(245, 199, 107, 0.18);
  border-color: rgba(245, 199, 107, 0.62);
}

#saveImportsBtn,
.button.danger-action {
  background: rgba(255, 103, 128, 0.18);
  border-color: rgba(255, 103, 128, 0.68);
  color: #ffd7de;
  box-shadow: 0 0 0 1px rgba(255, 103, 128, 0.08), 0 10px 26px rgba(255, 103, 128, 0.12);
}

#saveImportsBtn:hover,
.button.danger-action:hover {
  background: rgba(255, 103, 128, 0.28);
  border-color: rgba(255, 103, 128, 0.9);
  color: #fff1f4;
}

.custom-modal-message {
  margin: 0 0 20px;
  color: var(--muted);
  line-height: 1.5;
}

.modal-rich-message {
  max-height: 62vh;
  overflow: auto;
}

.save-warning p {
  margin: 0 0 10px;
  color: var(--muted);
}

.save-warning strong {
  color: var(--ink);
}

.save-warning-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.save-warning-summary span {
  border: 1px solid rgba(156, 190, 220, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
  padding: 7px 9px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.save-impact-table-wrap {
  max-height: 280px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.save-impact-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.save-impact-table th,
.save-impact-table td {
  padding: 8px;
  border-bottom: 1px solid rgba(156, 190, 220, 0.16);
  text-align: right;
  color: var(--ink);
}

.save-impact-table th:first-child,
.save-impact-table td:first-child {
  text-align: left;
}

.save-impact-table th {
  background: rgba(4, 13, 24, 0.72);
  color: var(--muted);
}

.save-impact-table .impact-danger {
  color: #ffc3cf;
  font-weight: 900;
}
