:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #16202a;
  --muted: #66717f;
  --border: #d8dee6;
  --accent: #136f63;
  --accent-dark: #0d5149;
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--text);
  background: var(--bg);
}

.shell {
  width: min(760px, calc(100% - 32px));
  margin: 0 auto;
  padding: 64px 0;
}

.shell.wide {
  width: min(1100px, calc(100% - 32px));
}

.panel,
.summary {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
}

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

.summary-actions form {
  margin: 0;
}

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

.secondary-panel {
  margin-top: 16px;
}

.operation-panel {
  margin-bottom: 16px;
}

.page-nav {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 16px;
}

.history-search {
  max-width: 620px;
  margin: 24px 0 18px;
}

.history-table {
  margin-top: 0;
}

.nowrap {
  white-space: nowrap;
}

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

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin-top: 20px;
}

.party-upload-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.party-upload-grid fieldset {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
}

.party-upload-grid legend {
  color: var(--accent-dark);
  font-weight: 700;
}

.party-upload-grid label:not(:first-of-type) {
  margin-top: 14px;
}

.summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

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

h1 {
  font-size: 32px;
}

h2 {
  margin-bottom: 16px;
  font-size: 18px;
}

.form {
  margin-top: 28px;
}

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

.input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.file-field {
  margin-top: 18px;
}

input,
textarea,
button,
.link-button {
  min-height: 44px;
  border-radius: 6px;
  font: inherit;
}

.full-button {
  width: 100%;
  justify-content: center;
  margin-top: 18px;
}

input {
  width: 100%;
  border: 1px solid var(--border);
  padding: 0 12px;
}

textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  resize: vertical;
  font: inherit;
}

.observations-form {
  min-width: 230px;
}

.observations-form textarea {
  display: block;
  min-height: 66px;
  margin-bottom: 7px;
}

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

.danger-link {
  color: var(--danger);
  font-weight: 700;
}

.delete-confirmation p {
  line-height: 1.5;
}

.confirmation-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

.confirmation-actions form {
  margin: 0;
}

.secondary-button {
  color: var(--accent-dark);
  background: #edf2f5;
}

input[type="file"] {
  min-height: auto;
  padding: 10px 12px;
  background: #fbfcfd;
}

button,
.link-button {
  border: 0;
  background: var(--accent);
  color: white;
  padding: 0 18px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

button:hover,
.link-button:hover {
  background: var(--accent-dark);
}

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

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

.section-head h2 {
  margin-bottom: 0;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 10px;
  color: var(--accent-dark);
  background: #edf7f5;
  font-size: 13px;
  font-weight: 700;
}

.bcra-panel {
  margin-bottom: 16px;
}

.company-panel {
  margin-bottom: 16px;
}

.operation-result {
  margin-bottom: 16px;
}

.operation-parties,
.sales-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 16px 0;
}

.sales-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.operation-parties article,
.sales-grid article {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfd;
}

.operation-parties span,
.sales-grid span,
.operation-parties small,
.sales-grid small,
.sales-grid em {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.operation-parties strong,
.sales-grid strong {
  display: block;
  margin: 6px 0;
}

.sales-grid em {
  margin-top: 6px;
  color: #8a5a00;
}

.alert-box {
  border-left: 4px solid var(--danger);
  padding: 8px 12px;
  background: #fff4f2;
}

.alert-box p {
  margin: 4px 0;
}

.company-facts {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.company-facts div,
.chart-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfcfd;
}

.company-facts div {
  min-height: 92px;
  padding: 12px;
}

.company-facts span,
.chart-head p {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.company-facts strong {
  display: block;
  margin-top: 6px;
  overflow-wrap: anywhere;
  font-size: 15px;
}

.chart-grid {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  gap: 14px;
}

.chart-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.chart-card {
  padding: 18px;
  min-width: 0;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

.chart-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.chart-head h3 {
  margin: 0;
  font-size: 15px;
  letter-spacing: 0;
}

.chart-head p {
  margin: 4px 0 0;
}

.chart-head strong {
  white-space: nowrap;
  font-size: 16px;
}

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

.chart-latest span {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.chart-card svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
  border-radius: 6px;
  background: #ffffff;
  font-family: Arial, Helvetica, sans-serif;
}

.chart-gridline {
  stroke: #e6ebf0;
  stroke-width: 1;
}

.chart-axis {
  stroke: #c5ced8;
  stroke-width: 1;
}

.chart-threshold {
  fill: none;
  stroke-width: 1.25;
  stroke-dasharray: 5 5;
  opacity: 0.55;
}

.chart-threshold-good {
  stroke: #16a34a;
}

.chart-threshold-watch {
  stroke: #d97706;
}

.chart-average {
  stroke: #b45309;
  stroke-width: 1.5;
  stroke-dasharray: 6 5;
}

.chart-average-label {
  fill: #92400e;
  font-size: 11px;
  font-weight: 700;
}

.chart-y-label,
.chart-x-label {
  fill: #5f6b78;
  font-size: 11px;
  font-weight: 600;
}

.chart-y-label {
  text-anchor: end;
}

.chart-area {
  opacity: 0.08;
}

.chart-line {
  fill: none;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.score-line {
  stroke: #155e75;
}

.debt-line {
  stroke: #2563eb;
}

.sales-line {
  stroke: #7c3aed;
}

.score-area {
  fill: #0f766e;
}

.debt-area {
  fill: #2563eb;
}

.sales-area {
  fill: #7c3aed;
}

.chart-dot {
  stroke: #ffffff;
  stroke-width: 1.8;
}

.score-dot {
  fill: #155e75;
}

.debt-dot {
  fill: #2563eb;
}

.sales-dot {
  fill: #7c3aed;
}


.bcra-metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.bcra-metrics div {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfd;
}

.bcra-metrics span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
}

.bcra-metrics strong {
  display: block;
  font-size: 18px;
}

.bcra-metrics small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-top: 12px;
}

.table-wrap.compact {
  max-width: 520px;
}

.table-wrap table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table-wrap th,
.table-wrap td {
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
  text-align: left;
  vertical-align: middle;
}

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

.table-wrap th {
  color: var(--muted);
  background: #f8fafb;
  font-weight: 700;
  white-space: nowrap;
}

.table-wrap .num {
  text-align: right;
  white-space: nowrap;
}

.group-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 8px;
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 700;
}

.group-A {
  color: #0d5149;
  background: #e6f4f1;
  border-color: #b7ddd6;
}

.group-B {
  color: #7a4b00;
  background: #fff4d8;
  border-color: #efd38d;
}

.group-C {
  color: #8a1f11;
  background: #fde9e7;
  border-color: #f5b8b1;
}

.group-unknown,
.group-Sin {
  color: var(--muted);
  background: #f1f3f5;
}

dl {
  margin: 0;
}

dl div {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

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

dd {
  margin: 0;
}

.files {
  margin: 0;
  padding-left: 18px;
}

.files li {
  margin: 8px 0;
}

a {
  color: var(--accent-dark);
}

.error {
  color: var(--danger);
  font-weight: 700;
}

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

.report pre {
  margin: 0;
  white-space: pre-wrap;
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.45;
}

.report-content {
  line-height: 1.45;
}

.report-content h1,
.report-content h2,
.report-content h3 {
  margin: 22px 0 10px;
}

.report-content h1:first-child,
.report-content h2:first-child {
  margin-top: 0;
}

.report-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0 20px;
  font-size: 14px;
}

.report-content th,
.report-content td {
  border-bottom: 1px solid var(--border);
  padding: 9px 10px;
  text-align: left;
  vertical-align: top;
}

.report-content th {
  color: var(--muted);
  font-weight: 700;
  background: #f8fafb;
}

.report-content td:nth-child(2),
.report-content td:nth-child(3),
.report-content td:nth-child(4),
.report-content td:nth-child(5),
.report-content th:nth-child(2),
.report-content th:nth-child(3),
.report-content th:nth-child(4),
.report-content th:nth-child(5) {
  white-space: nowrap;
}

.report-content ul {
  padding-left: 20px;
}

@media (max-width: 720px) {
  .shell {
    padding: 32px 0;
  }

  .summary,
  .input-row,
  .grid,
  .party-upload-grid,
  .operation-parties,
  .sales-grid,
  .company-facts,
  .chart-grid,
  .bcra-metrics {
    grid-template-columns: 1fr;
  }

  .summary {
    display: grid;
  }

  .link-button,
  button {
    justify-content: center;
  }
}
