:root {
  --blue: #003399;
  --blue-2: #0b4bbb;
  --accent: #e6effe;
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --canvas: #f9fafb;
  --white: #fff;
  --green: #10b981;
  --orange: #f59e0b;
  --red: #ef4444;
  --nav: #071c48;
  --radius: 12px;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: "Open Sans", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

button, input {
  font: inherit;
}

button {
  cursor: pointer;
}

.mono {
  font-family: "Roboto Mono", monospace;
  font-size: 13px;
}

.app {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--nav);
  color: #dbe7ff;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 8px 28px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: #fff;
  color: var(--blue);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 17px;
}

.brand-name {
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.4px;
}

.brand small {
  display: block;
  font-size: 11px;
  color: #8fa7d6;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nav-label {
  padding: 0 12px;
  margin: 12px 0 7px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #7890bd;
}

.nav-button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 11px;
  border: 0;
  background: transparent;
  color: #c7d5f0;
  padding: 11px 12px;
  border-radius: 8px;
  text-align: left;
  margin: 2px 0;
}

.nav-button svg {
  width: 18px;
  height: 18px;
}

.nav-button:hover,
.nav-button.active {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.nav-button.active {
  box-shadow: inset 3px 0 0 #65a2ff;
}

.sidebar-foot {
  margin-top: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  padding: 18px 10px 2px;
}

.system-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: #aebfdf;
  margin: 7px 0;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  display: inline-block;
}

/* Main Content & Topbar */
.main {
  min-width: 0;
}

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

.title {
  font-size: 20px;
  font-weight: 700;
  color: var(--blue);
}

.title span {
  color: #63708b;
  font-weight: 400;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f3f4f6;
  border: 1px solid #e6e8ec;
  padding: 8px 11px;
  border-radius: 8px;
  color: #6b7280;
  min-width: 220px;
}

.search input {
  border: 0;
  outline: 0;
  background: transparent;
  width: 100%;
  color: var(--ink);
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: var(--blue);
  font-weight: 700;
}

.content {
  padding: 24px 28px 40px;
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 13px;
}

.section-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
}

.eyebrow {
  font-size: 12px;
  color: var(--muted);
  margin-top: 3px;
}

.updated {
  font-size: 12px;
  color: var(--muted);
}

/* Pipeline */
.pipeline {
  display: grid;
  grid-template-columns: 1fr 24px 1fr 24px 1fr 24px 1fr;
  align-items: stretch;
  margin-bottom: 22px;
}

.stage {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 17px;
  min-width: 0;
  box-shadow: var(--shadow);
}

.stage-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.stage-number {
  font-family: "Roboto Mono", monospace;
  font-size: 11px;
  font-weight: 500;
  color: var(--blue);
  background: var(--accent);
  padding: 4px 7px;
  border-radius: 6px;
}

.stage h3 {
  font-size: 15px;
  margin: 7px 0 4px;
}

.stage p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.stage-metrics {
  display: flex;
  gap: 14px;
  margin-top: 14px;
}

.metric strong {
  display: block;
  font-family: "Roboto Mono", monospace;
  font-size: 18px;
}

.metric span {
  font-size: 11px;
  color: var(--muted);
}

.connector {
  position: relative;
}

.connector:before {
  content: "";
  position: absolute;
  top: 50%;
  left: 4px;
  right: 4px;
  height: 2px;
  background: #bfd1f0;
}

.connector:after {
  content: "";
  position: absolute;
  top: calc(50% - 4px);
  right: 3px;
  width: 8px;
  height: 8px;
  border-top: 2px solid #7d9fd8;
  border-right: 2px solid #7d9fd8;
  transform: rotate(45deg);
}

/* Upload Card */
.upload-card {
  display: grid;
  grid-template-columns: minmax(230px, 0.65fr) minmax(420px, 1.35fr);
  gap: 18px;
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  margin-bottom: 22px;
}

.upload-copy h2 {
  font-size: 16px;
  margin: 0 0 4px;
}

.upload-copy p {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
}

.dropzone {
  min-height: 86px;
  border: 1.5px dashed #9db4dc;
  border-radius: 10px;
  background: #f7faff;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 14px 18px;
  color: #52637e;
  transition: 0.15s;
}

.dropzone.drag {
  border-color: var(--blue);
  background: var(--accent);
}

.upload-icon {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: var(--blue);
  font-size: 20px;
  font-weight: 700;
}

.upload-text strong {
  display: block;
  color: var(--ink);
  font-size: 13px;
}

.upload-text span {
  display: block;
  font-size: 11px;
  margin-top: 2px;
}

.upload-button {
  border: 1px solid var(--blue);
  background: #fff;
  color: var(--blue);
  border-radius: 8px;
  padding: 8px 11px;
  font-weight: 700;
  white-space: nowrap;
}

.upload-files {
  grid-column: 2;
  display: none;
  gap: 7px;
  flex-wrap: wrap;
  margin-top: -8px;
}

.upload-files.show {
  display: flex;
}

.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid #d9e2f1;
  background: #f7faff;
  color: #334155;
  border-radius: 7px;
  padding: 6px 9px;
  font-size: 11px;
}

/* Work Area & Tables */
.workarea {
  display: grid;
  grid-template-columns: minmax(620px, 1.15fr) minmax(360px, 0.85fr);
  gap: 18px;
  align-items: start;
}

.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

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

.filters {
  display: flex;
  gap: 7px;
}

.filter {
  border: 1px solid var(--line);
  background: #fff;
  color: #374151;
  border-radius: 7px;
  padding: 7px 10px;
  font-size: 12px;
}

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

.count {
  font-family: "Roboto Mono", monospace;
  font-size: 12px;
  color: var(--muted);
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  white-space: nowrap;
}

th {
  text-align: left;
  padding: 11px 12px;
  background: #f7f8fa;
  color: #687386;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 700;
  border-bottom: 1px solid var(--line);
}

td {
  padding: 13px 12px;
  border-bottom: 1px solid #edf0f3;
  vertical-align: middle;
}

tbody tr {
  cursor: pointer;
  transition: 0.15s;
}

tbody tr:hover {
  background: #f4f7fc;
}

tbody tr.selected {
  background: var(--accent);
  box-shadow: inset 3px 0 0 var(--blue);
}

tbody tr.warning {
  background: #fffaf0;
}

tbody tr.warning.selected {
  background: #fff4d9;
}

.customer {
  font-weight: 600;
  color: #1f2937;
}

.sub {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-top: 2px;
}

.source {
  display: flex;
  align-items: center;
  gap: 6px;
}

.confidence {
  display: flex;
  align-items: center;
  gap: 7px;
}

.bar {
  width: 42px;
  height: 5px;
  border-radius: 9px;
  background: #e5e7eb;
  overflow: hidden;
}

.bar i {
  display: block;
  height: 100%;
  background: var(--green);
}

.bar.warn i {
  background: var(--orange);
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

.status:before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status.ok {
  background: #e8f8f3;
  color: #087f5b;
}

.status.warn {
  background: #fff3d7;
  color: #9a6500;
}

.status.neutral {
  background: #eef1f5;
  color: #64748b;
}

.status.err {
  background: #fdecec;
  color: #bf3030;
}

.more {
  border: 0;
  background: transparent;
  color: var(--blue);
  font-weight: 700;
}

/* Detail Pane */
.detail {
  position: sticky;
  top: 94px;
}

.detail-head {
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.detail-head h2 {
  font-size: 16px;
  margin: 0;
}

.detail-tabs {
  display: flex;
  border-bottom: 1px solid var(--line);
  padding: 0 16px;
}

.detail-tab {
  padding: 11px 10px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  border-bottom: 2px solid transparent;
}

.detail-tab.active {
  color: var(--blue);
  border-color: var(--blue);
  font-weight: 700;
}

.split {
  display: grid;
  grid-template-columns: 0.82fr 1.18fr;
  min-height: 420px;
}

.document {
  background: #eef1f5;
  padding: 14px;
  border-right: 1px solid var(--line);
}

.paper {
  background: #fff;
  box-shadow: 0 4px 14px rgba(31, 41, 55, 0.12);
  height: 100%;
  min-height: 390px;
  padding: 20px 18px;
  color: #687386;
  font-size: 8px;
  position: relative;
}

.paper-logo {
  font-size: 11px;
  font-weight: 700;
  color: #334155;
  margin-bottom: 28px;
}

.paper h4 {
  font-size: 10px;
  color: #111827;
  margin: 0 0 15px;
}

.paper-line {
  height: 4px;
  background: #d8dde5;
  border-radius: 2px;
  margin: 8px 0;
}

.paper-line.short {
  width: 58%;
}

.paper-table {
  border: 1px solid #d7dce4;
  margin-top: 25px;
}

.paper-row {
  height: 24px;
  border-bottom: 1px solid #e1e5ea;
  display: grid;
  grid-template-columns: 1fr 0.5fr;
}

.paper-row:last-child {
  border: 0;
}

.paper-row span:first-child {
  border-right: 1px solid #e1e5ea;
}

.zoom {
  position: absolute;
  bottom: 11px;
  right: 11px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 3px 6px;
  color: #475569;
  font-size: 9px;
}

.form {
  padding: 14px 16px;
  max-height: 470px;
  overflow: auto;
}

.group-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
  font-weight: 700;
  margin: 2px 0 10px;
}

.field {
  margin-bottom: 11px;
}

.field label {
  display: block;
  font-size: 11px;
  color: #5f6b7a;
  margin-bottom: 4px;
}

.field input {
  width: 100%;
  border: 1px solid #dce1e8;
  border-radius: 7px;
  padding: 8px 9px;
  color: #111827;
  outline: none;
  background: #fff;
  font-size: 13px;
}

.field input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0, 51, 153, 0.08);
}

.field.missing input {
  border-color: #f1b849;
  background: #fffaf0;
}

.field-note {
  display: flex;
  align-items: center;
  gap: 5px;
  color: #a66c00;
  font-size: 10px;
  margin-top: 4px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.approval {
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  background: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
}

.approval-info {
  font-size: 11px;
  color: var(--muted);
  margin-right: auto;
}

.primary {
  border: 0;
  border-radius: 8px;
  background: var(--blue);
  color: #fff;
  font-weight: 700;
  padding: 10px 14px;
  box-shadow: 0 4px 10px rgba(0, 51, 153, 0.18);
}

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

.primary:disabled {
  background: #aab5c8;
  cursor: not-allowed;
  box-shadow: none;
}

.secondary {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: #374151;
  padding: 9px 11px;
}

.mobile-menu {
  display: none;
  border: 0;
  background: transparent;
  color: var(--blue);
  padding: 4px;
}

.notice {
  display: none;
  padding: 10px 14px;
  background: #ecfdf5;
  color: #047857;
  border-bottom: 1px solid #b7edd7;
  font-size: 12px;
}

.notice.show {
  display: block;
}

/* Responsive Media Queries */
@media (max-width: 1200px) {
  .workarea {
    grid-template-columns: 1fr;
  }
  .detail {
    position: relative;
    top: 0;
  }
  .split {
    grid-template-columns: 280px 1fr;
  }
  .stage {
    padding: 14px 13px;
  }
  .stage-metrics {
    gap: 10px;
  }
}

@media (max-width: 800px) {
  .app {
    grid-template-columns: 1fr;
  }
  .sidebar {
    display: none;
  }
  .mobile-menu {
    display: block;
  }
  .topbar {
    padding: 0 16px;
  }
  .content {
    padding: 18px 14px;
  }
  .search {
    display: none;
  }
  .pipeline {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .connector {
    display: none;
  }
  .workarea {
    display: block;
  }
  .card {
    margin-bottom: 16px;
  }
  .table-wrap {
    max-width: 100vw;
  }
  .split {
    grid-template-columns: 1fr;
  }
  .document {
    display: none;
  }
  .form {
    max-height: none;
  }
  .title span {
    display: none;
  }
  .upload-card {
    grid-template-columns: 1fr;
  }
  .upload-files {
    grid-column: 1;
  }
  .dropzone {
    align-items: flex-start;
    flex-direction: column;
  }
}