:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #15202b;
  --muted: #657282;
  --line: #d9e0e7;
  --blue: #1e63d6;
  --blue-dark: #164ba5;
  --teal: #0f766e;
  --amber: #b7791f;
  --red: #c24141;
  --green: #1f7a4d;
  --shadow: 0 16px 40px rgba(17, 29, 48, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(90deg, rgba(30, 99, 214, 0.05) 0, rgba(30, 99, 214, 0.05) 1px, transparent 1px),
    linear-gradient(0deg, rgba(15, 118, 110, 0.04) 0, rgba(15, 118, 110, 0.04) 1px, transparent 1px),
    var(--bg);
  background-size: 42px 42px;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  cursor: pointer;
  transition: transform 160ms ease, background-color 160ms ease, border-color 160ms ease;
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.app-shell {
  max-width: 1480px;
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 4px 0 22px;
}

.topbar h1,
.section-toolbar h2 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: 30px;
  line-height: 1.16;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--teal);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.topbar-actions,
.button-row,
.toolbar-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.primary-button {
  color: #fff;
  background: var(--blue);
}

.primary-button:hover:not(:disabled) {
  background: var(--blue-dark);
}

.secondary-button,
.ghost-button {
  color: var(--ink);
  background: #eef2f6;
}

.secondary-button:hover,
.ghost-button:hover {
  background: #e2e8ef;
}

.ghost-button {
  background: transparent;
  border: 1px solid var(--line);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(310px, 420px) minmax(0, 1fr);
  gap: 18px;
}

.control-panel,
.overview-panel,
.table-section,
.insights-section {
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.control-panel {
  padding: 18px;
  align-self: start;
}

.overview-panel {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 18px;
  padding: 18px;
}

.table-section,
.insights-section {
  grid-column: 1 / -1;
}

.upload-zone {
  border: 1px dashed #9aa9b8;
  border-radius: 8px;
  background: #fbfcfd;
  min-height: 104px;
  display: grid;
  place-items: center;
}

.upload-zone.is-over {
  border-color: var(--blue);
  background: #f1f6ff;
}

.upload-zone input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.upload-zone label {
  width: 100%;
  min-height: 104px;
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
}

.upload-zone strong,
.upload-zone small {
  display: block;
}

.upload-zone small {
  margin-top: 3px;
  color: var(--muted);
  line-height: 1.35;
}

.upload-mark {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #deefe9;
  color: var(--teal);
  font-weight: 800;
}

.control-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 16px;
}

label {
  display: grid;
  gap: 6px;
  color: #334154;
  font-size: 13px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: #fff;
  color: var(--ink);
}

input:focus,
select:focus,
button:focus-visible {
  outline: 3px solid rgba(30, 99, 214, 0.18);
  outline-offset: 1px;
}

.toggle-row {
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 2px;
}

.toggle-row input {
  width: 18px;
  min-height: 18px;
}

.button-row {
  margin-top: 16px;
}

.button-row button {
  flex: 1;
}

.progress-wrap {
  margin-top: 16px;
}

.progress-track {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7edf4;
}

.progress-bar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--blue), var(--teal));
  transition: width 180ms ease;
}

#statusText {
  min-height: 22px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.statement-visual {
  border: 1px solid #cbd8e5;
  border-radius: 8px;
  background: #fdfefe;
  padding: 16px;
  min-height: 210px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 18px;
}

.visual-header {
  display: flex;
  gap: 8px;
}

.visual-header span {
  height: 10px;
  border-radius: 8px;
  background: #c4d5e7;
}

.visual-header span:nth-child(1) {
  width: 42%;
}

.visual-header span:nth-child(2) {
  width: 18%;
  background: #d8c68f;
}

.visual-header span:nth-child(3) {
  width: 26%;
  background: #a8d8cf;
}

.visual-graph {
  display: flex;
  align-items: end;
  gap: 10px;
  min-height: 88px;
  padding: 10px 4px 0;
  border-bottom: 1px solid #dce5ee;
}

.visual-graph i {
  flex: 1;
  min-width: 18px;
  border-radius: 6px 6px 0 0;
  background: #1e63d6;
}

.visual-graph i:nth-child(2n) {
  background: #0f766e;
}

.visual-graph i:nth-child(3n) {
  background: #b7791f;
}

.visual-lines {
  display: grid;
  gap: 9px;
}

.visual-lines span {
  height: 9px;
  border-radius: 999px;
  background: #e3eaf1;
}

.visual-lines span:nth-child(1) {
  width: 94%;
}

.visual-lines span:nth-child(2) {
  width: 78%;
}

.visual-lines span:nth-child(3) {
  width: 86%;
}

.visual-lines span:nth-child(4) {
  width: 64%;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
}

.metric-card {
  min-height: 94px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfd;
}

.metric-card span,
.summary-strip span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.metric-card strong {
  display: block;
  margin-top: 10px;
  font-size: 24px;
  line-height: 1.15;
}

.summary-strip {
  grid-column: 2;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  align-self: end;
}

.summary-strip div {
  border-left: 3px solid var(--line);
  padding: 4px 0 4px 12px;
}

.summary-strip strong {
  display: block;
  margin-top: 5px;
  font-size: 18px;
}

.section-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.section-toolbar h2 {
  font-size: 20px;
}

.section-toolbar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.toolbar-controls {
  justify-content: flex-end;
}

.toolbar-controls input {
  width: 220px;
}

.toolbar-controls select {
  width: 190px;
}

.table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
}

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

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

th {
  color: #3d4b5e;
  background: #f7f9fb;
  font-size: 12px;
  text-transform: uppercase;
}

td input,
td select {
  min-height: 36px;
  border-radius: 6px;
}

.date-input {
  width: 134px;
}

.amount-input {
  width: 112px;
  text-align: right;
}

.narration-input {
  min-width: 360px;
}

.confidence-pill {
  display: inline-flex;
  min-width: 64px;
  height: 28px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  background: #edf4ff;
  color: var(--blue-dark);
}

.confidence-pill.warn {
  background: #fff6dc;
  color: #8a5a0d;
}

.confidence-pill.bad {
  background: #ffeded;
  color: #a92f2f;
}

.delete-button {
  width: 36px;
  min-height: 36px;
  padding: 0;
  background: #f4eaea;
  color: var(--red);
}

.empty-cell {
  height: 120px;
  color: var(--muted);
  text-align: center;
}

.insight-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 18px;
}

.insight-item {
  min-height: 96px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfd;
}

.insight-item strong {
  display: block;
  margin-bottom: 8px;
}

.insight-item span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.insight-item.warn {
  border-color: #e6cd86;
  background: #fffaf0;
}

.insight-item.good {
  border-color: #9fd2bd;
  background: #f2fbf7;
}

.insight-item.danger {
  border-color: #e6b1b1;
  background: #fff6f6;
}

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

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

  .summary-strip {
    grid-column: 1;
  }

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

@media (max-width: 760px) {
  .app-shell {
    padding: 14px;
  }

  .topbar,
  .section-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions,
  .toolbar-controls,
  .button-row {
    width: 100%;
  }

  .topbar-actions button,
  .toolbar-controls input,
  .toolbar-controls select,
  .toolbar-controls button,
  .button-row button {
    width: 100%;
  }

  .control-grid,
  .metric-grid,
  .summary-strip,
  .insight-list {
    grid-template-columns: 1fr;
  }

  .topbar h1 {
    font-size: 24px;
  }
}
