:root {
  --black: #1d242b;
  --charcoal: #182027;
  --graphite: #1d242b;
  --graphite-2: #141a1f;
  --mist: #f5f5f2;
  --surface: #ffffff;
  --surface-2: #f0f0ed;
  --line: #deded8;
  --orange: #f26729;
  --orange-2: #d9581f;
  --orange-soft: #fff0e8;
  --danger: #b94a38;
  --muted: #6c7072;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--mist);
  color: var(--graphite-2);
  font-family: "SF Pro Text", "Segoe UI", "Aptos", "Helvetica Neue", sans-serif;
}

button, input, select { font: inherit; }
h1, h2, p { margin: 0; }

.hidden { display: none !important; }

.app {
  display: grid;
  grid-template-columns: 360px 1fr;
  min-height: 100vh;
}

.sidebar {
  background:
    linear-gradient(180deg, rgba(242, 103, 41, 0.14), transparent 26%),
    var(--black);
  color: #fff;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.brand {
  display: grid;
  gap: 12px;
  padding-bottom: 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.18);
}

.brandLogo {
  display: block;
  width: min(245px, 100%);
  height: auto;
  object-fit: contain;
}

.brand strong {
  display: block;
  font-size: 13px;
  letter-spacing: 0.08em;
}

.content {
  padding: 28px;
  overflow: auto;
}

.authPage {
  grid-column: 1 / -1;
  display: grid;
  place-items: center;
  padding: 32px;
}

.authCard {
  width: min(720px, 100%);
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(29, 36, 43, 0.08);
}

.authCard img {
  display: block;
  width: min(260px, 100%);
  padding: 16px;
  margin: 0 auto 22px;
  border-radius: 12px;
  background: var(--black);
}

.authCard h1 {
  font-size: clamp(28px, 3vw, 36px);
  line-height: 1.08;
  text-align: center;
  white-space: nowrap;
}

.authGrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 24px 0 16px;
}

.formMessage {
  min-height: 22px;
  margin-top: 12px;
  color: var(--danger);
  font-weight: 700;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.topActions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.eyebrow,
.label,
.field span,
.listHeader,
.metrics span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.sidebar .listHeader {
  color: rgba(255, 255, 255, 0.7);
}

h1 {
  color: var(--graphite);
  font-family: "SF Pro Display", "Segoe UI", "Aptos Display", "Helvetica Neue", sans-serif;
  font-size: clamp(34px, 4vw, 52px);
  font-weight: 760;
  line-height: 0.95;
  letter-spacing: -0.02em;
}

h2 {
  margin-top: 7px;
  color: var(--graphite-2);
  font-size: 24px;
  line-height: 1.1;
}

.statusPill {
  min-width: 120px;
  padding: 10px 14px;
  border-radius: 999px;
  background: var(--orange-soft);
  color: var(--orange-2);
  text-align: center;
  font-weight: 800;
}

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

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(38, 42, 43, 0.08);
  padding: 22px;
}

.selectedPanel,
.focusPanel,
.dashboardPanel,
.settingsPanel,
.formPanel,
.activityPanel,
.costsPanel,
.usersPanel {
  grid-column: span 2;
}

.selectedPanel code {
  display: block;
  margin-top: 10px;
  color: var(--muted);
  white-space: normal;
  overflow-wrap: anywhere;
}

.field {
  display: grid;
  gap: 8px;
}

.field.compact {
  gap: 10px;
}

.sidebar .field span,
.sidebar .listHeader {
  color: rgba(255, 255, 255, 0.7);
}

.sourceNote {
  min-height: 54px;
  padding: 12px;
  border: 1px solid rgba(242, 103, 41, 0.32);
  border-radius: 12px;
  background: rgba(242, 103, 41, 0.12);
  color: rgba(255, 255, 255, 0.82);
  font-size: 13px;
  line-height: 1.35;
}

input, select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--graphite-2);
  padding: 0 12px;
  outline: none;
}

.sidebar input,
.sidebar select {
  border-color: rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.09);
  color: #fff;
}

input:focus, select:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(242, 103, 41, 0.18);
}

.inline {
  display: grid;
  grid-template-columns: 1fr 44px;
  gap: 8px;
}

.rootPicker {
  grid-template-columns: 1fr 74px 44px;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--graphite-2);
  cursor: pointer;
  font-weight: 800;
}

.iconButton {
  color: #fff;
  background: var(--orange);
  font-size: 22px;
}

.textButton {
  color: #fff;
  background: rgba(242, 103, 41, 0.86);
  font-size: 13px;
  padding: 0 10px;
}

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

input:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.58;
  background: #eeeeea;
}

.primary {
  min-width: 190px;
  padding: 0 22px;
  background: var(--orange);
  color: #fff;
}

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

.ghost {
  min-height: 36px;
  padding: 0 12px;
}

.listHeader,
.progressHead,
.activityHead,
.cardHeadInline {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
}

.panelHint {
  max-width: 680px;
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.bulkActions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.bulkActions button {
  min-height: 36px;
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  font-size: 12px;
}

.bulkActions button.loading {
  background: var(--orange);
  opacity: 1;
}

.bulkActions button.loading::before {
  content: "";
  display: inline-block;
  width: 11px;
  height: 11px;
  margin-right: 7px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
  border-radius: 50%;
  vertical-align: -2px;
  animation: spin 0.8s linear infinite;
}

.inspectionTools {
  display: grid;
  gap: 8px;
  justify-items: end;
}

.inlineActions {
  display: flex;
  gap: 8px;
}

.inlineActions button {
  min-height: 32px;
  padding: 0 12px;
  font-size: 12px;
}

@keyframes spin { to { transform: rotate(360deg); } }

.folderList {
  display: grid;
  gap: 10px;
  overflow: auto;
  padding-right: 4px;
}

.folder {
  width: 100%;
  min-height: 60px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.075);
  color: #fff;
  text-align: left;
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 10px;
  align-items: start;
}

.folder.active {
  border-color: var(--orange);
  background: rgba(242, 103, 41, 0.18);
}

.folder.errorRow {
  grid-template-columns: 1fr;
  border-color: rgba(185, 74, 56, 0.55);
  background: rgba(185, 74, 56, 0.14);
}

.folder.loadingRow {
  grid-template-columns: 1fr;
  border-color: rgba(242, 103, 41, 0.5);
  background: rgba(242, 103, 41, 0.12);
}

.folder strong,
.folder span {
  display: block;
  overflow-wrap: anywhere;
}

.folder input {
  width: 18px;
  min-height: 18px;
  margin-top: 2px;
  accent-color: var(--orange);
}

.folder span {
  margin-top: 5px;
  color: rgba(255, 255, 255, 0.66);
  font-size: 12px;
}

.statusGrid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.statusBox {
  padding: 14px;
  border-radius: 12px;
  background: var(--surface-2);
}

.statusBox span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.statusBox strong {
  display: block;
  margin-top: 5px;
}

.dashboardCards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.dashboardCard {
  min-height: 116px;
  padding: 16px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid rgba(29, 36, 43, 0.04);
}

.dashboardCard span,
.dashboardCard small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.dashboardCard span {
  text-transform: uppercase;
}

.dashboardCard strong {
  display: block;
  margin: 12px 0 6px;
  color: var(--graphite);
  font-size: 30px;
  line-height: 1;
  overflow-wrap: anywhere;
}

.dashboardCard.costCard {
  background: var(--orange);
  border-color: rgba(242, 103, 41, 0.35);
}

.dashboardCard.costCard span,
.dashboardCard.costCard strong,
.dashboardCard.costCard small {
  color: #fff;
}

.dashboardCard.costCard strong {
  font-size: 28px;
}

.selectionHint {
  margin-top: 10px;
  color: var(--orange);
  font-weight: 800;
}

.selectedList {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.selectedChip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 8px 10px;
  border-radius: 999px;
  background: var(--orange-soft);
  color: var(--graphite-2);
  font-size: 13px;
  font-weight: 800;
}

.selectedChip span { overflow-wrap: anywhere; }

.selectedChip button {
  display: grid;
  place-items: center;
  width: 22px;
  min-width: 22px;
  min-height: 22px;
  height: 22px;
  padding: 0;
  border-radius: 50%;
  background: var(--orange);
  color: #fff;
  line-height: 1;
}

.focusList {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.focusButton {
  min-height: 42px;
  padding: 10px 12px;
  text-align: left;
  background: var(--surface-2);
  color: var(--graphite-2);
  overflow-wrap: anywhere;
}

.focusButton.active {
  background: var(--orange);
  color: #fff;
}

.twoCols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

.twoCols.narrow { grid-template-columns: 1fr 180px; }

.actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-top: 8px;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--graphite-2);
  font-weight: 700;
}

.toggle input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--orange);
}

.cardHeadInline { margin-bottom: 16px; }

.dataStatus {
  min-height: 44px;
  padding: 12px;
  margin-bottom: 14px;
  border-radius: 10px;
  background: var(--orange-soft);
  color: var(--graphite-2);
  font-size: 13px;
  font-weight: 700;
}

.contractorGrid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin: 14px 0;
}

.contractorGrid .wide { grid-column: span 2; }

.userGrid {
  display: grid;
  grid-template-columns: 1fr 1.2fr 1fr;
  gap: 14px;
  margin: 16px 0 12px;
}

.userList {
  display: grid;
  gap: 8px;
}

.userItem {
  padding: 12px;
  border-radius: 10px;
  background: var(--surface-2);
}

.userItem strong,
.userItem span {
  display: block;
}

.userItem span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.inspectionList {
  display: grid;
  gap: 8px;
  max-height: 340px;
  margin-top: 16px;
  overflow: auto;
}

.inspectionItem {
  display: grid;
  grid-template-columns: 18px 1fr 28px;
  gap: 10px;
  align-items: flex-start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  cursor: pointer;
}

.inspectionItem.active {
  border-color: var(--orange);
  background: rgba(242, 103, 41, 0.09);
}

.inspectionItem.generated {
  border-color: rgba(73, 190, 99, 0.36);
}

.inspectionItem input {
  margin-top: 2px;
  accent-color: var(--orange);
}

.inspectionItem input:disabled {
  opacity: 0.55;
}

.inspectionItem strong,
.inspectionItem span {
  display: block;
  overflow-wrap: anywhere;
}

.inspectionItem span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.inspectionItem small {
  display: inline-block;
  margin-top: 6px;
  color: #2f8f46;
  font-size: 12px;
  font-weight: 800;
}

.inspectionItem .modelBadge {
  width: fit-content;
  padding: 4px 8px;
  border-radius: 999px;
  color: #fff;
  font-size: 11px;
  line-height: 1;
}

.inspectionItem .modelBadge.standard {
  background: #1d242b;
}

.inspectionItem .modelBadge.road {
  background: #2f6fbd;
}

.inspectionItem .modelBadge.refusal {
  background: #f26729;
}

.inspectionItem em {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #49be63;
  color: #fff;
  font-style: normal;
  font-weight: 900;
}

.inspectionItem.error {
  border-color: var(--danger);
  color: var(--danger);
}

#progressValue {
  color: var(--orange);
  font-size: 34px;
}

.bar {
  height: 12px;
  margin: 18px 0;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-2);
}

#progressBar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--orange), #ff9a57);
  transition: width 240ms ease;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.metrics div {
  min-height: 74px;
  padding: 12px;
  border-radius: 10px;
  background: var(--surface-2);
}

.metrics strong {
  display: block;
  margin-top: 8px;
  color: var(--graphite);
  font-size: 22px;
}

.activity {
  display: grid;
  gap: 10px;
  max-height: 360px;
  margin-top: 16px;
  overflow: auto;
}

.historyTable {
  margin-top: 16px;
  overflow-x: auto;
}

.historyTable table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

.historyTable th,
.historyTable td {
  padding: 12px 10px;
  border-bottom: 1px solid rgba(29, 36, 43, 0.08);
  text-align: left;
  vertical-align: top;
}

.historyTable th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.historyTable td {
  color: var(--graphite-2);
  font-size: 13px;
  font-weight: 700;
}

.historyStatus {
  display: inline-flex;
  min-width: 86px;
  justify-content: center;
  padding: 5px 8px;
  border-radius: 999px;
  color: var(--graphite-2);
  background: var(--surface-2);
  font-size: 12px;
  font-weight: 900;
}

.historyStatus.done {
  color: #176b35;
  background: #dff4e6;
}

.historyStatus.error,
.historyStatus.blocked {
  color: #9b2c1f;
  background: #fde4df;
}

.historyStatus.running,
.historyStatus.queued,
.historyStatus.validating {
  color: #9a4b10;
  background: var(--orange-soft);
}

.event {
  display: grid;
  gap: 4px;
  padding: 12px;
  border-left: 4px solid var(--orange);
  border-radius: 8px;
  background: var(--surface-2);
}

.event.warn { border-left-color: var(--orange); }
.event.error { border-left-color: var(--danger); }
.event strong { color: var(--graphite-2); }

.eventTop {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.event time {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.event small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.event span {
  color: var(--muted);
  font-size: 13px;
}

.eventLink {
  width: fit-content;
  margin-top: 4px;
  color: var(--orange-2);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.eventLink:hover {
  text-decoration: underline;
}

.costSummary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.costLine {
  display: grid;
  grid-template-columns: minmax(160px, 0.6fr) 1fr;
  gap: 12px;
  padding: 12px;
  border-radius: 8px;
  background: var(--surface-2);
}

.costLine.highlight {
  background: var(--orange-soft);
  border: 1px solid rgba(242, 103, 41, 0.18);
}

.costLine.total {
  background: #1d242b;
  color: #fff;
}

.costLine.total strong,
.costLine.total span {
  color: #fff;
}

.costLine.total span {
  font-size: 28px;
  font-weight: 900;
  line-height: 1.1;
}

.costLine strong {
  color: var(--graphite-2);
}

.costLine span {
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 980px) {
  .app,
  .grid,
  .twoCols,
  .twoCols.narrow,
  .contractorGrid,
  .userGrid,
  .authGrid,
  .dashboardCards,
  .statusGrid {
    grid-template-columns: 1fr;
  }

  .contractorGrid .wide { grid-column: auto; }

  .selectedPanel,
  .focusPanel,
  .dashboardPanel,
  .settingsPanel,
  .formPanel,
  .activityPanel,
  .usersPanel {
    grid-column: auto;
  }

  .sidebar { min-height: 40vh; }

  .actions,
  .topActions,
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }
}
