:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --line: #e3e7ee;
  --line-strong: #cfd6df;
  --text: #16202a;
  --muted: #66727f;
  --accent: #1769ff;
  --accent-soft: #eef4ff;
  --danger: #c43d3d;
  --success: #1f8b4c;
  --shadow: 0 8px 24px rgba(22, 32, 42, 0.06);
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 10px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  font-family: "Manrope", "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

button,
input,
select {
  font: inherit;
}

.page-shell {
  width: min(1500px, calc(100% - 24px));
  margin: 0 auto;
  padding: 12px 0 20px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

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

.eyebrow,
.section-step {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.topbar h1,
.section-head h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.05;
}

.topbar-text,
.section-text,
.field-hint,
.alert-card strong {
  color: var(--muted);
}

.topbar-text {
  margin: 6px 0 0;
  font-size: 14px;
}

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

.primary-button,
.secondary-button,
.ghost-button,
.tiny-button,
.status-button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.primary-button,
.secondary-button,
.ghost-button,
.tiny-button,
.status-button,
.choice-button,
.stepper-button,
.clear-inline-button,
.spec-option {
  touch-action: manipulation;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.primary-button,
.secondary-button,
.ghost-button {
  padding: 0 16px;
  font-weight: 700;
}

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

.primary-button:disabled,
.secondary-button:disabled,
.ghost-button:disabled,
.tiny-button:disabled,
.status-button:disabled,
.choice-button:disabled,
.stepper-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.secondary-button {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: #d7e5ff;
}

.ghost-button {
  background: #fff;
  color: var(--muted);
  border-color: var(--line-strong);
}

.workspace {
  margin-top: 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.view-switch {
  margin-top: 12px;
  padding: 6px;
  display: inline-flex;
  gap: 6px;
}

.view-tab {
  min-height: 40px;
  padding: 0 16px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.view-tab.is-active {
  background: var(--text);
  color: #fff;
}

.section-panel {
  padding: 14px;
  min-height: calc(100vh - 120px);
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.section-text {
  margin: 6px 0 0;
  font-size: 13px;
}

.stack {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

.entry-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 10px;
  display: grid;
  gap: 8px;
}

.entry-card.is-empty {
  background: #fafbfc;
}

.entry-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.entry-top h3 {
  margin: 0;
  font-size: 14px;
}

.tiny-button {
  min-height: 30px;
  padding: 0 10px;
  background: #fff5f5;
  color: var(--danger);
}

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

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

.field label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
}

.field.is-invalid label {
  color: var(--danger);
}

.field[data-span="3"] { grid-column: span 3; }
.field[data-span="4"] { grid-column: span 4; }
.field[data-span="5"] { grid-column: span 5; }
.field[data-span="6"] { grid-column: span 6; }
.field[data-span="7"] { grid-column: span 7; }
.field[data-span="12"] { grid-column: span 12; }

.field input,
.field select {
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  outline: none;
}

.field input:focus,
.field select:focus {
  border-color: var(--accent);
}

.field.is-invalid input,
.field.is-invalid select,
.field.is-invalid .stepper-input,
.field.is-invalid .input-with-action input,
.field.is-invalid .input-with-action select {
  border-color: var(--danger);
  background: #fff7f7;
}

.input-with-action {
  position: relative;
}

.input-with-action input,
.input-with-action select {
  padding-right: 36px;
  appearance: none;
  -webkit-appearance: none;
}

.input-with-action input::-webkit-calendar-picker-indicator,
.input-with-action select::-ms-expand {
  opacity: 0;
  pointer-events: none;
}

.input-with-action input[list]::-webkit-calendar-picker-indicator {
  display: none;
  width: 0;
  margin: 0;
  padding: 0;
  opacity: 0;
  pointer-events: none;
}

.clear-inline-button {
  position: absolute;
  top: 50%;
  right: 6px;
  width: 26px;
  height: 26px;
  transform: translateY(-50%);
  border: 0;
  border-radius: 999px;
  background: #eef2f6;
  color: var(--muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

.clear-inline-button.is-chevron {
  font-size: 16px;
  font-weight: 700;
}

.clear-inline-button:hover {
  background: #e1e8f0;
  color: var(--text);
}

.spec-autocomplete {
  position: absolute;
  z-index: 1000;
  max-height: 320px;
  overflow: auto;
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  box-shadow: 0 16px 32px rgba(22, 32, 42, 0.12);
  padding: 6px;
  min-width: 320px;
}

.spec-option {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 0;
  background: transparent;
  border-radius: 10px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  text-align: left;
  cursor: pointer;
}

.spec-option:hover,
.spec-option.active {
  background: var(--accent-soft);
}

.spec-option-text {
  min-width: 0;
  flex: 1;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  overflow-wrap: anywhere;
  line-height: 1.3;
}

.spec-option-price {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.status-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.choice-group {
  display: flex;
  gap: 6px;
}

.stepper {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 38px;
  align-items: center;
  gap: 6px;
}

.status-button {
  min-height: 34px;
  padding: 0 10px;
  background: #f3f5f8;
  color: var(--muted);
}

.choice-button {
  min-height: 38px;
  min-width: 64px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #f3f5f8;
  color: var(--muted);
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.status-button.active {
  background: var(--accent);
  color: #fff;
}

.choice-button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.stepper-button {
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #f3f5f8;
  color: var(--text);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

.stepper-input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
  padding: 0 10px;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  outline: none;
}

.stepper-input:focus {
  border-color: var(--accent);
}

.save-badge {
  min-height: 36px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: #eef8f1;
  color: var(--success);
  font-size: 12px;
  font-weight: 700;
}

.alerts {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

.alerts-inline {
  margin-top: 12px;
}

.alert-card {
  border: 1px solid #f0cccc;
  border-radius: var(--radius-md);
  padding: 10px 12px;
  background: #fff7f7;
}

.alert-card p {
  margin: 6px 0 0;
  line-height: 1.45;
}

.reports-layout {
  margin-top: 12px;
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.reports-panel {
  padding: 14px;
  min-height: 480px;
}

.reports-section-head {
  align-items: center;
}

.reports-note {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.reports-list,
.report-detail {
  margin-top: 10px;
  display: grid;
  gap: 10px;
}

.report-list-button {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  display: grid;
  gap: 8px;
  transition: border-color 0.15s ease, background-color 0.15s ease, transform 0.15s ease;
}

.report-list-button:hover {
  border-color: var(--line-strong);
  transform: translateY(-1px);
}

.report-list-button.is-active {
  border-color: #bdd3ff;
  background: var(--accent-soft);
}

.report-list-head,
.report-hero-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.report-list-title,
.report-hero-title {
  margin: 0;
  font-size: 16px;
  line-height: 1.2;
}

.report-list-text,
.report-hero-text,
.empty-state p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.report-meta,
.report-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.report-chip,
.status-tag,
.job-type-tag {
  min-height: 28px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: #f3f5f8;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.report-chip.is-accent,
.job-type-tag.is-common {
  background: var(--accent-soft);
  color: var(--accent);
}

.status-tag.status-yes {
  background: #eef8f1;
  color: var(--success);
}

.status-tag.status-no,
.status-tag.status-off {
  background: #f3f5f8;
  color: var(--muted);
}

.status-tag.status-medical {
  background: #fff4e7;
  color: #a05a00;
}

.report-hero {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 10px;
}

.report-block {
  display: grid;
  gap: 10px;
}

.report-block-head h3 {
  margin: 0;
  font-size: 17px;
}

.report-block-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.table-hint {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.table-shell {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: auto;
}

.report-table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
  background: #fff;
}

.report-table th,
.report-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.report-table th {
  background: #fafbfc;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.report-table td {
  font-size: 13px;
}

.report-table tbody tr:last-child td {
  border-bottom: 0;
}

.align-right {
  text-align: right;
}

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

.empty-state {
  padding: 18px;
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  background: #fafbfc;
  display: grid;
  gap: 6px;
}

.empty-state h3 {
  margin: 0;
  font-size: 16px;
}

.empty-state.is-error {
  border-style: solid;
  border-color: #f0cccc;
  background: #fff7f7;
}

@media (max-width: 1100px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .reports-layout {
    grid-template-columns: 1fr;
  }

  .section-panel {
    min-height: auto;
  }

  .reports-panel {
    min-height: auto;
  }
}

@media (max-width: 760px) {
  .page-shell {
    width: min(100% - 16px, 1380px);
    padding-top: 8px;
  }

  .topbar,
  .section-panel {
    padding: 14px;
  }

  .topbar,
  .topbar-actions,
  .entry-top {
    flex-direction: column;
  }

  .view-switch {
    width: 100%;
  }

  .view-tab {
    flex: 1;
  }

  .fields-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .field[data-span="3"],
  .field[data-span="4"],
  .field[data-span="5"],
  .field[data-span="6"],
  .field[data-span="7"] {
    grid-column: span 6;
  }

  .report-list-head,
  .report-hero-head {
    flex-direction: column;
  }

}
