:root {
  --bg: #edf1f5;
  --panel: #ffffff;
  --panel2: #f8fafc;
  --txt: #111827;
  --muted: #4b5563;
  --soft: #6b7280;
  --accent: #2563eb;
  --accent2: #0f766e;
  --warn: #b45309;
  --border: #d8dee7;
  --border2: #e5e7eb;
  --shadow: 0 10px 28px rgba(15, 23, 42, .08);
  --sidebar-width: 360px;
  --cell-py: 7px;
  --cell-px: 9px;
  --table-font-size: 12px;
}

body.theme-dark {
  --bg: #111827;
  --panel: #1f2937;
  --panel2: #172033;
  --txt: #e5e7eb;
  --muted: #cbd5e1;
  --soft: #94a3b8;
  --border: #334155;
  --border2: #2f3b4f;
  --shadow: 0 10px 28px rgba(0, 0, 0, .35);
}

body.density-compact {
  --cell-py: 4px;
  --cell-px: 7px;
  --table-font-size: 11px;
}

body.density-comfort {
  --cell-py: 9px;
  --cell-px: 12px;
  --table-font-size: 13px;
}

html,
body {
  min-height: 100%;
}

body {
  min-width: 0;
  background: var(--bg);
  padding: 16px;
  line-height: 1.45;
  font-size: 13px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.container {
  width: min(100%, 1360px);
  max-width: 1360px;
  min-height: calc(100vh - 32px);
  margin: 0 auto;
  background: var(--bg);
  border-radius: 10px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, .10);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.hero {
  background: #ffffff;
  color: var(--txt);
  padding: 12px 18px;
  text-align: left;
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  border-bottom: 1px solid var(--border);
  border-radius: 10px 10px 0 0;
  box-shadow: 0 2px 12px rgba(15, 23, 42, .05);
}

.hero h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
  letter-spacing: 0;
  font-weight: 750;
}

.hero p {
  display: none;
}

.heroFine {
  margin-top: 4px;
  font-size: 12px;
  color: var(--soft);
}

.heroBadge {
  position: static;
}

.heroMeta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.heroSelect {
  min-height: 32px;
  width: auto;
  padding: 0 28px 0 10px;
  border-radius: 6px;
  font-size: 12px;
}

.heroMeta .heroSelect,
.heroMeta .btn,
.heroMeta .badge,
.heroMeta .pill,
#authContainer > button,
#authContainer .auth-user-badge > span,
#authContainer .auth-user-badge > button,
#authContainer .auth-disabled-badge {
  min-height: 32px;
  height: 32px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--txt);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 650;
  line-height: 1;
  box-shadow: none;
  white-space: nowrap;
}

.heroMeta .badge,
.heroMeta .pill {
  cursor: default;
}

#authContainer {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
}

#authContainer .auth-user-badge {
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
}

#authContainer .auth-user-badge > span {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}

#authContainer > button,
#authContainer .auth-user-badge > button,
#authContainer .auth-disabled-badge {
  border-radius: 6px !important;
  border: 1px solid var(--border) !important;
  background: #ffffff !important;
  color: var(--txt) !important;
  padding: 0 10px !important;
  box-shadow: none !important;
  font-size: 12px !important;
}

.heroMeta .btn:hover,
#authContainer button:hover {
  border-color: rgba(37, 99, 235, .55);
  background: #f8fbff;
}

.heroActions {
  margin: 0;
  display: contents;
}

.heroActions .btn {
  background: #ffffff;
  border-color: var(--border);
  color: var(--txt);
  font-weight: 650;
}

.content {
  padding: 18px;
  flex: 1;
  min-height: 0;
}

.wrap {
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  padding: 0;
}

.grid {
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  gap: 14px;
  justify-content: center;
}

.grid > .card:first-child {
  position: sticky;
  top: 74px;
}

.grid > .card:last-child {
  min-height: calc(100vh - 132px);
}

.card {
  background: var(--panel);
  border-color: var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.card .hd {
  min-height: 42px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border2);
  background: var(--panel2);
  border-radius: 8px 8px 0 0;
}

.card .bd {
  padding: 12px;
}

.drop {
  border-color: rgba(37, 99, 235, .48);
  border-radius: 8px;
  padding: 12px;
  text-align: left;
  background: #f7faff;
}

.drop.drag {
  background: #ebf3ff;
  border-color: rgba(37, 99, 235, .85);
}

.drop b {
  font-size: 13px;
}

.drop .hint {
  color: var(--soft);
  margin-top: 4px;
}

.filepick {
  justify-content: flex-start;
}

.fileStatus {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

label {
  font-size: 11px;
  font-weight: 700;
  margin: 8px 0 5px;
}

select,
input[type="text"],
input[type="number"] {
  min-height: 34px;
  padding: 7px 9px;
  border-radius: 6px;
  font-size: 12px;
}

.btn {
  min-height: 32px;
  padding: 7px 10px;
  border-radius: 6px;
  font-weight: 650;
}

.btn.primary {
  background: #1d4ed8;
  border-color: #1d4ed8;
  color: #ffffff;
}

.btn.primary:hover {
  background: #1e40af;
}

.btn.active {
  background: #e8f0ff;
  border-color: rgba(37, 99, 235, .58);
  color: #1d4ed8;
}

.btnGroup {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.exportMenuWrap {
  position: relative;
  flex: 1 1 auto;
}

.exportMenuWrap > .btn {
  width: 100%;
}

.exportOptions {
  position: absolute;
  right: 0;
  bottom: calc(100% + 6px);
  min-width: 180px;
  max-height: min(50vh, 280px);
  overflow: auto;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 14px 34px rgba(15, 23, 42, .18);
  z-index: 40;
}

.exportOptions[hidden] {
  display: none;
}

.exportOption {
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--txt);
  text-align: left;
  border-radius: 6px;
  padding: 8px 10px;
  cursor: pointer;
  font-size: 12px;
}

.exportOption:hover {
  background: #eef2f7;
}

.toolbarMini {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.toolbarMini select {
  width: auto;
  min-height: 30px;
  padding: 5px 8px;
}

.viewTabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border);
  background: #eef2f7;
  border-radius: 8px;
}

.tabBtn {
  min-height: 30px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 750;
  line-height: 1.15;
  overflow-wrap: anywhere;
  padding: 4px 6px;
  white-space: normal;
}

.tabBtn:hover {
  background: #ffffff;
}

.tabBtn.active {
  background: #ffffff;
  color: #1d4ed8;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .12);
}

.tabBtn:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.workbookToolbar {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
}

.workbookTabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border);
  background: #eef2f7;
  border-radius: 8px;
}

.workbookStats {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  padding: 5px 8px;
  border: 1px solid var(--border2);
  border-radius: 8px;
  background: #fbfdff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.workbookNotice {
  margin-top: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border2);
  border-radius: 8px;
  background: #fbfdff;
}

.workbookSheet {
  display: grid;
  gap: 12px;
  margin-top: 10px;
}

.workbookSectionTitle {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  padding: 5px 9px;
  border: 1px solid #9fb5d1;
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background: #d9e8fb;
  color: #17365d;
  font-weight: 800;
}

.workbookTableWrap {
  border-top-left-radius: 0;
  max-height: calc(50vh - 120px);
}

.srOnly {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.metaDetails {
  margin-top: 10px;
  border: 1px solid var(--border2);
  border-radius: 8px;
  background: #fbfdff;
}

.metaDetails summary {
  cursor: pointer;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 750;
  color: var(--txt);
}

.metaDetails .meta {
  margin: 0;
  padding: 0 10px 10px;
}

.pill {
  background: #ffffff;
}

.badge {
  background: #eef7f4;
  border-color: rgba(15, 118, 110, .28);
  color: #0f766e;
  letter-spacing: 0;
}

.tagPanel {
  display: grid;
  gap: 8px;
  margin: 8px 0 10px;
}

.tagGroup label {
  margin: 0 0 5px;
}

.tagSearchInput {
  width: 100%;
  margin: 0 0 6px;
}

.tagCloud {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  min-height: 28px;
  padding: 6px;
  border: 1px solid var(--border2);
  border-radius: 8px;
  background: #fbfdff;
}

.tagCloud.compact {
  max-height: 88px;
  overflow: auto;
}

#policyNameTags.tagCloud.compact {
  max-height: 176px;
  min-height: 56px;
  align-content: flex-start;
}

.tagBtn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 260px;
  min-height: 26px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #ffffff;
  color: var(--muted);
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 720;
  cursor: pointer;
}

.tagBtn:hover {
  border-color: rgba(37, 99, 235, .55);
  color: #1d4ed8;
  background: #f8fbff;
}

.tagBtn.active {
  border-color: rgba(37, 99, 235, .62);
  background: #eff6ff;
  color: #1d4ed8;
}

.tagBtn span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tagBtn code {
  font-family: var(--mono);
  border: 1px solid rgba(37, 99, 235, .18);
  background: #eef2ff;
  color: #1d4ed8;
  border-radius: 999px;
  padding: 0 5px;
  font-size: 10px;
}

.tagEmpty {
  color: var(--soft);
  font-size: 11px;
}

.fileNamePreview {
  background: #f8fafc;
  border-color: var(--border2);
  border-radius: 6px;
}

.fileChips {
  display: grid;
  gap: 6px;
  margin-top: 8px;
  max-height: 142px;
  overflow: auto;
}

.fileChip {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
  width: 100%;
  border: 1px solid var(--border2);
  border-radius: 7px;
  background: #ffffff;
  padding: 6px 7px;
  text-align: left;
}

.fileChip.active {
  border-color: rgba(37, 99, 235, .55);
  background: #eff6ff;
}

.fileChipTag {
  font-family: var(--mono);
  font-weight: 800;
  color: #1d4ed8;
  font-size: 11px;
}

.fileChipName {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  color: #111827;
}

.fileChipActions {
  display: flex;
  gap: 2px;
}

.fileChipBtn {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 800;
  padding: 2px 4px;
}

.fileChipBtn:hover {
  color: #1d4ed8;
  background: #eef2f7;
  border-radius: 4px;
}

.fileChipRemove {
  color: #991b1b;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 650;
}

.status:before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--soft);
}

.status.ok:before {
  background: var(--ok);
}

.status.bad:before {
  background: var(--bad);
}

.status.neutral:before {
  background: var(--soft);
}

.tableWrap {
  border-radius: 8px;
  background: #ffffff;
}

.xScrollBar {
  display: none;
  width: 100%;
  height: 16px;
  overflow-x: auto;
  overflow-y: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fafc;
  scrollbar-gutter: stable;
}

.xScrollBarInner {
  height: 1px;
}

#tableWrap,
#panelKV .tableWrap,
#panelWorkbook .tableWrap,
#panelCompare .tableWrap {
  max-height: calc(100vh - 345px);
}

#tblBin {
  min-width: 100%;
}

table {
  font-size: var(--table-font-size);
  font-variant-numeric: tabular-nums;
}

th,
td {
  padding: var(--cell-py) var(--cell-px);
  vertical-align: middle;
  text-align: center;
}

th {
  z-index: 5;
  background: #f3f6fa;
  font-weight: 750;
  box-shadow: 0 1px 0 rgba(17, 24, 39, .08);
}

td.num {
  text-align: center;
  font-family: var(--mono);
}

td.valueCell {
  max-width: 520px;
  overflow: hidden;
  text-overflow: ellipsis;
}

mark.match {
  background: #fde68a;
  color: #111827;
  border-radius: 3px;
  padding: 0 1px;
}

.checklist {
  border-radius: 8px;
  padding: 6px;
  max-height: 190px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 8px;
  border: 1px solid var(--border2);
  border-radius: 999px;
  background: #ffffff;
}

.check.active {
  border-color: rgba(37, 99, 235, .62);
  background: #eff6ff;
}

.compareAdvancedPickers {
  display: none;
}

.compareSummary {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  margin: 10px 0;
}

.compareCounter {
  border: 1px solid var(--border2);
  border-radius: 8px;
  background: #fbfdff;
  padding: 8px;
}

.compareCounter b {
  display: block;
  font-size: 16px;
  line-height: 1.1;
  color: #111827;
}

.compareCounter span {
  display: block;
  margin-top: 3px;
  font-size: 11px;
  color: var(--muted);
}

.schemaHint {
  border: 1px solid var(--border2);
  border-radius: 8px;
  background: #f8fafc;
  padding: 8px 10px;
  margin: 10px 0;
  font-size: 11px;
  color: var(--muted);
}

.analysis-row {
  cursor: pointer;
}

.analysis-row:hover td {
  outline: 1px solid rgba(37, 99, 235, .22);
  outline-offset: -1px;
}

.analysis-row.active td {
  background: #dbeafe !important;
}

.analysis-diff td,
.diff-left-only td {
  background: #fff7ed;
}

.analysis-missing td,
.diff-right-only td {
  background: #ecfdf5;
}

.diff-modified td {
  background: #eff6ff;
}

.analysis-result {
  font-weight: 800;
}

.detailTitle {
  margin: 12px 0 8px;
  font-weight: 800;
  color: var(--txt);
}

body.theme-dark .hero,
body.theme-dark .footer,
body.theme-dark .card,
body.theme-dark .exportOptions {
  background: var(--panel);
  color: var(--txt);
}

body.theme-dark .drop,
body.theme-dark .metaDetails,
body.theme-dark .compareCounter,
body.theme-dark .schemaHint,
body.theme-dark .tableWrap,
body.theme-dark .xScrollBar {
  background: #172033;
}

body.theme-dark select,
body.theme-dark input,
body.theme-dark .btn,
body.theme-dark .fileChip,
body.theme-dark .pill,
body.theme-dark .tagCloud,
body.theme-dark .tagBtn,
body.theme-dark .check {
  background: #111827;
  color: var(--txt);
  border-color: var(--border);
}

body.theme-dark .fileChipName,
body.theme-dark td,
body.theme-dark th,
body.theme-dark .metaItem b,
body.theme-dark .compareCounter b {
  color: var(--txt);
}

body.theme-dark th {
  background: #243044;
}

body.theme-dark code.kv,
body.theme-dark .meta code,
body.theme-dark .footer code,
body.theme-dark .fileNamePreview {
  background: #111827;
  color: #dbeafe;
}

body.theme-dark .tabBtn.active,
body.theme-dark .fileChip.active {
  background: #1e3a5f;
}

body.theme-dark .exportOption {
  color: var(--txt);
}

.footer {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  background: #ffffff;
}

@media (max-width: 1180px) {
  body {
    padding: 10px;
  }

  .container {
    min-height: calc(100vh - 20px);
  }

  .hero {
    align-items: flex-start;
    flex-direction: column;
  }

  .heroMeta {
    justify-content: flex-start;
  }

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

  .grid > .card:first-child {
    position: static;
  }

  .grid > .card:last-child {
    min-height: 0;
  }
}

@media (max-width: 720px) {
  body {
    padding: 0;
  }

  .container {
    width: 100%;
    min-height: 100vh;
    border-radius: 0;
  }

  .hero {
    border-radius: 0;
  }

  .content {
    padding: 12px;
  }
}
