:root {
  --bg: #eef3f8;
  --panel: #ffffff;
  --panel-strong: #f7fafc;
  --ink: #0d1628;
  --text: #172033;
  --muted: #627086;
  --line: #d8e2ee;
  --accent: #1f6feb;
  --accent-strong: #1d4ed8;
  --accent-soft: #e0ecff;
  --mint: #14b8a6;
  --green: #0f8a5f;
  --amber: #d97706;
  --rose: #e11d48;
  --shadow: 0 22px 60px rgba(15, 23, 42, 0.13);
  --shadow-soft: 0 10px 26px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, sans-serif;
  background:
    linear-gradient(180deg, #0d1628 0, #0d1628 278px, var(--bg) 278px),
    var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  padding: 18px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  max-width: 1680px;
  margin: 0 auto;
  padding: 24px 4px 28px;
  color: #ffffff;
}

.eyebrow {
  margin: 0 0 6px;
  color: #7dd3fc;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 36px;
  letter-spacing: 0;
}

.ghost-button,
.mode-button,
.group-button,
.favorite-button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
}

.ghost-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 16px;
  border-radius: 8px;
  font-weight: 700;
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  backdrop-filter: blur(10px);
}

.ghost-button.is-active,
.favorite-button.is-active {
  border-color: #f59e0b;
  background: #fffbeb;
  color: #92400e;
}

.workspace {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 360px;
  gap: 20px;
  max-width: 1680px;
  margin: 0 auto;
  padding: 0 0 24px;
}

.sidebar,
.catalog,
.detail-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.sidebar {
  align-self: start;
  padding: 16px;
  background: linear-gradient(180deg, #ffffff 0%, #f7fafc 100%);
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.mode-button {
  min-height: 36px;
  border-radius: 8px;
  font-weight: 700;
}

.mode-button.is-active {
  border-color: var(--accent);
  background: linear-gradient(135deg, var(--accent), #0f8a5f);
  color: #ffffff;
}

.search-label {
  display: block;
  margin: 18px 0 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.search-input,
.group-select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 12px;
  background: #ffffff;
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(15, 23, 42, 0.03);
}

.search-input:focus,
.group-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.16);
  outline: none;
}

.mobile-filter {
  display: none;
}

.group-list {
  display: grid;
  gap: 6px;
  margin-top: 18px;
}

.group-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 40px;
  border-radius: 10px;
  padding: 0 12px;
  text-align: left;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.group-button:hover {
  background: #f1f6fd;
  border-color: #bfd0e4;
  transform: translateX(2px);
}

.group-button.is-active {
  border-color: var(--accent);
  background: linear-gradient(135deg, var(--accent-soft), #ecfdf5);
  color: var(--accent-strong);
  font-weight: 700;
}

.group-count {
  color: var(--muted);
  font-size: 12px;
}

.catalog {
  min-width: 0;
  padding: 22px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(255, 255, 255, 0.98)),
    var(--panel);
}

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

.catalog-head h2 {
  margin-bottom: 7px;
  font-size: 28px;
}

.catalog-head p {
  margin-bottom: 0;
  color: var(--muted);
}

.view-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: #e0ecff;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.badge-soft {
  background: #ecfdf5;
  color: var(--green);
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.metric-card {
  position: relative;
  overflow: hidden;
  display: grid;
  gap: 12px;
  min-height: 210px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background:
    linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  text-align: left;
  box-shadow: var(--shadow-soft);
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.metric-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: linear-gradient(180deg, var(--accent), var(--mint), var(--amber));
}

.metric-card:hover {
  border-color: #b6c8dd;
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.14);
  transform: translateY(-2px);
}

.metric-card.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.16), 0 18px 42px rgba(15, 23, 42, 0.14);
}

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

.metric-card h3 {
  margin-bottom: 4px;
  font-size: 18px;
  color: var(--ink);
}

.metric-short {
  color: var(--muted);
  font-size: 13px;
}

.metric-description {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.formula {
  margin: 0;
  padding: 11px 12px;
  border-radius: 8px;
  background: linear-gradient(135deg, #eef4ff, #edfdf8);
  color: #20304f;
  font-weight: 700;
  border: 1px solid #d9e7fb;
}

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

.tag {
  padding: 5px 8px;
  border-radius: 999px;
  background: #f8fafc;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.favorite-button {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  font-size: 18px;
  transition: background 160ms ease, transform 160ms ease;
}

.favorite-button:hover {
  transform: scale(1.04);
}

.detail-panel {
  align-self: start;
  position: sticky;
  top: 20px;
  padding: 20px;
  border-color: #cbd8e8;
  background:
    linear-gradient(180deg, #10203a 0, #10203a 96px, #ffffff 96px);
}

.detail-panel h2 {
  margin-bottom: 5px;
  font-size: 24px;
  color: #ffffff;
}

.detail-panel > .metric-short {
  color: #b9c7da;
}

.detail-section {
  margin-top: 18px;
  padding: 14px;
  border: 1px solid #e4ebf4;
  border-radius: 10px;
  background: #ffffff;
}

.detail-section h3 {
  margin-bottom: 8px;
  color: var(--accent-strong);
  font-size: 13px;
  text-transform: uppercase;
}

.detail-section p,
.detail-section li {
  color: #334155;
  line-height: 1.5;
}

.detail-section ul {
  margin: 0;
  padding-left: 18px;
}

.empty-state,
.empty-detail {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 260px minmax(0, 1fr);
  }

  .detail-panel {
    grid-column: 1 / -1;
    position: static;
  }
}

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 10px 0 18px;
  }

  h1 {
    font-size: 28px;
  }

  .workspace {
    display: block;
    padding: 0;
  }

  .sidebar,
  .catalog,
  .detail-panel {
    margin-bottom: 12px;
    box-shadow: none;
  }

  .group-list {
    display: none;
  }

  .mobile-filter {
    display: block;
  }

  .catalog {
    padding: 16px;
  }

  .catalog-head {
    display: block;
  }

  .view-badges {
    justify-content: flex-start;
    margin-top: 12px;
  }

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