:root {
  --theme: #007f8c;
  --theme-dark: #005e68;
  --ink: #0c2548;
  --muted: #6b7890;
  --line: #d8e1ec;
  --page: #f3f7fb;
  --soft: #e9f4ff;
  --good: #128342;
  --warn: #c47a00;
  --bad: #c42a3b;
  --purple: #8236aa;
  --gold: #f3c432;
  --silver: #9fb0c2;
  --bronze: #bd7a50;
  font-family: Arial, Helvetica, sans-serif;
}

* {
  box-sizing: border-box;
}

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

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

button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--theme-dark);
  font-weight: 800;
  cursor: pointer;
}

.button-link {
  display: inline-grid;
  place-items: center;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--theme-dark);
  font-weight: 800;
  text-decoration: none;
}

input,
textarea,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  color: var(--ink);
}

input[readonly],
.computed-input {
  background: #eef7f8;
  border-color: #a8d8de;
  color: var(--theme-dark);
  font-weight: 900;
  cursor: not-allowed;
}

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

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.app-header p,
.logo-mark p,
.report-date,
.metric span,
.tiny {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.app-header h1 {
  margin: 2px 0 0;
  font-size: 18px;
}

.app-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 14px 14px 88px;
}

.control-strip,
.panel,
.report-preview {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(12, 37, 72, 0.06);
}

.control-strip {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
  padding: 12px;
}

.generate-btn {
  min-height: 52px;
  border: 0;
  background: var(--theme);
  color: #fff;
  font-size: 16px;
  box-shadow: 0 8px 20px rgba(0, 93, 170, 0.25);
}

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

.report-preview {
  overflow: hidden;
  margin-bottom: 14px;
}

.preview-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 10px;
  margin: 14px 0 8px;
  padding: 0 2px;
  scroll-margin-top: 84px;
}

.preview-heading p {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.preview-heading h2 {
  margin: 0;
  color: var(--theme-dark);
  font-size: 20px;
}

.preview-heading span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-align: right;
}

.report-preview.generated-pulse {
  outline: 3px solid rgba(0, 93, 170, 0.24);
  outline-offset: 3px;
}

.report {
  width: 100%;
  background: #fff;
}

.report-inner {
  padding: 14px;
}

.report-top {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.logo-mark strong {
  display: block;
  color: #008aa7;
  font-size: 40px;
  line-height: 0.9;
  letter-spacing: 0;
}

.logo-mark .orange {
  color: #f26a21;
}

.ctos-logo {
  display: block;
  width: min(185px, 100%);
  height: auto;
}

.report-heading {
  text-align: center;
}

.report-heading h2 {
  margin: 0;
  color: #061f44;
  font-size: clamp(28px, 7vw, 42px);
  line-height: 1;
}

.report-date {
  margin-top: 7px;
  color: var(--theme-dark);
  font-size: 16px;
}

.days-card {
  justify-self: center;
  min-width: 132px;
  padding: 10px;
  border-radius: 8px;
  background: var(--theme);
  color: #fff;
  text-align: center;
}

.days-card span {
  display: block;
  font-size: 12px;
  font-weight: 900;
}

.days-card strong {
  display: block;
  font-size: 34px;
  line-height: 1;
}

.days-card small {
  font-weight: 800;
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 10px 0;
}

.metric,
.achievement-card,
.report-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.metric {
  padding: 10px 10px;
  text-align: center;
}

.metric-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin: 0 auto 6px;
  border-radius: 999px;
  background: #e6f5f6;
  color: var(--theme);
}

.metric-icon svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.metric strong {
  display: block;
  margin: 2px 0;
  color: #061f44;
  font-size: 36px;
}

.delta {
  color: var(--muted);
  font-size: 15px;
  font-weight: 800;
}

.delta.up {
  color: var(--good);
}

.achievement-card {
  display: grid;
  place-items: center;
  padding: 8px;
  text-align: center;
  background: #f7fbff;
}

.donut {
  --percent: 0;
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  margin: 4px auto;
  border-radius: 999px;
  background: conic-gradient(var(--theme) calc(var(--percent) * 1%), #dce8f3 0);
}

.donut span {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 999px;
  background: #fff;
  color: #061f44;
  font-size: 18px;
  font-weight: 900;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.performance-table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
  font-size: 13px;
  table-layout: fixed;
}

.performance-table th {
  background: #06456f;
  color: #fff;
  font-size: 11px;
  text-transform: uppercase;
}

.performance-table th,
.performance-table td {
  border: 1px solid var(--line);
  padding: 4px 5px;
  text-align: center;
  vertical-align: middle;
  line-height: 1.1;
}

.performance-table th:nth-child(1),
.performance-table td:nth-child(1) {
  width: 38px;
}

.performance-table th:nth-child(2),
.performance-table td:nth-child(2) {
  width: 26%;
}

.performance-table th:nth-child(3),
.performance-table td:nth-child(3) {
  width: 9%;
}

.performance-table th:nth-child(4),
.performance-table td:nth-child(4) {
  width: 10%;
}

.performance-table th:nth-child(5),
.performance-table td:nth-child(5) {
  width: 9%;
}

.performance-table th:nth-child(n+6),
.performance-table td:nth-child(n+6) {
  width: 8%;
}

.performance-table td:nth-child(2),
.performance-table th:nth-child(2) {
  text-align: center;
}

.performance-table td:nth-child(2) strong {
  display: block;
  font-size: 12px;
  line-height: 1.15;
}

.performance-table td:nth-child(2) span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.performance-table td:nth-child(n+6) {
  color: #061f44;
  font-size: 16px;
  font-weight: 600;
}

.leader-row td {
  background: linear-gradient(90deg, var(--theme-dark), var(--theme));
  color: #fff;
  font-weight: 900;
  text-align: center;
  font-size: 14px;
}

.total-row td {
  background: var(--theme);
  color: #fff;
  font-weight: 900;
}

.negative {
  color: var(--bad);
  font-weight: 900;
}

.positive {
  color: var(--good);
  font-weight: 900;
}

.signup-increment {
  color: var(--good);
  font-weight: 900;
}

.report-lower {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.report-box {
  overflow: hidden;
}

.box-title {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--theme-dark);
  font-size: 17px;
  font-weight: 900;
  text-align: center;
}

.box-body {
  padding: 9px;
}

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

.summary-table th,
.summary-table td {
  border-bottom: 1px solid var(--line);
  padding: 8px 6px;
  text-align: center;
}

.summary-table th:first-child,
.summary-table td:first-child {
  text-align: center;
}

.progress {
  height: 10px;
  border-radius: 99px;
  background: #e8eef5;
  overflow: hidden;
}

.progress span {
  display: block;
  height: 100%;
  background: #91d48d;
}

.progress.need span {
  background: #ffc34d;
}

.progress.critical span {
  background: #ff6b6b;
}

.podium {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  align-items: end;
}

.rank-card {
  position: relative;
  min-height: 104px;
  border: 2px solid var(--line);
  border-radius: 8px;
  padding: 20px 8px 10px;
  text-align: center;
  background: #fff;
}

.rank-card.rank-1 {
  border-color: #f2d46f;
  background: #fff9dd;
  min-height: 128px;
}

.medal {
  position: absolute;
  top: -13px;
  left: 50%;
  transform: translateX(-50%);
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  color: #fff;
  font-weight: 900;
}

.rank-1 .medal {
  background: var(--gold);
}

.rank-2 .medal {
  background: var(--silver);
}

.rank-3 .medal {
  background: var(--bronze);
}

.rank-card strong {
  display: block;
  font-size: 18px;
}

.rank-card .big {
  display: block;
  margin-top: 6px;
  color: var(--theme-dark);
  font-size: 40px;
  font-weight: 900;
}

.chart {
  width: 100%;
  height: 160px;
}

.editor-grid {
  display: grid;
  gap: 14px;
}

.panel {
  padding: 14px;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.panel-title h2 {
  margin: 0;
  font-size: 18px;
}

.bdo-inputs,
.settings-groups {
  display: grid;
  gap: 10px;
}

.bdo-card {
  border: 1px solid var(--line);
  border-left: 5px solid var(--theme);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.bdo-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.bdo-card h3 {
  margin: 0;
  font-size: 15px;
}

.delete-bdo-btn {
  flex: 0 0 auto;
  min-height: 36px;
  border-color: #f3b4b4;
  background: #fff5f5;
  color: #b42318;
  padding: 8px 10px;
  font-size: 12px;
}

.delete-bdo-btn:hover {
  border-color: #d92d20;
  background: #fee4e2;
}

.transparent-tm-field {
  justify-content: flex-start;
  border: 1px dashed var(--theme);
  border-radius: 8px;
  padding: 10px;
  background: var(--soft);
  color: var(--theme-dark);
  font-weight: 800;
}

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

.input-grid .wide {
  grid-column: 1 / -1;
}

fieldset {
  display: grid;
  gap: 10px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

legend {
  padding: 0 6px;
  color: var(--theme-dark);
  font-weight: 900;
}

.check {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
}

.check input {
  width: auto;
  min-height: auto;
}

.check-grid,
.region-settings,
.auto-list {
  display: grid;
  gap: 8px;
}

.auto-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.auto-list span {
  padding: 8px;
  border-radius: 8px;
  background: var(--soft);
  color: var(--theme-dark);
  font-size: 12px;
  font-weight: 800;
}

.history-list {
  display: grid;
  gap: 8px;
}

.history-item {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.image-result {
  display: grid;
  gap: 12px;
  margin: 14px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.image-result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.image-result-head h2 {
  margin: 0;
  color: var(--theme-dark);
  font-size: 18px;
}

.image-result img {
  width: 100%;
  max-height: 70vh;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: contain;
  background: #fff;
}

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

.mobile-help {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.bottom-action {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(8px);
}

.bottom-action button {
  width: 100%;
}

.hide {
  display: none !important;
}

@media (min-width: 760px) {
  .app-header {
    padding: 16px 24px;
  }

  .app-shell {
    padding: 18px 18px 92px;
  }

  .control-strip {
    grid-template-columns: 220px 1fr 330px;
    align-items: end;
  }

  .report-top {
    grid-template-columns: 220px 1fr 170px;
  }

  .days-card {
    justify-self: end;
  }

  .metric-row {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .report-lower {
    grid-template-columns: 1fr 1fr;
  }

  .report-lower .wide-box {
    grid-column: span 1;
  }

  .podium {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: end;
  }

  .rank-card.rank-1 {
    min-height: 150px;
  }

  .editor-grid {
    grid-template-columns: 1.1fr 0.9fr;
  }

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

  .settings-groups {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media print {
  body {
    background: #fff;
  }

  .app-header,
  .control-strip,
  .editor-grid,
  .panel,
  .bottom-action {
    display: none !important;
  }

  .app-shell {
    padding: 0;
  }

  .report-preview {
    border: 0;
    box-shadow: none;
  }
}
