:root {
  --bg: #f7f7f4;
  --surface: #ffffff;
  --surface-soft: #f0f3f1;
  --ink: #171a1f;
  --muted: #667085;
  --line: #d9ddd6;
  --accent: #0f766e;
  --accent-soft: #d9eeea;
  --danger: #a15c07;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  letter-spacing: 0;
}

.app-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  padding: 24px clamp(18px, 4vw, 48px);
  border-bottom: 1px solid var(--line);
  background: rgba(247, 247, 244, 0.92);
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(12px);
}

h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1;
  font-weight: 760;
}

.app-header p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

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

.header-meta span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
  color: var(--muted);
  background: var(--surface);
  font-size: 12px;
  white-space: nowrap;
}

.layout {
  display: grid;
  grid-template-columns: 296px minmax(0, 1fr);
  gap: 28px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px clamp(18px, 4vw, 48px) 56px;
}

.sidebar {
  position: sticky;
  top: 110px;
  align-self: start;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  padding: 18px;
}

.control-group + .control-group {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.group-title {
  margin-bottom: 12px;
  font-size: 13px;
  font-weight: 750;
}

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

input,
select,
button {
  width: 100%;
  min-height: 42px;
  border-radius: 7px;
  font: inherit;
}

input,
select {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  padding: 0 11px;
  margin-bottom: 10px;
}

input:focus,
select:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

.actions {
  display: grid;
  grid-template-columns: 1fr 78px;
  gap: 10px;
  margin-top: 20px;
}

button {
  border: 0;
  background: var(--accent);
  color: white;
  font-weight: 740;
  cursor: pointer;
  transition: background 140ms ease, transform 140ms ease;
}

button:hover {
  background: #0b5f59;
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.55;
  cursor: wait;
  transform: none;
}

button.ghost {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-weight: 680;
}

button.ghost:hover {
  background: var(--surface-soft);
}

.status-line {
  min-height: 18px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.status-line.busy {
  color: var(--accent);
}

.data-note {
  margin: 4px 0 0;
  color: #8a94a3;
  font-size: 11px;
  line-height: 1.35;
}

.workspace {
  min-width: 0;
}

.empty-state {
  display: grid;
  gap: 8px;
  min-height: 220px;
  place-content: center;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.55);
  padding: 28px;
}

.empty-state strong {
  color: var(--ink);
  font-size: 18px;
}

.summary {
  display: grid;
  grid-template-columns: minmax(180px, 1.15fr) minmax(150px, 0.9fr) minmax(140px, 0.8fr) minmax(180px, 1.05fr);
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}

.metric {
  min-height: 112px;
  padding: 18px 20px;
  border-right: 1px solid var(--line);
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.metric:last-child {
  border-right: 0;
}

.metric small {
  display: block;
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
}

.metric-value {
  display: block;
  max-width: 100%;
  font-size: clamp(30px, 3vw, 42px);
  line-height: 0.96;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.metric-value.date-value {
  font-size: clamp(20px, 1.55vw, 25px);
  line-height: 1.08;
  letter-spacing: 0;
}

.metric.featured {
  background: linear-gradient(180deg, #ffffff 0%, #f7faf8 100%);
}

.metric.featured .metric-value {
  color: #061411;
}

.metric.context {
  background: #fbfbf8;
}

.metric .sub {
  display: block;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
}

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin: 28px 0 10px;
}

h2 {
  margin: 0;
  font-size: 16px;
  line-height: 1.2;
}

.note {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
}

th,
td {
  padding: 13px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

th {
  background: #fafbf9;
  color: var(--muted);
  font-size: 12px;
  font-weight: 740;
}

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

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

.digit {
  width: 56px;
  padding: 7px 6px;
  border-radius: 7px;
  background: var(--surface-soft);
  text-align: center;
  font-weight: 760;
  font-variant-numeric: tabular-nums;
}

.digit.actual {
  background: var(--accent-soft);
  color: var(--accent);
}

.digit span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 520;
}

.rank {
  color: var(--accent);
  font-weight: 780;
}

.warn {
  color: var(--danger);
}

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

@media (max-width: 860px) {
  .app-header {
    align-items: start;
    flex-direction: column;
  }

  .header-meta {
    justify-content: start;
  }

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

  .sidebar {
    position: static;
  }

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

  .metric:nth-child(2n) {
    border-right: 0;
  }

  .metric:nth-child(-n + 2) {
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 1180px) and (min-width: 861px) {
  .summary {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
  }

  .metric:nth-child(2n) {
    border-right: 0;
  }

  .metric:nth-child(-n + 2) {
    border-bottom: 1px solid var(--line);
  }
}

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

  .metric,
  .metric:nth-child(2n),
  .metric:nth-child(-n + 2) {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .metric:last-child {
    border-bottom: 0;
  }
}
