*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue:         #1a73e8;
  --blue-dark:    #1557b0;
  --blue-light:   #e8f0fe;
  --red:          #d93025;
  --red-light:    #fce8e6;
  --green:        #188038;
  --green-light:  #e6f4ea;
  --orange:       #e37400;
  --orange-light: #fef3e2;
  --grey:         #5f6368;
  --grey-light:   #f1f3f4;
  --bg:           #f8f9fa;
  --white:        #ffffff;
  --border:       #dadce0;
  --text:         #202124;
  --text2:        #5f6368;
  --nav:          #212121;
  --shadow-sm:    0 1px 2px rgba(0,0,0,.1);
  --shadow:       0 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.08);
}

body {
  font-family: 'Google Sans', Roboto, -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 13px;
  line-height: 1.5;
}

/* ── Top nav ── */
.topnav {
  height: 56px;
  background: var(--nav);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: 0 1px 4px rgba(0,0,0,.4);
}
.topnav-logo {
  display: flex; align-items: center; gap: 8px;
}
.topnav-title { color: #fff; font-size: .95rem; font-weight: 500; }
.topnav-sep   { color: #5f6368; }
.topnav-sub   { color: #9aa0a6; font-size: .8rem; }
.topnav-spacer { flex: 1; }
.topnav-btn {
  background: transparent;
  border: 1px solid #5f6368;
  color: #e8eaed;
  border-radius: 4px;
  padding: 5px 14px;
  font-size: .8rem;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s;
}
.topnav-btn:hover { background: rgba(255,255,255,.08); }

/* ── Tab bar ── */
.tabbar {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  padding: 0 20px;
  gap: 0;
  position: sticky;
  top: 56px;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}
.tab-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 14px 18px 12px;
  font-size: .85rem;
  font-weight: 500;
  color: var(--text2);
  cursor: pointer;
  border: none;
  background: transparent;
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
  font-family: inherit;
  transition: color .15s;
  white-space: nowrap;
}
.tab-btn:hover { color: var(--blue); background: var(--blue-light); }
.tab-btn.active { color: var(--blue); border-bottom-color: var(--blue); }
.tab-badge {
  background: #ea4335;
  color: #fff;
  border-radius: 10px;
  font-size: .65rem;
  font-weight: 700;
  padding: 1px 5px;
  min-width: 16px;
  text-align: center;
  display: none;
}
.tab-badge.show { display: inline-block; }

/* ── Main layout ── */
.main { padding: 20px 24px; }

/* ── Upload view ── */
.upload-wrap {
  max-width: 640px;
  margin: 32px auto;
}
.page-heading { font-size: 1.1rem; font-weight: 400; margin-bottom: 4px; }
.page-sub     { font-size: .8rem; color: var(--text2); margin-bottom: 24px; }

.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 24px;
}
.card-title {
  font-size: .7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text2);
  margin-bottom: 18px;
}

.upload-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
@media (max-width: 560px) { .upload-row { flex-direction: column; } }

.upload-box {
  flex: 1;
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 18px 12px;
  text-align: center;
  cursor: pointer;
  position: relative;
  background: var(--bg);
  transition: border-color .2s, background .2s;
}
.upload-box:hover        { border-color: var(--blue); background: var(--blue-light); }
.upload-box.has-file     { border-style: solid; border-color: var(--green); background: var(--green-light); }
.upload-box input[type=file] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%;
}
.upload-ver {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--blue); color: #fff; font-weight: 700; font-size: .75rem;
  margin: 0 auto 7px;
}
.upload-ver.b { background: #7627bb; }
.upload-hint  { font-size: .75rem; color: var(--text2); line-height: 1.5; }
.upload-fname { font-size: .75rem; color: var(--green); margin-top: 5px; font-weight: 500; word-break: break-all; }
.upload-arrow { color: var(--text2); font-size: 1.1rem; flex-shrink: 0; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--blue); color: #fff; border: none;
  border-radius: 4px; padding: 8px 20px;
  font-size: .85rem; font-weight: 500; cursor: pointer;
  font-family: inherit; transition: background .15s, box-shadow .15s;
  margin-top: 18px;
}
.btn:hover { background: var(--blue-dark); box-shadow: var(--shadow); }

.error-msg {
  display: flex; align-items: center; gap: 8px;
  background: var(--red-light); border: 1px solid #f5c6c4;
  color: var(--red); border-radius: 6px;
  padding: 10px 14px; margin-bottom: 16px; font-size: .85rem;
}

/* ── Diff view ── */
.diff-wrap { display: flex; flex-direction: column; gap: 0; }

/* File compare header */
.compare-header {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
}
.file-chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 4px; padding: 3px 8px;
  font-family: 'Roboto Mono', monospace; font-size: .75rem;
}
.file-chip .ver {
  background: var(--blue); color: #fff;
  border-radius: 3px; padding: 1px 5px;
  font-size: .65rem; font-weight: 700;
}
.file-chip .ver.b { background: #7627bb; }
.cmp-arrow { color: var(--text2); }
.stat-pills { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.stat-pill {
  display: inline-flex; align-items: center; gap: 4px;
  border-radius: 12px; padding: 3px 10px;
  font-size: .75rem; font-weight: 500; border: 1px solid;
}
.stat-pill.add { background: var(--green-light); color: var(--green); border-color: #a8d5b5; }
.stat-pill.del { background: var(--red-light);   color: var(--red);   border-color: #f5c6c4; }
.stat-pill.mod { background: var(--orange-light); color: var(--orange); border-color: #f9d9a5; }
.stat-dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

/* ── Two-panel list ── */
.list-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 16px;
}
.list-panel { display: flex; flex-direction: column; min-width: 0; }
.list-panel + .list-panel { border-left: 1px solid var(--border); }

.list-panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--grey-light);
  border-bottom: 1px solid var(--border);
  font-size: .78rem;
  font-weight: 500;
  color: var(--text2);
  flex-shrink: 0;
}
.list-panel-header .ver-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--blue); flex-shrink: 0;
}
.list-panel-header .ver-dot.b { background: #7627bb; }
.list-panel-header .fname {
  font-family: 'Roboto Mono', monospace;
  font-size: .72rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  flex: 1;
}
.list-panel-header .count {
  background: var(--border); border-radius: 10px;
  padding: 1px 6px; font-size: .65rem; font-weight: 600; color: var(--text2);
  flex-shrink: 0;
}

.list-search {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.list-search input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 5px 10px;
  font-size: .78rem;
  font-family: inherit;
  color: var(--text);
  background: var(--white);
  outline: none;
}
.list-search input:focus { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(26,115,232,.15); }

.list-body {
  overflow-y: auto;
  max-height: 380px;
  flex: 1;
}

.list-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border-bottom: 1px solid #f1f3f4;
  cursor: pointer;
  transition: background .1s;
  user-select: none;
}
.list-item:last-child { border-bottom: none; }
.list-item:hover       { background: #f8f9fa; }
.list-item.selected    { background: var(--blue-light); }
.list-item.selected .item-name { color: var(--blue); font-weight: 500; }

/* status dot */
.sdot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.sdot.unchanged { background: #bdc1c6; }
.sdot.modified  { background: var(--orange); }
.sdot.added     { background: var(--green); }
.sdot.removed   { background: var(--red); }

.item-name {
  flex: 1; font-size: .82rem; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.item-name.strike { text-decoration: line-through; color: var(--text2); }

.item-badge {
  flex-shrink: 0;
  font-size: .65rem; font-weight: 600; border-radius: 3px;
  padding: 1px 5px; text-transform: uppercase; letter-spacing: .03em;
}
.item-badge.added    { background: var(--green-light); color: var(--green); }
.item-badge.removed  { background: var(--red-light);   color: var(--red); }
.item-badge.modified { background: var(--orange-light); color: var(--orange); }

.list-empty {
  padding: 32px;
  text-align: center;
  color: var(--text2);
  font-size: .8rem;
}

/* ── Status filter bar ── */
.status-filters {
  display: flex;
  gap: 4px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--white);
  flex-wrap: wrap;
}
.sf-btn {
  display: inline-flex; align-items: center; gap: 4px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 3px 9px;
  font-size: .72rem; font-weight: 500;
  cursor: pointer; font-family: inherit;
  background: var(--white); color: var(--text2);
  transition: background .12s, border-color .12s, color .12s;
  white-space: nowrap;
}
.sf-btn:hover { background: var(--grey-light); }
.sf-btn.active-all     { background: var(--text); color: #fff; border-color: var(--text); }
.sf-btn.active-added   { background: var(--green); color: #fff; border-color: var(--green); }
.sf-btn.active-removed { background: var(--red);   color: #fff; border-color: var(--red); }
.sf-btn.active-modified{ background: var(--orange); color: #fff; border-color: var(--orange); }
.sf-btn .sf-dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

/* ── Detail panel ── */
.detail-panel {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
  display: none;
}
.detail-panel.open { display: block; }

.detail-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--grey-light);
  border-bottom: 1px solid var(--border);
}
.detail-title { font-size: .9rem; font-weight: 500; flex: 1; min-width: 0; word-break: break-word; }
.detail-badge {
  flex-shrink: 0;
  font-size: .7rem; font-weight: 600; border-radius: 3px;
  padding: 2px 7px; text-transform: uppercase; letter-spacing: .04em;
}
.detail-badge.added    { background: var(--green-light); color: var(--green); }
.detail-badge.removed  { background: var(--red-light);   color: var(--red); }
.detail-badge.modified { background: var(--orange-light); color: var(--orange); }
.detail-badge.unchanged{ display: none; }
.detail-close {
  flex-shrink: 0;
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; cursor: pointer;
  color: var(--text2); font-size: .9rem;
  transition: background .15s;
  border: none; background: transparent;
}
.detail-close:hover { background: var(--border); }

/* Two-column config view */
.detail-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.detail-col { min-width: 0; }
.detail-col + .detail-col { border-left: 1px solid var(--border); }

.detail-col-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: #fafafa;
  border-bottom: 1px solid var(--border);
  font-size: .72rem;
  font-weight: 500;
  color: var(--text2);
}
.detail-col-header .ver-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--blue); }
.detail-col-header .ver-dot.b { background: #7627bb; }

.config-body { padding: 4px 0; }

.prop-row {
  display: flex;
  align-items: baseline;
  gap: 0;
  padding: 6px 14px;
  border-bottom: 1px solid #f8f9fa;
}
.prop-row:last-child { border-bottom: none; }
.prop-row.changed-del { background: #fff0ee; }
.prop-row.changed-add { background: #f0fff4; }

.prop-key {
  flex-shrink: 0;
  width: 38%;
  font-size: .75rem;
  color: var(--text2);
  padding-right: 8px;
  word-break: break-word;
  padding-top: 1px;
}
.prop-val {
  flex: 1;
  font-size: .78rem;
  color: var(--text);
  min-width: 0;
  word-break: break-word;
}

/* value types */
.v-str  { color: var(--text); }
.v-num  { color: #188038; font-family: 'Roboto Mono', monospace; }
.v-bool { color: #7627bb; font-family: 'Roboto Mono', monospace; }
.v-null { color: var(--text2); font-style: italic; }

.v-list { list-style: none; padding: 0; margin: 0; }
.v-list li {
  display: flex; align-items: baseline; gap: 5px;
  padding: 1px 0;
  font-size: .78rem; color: var(--text);
}
.v-list li::before { content: "•"; color: var(--text2); flex-shrink: 0; }

.v-params { display: flex; flex-direction: column; gap: 2px; }
.v-param  { display: flex; align-items: baseline; gap: 6px; }
.v-param-key {
  font-size: .72rem; color: var(--text2);
  background: var(--grey-light); border-radius: 3px;
  padding: 1px 5px; flex-shrink: 0; white-space: nowrap;
}
.v-param-val { font-size: .78rem; color: var(--text); }

.v-obj { display: flex; flex-direction: column; gap: 2px; }
.v-obj-entry { font-size: .75rem; color: var(--text2); }
.v-obj-entry span { color: var(--text); }

.detail-absent {
  padding: 40px 16px;
  text-align: center;
  color: var(--text2);
  font-size: .8rem;
  font-style: italic;
}

/* no-diff banner */
.no-diff {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 48px;
  text-align: center;
  color: var(--text2);
  box-shadow: var(--shadow);
}
.no-diff svg { display: block; margin: 0 auto 12px; }

/* ── Settings modal ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 500;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 80px;
}
.modal-overlay.open { display: flex; }
.modal-panel {
  background: var(--white);
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0,0,0,.2);
  width: 540px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 120px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-header {
  display: flex; align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-header h2 { font-size: .95rem; font-weight: 500; flex: 1; }
.modal-close {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; border: none; background: transparent;
  color: var(--text2); cursor: pointer; font-size: .9rem;
}
.modal-close:hover { background: var(--grey-light); }
.modal-body {
  overflow-y: auto;
  padding: 0;
  flex: 1;
}
.modal-section {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-section:last-child { border-bottom: none; }
.modal-section-title {
  font-size: .8rem; font-weight: 600;
  color: var(--text); margin-bottom: 4px;
}
.modal-section-desc {
  font-size: .75rem; color: var(--text2); margin-bottom: 12px;
}

/* Chips (excluded fields) */
.chip-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.ex-chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--blue-light); color: var(--blue);
  border: 1px solid #c5d8fb;
  border-radius: 14px; padding: 3px 8px 3px 10px;
  font-size: .75rem; font-family: 'Roboto Mono', monospace;
}
.ex-chip button {
  border: none; background: transparent;
  color: var(--blue); cursor: pointer;
  font-size: .75rem; padding: 0; line-height: 1;
  opacity: .7;
}
.ex-chip button:hover { opacity: 1; }

/* Add-row */
.add-row {
  display: flex; gap: 6px; align-items: center; flex-wrap: wrap;
}
.add-row input, .add-row select {
  border: 1px solid var(--border);
  border-radius: 4px; padding: 5px 8px;
  font-size: .78rem; font-family: inherit;
  color: var(--text); background: var(--white); outline: none;
}
.add-row input:focus, .add-row select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(26,115,232,.15);
}
.add-row input.wide { flex: 1; min-width: 120px; }
.add-row .add-btn {
  background: var(--blue); color: #fff; border: none;
  border-radius: 4px; padding: 5px 12px;
  font-size: .78rem; font-weight: 500; cursor: pointer;
  font-family: inherit; white-space: nowrap;
}
.add-row .add-btn:hover { background: var(--blue-dark); }

/* Entity rule rows */
.rule-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.rule-row {
  display: flex; align-items: center; gap: 6px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; padding: 7px 10px;
  font-size: .78rem;
}
.rule-row .rule-field { color: var(--text2); font-family: 'Roboto Mono', monospace; }
.rule-row .rule-op    { color: var(--text2); }
.rule-row .rule-val   { font-weight: 500; color: var(--text); flex: 1; font-family: 'Roboto Mono', monospace; word-break: break-all; }
.rule-row .rule-del   {
  border: none; background: transparent; color: var(--text2);
  cursor: pointer; font-size: .8rem; padding: 2px 4px; border-radius: 3px;
  flex-shrink: 0;
}
.rule-row .rule-del:hover { background: var(--red-light); color: var(--red); }
.ex-active-badge {
  display: none;
  background: var(--orange-light); color: var(--orange);
  border: 1px solid #f9d9a5; border-radius: 10px;
  font-size: .7rem; font-weight: 600; padding: 2px 8px;
  margin-left: 8px; vertical-align: middle;
}
.ex-active-badge.show { display: inline; }

/* Settings trigger button */
.settings-btn {
  display: inline-flex; align-items: center; gap: 5px;
  border: 1px solid var(--border); border-radius: 4px;
  background: var(--white); color: var(--text2);
  padding: 4px 10px; font-size: .75rem; cursor: pointer;
  font-family: inherit; transition: background .12s;
  white-space: nowrap;
}
.settings-btn:hover { background: var(--grey-light); }
.settings-btn.has-rules { border-color: var(--orange); color: var(--orange); }

/* ── Upload page no result ── */
@media (max-width: 680px) {
  .list-panels { grid-template-columns: 1fr; }
  .list-panel + .list-panel { border-left: none; border-top: 1px solid var(--border); }
  .detail-cols { grid-template-columns: 1fr; }
  .detail-col + .detail-col { border-left: none; border-top: 1px solid var(--border); }
}