:root {
  color-scheme: light;
  --ink: #1f3349;
  --muted: #61758b;
  --line: #d9e2ec;
  --panel: #ffffff;
  --surface: #f4f7fa;
  --navy: #17324d;
  --teal: #0e7490;
  --teal-soft: #e6f6fa;
  --high: #b42318;
  --high-bg: #fde2e2;
  --medium: #966500;
  --medium-bg: #fff0c2;
  --low: #1d4ed8;
  --low-bg: #e8f1ff;
  --info: #4b5563;
  --info-bg: #eceff3;
  --ok: #166534;
  --ok-bg: #e6f4ea;
  font-family: Aptos, Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--surface);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  padding: 24px 24px 8px;
}

.login-shell {
  align-items: center;
  display: grid;
  min-height: 100vh;
  padding: 24px;
}

.login-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 20px 50px rgba(31, 51, 73, 0.12);
  margin: 0 auto;
  max-width: 440px;
  padding: 28px;
  width: 100%;
}

.login-form {
  display: grid;
  gap: 14px;
  margin-top: 22px;
}

.login-form label {
  display: grid;
  gap: 6px;
}

.login-form label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.login-form input {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 42px;
  padding: 0 12px;
  width: 100%;
}

.topbar,
.report-header {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin: 0 auto 16px;
  max-width: 1440px;
}

.topbar-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.app-footer {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  margin: 0 auto;
  max-width: 1440px;
  padding: 0 24px 24px;
}

.app-footer p {
  margin: 4px 0;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.2;
}

h2 {
  font-size: 18px;
}

.eyebrow {
  color: var(--teal);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  margin: 0 0 4px;
  text-transform: uppercase;
}

.muted {
  color: var(--muted);
  margin: 4px 0 0;
}

.read-only-pill {
  background: var(--ok-bg);
  border: 1px solid #9bd3aa;
  border-radius: 999px;
  color: var(--ok);
  font-weight: 700;
  padding: 8px 14px;
}

.upload-panel,
.report-section,
.history-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(31, 51, 73, 0.06);
  margin: 0 auto 18px;
  max-width: 1440px;
  padding: 20px;
}

.upload-panel {
  display: grid;
  gap: 18px;
}

.upload-form {
  align-items: center;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(260px, 1fr) 120px 120px auto auto;
}

.file-drop {
  align-items: center;
  background: var(--teal-soft);
  border: 1px dashed var(--teal);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  min-height: 52px;
  padding: 0 16px;
}

.file-drop input {
  inline-size: 1px;
  opacity: 0;
  position: absolute;
}

.checkbox {
  align-items: center;
  display: inline-flex;
  gap: 8px;
  white-space: nowrap;
}

.number-field {
  display: grid;
  gap: 4px;
}

.number-field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.number-field input {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 34px;
  padding: 0 8px;
}

.primary-button,
.secondary-button,
.danger-button,
.text-button,
.icon-button {
  border: 0;
  cursor: pointer;
}

.primary-button,
.secondary-button,
.danger-button {
  border-radius: 8px;
  font-weight: 700;
  min-height: 42px;
  padding: 0 16px;
}

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

.secondary-button {
  background: #eef3f8;
  color: var(--ink);
}

.danger-button {
  background: var(--high-bg);
  color: var(--high);
}

.text-button {
  background: transparent;
  color: var(--teal);
  font-weight: 700;
  padding: 0;
}

.icon-button {
  align-items: center;
  background: #eef3f8;
  border-radius: 999px;
  color: var(--ink);
  display: inline-flex;
  font-weight: 700;
  height: 34px;
  justify-content: center;
  width: 34px;
}

.status-panel,
.error-panel {
  border-radius: 8px;
  padding: 12px;
}

.status-panel {
  background: #f8fbfd;
  border: 1px solid var(--line);
}

.status-line {
  display: flex;
  font-size: 14px;
  gap: 12px;
  justify-content: space-between;
}

#status-label {
  font-weight: 700;
}

.progress-track {
  background: #dce6ef;
  border-radius: 999px;
  height: 8px;
  margin-top: 10px;
  overflow: hidden;
}

.progress-bar {
  background: var(--teal);
  height: 100%;
  transition: width 220ms ease;
  width: 8%;
}

.error-panel {
  background: var(--high-bg);
  border: 1px solid #f4aaa4;
  color: var(--high);
}

.summary-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  margin: 18px 0;
}

.meta-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.meta-grid div {
  background: #f8fbfd;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
}

.meta-grid span {
  color: var(--muted);
  display: block;
  font-size: 11px;
  font-weight: 700;
}

.meta-grid strong {
  display: block;
  font-size: 12px;
  margin-top: 2px;
}

.history-heading {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
}

.history-list {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
}

.history-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  min-width: 0;
  overflow: hidden;
  padding: 12px;
}

.history-card strong,
.history-card span,
.history-card p {
  display: block;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.history-card strong {
  line-height: 1.25;
}

.history-title span:first-of-type {
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

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

.history-rename {
  align-items: end;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) auto;
}

.history-rename label {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.history-rename input {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 36px;
  min-width: 0;
  padding: 0 10px;
  width: 100%;
}

.history-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.history-card .secondary-button,
.history-card .danger-button {
  min-height: 34px;
}

.summary-card {
  background: #f8fbfd;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: inherit;
  cursor: pointer;
  padding: 14px;
  text-align: left;
}

.summary-card:hover,
.summary-card.is-active {
  border-color: var(--teal);
  box-shadow: inset 0 0 0 1px var(--teal);
}

.summary-card.is-active {
  background: var(--teal-soft);
}

.summary-label {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-bottom: 8px;
}

.summary-value {
  display: block;
  font-size: 24px;
}

.rules-band {
  border-block: 1px solid var(--line);
  margin-bottom: 14px;
  padding: 12px 0;
}

.rules-band ul {
  color: var(--muted);
  margin: 10px 0 0;
  padding-left: 18px;
}

.review-status-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.review-filter-button {
  align-items: center;
  background: #eef3f8;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  gap: 6px;
  font-weight: 700;
  min-height: 34px;
  padding: 0 12px;
}

.review-filter-button.is-active {
  border: 2px solid #111827;
  border-radius: 0;
}

.review-filter-button.is-active::before {
  content: "\2713";
  font-weight: 900;
  line-height: 1;
}

.review-filter-button.review-likely-valid-operational-variance {
  background: var(--ok-bg);
  color: var(--ok);
}

.review-filter-button.review-likely-true-discrepancy {
  background: var(--high-bg);
  color: var(--high);
}

.review-filter-button.review-needs-manual-review,
.review-filter-button.review-warning {
  background: var(--medium-bg);
  color: var(--medium);
}

.table-toolbar {
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(220px, 1.2fr) repeat(7, minmax(140px, 1fr));
  margin-bottom: 12px;
}

.table-toolbar input,
.table-toolbar select {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 40px;
  padding: 0 12px;
}

.table-scroll-top {
  border: 1px solid var(--line);
  border-radius: 8px 8px 0 0;
  border-bottom: 0;
  height: 16px;
  margin-bottom: -1px;
  overflow-x: auto;
  overflow-y: hidden;
}

.table-scroll-spacer {
  height: 1px;
}

.table-wrap {
  border: 1px solid var(--line);
  border-radius: 0 0 8px 8px;
  max-height: 68vh;
  overflow: auto;
}

table {
  border-collapse: collapse;
  inline-size: 100%;
  min-width: 2680px;
  table-layout: fixed;
}

.col-type {
  width: 112px;
}

.col-date {
  width: 112px;
}

.col-employee {
  width: 190px;
}

.col-asset {
  width: 220px;
}

.col-asset-type {
  width: 190px;
}

.col-job {
  width: 150px;
}

.col-hours {
  width: 96px;
}

.col-diff,
.col-evidence,
.col-ai {
  width: 82px;
}

.col-classification {
  width: 250px;
}

.col-confidence {
  width: 118px;
}

.col-status {
  width: 170px;
}

.col-severity {
  width: 104px;
}

.col-review {
  width: 240px;
}

.col-reason {
  width: 380px;
}

th {
  background: var(--navy);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 1;
}

th button {
  background: transparent;
  border: 0;
  color: inherit;
  cursor: pointer;
  font-weight: 700;
  inline-size: 100%;
  padding: 11px 10px;
  text-align: left;
}

td {
  border-top: 1px solid var(--line);
  padding: 9px 10px;
  vertical-align: top;
  overflow-wrap: anywhere;
}

#results-table th:nth-child(1),
#results-table td:nth-child(1),
#results-table th:nth-child(2),
#results-table td:nth-child(2),
#results-table th:nth-child(7),
#results-table td:nth-child(7),
#results-table th:nth-child(8),
#results-table td:nth-child(8),
#results-table th:nth-child(9),
#results-table td:nth-child(9),
#results-table th:nth-child(11),
#results-table td:nth-child(11),
#results-table th:nth-child(12),
#results-table td:nth-child(12) {
  overflow-wrap: normal;
  white-space: nowrap;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover {
  background: #f6fbff;
}

.numeric {
  text-align: right;
}

.status-pill {
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 700;
  max-width: 100%;
  padding: 4px 8px;
  white-space: nowrap;
}

.reason-cell {
  line-height: 1.28;
}

.reason-text {
  display: -webkit-box;
  max-height: calc(1.28em * 4);
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
}

.severity-High,
.status-missing-in-timefiler,
.status-time-mismatch.severity-High {
  background: var(--high-bg);
  color: var(--high);
}

.severity-Medium,
.status-unmatched-asset-mapping,
.status-time-mismatch {
  background: var(--medium-bg);
  color: var(--medium);
}

.severity-Low {
  background: var(--low-bg);
  color: var(--low);
}

.severity-Info {
  background: var(--info-bg);
  color: var(--info);
}

.severity-OK,
.status-matched {
  background: var(--ok-bg);
  color: var(--ok);
}

.review-likely-valid-operational-variance {
  background: var(--ok-bg);
  color: var(--ok);
}

.review-likely-true-discrepancy {
  background: var(--high-bg);
  color: var(--high);
}

.review-needs-manual-review,
.review-warning {
  background: var(--medium-bg);
  color: var(--medium);
}

.modal-backdrop {
  align-items: center;
  background: rgba(15, 23, 42, 0.48);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 24px;
  position: fixed;
  z-index: 20;
}

.modal {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.28);
  max-height: 90vh;
  max-width: 1180px;
  overflow: hidden;
  width: min(1180px, 100%);
}

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

.modal-body {
  max-height: calc(90vh - 78px);
  overflow: auto;
  padding: 18px 20px 24px;
}

.detail-summary-panel {
  background: #fff;
  border: 1px solid var(--line);
  border-left: 5px solid var(--teal);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
  padding: 14px;
}

.detail-summary-title {
  align-items: baseline;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: space-between;
}

.detail-summary-title span,
.summary-chip-group span,
.detail-list-row span,
.comparison-value span,
.source-field span,
.timeline-item span,
.timeline-item em {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.detail-summary-title strong {
  overflow-wrap: anywhere;
}

.detail-summary-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.summary-chip-group {
  align-items: center;
  background: #f8fbfd;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: inline-flex;
  gap: 8px;
  min-height: 40px;
  padding: 6px 8px;
}

.detail-summary-reason {
  border-top: 1px solid var(--line);
  line-height: 1.45;
  margin: 0;
  overflow-wrap: anywhere;
  padding-top: 12px;
}

.detail-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr 1fr;
}

.detail-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.detail-section h3 {
  background: #f5f8fb;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  margin: 0;
  padding: 10px 12px;
}

.detail-list,
.comparison-list,
.source-record-list,
.timeline-list {
  display: grid;
  gap: 10px;
  max-height: 360px;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 12px;
}

.detail-list-row {
  display: grid;
  gap: 5px;
  grid-template-columns: minmax(120px, 0.35fr) minmax(0, 1fr);
}

.detail-list-row strong,
.comparison-value strong,
.source-field strong,
.timeline-item strong {
  font-size: 12px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.comparison-row,
.source-record,
.timeline-item {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-width: 0;
  padding: 10px;
}

.comparison-heading {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: space-between;
  margin-bottom: 8px;
}

.comparison-value {
  display: grid;
  gap: 4px;
  margin-top: 6px;
}

.source-record {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.source-record h4 {
  grid-column: 1 / -1;
  margin: 0;
}

.source-field {
  min-width: 0;
}

.source-field span {
  display: block;
  margin-bottom: 2px;
}

.timeline-item {
  align-items: baseline;
  display: grid;
  gap: 6px;
  grid-template-columns: minmax(150px, auto) minmax(80px, auto) minmax(0, 1fr);
}

.empty-state {
  color: var(--muted);
  padding: 14px;
}

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

  .upload-form,
  .table-toolbar,
  .summary-grid,
  .history-list,
  .detail-grid,
  .detail-list-row,
  .timeline-item {
    grid-template-columns: 1fr;
  }

  .topbar,
  .report-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    justify-content: flex-start;
  }
}
