:root {
  --stc-purple: #4f008c;
  --stc-purple-2: #6b18c9;
  --stc-magenta: #ff375e;
  --stc-teal: #00b5c8;
  --stc-green: #18b981;
  --stc-yellow: #ffb81c;
  --ink: #17152f;
  --muted: #6c6786;
  --line: #ece8f4;
  --bg: #f7f5fb;
  --card: #ffffff;
  --shadow: 0 16px 40px rgba(31, 18, 71, 0.08);
  font-family: "Inter", "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }
button, input, select { font: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 230px 1fr; }
.sidebar {
  color: white;
  padding: 26px 18px;
  background: radial-gradient(circle at 90% 10%, #7b2de0 0, transparent 28%), linear-gradient(180deg, #5c0baa 0%, #35006c 100%);
  display: flex;
  flex-direction: column;
  gap: 28px;
}
.brand-lockup { display: flex; justify-content: space-between; align-items: flex-start; }
.stc-logo { font-size: 42px; line-height: 0.86; font-weight: 800; letter-spacing: 0; }
.stc-logo span { display: block; font-size: 14px; font-weight: 500; margin-left: 36px; margin-top: 8px; }
.collapse-button {
  width: 28px; height: 28px; border: 0; border-radius: 50%;
  color: white; background: rgba(255,255,255,.15); font-size: 24px; line-height: 1;
}
.side-nav { display: grid; gap: 8px; }
.side-nav button, .side-nav a {
  border: 0; color: rgba(255,255,255,.86); text-align: left; padding: 13px 14px;
  border-radius: 8px; background: transparent; font-weight: 650; text-decoration: none;
}
.side-nav button.active, .side-nav button:hover, .side-nav a.active, .side-nav a:hover { background: rgba(255,255,255,.13); color: white; }
.user-card { margin-top: auto; display: flex; align-items: center; gap: 12px; border-top: 1px solid rgba(255,255,255,.16); padding-top: 18px; }
.avatar { width: 42px; height: 42px; border-radius: 50%; background: white; color: var(--stc-purple); display: grid; place-items: center; font-weight: 800; }
.user-card strong, .user-card span { display: block; }
.user-card span { color: rgba(255,255,255,.72); font-size: 12px; margin-top: 4px; }

.main { min-width: 0; padding: 28px 32px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 28px; }
.topbar h1 { margin: 0 0 8px; color: var(--stc-purple); font-size: 32px; line-height: 1.1; }
.topbar p { margin: 0; color: var(--muted); }
.top-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.last-fetch, .ghost-button, .primary-button {
  border: 1px solid var(--line); border-radius: 8px; min-height: 44px; padding: 0 18px;
  background: white; color: var(--ink); display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 750;
}
.last-fetch { color: #36314f; font-size: 13px; }
.primary-button { border-color: var(--stc-purple); background: var(--stc-purple); color: white; box-shadow: 0 10px 24px rgba(79,0,140,.2); }
.ghost-button:hover, .primary-button:hover { transform: translateY(-1px); transition: .18s ease; }

.page { display: none; }
.active-page { display: block; }
.stats-grid { display: grid; grid-template-columns: repeat(6, minmax(150px, 1fr)); gap: 18px; margin-bottom: 22px; }
.metric {
  background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 22px 18px 18px 82px;
  min-height: 112px; box-shadow: var(--shadow); position: relative;
}
.metric:before {
  content: ""; position: absolute; left: 22px; top: 26px; width: 44px; height: 44px; border-radius: 10px;
  background: linear-gradient(135deg, var(--stc-purple), var(--stc-purple-2));
}
.metric.existing:before { background: linear-gradient(135deg, var(--stc-green), #0d9e78); }
.metric.new:before { background: linear-gradient(135deg, var(--stc-magenta), #ff7b99); }
.metric.modified:before { background: linear-gradient(135deg, var(--stc-yellow), #f29900); }
.metric.removed:before { background: linear-gradient(135deg, #7b7f9c, #555a7d); }
.metric.issues:before { background: linear-gradient(135deg, var(--stc-teal), #008ba6); }
.metric span { display: block; color: #4a4564; font-size: 13px; font-weight: 800; margin-bottom: 6px; }
.metric strong { display: block; font-size: 28px; line-height: 1; }
.metric small { display: block; color: var(--muted); margin-top: 10px; font-weight: 650; }

.content-grid { display: block; }
.snapshots-card, .filters-card, .table-card, .simple-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow);
}
.snapshots-card { padding: 16px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.panel-head h2 { margin: 0; font-size: 16px; }
.mini-button, .wide-button, .row-action, .table-toolbar button {
  border: 1px solid #ded7ee; background: white; color: var(--stc-purple); border-radius: 8px; font-weight: 800;
}
.mini-button { min-height: 32px; padding: 0 10px; }
.wide-button { width: 100%; min-height: 44px; margin-top: 14px; }
.snapshot-list { display: grid; gap: 12px; }
.snapshot-item { border: 1px solid #ebe6f4; background: #fbfaff; border-radius: 8px; padding: 14px; }
.snapshot-item.active { border-color: #9c6bdf; box-shadow: inset 3px 0 0 var(--stc-purple); }
.snapshot-item div { display: flex; align-items: center; gap: 8px; }
.snapshot-item strong { font-size: 13px; }
.snapshot-item em { margin-left: auto; font-style: normal; color: var(--stc-purple); border: 1px solid #d9c7fb; border-radius: 6px; padding: 2px 7px; font-size: 11px; font-weight: 800; }
.snapshot-item p { margin: 10px 0; color: #4a4564; font-size: 12px; font-weight: 650; }
.snapshot-item footer { display: flex; justify-content: space-between; gap: 6px; }
.snapshot-item footer button { border: 0; background: transparent; font-size: 11px; font-weight: 800; color: var(--stc-purple); padding: 0; }
.radio-dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--stc-purple); display: inline-block; box-shadow: inset 0 0 0 3px white; background: var(--stc-purple); }

.workspace { display: grid; gap: 22px; min-width: 0; }
.filters-card { padding: 18px; display: grid; grid-template-columns: 1.8fr repeat(4, minmax(140px, 1fr)) auto; gap: 14px; align-items: end; }
.labels-only-title { display: none; }
.filters-card label { color: #4b4566; font-size: 12px; font-weight: 800; display: grid; gap: 8px; }
input, select {
  width: 100%; border: 1px solid #e2ddec; border-radius: 8px; min-height: 44px; padding: 0 14px; color: var(--ink); background: white;
}
.advanced-button { min-height: 44px; padding: 0 18px; border: 1px solid #cdb8ef; border-radius: 8px; color: var(--stc-purple); background: #fbf8ff; font-weight: 850; }
.active-pill { grid-column: 1 / -1; justify-self: start; background: #f4edff; color: var(--stc-purple); border: 1px solid #d8c4f7; border-radius: 8px; padding: 9px 12px; font-size: 12px; font-weight: 800; }
.advanced-panel { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }

.labels-only-mode .topbar { margin-bottom: 18px; }
.labels-only-mode .stats-grid,
.labels-only-mode .snapshots-card { display: none; }
.labels-only-mode .content-grid { display: block; }
.labels-only-mode .workspace { gap: 16px; }
.labels-only-mode .filters-card {
  grid-template-columns: repeat(5, minmax(170px, 1fr));
  align-items: start;
}
.labels-only-mode .labels-only-title { display: block; grid-column: 1 / -1; }
.labels-only-mode .labels-only-title h2 {
  margin: 0 0 6px;
  color: var(--stc-purple);
  font-size: 22px;
  line-height: 1.2;
}
.labels-only-mode .labels-only-title p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}
.labels-only-mode .filters-card label:not(.labels-search-field),
.labels-only-mode .advanced-button,
.labels-only-mode .active-pill,
.labels-only-mode .advanced-panel { display: none !important; }

.table-card { overflow: hidden; }
.table-toolbar { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px; color: #5c5675; font-size: 13px; font-weight: 750; }
.table-toolbar div { display: flex; align-items: center; gap: 10px; }
.table-toolbar label { display: flex; align-items: center; gap: 8px; }
.table-toolbar select { width: 72px; min-height: 34px; }
.table-toolbar button { width: 34px; height: 34px; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; min-width: 1160px; }
th, td { padding: 14px 13px; border-top: 1px solid #f0edf6; text-align: left; vertical-align: top; font-size: 12px; line-height: 1.45; }
th { background: #faf9fd; color: #4a4564; font-weight: 850; white-space: nowrap; }
.id-text { color: var(--stc-purple); font-weight: 850; font-size: 11px; }
.text-cell { max-width: 220px; }
.rtl { direction: rtl; text-align: right; }
.issue, .status, .change { display: inline-flex; border-radius: 999px; padding: 5px 8px; font-weight: 850; font-size: 11px; white-space: nowrap; }
.issue.none { color: #047857; background: #e8fbf4; }
.issue.danger { color: #be123c; background: #fff1f3; }
.issue.warning { color: #92400e; background: #fff8e1; }
.status { color: #067a54; background: #e9fbf4; }
.change.existing { color: #067a54; background: #e9fbf4; }
.change.created { color: #be123c; background: #ffeaf0; }
.change.new { color: #be123c; background: #ffeaf0; }
.change.modified { color: #a16207; background: #fff4cb; }
.change.removed { color: #4b5563; background: #eef0f5; }
.row-action { min-height: 32px; padding: 0 12px; }
.empty-row, .empty-box { text-align: center; color: var(--muted); padding: 30px; }

.simple-page h2 { margin: 0 0 16px; color: var(--stc-purple); }
.simple-card { padding: 20px; min-height: 120px; }
.history-controls {
  min-height: 0;
  margin-bottom: 16px;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 14px;
}
.history-controls label {
  display: grid;
  gap: 8px;
  color: #4b4566;
  font-size: 12px;
  font-weight: 800;
}
.history-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.history-summary span {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfaff;
  padding: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.history-summary strong {
  display: block;
  color: var(--stc-purple);
  font-size: 22px;
  margin-top: 4px;
}
.history-table { min-width: 1380px; }
.compare-cards, .issue-grid { display: grid; grid-template-columns: repeat(3, minmax(140px, 1fr)); gap: 14px; }
.compare-cards button, .issue-grid span, .snapshot-row {
  border: 1px solid var(--line); background: #fbfaff; border-radius: 8px; padding: 16px; text-align: left; color: var(--ink); font-weight: 750;
}
.compare-cards strong, .issue-grid strong { display: block; font-size: 24px; margin-top: 8px; }
.snapshot-full { display: grid; gap: 10px; }
#apiContent { display: flex; gap: 10px; flex-wrap: wrap; }
#apiContent code { background: #f3effa; color: var(--stc-purple); padding: 10px; border-radius: 8px; }

.language-page { display: none; }
.language-page.active-page { display: block; }
.language-page-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 18px;
}
.language-page-head h2 { margin: 0 0 6px; color: var(--stc-purple); font-size: 24px; line-height: 1.2; }
.language-page-head p { margin: 0; color: var(--muted); font-size: 13px; }
.language-page-head span {
  color: #4a4564; background: white; border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; font-size: 12px; font-weight: 800; white-space: nowrap;
}
.language-controls {
  display: grid; grid-template-columns: 2fr repeat(3, minmax(180px, 1fr)); gap: 14px;
  padding: 18px; margin-bottom: 18px; background: white; border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow);
}
.language-controls label {
  display: grid; gap: 8px; color: #4b4566; font-size: 12px; font-weight: 800;
}
.language-summary {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px;
}
.language-summary article {
  min-height: 88px; padding: 16px; background: white; border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 8px 22px rgba(31, 18, 71, .06); border-top: 3px solid var(--stc-purple);
}
.language-summary article:nth-child(4n+2) { border-top-color: var(--stc-magenta); }
.language-summary article:nth-child(4n+3) { border-top-color: var(--stc-teal); }
.language-summary article:nth-child(4n+4) { border-top-color: var(--stc-yellow); }
.language-summary span { display: block; color: var(--muted); font-size: 11px; font-weight: 800; }
.language-summary strong { display: block; margin-top: 9px; color: var(--ink); font-size: 24px; line-height: 1; }
.language-table { min-width: 1420px; }
.language-table .text-cell { min-width: 230px; max-width: 300px; }
.consistency-issue {
  display: inline-flex; max-width: 210px; border-radius: 6px; padding: 6px 8px;
  font-size: 11px; line-height: 1.3; font-weight: 850;
}
.consistency-issue.danger { color: #be123c; background: #fff1f3; }
.consistency-issue.warning { color: #92400e; background: #fff8e1; }
.consistency-issue.case { color: #4f008c; background: #f4edff; }
.consistency-issue.mapping { color: #075985; background: #eaf8fc; }
.occurrence-count {
  display: inline-grid; place-items: center; min-width: 34px; height: 30px; padding: 0 8px;
  color: var(--stc-purple); background: #f4edff; border: 1px solid #ddc9f8; border-radius: 6px;
}

.dictionary-page { display: none; }
.dictionary-page.active-page { display: block; }
.dictionary-page-head,
.dictionary-section-head,
.dictionary-results-head,
.dictionary-downloads {
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
}
.dictionary-page-head { align-items: flex-end; margin-bottom: 18px; }
.dictionary-page-head h2,
.dictionary-section-head h3,
.dictionary-results-head h3,
.dictionary-downloads h3 { margin: 0 0 6px; color: var(--stc-purple); line-height: 1.2; }
.dictionary-page-head h2 { font-size: 24px; }
.dictionary-section-head h3,
.dictionary-results-head h3,
.dictionary-downloads h3 { font-size: 17px; }
.dictionary-page-head p,
.dictionary-section-head p,
.dictionary-results-head p,
.dictionary-downloads p { margin: 0; color: var(--muted); font-size: 13px; }
.dictionary-page-head > span {
  color: #4a4564; background: white; border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; font-size: 12px; font-weight: 800; white-space: nowrap;
}
.dictionary-upload-panel {
  padding: 20px; margin-bottom: 18px; background: white; border: 1px solid var(--line);
  border-radius: 8px; box-shadow: var(--shadow);
}
.dictionary-drop-zone {
  width: 100%; min-height: 150px; margin-top: 18px; border: 1px dashed #bca3da; border-radius: 8px;
  background: #fbf9fe; color: var(--ink); display: grid; place-content: center; gap: 8px; text-align: center;
  transition: border-color .18s ease, background .18s ease, transform .18s ease;
}
.dictionary-drop-zone:hover,
.dictionary-drop-zone.dragging { border-color: var(--stc-purple); background: #f6f0fc; transform: translateY(-1px); }
.dictionary-drop-zone strong { color: var(--stc-purple); font-size: 16px; }
.dictionary-drop-zone span { color: var(--muted); font-size: 12px; }
.dictionary-file-meta {
  margin-top: 14px; padding: 12px 14px; border-left: 3px solid var(--stc-teal); background: #f3fbfc;
  border-radius: 6px; display: flex; justify-content: space-between; gap: 12px; align-items: center;
}
.dictionary-file-meta[hidden], .dictionary-progress[hidden], #dictionaryResults[hidden] { display: none !important; }
.dictionary-file-meta strong { overflow-wrap: anywhere; }
.dictionary-file-meta span { color: var(--muted); font-size: 12px; white-space: nowrap; }
.dictionary-progress { margin-top: 14px; }
.dictionary-progress div { display: flex; justify-content: space-between; gap: 12px; color: #4a4564; font-size: 12px; font-weight: 800; }
.dictionary-progress progress { width: 100%; height: 10px; margin-top: 8px; accent-color: var(--stc-purple); }
.dictionary-summary {
  display: grid; grid-template-columns: repeat(7, minmax(130px, 1fr)); gap: 12px; margin-bottom: 18px;
}
.dictionary-summary article {
  min-height: 88px; padding: 15px; background: white; border: 1px solid var(--line); border-top: 3px solid var(--stc-purple);
  border-radius: 8px; box-shadow: 0 8px 22px rgba(31, 18, 71, .06);
}
.dictionary-summary article:nth-child(3) { border-top-color: var(--stc-teal); }
.dictionary-summary article:nth-child(4),
.dictionary-summary article:nth-child(5) { border-top-color: var(--stc-yellow); }
.dictionary-summary article:nth-child(6) { border-top-color: var(--stc-magenta); }
.dictionary-summary article:nth-child(7) { border-top-color: var(--stc-green); }
.dictionary-summary span { display: block; color: var(--muted); font-size: 11px; font-weight: 800; }
.dictionary-summary strong { display: block; margin-top: 9px; color: var(--ink); font-size: 24px; line-height: 1; }
.dictionary-results-head { align-items: flex-end; margin: 8px 0 14px; }
.dictionary-filters { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.dictionary-filters button {
  min-height: 36px; padding: 0 12px; border: 1px solid #ddd4eb; border-radius: 6px; background: white;
  color: #514a69; font-size: 12px; font-weight: 800; transition: .16s ease;
}
.dictionary-filters button:hover,
.dictionary-filters button.active { border-color: var(--stc-purple); background: var(--stc-purple); color: white; }
.dictionary-table { min-width: 1460px; }
.dictionary-table td:first-child strong,
.dictionary-table td:first-child small { display: block; }
.dictionary-table td:first-child small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.dictionary-exception-row td { background: #fffaf0; }
.dictionary-badge {
  display: inline-flex; max-width: 180px; padding: 5px 8px; border-radius: 6px; font-size: 11px; line-height: 1.3;
  font-weight: 850; white-space: normal;
}
.dictionary-badge.matched { color: #067a54; background: #e9fbf4; }
.dictionary-badge.updated { color: #075985; background: #eaf8fc; }
.dictionary-badge.warning { color: #92400e; background: #fff1c7; }
.dictionary-badge.review { color: #9f1239; background: #ffe8ef; }
.dictionary-badge.neutral { color: #4b5563; background: #eef0f5; }
.dictionary-method { color: #514a69; font-size: 11px; font-weight: 750; white-space: nowrap; }
.dictionary-downloads {
  margin-top: 18px; padding: 20px; background: white; border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow);
}
.dictionary-downloads > div:last-child { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }

.drawer-backdrop { position: fixed; inset: 0; background: rgba(15, 8, 32, .38); display: flex; justify-content: flex-end; z-index: 20; }
.drawer-backdrop[hidden] { display: none !important; }
.detail-drawer {
  width: min(520px, 100vw); height: 100%; background: white; box-shadow: -20px 0 50px rgba(22, 11, 48, .22);
  animation: slideIn .22s ease both; display: flex; flex-direction: column;
}
@keyframes slideIn { from { transform: translateX(28px); opacity: .7; } to { transform: translateX(0); opacity: 1; } }
.detail-drawer header { padding: 24px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 16px; }
.detail-drawer h2 { margin: 0 0 8px; color: var(--stc-purple); }
.detail-drawer p { margin: 0; color: var(--muted); }
#closeDrawer { border: 0; background: #f4f0fa; color: var(--stc-purple); width: 38px; height: 38px; border-radius: 50%; font-size: 24px; }
.drawer-content { padding: 22px; overflow: auto; display: grid; gap: 12px; }
.detail-field { border: 1px solid var(--line); border-radius: 8px; padding: 12px; background: #fcfbfe; }
.detail-field span { display: block; color: var(--muted); font-size: 11px; font-weight: 850; text-transform: uppercase; margin-bottom: 6px; }
.detail-field p { margin: 0; color: var(--ink); overflow-wrap: anywhere; }
.toast { position: fixed; right: 24px; bottom: 24px; background: var(--ink); color: white; padding: 14px 16px; border-radius: 8px; box-shadow: var(--shadow); z-index: 30; }

@media (max-width: 1200px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; display: block; }
  .side-nav { grid-template-columns: repeat(3, 1fr); }
  .user-card { display: none; }
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
  .content-grid { grid-template-columns: 1fr; }
  .filters-card { grid-template-columns: repeat(2, 1fr); }
  .language-controls { grid-template-columns: repeat(2, 1fr); }
  .dictionary-summary { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 760px) {
  .main { padding: 20px; }
  .topbar, .table-toolbar, .language-page-head, .dictionary-page-head, .dictionary-section-head, .dictionary-results-head, .dictionary-downloads { align-items: stretch; flex-direction: column; }
  .top-actions, .table-toolbar div { justify-content: flex-start; }
  .stats-grid, .filters-card, .advanced-panel, .compare-cards, .issue-grid, .history-controls, .history-summary, .language-controls, .dictionary-summary { grid-template-columns: 1fr; }
  .metric { padding-left: 76px; }
  .dictionary-file-meta { align-items: flex-start; flex-direction: column; }
  .dictionary-file-meta span { white-space: normal; }
  .dictionary-filters, .dictionary-downloads > div:last-child { justify-content: flex-start; }
}
