:root {
  --navy: #084175;
  --navy-2: #0b487c;
  --cyan: #3fbeeb;
  --green: #00ce7d;
  --mist: #d3dde6;
  --paper: #f6f9fb;
  --surface: #ffffff;
  --ink: #162333;
  --muted: #637381;
  --line: #d9e3ea;
  --warning: #f5a623;
  --warning-bg: #fff3d8;
  --danger: #d94b3d;
  --danger-bg: #ffe8e5;
  --blue-bg: #e7f6fd;
  --green-bg: #e4fbf2;
  --shadow: 0 18px 45px rgba(8, 65, 117, 0.12);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Onest, Roboto, Arial, sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

.topbar {
  min-height: 72px;
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

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

.brand img {
  width: 172px;
  max-width: 40vw;
  height: auto;
  display: block;
}

.brand div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.brand strong {
  font-size: 18px;
  line-height: 1.2;
  color: var(--navy);
}

.brand span,
.mode-pill,
.sheet-info,
.metric span {
  color: var(--muted);
  font-size: 13px;
}

.mode-pill {
  border: 1px solid var(--mist);
  background: #f8fbfd;
  border-radius: 8px;
  padding: 9px 12px;
  white-space: nowrap;
}

.app {
  width: min(1680px, calc(100vw - 32px));
  margin: 18px auto 34px;
  display: grid;
  gap: 14px;
}

.summary,
.workspace,
.empty-state {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.landing {
  min-height: 360px;
  padding: 34px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(420px, 560px);
  gap: 32px;
  align-items: center;
  background: var(--navy);
  color: #fff;
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.landing-copy {
  max-width: 720px;
  display: grid;
  gap: 18px;
}

.eyebrow {
  color: var(--cyan);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.landing h1 {
  margin: 0;
  font-size: clamp(40px, 6vw, 76px);
  line-height: 0.96;
  letter-spacing: 0;
}

.landing p {
  margin: 0;
  max-width: 680px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 18px;
  line-height: 1.55;
}

.landing-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.landing-facts span {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 8px;
  padding: 0 11px;
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  font-size: 13px;
}

.upload-panel {
  padding: 18px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  align-items: stretch;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.18);
}

.has-result .landing {
  min-height: auto;
  padding: 12px;
  grid-template-columns: 1fr;
  background: var(--surface);
  border: 1px solid var(--line);
}

.has-result .landing-copy {
  display: none;
}

.has-result .upload-panel {
  padding: 0;
  grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr) auto;
  align-items: stretch;
  border: 0;
  box-shadow: none;
}

.has-result .panel-title {
  display: none;
}

.has-result .file-box {
  min-height: 58px;
}

.panel-title {
  display: grid;
  gap: 4px;
  padding-bottom: 4px;
}

.panel-title span {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.panel-title strong {
  color: var(--navy);
  font-size: 22px;
  line-height: 1.2;
}

.file-box {
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  display: grid;
  align-content: center;
  gap: 8px;
  cursor: pointer;
  background: #fbfdfe;
  transition: border-color 0.16s ease, background 0.16s ease;
}

.file-box:hover,
.file-box:focus-within {
  border-color: var(--cyan);
  background: var(--blue-bg);
}

.file-box span {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.file-box strong {
  color: var(--navy);
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-box input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-content: center;
}

.primary-button,
.ghost-button,
.filter {
  border-radius: 8px;
  min-height: 40px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease, border-color 0.12s ease;
}

.primary-button {
  background: var(--navy);
  color: #fff;
  padding: 0 20px;
  font-weight: 700;
}

.primary-button:hover {
  background: var(--navy-2);
}

.ghost-button {
  background: #fff;
  color: var(--navy);
  border-color: var(--mist);
  padding: 0 16px;
  font-weight: 700;
}

.primary-button:active,
.ghost-button:active,
.filter:active {
  transform: translateY(1px);
}

.summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 0;
  overflow: hidden;
}

.metric {
  padding: 15px 18px;
  border-right: 1px solid var(--line);
  display: grid;
  gap: 5px;
}

.metric:last-child {
  border-right: 0;
}

.metric strong {
  font-size: 28px;
  line-height: 1;
  color: var(--navy);
}

.metric.is-warning strong {
  color: #a86a00;
}

.metric.is-danger strong {
  color: var(--danger);
}

.metric.is-blue strong {
  color: #007ab0;
}

.workspace {
  overflow: hidden;
}

.workspace-toolbar {
  padding: 12px 14px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, auto);
  gap: 12px;
  align-items: center;
  border-bottom: 1px solid var(--line);
}

.sheet-info {
  line-height: 1.35;
  min-width: 0;
}

.workspace .sheet-info {
  display: none;
}

.filter-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.legend {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.legend span {
  min-height: 30px;
  padding: 0 9px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--navy);
  background: #fff;
  font-size: 12px;
}

.mark {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
}

.mark-item_number {
  background: #8b5cf6;
}

.mark-quantity {
  background: var(--warning);
}

.mark-money {
  background: var(--green);
}

.mark-text {
  background: var(--cyan);
}

.mark-missing,
.mark-extra {
  background: var(--danger);
}

.mark-moved {
  background: var(--green);
}

.filter {
  min-height: 34px;
  padding: 0 11px;
  color: var(--navy);
  background: #fff;
  border-color: var(--mist);
  font-size: 13px;
}

.filter.is-active {
  color: #fff;
  background: var(--navy);
  border-color: var(--navy);
}

.search {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  outline: none;
}

.toolbar-actions {
  display: grid;
  grid-template-columns: auto minmax(220px, 300px);
  gap: 8px;
  align-items: center;
}

.all-diffs-button {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--navy);
  border-radius: 8px;
  background: var(--navy);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

.all-diffs-button:hover {
  background: var(--navy-2);
}

.search:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(63, 190, 235, 0.15);
}

.split-title,
.split-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.split-title {
  background: var(--navy);
  color: #fff;
}

.split-title > div {
  min-width: 0;
  padding: 12px 14px;
  display: flex;
  align-items: baseline;
  gap: 10px;
  border-right: 1px solid rgba(255, 255, 255, 0.22);
}

.split-title > div:last-child {
  border-right: 0;
}

.split-title span {
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
  text-transform: uppercase;
}

.split-title strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sheet-tabs {
  min-height: 38px;
  padding: 7px 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: #fbfdfe;
}

.sheet-tab {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  max-width: 360px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #fff;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sheet-tab.is-active {
  color: var(--navy);
  border-color: rgba(63, 190, 235, 0.55);
  background: var(--blue-bg);
  font-weight: 700;
}

.full-view {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  background: var(--navy);
  border-bottom: 1px solid var(--line);
}

.sheet-panel {
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.sheet-panel:first-child {
  box-shadow: inset 6px 0 0 var(--cyan);
}

.sheet-panel:last-child {
  box-shadow: inset 6px 0 0 var(--green);
}

.sheet-caption {
  min-height: 44px;
  padding: 10px 14px 10px 20px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  color: var(--navy);
  border-bottom: 1px solid var(--line);
  background: #f8fbfd;
}

.sheet-caption span {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.sheet-scroll {
  height: min(68vh, 760px);
  min-height: 420px;
  overflow: auto;
  background: #fff;
}

.excel-grid {
  display: grid;
  align-items: stretch;
  width: max-content;
  min-width: 100%;
  color: #233447;
  font-size: 12px;
}

.excel-corner,
.excel-col-head,
.excel-row-head,
.excel-cell {
  min-height: 34px;
  border-right: 1px solid #e2e9ee;
  border-bottom: 1px solid #e2e9ee;
}

.excel-corner,
.excel-col-head {
  position: sticky;
  top: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--navy);
  background: #eef5f8;
  font-weight: 800;
}

.excel-corner {
  left: 0;
  z-index: 6;
}

.excel-row-head {
  position: sticky;
  left: 0;
  z-index: 3;
  background: #f8fbfd;
  color: var(--muted);
  font-weight: 700;
  text-align: right;
  padding: 0 8px;
}

.excel-cell,
.excel-row-head {
  border-top: 0;
  border-left: 0;
  cursor: pointer;
}

.excel-cell {
  background: #fff;
  color: var(--ink);
  padding: 6px 8px;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.excel-cell:hover,
.excel-row-head:hover {
  box-shadow: inset 0 0 0 2px rgba(63, 190, 235, 0.45);
}

.excel-cell.is-numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.excel-cell.row-changed {
  background: #fffdf7;
}

.excel-row-head.row-changed {
  color: #8c5b00;
  background: #fff3d8;
}

.excel-cell.row-missing,
.excel-row-head.row-missing {
  background: var(--danger-bg);
}

.excel-cell.row-extra,
.excel-row-head.row-extra {
  background: #edf7ff;
}

.excel-cell.row-moved,
.excel-row-head.row-moved {
  box-shadow: inset 4px 0 0 var(--green);
}

.excel-cell.cell-number {
  background: var(--warning-bg);
  box-shadow: inset 0 0 0 2px rgba(245, 166, 35, 0.5);
  font-weight: 800;
}

.excel-cell.cell-item_number {
  background: #f0e9ff;
  box-shadow: inset 0 0 0 2px rgba(139, 92, 246, 0.52);
  font-weight: 800;
}

.excel-cell.cell-quantity {
  background: var(--warning-bg);
  box-shadow: inset 0 0 0 2px rgba(245, 166, 35, 0.5);
  font-weight: 800;
}

.excel-cell.cell-money {
  background: var(--green-bg);
  box-shadow: inset 0 0 0 2px rgba(0, 206, 125, 0.42);
  font-weight: 800;
}

.excel-cell.cell-text {
  background: var(--blue-bg);
  box-shadow: inset 0 0 0 2px rgba(63, 190, 235, 0.5);
  font-weight: 800;
}

.excel-cell.is-search-hit {
  box-shadow: inset 0 0 0 2px var(--green);
}

.excel-cell.is-selected-row,
.excel-row-head.is-selected-row {
  background: #dff4fd !important;
  box-shadow: inset 0 3px 0 var(--navy), inset 0 -3px 0 var(--navy);
  color: var(--navy);
  font-weight: 800;
}

.excel-row-head.is-selected-row {
  background: #fff3d8 !important;
  box-shadow: inset 0 3px 0 var(--navy), inset 0 -3px 0 var(--navy), inset 4px 0 0 var(--navy);
}

.excel-cell.is-selected-row:first-of-type {
  box-shadow: inset 0 3px 0 var(--navy), inset 0 -3px 0 var(--navy), inset 3px 0 0 var(--navy);
}

.details-panel {
  padding: 14px;
  display: grid;
  gap: 12px;
  background: #fbfdfe;
  border-top: 0;
}

.details-panel > strong,
.details-head strong {
  color: var(--navy);
  font-size: 16px;
}

.details-panel > span,
.details-head span {
  color: var(--muted);
  font-size: 13px;
}

.details-head {
  display: grid;
  gap: 4px;
}

.details-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.details-grid {
  display: grid;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.all-diffs-list {
  display: grid;
  gap: 8px;
  max-height: 360px;
  overflow: auto;
}

.all-diff-row {
  width: 100%;
  display: grid;
  grid-template-columns: 150px 260px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.all-diff-row:hover {
  border-color: var(--cyan);
  box-shadow: inset 0 0 0 1px rgba(63, 190, 235, 0.45);
}

.all-diff-row > strong {
  color: var(--navy);
  white-space: nowrap;
}

.all-diff-row > span {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.all-diff-row > em {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  color: var(--muted);
  font-style: normal;
  font-size: 12px;
}

.detail-row {
  display: grid;
  grid-template-columns: minmax(140px, 0.7fr) minmax(0, 1fr) minmax(0, 1fr);
  border-bottom: 1px solid var(--line);
}

.detail-row:last-child {
  border-bottom: 0;
}

.detail-row > span,
.detail-row > strong {
  padding: 9px 10px;
  border-right: 1px solid var(--line);
  font-size: 13px;
  line-height: 1.35;
  word-break: break-word;
}

.detail-row > :last-child {
  border-right: 0;
}

.detail-header {
  background: #eef5f8;
  color: var(--navy);
  font-weight: 800;
}

.sheet-side {
  min-width: 0;
  overflow-x: auto;
  border-right: 1px solid var(--line);
}

.sheet-side:last-child {
  border-right: 0;
}

.cells {
  display: grid;
  grid-template-columns: 68px minmax(260px, 2fr) 124px 64px 88px 106px 106px 118px 118px 118px;
  min-width: 1180px;
}

.cells-header {
  background: #eef5f8;
  color: var(--navy);
  font-weight: 700;
  position: sticky;
  top: 73px;
  z-index: 3;
}

.cell {
  min-height: 42px;
  padding: 9px 10px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
}

.cell:last-child {
  border-right: 0;
}

.cell.is-name {
  align-items: flex-start;
  white-space: normal;
}

.cell.is-number {
  justify-content: flex-end;
  font-variant-numeric: tabular-nums;
}

.cell.is-diff {
  background: var(--warning-bg);
  box-shadow: inset 0 0 0 1px rgba(245, 166, 35, 0.45);
}

.row-meta {
  grid-column: 1 / -1;
  padding: 7px 14px;
  display: flex;
  gap: 8px;
  align-items: center;
  min-height: 34px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.row-meta strong {
  color: var(--navy);
  font-size: 13px;
}

.tag {
  border-radius: 8px;
  padding: 3px 7px;
  font-size: 12px;
  color: var(--navy);
  background: var(--blue-bg);
}

.tag.is-item_number {
  color: #5b21b6;
  background: #f0e9ff;
}

.tag.is-quantity,
.tag.is-text {
  color: #825300;
  background: var(--warning-bg);
}

.tag.is-money {
  color: #006b45;
  background: var(--green-bg);
}

.tag.is-text {
  color: #075985;
  background: var(--blue-bg);
}

.tag.is-missing,
.tag.is-extra {
  color: #9f261c;
  background: var(--danger-bg);
}

.tag.is-moved {
  color: #006b45;
  background: var(--green-bg);
}

.diff-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.diff-row.status-missing .sheet-side:first-child .cells,
.diff-row.status-extra .sheet-side:last-child .cells {
  background: var(--danger-bg);
}

.diff-row.status-ok .row-meta {
  display: none;
}

.placeholder {
  min-height: 42px;
  background: #f7fafc;
  border-bottom: 1px solid var(--line);
}

.empty-state {
  padding: 38px;
  display: grid;
  justify-items: center;
  gap: 8px;
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  color: var(--navy);
  font-size: 20px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: min(440px, calc(100vw - 44px));
  background: #172331;
  color: #fff;
  border-radius: 8px;
  padding: 13px 15px;
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.22);
  z-index: 20;
}

[hidden] {
  display: none !important;
}

@media (max-width: 1180px) {
  .landing,
  .workspace-toolbar {
    grid-template-columns: 1fr;
  }

  .landing {
    padding: 26px;
  }

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

  .has-result .upload-panel {
    grid-template-columns: 1fr;
  }

  .filter-row {
    justify-content: flex-start;
  }

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

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

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

  .sheet-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .sheet-scroll {
    height: 520px;
  }
}

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 14px 16px;
  }

  .app {
    width: calc(100vw - 20px);
    margin-top: 10px;
  }

  .landing {
    min-height: auto;
    padding: 22px 14px;
    gap: 22px;
  }

  .landing h1 {
    font-size: 40px;
  }

  .landing p {
    font-size: 15px;
  }

  .brand {
    width: 100%;
  }

  .brand img {
    width: 142px;
  }

  .split-title,
  .split-row,
  .diff-row,
  .detail-row {
    grid-template-columns: 1fr;
  }

  .detail-row > span,
  .detail-row > strong {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .detail-row > :last-child {
    border-bottom: 0;
  }

  .split-title > div:first-child {
    border-bottom: 1px solid rgba(255, 255, 255, 0.22);
  }

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

  .metric {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .metric:last-child {
    border-bottom: 0;
  }
}
