:root {
  --bg: #151b17;
  --panel: rgba(30, 40, 33, 0.94);
  --panel-strong: #242e27;
  --line: rgba(221, 234, 222, 0.17);
  --line-strong: rgba(221, 234, 222, 0.3);
  --text: #f2f5ed;
  --muted: #aebbb0;
  --accent: #b9f76a;
  --accent-soft: rgba(185, 247, 106, 0.14);
  --blue: #91c8ff;
  --amber: #ffce73;
  --danger: #ff8c7d;
  --grid: rgba(255, 255, 255, 0.027);
  --input: rgba(25, 33, 28, 0.96);
  --subtle: rgba(255, 255, 255, 0.06);
  --faint-line: rgba(221, 234, 222, 0.1);
  --shadow: 0 14px 40px rgba(0, 0, 0, 0.18);
  --radius: 18px;
  --mono: "SFMono-Regular", "Cascadia Code", "Roboto Mono", monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
}

:root[data-theme="light"] {
  --bg: #eef2ea;
  --panel: rgba(255, 255, 255, 0.92);
  --panel-strong: #ffffff;
  --line: rgba(34, 48, 36, 0.15);
  --line-strong: rgba(34, 48, 36, 0.28);
  --text: #19231b;
  --muted: #637067;
  --accent: #4e7d16;
  --accent-soft: rgba(78, 125, 22, 0.12);
  --blue: #245f91;
  --amber: #8a5a08;
  --danger: #a73d31;
  --grid: rgba(26, 39, 28, 0.05);
  --input: rgba(255, 255, 255, 0.96);
  --subtle: rgba(30, 46, 33, 0.06);
  --faint-line: rgba(34, 48, 36, 0.09);
  --shadow: 0 14px 40px rgba(43, 58, 46, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  transition: background-color 180ms ease, color 180ms ease;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 32px 32px;
  transition: background-color 180ms ease;
}

button,
input {
  font: inherit;
}

.ambient {
  position: fixed;
  z-index: -1;
  border-radius: 999px;
  filter: blur(100px);
  opacity: 0.11;
  pointer-events: none;
}

.ambient-one {
  width: 440px;
  height: 440px;
  top: -180px;
  right: 8%;
  background: var(--accent);
}

.ambient-two {
  width: 360px;
  height: 360px;
  left: -180px;
  top: 50%;
  background: #4695ff;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1440px;
  margin: 0 auto;
  padding: 28px 36px;
  border-bottom: 1px solid var(--line);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 18px;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  font-family: var(--mono);
  font-size: 10px;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.theme-icon {
  color: var(--accent);
  font-size: 15px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--accent);
  border-radius: 12px;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: -0.05em;
  box-shadow: inset 0 0 18px var(--accent-soft);
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 15px;
  letter-spacing: 0.01em;
}

.brand small {
  margin-top: 3px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
}

.live-state {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
}

.pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 0 5px rgba(255, 206, 115, 0.1);
}

.pulse.online {
  background: var(--accent);
  box-shadow: 0 0 0 5px var(--accent-soft);
}

.pulse.error {
  background: var(--danger);
  box-shadow: 0 0 0 5px rgba(255, 140, 125, 0.1);
}

main {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 36px 48px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(420px, 1fr) minmax(460px, 0.9fr);
  gap: 40px;
  align-items: center;
  padding: 30px 0 26px;
}

.eyebrow,
.section-label {
  color: var(--accent);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.17em;
  text-transform: uppercase;
}

h1 {
  margin: 7px 0 9px;
  font-size: clamp(34px, 4vw, 52px);
  font-weight: 680;
  letter-spacing: -0.045em;
  line-height: 1;
}

h1 span {
  color: var(--muted);
  font-weight: 420;
}

.hero-copy {
  max-width: 560px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.hero-actions {
  display: flex;
  flex-direction: row;
  gap: 8px;
}

.search {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-height: 44px;
  padding: 0 13px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--input);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search span {
  color: var(--accent);
  font-size: 17px;
}

.search input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.search input::placeholder {
  color: #6f796f;
}

.refresh-button {
  flex: 0 0 132px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  transition: color 160ms ease, border-color 160ms ease;
}

.refresh-button:hover {
  border-color: var(--line-strong);
  color: var(--text);
}

.refresh-button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.metric {
  min-height: 125px;
  padding: 22px;
  border-right: 1px solid var(--line);
}

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

.metric-label {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.metric-value {
  display: block;
  margin-top: 16px;
  font-family: var(--mono);
  font-size: clamp(25px, 3vw, 38px);
  line-height: 1;
}

.metric-note {
  display: block;
  margin-top: 9px;
  color: var(--muted);
  font-size: 11px;
}

.skeleton {
  background: linear-gradient(
    100deg,
    transparent 25%,
    rgba(255, 255, 255, 0.035) 45%,
    transparent 65%
  );
  background-size: 240% 100%;
  animation: shimmer 1.4s infinite;
}

.product-nav {
  padding: 44px 0 26px;
}

.product-filters {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-width: thin;
}

.product-chip {
  flex: 0 0 auto;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  cursor: pointer;
}

.product-chip:hover,
.product-chip.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.product-chip b {
  margin-left: 6px;
  font-weight: 500;
  opacity: 0.65;
}

.content {
  display: grid;
  gap: 14px;
}

.product {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.product-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--line);
}

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

.product-title > div {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
}

.product-index {
  color: var(--accent);
  font-family: var(--mono);
  font-size: 11px;
}

.product h2 {
  margin: 0;
  font-size: 17px;
  letter-spacing: -0.025em;
}

.namespace {
  margin-top: 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
}

.workload-count {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
}

.workloads {
  display: grid;
}

.workload {
  padding: 15px 18px 17px;
  border-bottom: 1px solid var(--line);
}

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

.workload-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 11px;
}

.workload-name {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.workload-name h3 {
  margin: 0;
  font-size: 13px;
}

.kind,
.mode,
.replicas,
.maturity {
  border-radius: 6px;
  padding: 3px 6px;
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.05em;
}

.kind {
  background: rgba(145, 200, 255, 0.1);
  color: var(--blue);
}

.mode {
  background: rgba(255, 206, 115, 0.1);
  color: var(--amber);
}

.replicas {
  background: var(--subtle);
  color: var(--muted);
}

.maturity {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  padding: 0;
  text-align: right;
}

.maturity b {
  font-size: 8px;
  font-weight: 650;
}

.maturity small {
  color: var(--muted);
  font-size: 8px;
  letter-spacing: 0;
}

.maturity-collecting,
.maturity-warming {
  color: var(--amber);
}

.maturity-early {
  color: #e0ad56;
}

.maturity-learning {
  color: var(--blue);
}

.maturity-usable,
.maturity-mature {
  color: var(--accent);
}

.container-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.container-table th:nth-child(1) {
  width: 9%;
}

.container-table th:nth-child(2),
.container-table th:nth-child(4) {
  width: 12%;
}

.container-table th:nth-child(3) {
  width: 25%;
}

.container-table th:nth-child(5) {
  width: 42%;
}

.container-table th {
  padding: 0 12px 10px;
  color: #717c72;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-align: right;
  text-transform: uppercase;
}

.container-table th:first-child,
.container-table td:first-child {
  padding-left: 0;
  text-align: left;
}

.container-table td {
  padding: 13px 12px;
  border-top: 1px solid var(--faint-line);
  font-family: var(--mono);
  font-size: 11px;
  text-align: right;
  vertical-align: middle;
}

.container-name {
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.resource-pair {
  display: inline-grid;
  grid-template-columns: auto auto;
  gap: 8px;
  align-items: baseline;
}

.resource-pair b {
  color: var(--text);
  font-weight: 600;
}

.resource-pair small {
  color: var(--muted);
}

.empty-value b {
  color: #687269;
  font-size: 9px;
  font-weight: 500;
}

.delta-list {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 5px;
}

.delta {
  padding: 2px 4px;
  border-radius: 4px;
  font-size: 7px;
}

.delta.up {
  background: rgba(255, 140, 125, 0.1);
  color: var(--danger);
}

.delta.down {
  background: rgba(145, 200, 255, 0.1);
  color: var(--blue);
}

.delta.same {
  background: var(--accent-soft);
  color: var(--accent);
}

.target-cell {
  background: linear-gradient(90deg, transparent, var(--accent-soft));
}

.target-cell .resource-pair b {
  color: var(--accent);
}

.limit-cell {
  background: linear-gradient(90deg, transparent, rgba(145, 200, 255, 0.07));
}

.limit-recommendation {
  display: inline-flex;
  max-width: 100%;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
}

.limit-recommendation > .resource-pair b {
  color: var(--blue);
}

.limit-status,
.limit-actions,
.request-actions,
.limit-evidence {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 4px;
}

.request-actions {
  margin-top: 4px;
}

.limit-confidence,
.limit-action,
.limit-evidence span {
  padding: 2px 4px;
  border-radius: 4px;
  font-size: 7px;
  line-height: 1.25;
}

.limit-confidence {
  border: 1px solid currentColor;
}

.limit-collecting {
  color: var(--amber);
}

.limit-preliminary {
  color: #e0ad56;
}

.limit-medium {
  color: var(--blue);
}

.limit-ready {
  color: var(--accent);
}

.limit-evidence span {
  background: var(--subtle);
  color: var(--muted);
}

.limit-action {
  background: var(--subtle);
  color: var(--muted);
}

.action-increase {
  background: rgba(255, 140, 125, 0.1);
  color: var(--danger);
}

.action-decrease {
  background: rgba(145, 200, 255, 0.1);
  color: var(--blue);
}

.action-set {
  background: rgba(255, 206, 115, 0.1);
  color: var(--amber);
}

.action-keep {
  background: var(--accent-soft);
  color: var(--accent);
}

.limit-unavailable {
  color: var(--muted);
  font-size: 9px;
}

.pending,
.empty,
.error-card {
  padding: 58px 24px;
  color: var(--muted);
  text-align: center;
}

.error-card {
  border: 1px solid rgba(255, 140, 125, 0.25);
  border-radius: var(--radius);
  background: rgba(255, 140, 125, 0.05);
  color: var(--danger);
}

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 220px;
  color: var(--muted);
}

.loading span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: bounce 1s infinite alternate;
}

.loading span:nth-child(2) {
  animation-delay: 140ms;
}

.loading span:nth-child(3) {
  animation-delay: 280ms;
}

.loading p {
  margin-left: 8px;
  font-family: var(--mono);
  font-size: 11px;
}

footer {
  display: flex;
  justify-content: space-between;
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px 36px 34px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
}

footer strong {
  color: var(--accent);
}

@keyframes shimmer {
  to {
    background-position: -240% 0;
  }
}

@keyframes bounce {
  to {
    transform: translateY(-6px);
    opacity: 0.4;
  }
}

@media (max-width: 900px) {
  .hero {
    grid-template-columns: 1fr;
    gap: 18px;
  }

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

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

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

}

@media (max-width: 620px) {
  .topbar,
  main,
  footer {
    padding-left: 18px;
    padding-right: 18px;
  }

  .topbar {
    padding-top: 18px;
    padding-bottom: 18px;
  }

  .brand small,
  .live-state span:last-child {
    display: none;
  }

  .topbar-actions {
    gap: 9px;
  }

  .theme-toggle {
    width: 36px;
    padding: 0;
    justify-content: center;
  }

  .theme-label {
    display: none;
  }

  .hero {
    padding: 26px 0 22px;
  }

  h1 {
    font-size: 36px;
  }

  .hero-actions {
    flex-direction: column;
  }

  .refresh-button {
    flex-basis: 42px;
  }

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

  .metric {
    min-height: 105px;
    padding: 17px;
  }

  .product-header,
  .workload {
    padding: 13px 14px;
  }

  .workload-heading {
    align-items: flex-start;
    margin-bottom: 8px;
  }

  .maturity {
    align-items: flex-start;
    text-align: left;
  }

  .container-table,
  .container-table tbody,
  .container-table tr,
  .container-table td {
    display: block;
    width: 100%;
  }

  .container-table thead {
    display: none;
  }

  .container-table tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    padding: 15px 0;
    border-top: 1px solid var(--line);
  }

  .container-table td {
    display: block !important;
    padding: 5px 0;
    border: 0;
    text-align: left;
  }

  .container-table td:first-child {
    grid-column: 1 / -1;
    margin-bottom: 8px;
    font-size: 12px;
  }

  .container-table td::before {
    display: block;
    margin-bottom: 4px;
    color: #717c72;
    font-size: 8px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
  }

  .container-table td:nth-child(2)::before {
    content: "Текущий request";
  }

  .container-table td:nth-child(3)::before {
    content: "Target request";
  }

  .container-table td:nth-child(4)::before {
    content: "Текущий limit";
  }

  .container-table td:nth-child(5)::before {
    content: "Рекомендованный limit";
  }

  .target-cell,
  .limit-cell {
    background: none;
  }

  .delta-list,
  .limit-status,
  .limit-actions,
  .request-actions,
  .limit-evidence {
    justify-content: flex-start;
  }

  .limit-recommendation {
    align-items: flex-start;
  }

  footer {
    gap: 16px;
    align-items: flex-start;
    flex-direction: column;
  }
}
