:root {
  color-scheme: light;
  --ink: #17233a;
  --muted: #66758a;
  --line: #d8e1eb;
  --paper: #ffffff;
  --wash: #f4f7fb;
  --green: #1f4e79;
  --green-dark: #0b2545;
  --coral: #c44d3a;
  --gold: #9b6a09;
  --blue: #3b82c4;
  --violet: #52657a;
  --shadow: 0 10px 28px rgba(11, 37, 69, 0.08);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--wash);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.sidebar {
  background: #0b1f3a;
  color: white;
  min-width: 0;
  overflow: hidden;
  padding: 22px 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: white;
  color: var(--green);
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: rgba(255, 255, 255, 0.72);
  margin-top: 3px;
}

.nav {
  display: grid;
  gap: 7px;
}

.nav-item {
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: rgba(255, 255, 255, 0.78);
  padding: 11px 12px;
  text-align: left;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.13);
  color: white;
}

.workspace {
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
  padding: 28px 30px;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--green);
  font-weight: 800;
  font-size: 0.78rem;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1,
h2 {
  letter-spacing: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 2rem;
}

h2 {
  font-size: 1.05rem;
}

.profile-switcher {
  display: flex;
  gap: 7px;
  padding: 5px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.profile-chip {
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  padding: 8px 11px;
}

.profile-chip.active {
  background: var(--green);
  color: white;
}

.identity-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
  padding: 12px 14px;
  background: #eaf3fb;
  border: 1px solid #c9ddf0;
  border-radius: 8px;
}

.identity-strip span {
  color: var(--green-dark);
  font-weight: 800;
}

.identity-strip small {
  color: var(--muted);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 13px;
  margin-bottom: 18px;
}

.metric,
.panel,
.card-tile {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric {
  min-height: 116px;
  padding: 18px;
}

.metric span,
.metric small,
.panel-header p,
.flow-list small,
.issue small,
.duplicate-card small,
.match-row small,
.rule small,
.card-tile small,
.card-tile p {
  color: var(--muted);
}

.metric strong {
  display: block;
  margin: 8px 0 4px;
  font-size: 1.65rem;
}

.metric.urgent strong {
  color: var(--coral);
}

.content-grid,
.split-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
}

.panel {
  padding: 20px;
}

.panel-header {
  margin-bottom: 14px;
}

.panel-header p {
  margin-bottom: 0;
}

.panel-header.with-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.flow-list,
.issue-list,
.rules-list,
.duplicate-list,
.reconciliation-board {
  display: grid;
  gap: 10px;
}

.flow-list article,
.issue,
.rule,
.match-row,
.duplicate-card,
.ocr-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfd;
}

.flow-list strong,
.issue strong,
.rule strong,
.match-row strong,
.duplicate-card strong {
  display: block;
  margin-bottom: 4px;
}

.form-grid {
  display: grid;
  gap: 12px;
}

.two-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: white;
  padding: 10px 11px;
}

.primary-action,
.secondary-action,
.actions button,
.duplicate-card button,
.card-tile button {
  border: 0;
  border-radius: 8px;
  padding: 10px 12px;
  font-weight: 800;
}

.primary-action {
  background: var(--green);
  color: white;
}

.primary-action:hover {
  background: var(--green-dark);
}

.secondary-action,
.actions button,
.duplicate-card button,
.card-tile button {
  background: #eaf3fb;
  color: var(--green-dark);
}

.table-wrap {
  overflow-x: auto;
}

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

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 11px 8px;
  text-align: left;
  font-size: 0.9rem;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
}

.actions {
  display: flex;
  gap: 6px;
}

.actions button[disabled] {
  opacity: 0.45;
  cursor: default;
}

.status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 0.76rem;
  font-weight: 800;
  white-space: nowrap;
}

.status.matched {
  background: #eaf3fb;
  color: var(--green-dark);
}

.status.pending {
  background: #fff7e6;
  color: var(--gold);
}

.status.review,
.status.duplicate {
  background: #fcebe7;
  color: var(--coral);
}

.status.deleted {
  background: #eceff3;
  color: var(--muted);
}

.confidence {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.line-items {
  min-width: 210px;
  line-height: 1.5;
}

.muted-row {
  opacity: 0.58;
}

.ocr-card span,
.ocr-card strong {
  display: block;
}

.photo-preview {
  display: grid;
  min-height: 150px;
  place-items: center;
  border: 1px dashed #a9b8c8;
  border-radius: 8px;
  background: #fbfcfd;
  color: var(--muted);
  overflow: hidden;
  cursor: pointer;
}

.photo-preview:focus,
.photo-preview.dragging {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(59, 130, 196, 0.18);
  outline: 0;
}

.photo-preview img {
  width: 100%;
  max-height: 260px;
  object-fit: contain;
  background: #f7f9fb;
}

.photo-preview span {
  padding: 10px;
  text-align: center;
}

.ocr-card strong {
  margin: 6px 0 12px;
}

.classification-box {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfd;
}

.ocr-progress {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #eef4f8;
  color: var(--blue);
  font-weight: 800;
}

.classification-box h3 {
  margin: 0 0 6px;
  font-size: 0.95rem;
}

.classification-box p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.warning-text {
  color: var(--coral);
}

dl {
  display: grid;
  gap: 8px;
  margin: 0;
}

dl div,
.match-detail {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

dd {
  margin: 0;
  font-weight: 800;
}

.match-detail {
  margin-top: 10px;
  padding: 10px;
  border-radius: 8px;
  background: #eef4f8;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.card-tile {
  padding: 18px;
}

.role {
  margin: 8px 0;
  color: var(--violet);
  font-weight: 900;
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
  }

  .nav {
    grid-template-columns: repeat(7, max-content);
    max-width: 100%;
    overflow-x: auto;
    width: 100%;
  }

  .nav-item {
    text-align: center;
  }

  .metrics-grid,
  .content-grid,
  .split-layout,
  .cards-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .sidebar {
    padding: 14px 12px 10px;
  }

  .brand {
    margin-bottom: 12px;
  }

  .nav {
    gap: 5px;
    padding-bottom: 3px;
  }

  .nav-item {
    min-height: 42px;
    padding: 10px 12px;
  }

  .workspace {
    padding: 16px;
  }

  .topbar,
  .panel-header.with-action,
  .two-cols {
    align-items: stretch;
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  h1 {
    font-size: 1.55rem;
  }

  .profile-switcher {
    overflow-x: auto;
  }

  .metric,
  .panel {
    box-shadow: none;
  }
}
