:root {
  --bg: #f4f8ff;
  --surface: #ffffff;
  --surface-soft: #f5f9ff;
  --text: #162036;
  --muted: #4f5f78;
  --line: #3b82f6;
  --line-soft: #bfd8ff;
  --card-border: #d8e3f2;
  --blue: #2f76f6;
  --blue-soft: #eaf2ff;
  --violet: #9d42f5;
  --violet-soft: #f2e7ff;
  --green: #0ccb54;
  --orange: #ff6a00;
  --orange-soft: #fff5e7;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Inter", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top center, rgba(255, 255, 255, 0.9), transparent 28%),
    linear-gradient(180deg, #eff5ff 0%, var(--bg) 45%, #eef4ff 100%);
}

h1,
h2,
h3,
h4,
p,
ul {
  margin: 0;
}

.page {
  width: min(1540px, calc(100vw - 44px));
  margin: 0 auto;
  padding: 14px 0 24px;
}

.page-header {
  padding: 4px 0 12px;
}

.page-header-topline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.page-header h1 {
  font-size: clamp(1.7rem, 3vw, 3.15rem);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.04em;
}

.page-header p {
  margin-top: 8px;
  font-size: clamp(0.92rem, 1.1vw, 1.25rem);
  color: var(--muted);
}

.top-tabs {
  display: inline-flex;
  gap: 8px;
  margin-bottom: 10px;
  padding: 5px;
  border: 1px solid var(--card-border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
}

.top-tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 14px;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

.top-tab.active {
  background: var(--blue);
  color: #fff;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.products-block,
.org-block,
.costs-block,
.registry-block {
  margin-top: 12px;
}

.block-title {
  margin-bottom: 12px;
  font-size: clamp(1.45rem, 1.8vw, 2rem);
  font-weight: 800;
  letter-spacing: -0.04em;
}

.product-groups,
.group-products-grid,
.members-grid,
.cost-summary-grid {
  display: grid;
  gap: 14px;
}

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

.product-groups {
  grid-template-columns: 1fr;
  align-items: start;
}

.group-products-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
}

.product-group {
  display: grid;
  gap: 12px;
}

.product-group + .product-group {
  margin-top: 20px;
}

.product-group-header {
  display: grid;
  gap: 4px;
  margin-bottom: 0;
  padding-bottom: 8px;
  border-bottom: 1px solid #dde8f7;
}

.product-group-header h3 {
  font-size: 0.98rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.product-group-header p {
  color: var(--muted);
  font-size: 0.74rem;
  text-align: left;
  max-width: 56ch;
}

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

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

.product-card,
.member-card,
.summary-card,
.year-card,
.registry-card {
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  box-shadow: 0 6px 18px rgba(59, 130, 246, 0.035);
}

.registry-card {
  padding: 16px;
  display: grid;
  gap: 14px;
  align-content: space-between;
  min-height: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.96), rgba(246,250,255,0.92));
}

.registry-top {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.registry-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: #2250df;
  background: linear-gradient(180deg, #eef5ff, #dfeeff);
}

.registry-copy {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.registry-copy .badge {
  margin-top: 0;
  width: fit-content;
}

.registry-copy h3 {
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.25;
}

.registry-copy p {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.registry-action {
  width: fit-content;
}

.registry-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.registry-action.secondary {
  background: #eef4ff;
  color: #214fd8;
}

.product-card {
  min-height: 0;
  padding: 16px;
  overflow: hidden;
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 12px;
  background: linear-gradient(180deg, rgba(255,255,255,0.96), rgba(247,250,255,0.92));
  border-radius: 20px;
  box-shadow: 0 10px 24px rgba(45, 95, 180, 0.06);
  height: 100%;
}

.product-top {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  min-height: 0;
}

.product-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: #fff;
  flex: 0 0 auto;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.product-icon.blue {
  background: linear-gradient(180deg, #3f8bff, var(--blue));
}

.product-icon.violet {
  background: linear-gradient(180deg, #ad55ff, var(--violet));
}

.product-icon.astons-brand {
  color: #d32f2f;
  background: linear-gradient(180deg, #ffffff, #f4f7fb);
  border: 1px solid rgba(211, 47, 47, 0.14);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.product-icon.favicon {
  background: linear-gradient(180deg, #ffffff, #f4f7fb);
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.product-icon.favicon img {
  display: block;
  border-radius: 4px;
}

.product-icon svg,
.meta-icon svg,
.toggle-icon svg,
.salary-toggle svg,
.summary-icon svg {
  display: block;
}

.product-name {
  font-size: clamp(0.96rem, 1.02vw, 1.08rem);
  font-weight: 800;
  line-height: 1.2;
  word-break: break-word;
}

.product-copy {
  display: grid;
  grid-template-rows: auto 1fr;
  align-content: start;
  min-width: 0;
}

.product-heading {
  display: grid;
  gap: 3px;
}

.product-kicker {
  color: #2960d7;
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.product-desc {
  margin-top: 6px;
  max-width: 42ch;
  color: var(--muted);
  font-size: clamp(0.76rem, 0.82vw, 0.84rem);
  line-height: 1.38;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: auto;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 8px;
  padding: 5px 9px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.66rem;
  line-height: 1;
}

.product-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 12px;
  border-radius: 999px;
  background: #162036;
  color: #fff;
  text-decoration: none;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
  transition: transform 140ms ease, opacity 140ms ease;
}

.product-action:hover {
  opacity: 0.92;
  transform: translateY(-1px);
}

.product-action.disabled {
  background: #dbe5f3;
  color: #5f6f88;
  cursor: default;
  pointer-events: none;
}

.badge.blue {
  color: #2250df;
  background: var(--blue-soft);
}

.badge.violet {
  color: #8722ec;
  background: var(--violet-soft);
}

.org-section {
  margin-top: 18px;
}

.org-section:first-child {
  margin-top: 8px;
}

.org-section-header {
  margin-bottom: 12px;
}

.org-section-header h3,
.year-card h3 {
  font-size: clamp(1.45rem, 1.7vw, 1.85rem);
  font-weight: 700;
  letter-spacing: -0.04em;
}

.section-line {
  margin-top: 8px;
  width: 100%;
  height: 2px;
  border-radius: 999px;
  background: var(--line);
}

.member-card {
  padding: 16px 16px 14px;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.contractor-card {
  background: linear-gradient(180deg, rgba(255, 250, 241, 0.96), rgba(255, 246, 230, 0.92));
  border-color: rgba(241, 168, 64, 0.35);
  box-shadow: 0 8px 20px rgba(214, 145, 33, 0.08);
}

.member-card[open] {
  box-shadow: 0 8px 18px rgba(59, 130, 246, 0.05);
}

.contractor-card[open] {
  box-shadow: 0 10px 22px rgba(214, 145, 33, 0.12);
}

.contractor-card .toggle-row,
.contractor-card .salary-toggle.active,
.contractor-card .salary-toggle:hover {
  color: #d07a14;
}

.member-summary {
  list-style: none;
  cursor: pointer;
}

.member-summary::-webkit-details-marker {
  display: none;
}

.member-headline {
  display: flex;
  align-items: center;
  gap: 6px;
}

.member-name {
  font-size: clamp(1.1rem, 1.28vw, 1.45rem);
  font-weight: 800;
  line-height: 1.12;
  letter-spacing: -0.04em;
}

.member-role {
  margin-top: 4px;
  color: var(--muted);
  font-size: clamp(0.8rem, 0.96vw, 0.95rem);
  line-height: 1.3;
}

.member-meta {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.meta-row,
.toggle-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: clamp(0.82rem, 0.94vw, 0.94rem);
}

.meta-row {
  color: #44526a;
}

.meta-icon.money {
  color: var(--green);
}

.salary-value {
  min-width: 56px;
  font-weight: 600;
}

.salary-value.locked {
  color: #7e8ca6;
}

.salary-toggle {
  width: 22px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  margin-left: 2px;
  border: 0;
  background: transparent;
  color: #7e8ca6;
  cursor: pointer;
  border-radius: 999px;
}

.salary-toggle:hover {
  color: #2663f6;
}

.salary-toggle.active {
  color: #2663f6;
}

.salary-toggle.locked,
.salary-toggle:disabled {
  color: #a3afc4;
  cursor: not-allowed;
  opacity: 0.85;
}

.salary-toggle.locked:hover,
.salary-toggle:disabled:hover {
  color: #a3afc4;
}

.toggle-row {
  margin-top: 10px;
  color: #2663f6;
  font-weight: 600;
}

.toggle-icon {
  width: 16px;
  height: 16px;
  display: inline-grid;
  place-items: center;
  transition: transform 160ms ease;
}

.member-card[open] .toggle-icon {
  transform: rotate(180deg);
}

.backlog {
  margin-top: 10px;
  padding-top: 2px;
}

.backlog h4 {
  margin-bottom: 8px;
  font-size: clamp(0.86rem, 0.96vw, 0.98rem);
  color: #3f4b62;
}

.backlog ul {
  padding-left: 18px;
  color: var(--muted);
  font-size: clamp(0.78rem, 0.88vw, 0.9rem);
  line-height: 1.35;
}

.backlog li + li {
  margin-top: 2px;
}

.costs-intro {
  display: grid;
  gap: 14px;
}

.registry-intro {
  margin-bottom: 14px;
}

.top-spaced {
  margin-top: 18px;
}

.subsection-title {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.unit-table td:last-child,
.unit-table th:last-child {
  white-space: nowrap;
}

.invoice-card h3 {
  font-size: 0.92rem;
  word-break: break-word;
}

.costs-copy {
  max-width: 70ch;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

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

.summary-card {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 14px;
}

.summary-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--surface-soft);
  color: var(--blue);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

.summary-label {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.summary-value {
  margin-top: 3px;
  font-size: 1.1rem;
  font-weight: 800;
}

.summary-note {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.78rem;
}

.income-text {
  color: #0b9b52;
}

.expense-text {
  color: #d0672f;
}

.year-sections {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.year-card {
  padding: 14px;
}

.year-topline {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.year-caption {
  color: var(--muted);
  font-size: 0.82rem;
}

.table-wrap {
  overflow-x: auto;
}

.cost-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

.cost-table th,
.cost-table td {
  padding: 10px 8px;
  border-bottom: 1px solid #e4ecf8;
  text-align: left;
  white-space: nowrap;
  font-size: 0.82rem;
}

.cost-table th {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.cost-table td:last-child,
.cost-table th:last-child {
  text-align: right;
}

.cost-table td:nth-child(2),
.cost-table td:nth-child(3),
.cost-table td:nth-child(4),
.cost-table td:nth-child(5) {
  text-align: right;
}

.seo-table td:nth-child(6),
.seo-table th:nth-child(6) {
  text-align: right;
}

.cost-table .row-total {
  font-weight: 700;
  color: var(--text);
}

.cost-table .row-total.income-text {
  color: #0b9b52;
}

.cost-table .row-total.expense-text {
  color: #d0672f;
}

.summary-row.expanded td {
  background: #f8fbff;
}

.detail-row {
  display: none;
}

.detail-row.expanded {
  display: table-row;
}

.detail-row td {
  padding: 0 0 12px;
  border-bottom: 1px solid #e4ecf8;
}

.detail-panels {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 10px 4px 0;
}

.detail-panel {
  border-radius: 14px;
  padding: 12px;
}

.income-panel {
  background: #f2fff7;
  border: 1px solid #cdeed8;
}

.expense-panel {
  background: #fff7ef;
  border: 1px solid #f5dcc8;
}

.detail-label {
  margin-bottom: 10px;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.detail-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 0;
  font-size: 0.82rem;
}

.detail-item.total {
  margin-top: 6px;
  padding-top: 10px;
  border-top: 1px solid rgba(22, 32, 54, 0.1);
  font-weight: 700;
}

.row-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  background: transparent;
  color: #2663f6;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}

.row-toggle-icon {
  width: 14px;
  height: 14px;
  display: inline-grid;
  place-items: center;
}

.summary-row.expanded .row-toggle-icon {
  transform: rotate(180deg);
}

.cost-table tfoot td {
  font-weight: 800;
  background: #f7faff;
}

@media (max-width: 1180px) {
  .group-products-grid,
  .members-grid.cols-2,
  .members-grid.cols-3,
  .cost-summary-grid,
  .registry-grid {
    grid-template-columns: 1fr;
  }

  .detail-panels {
    grid-template-columns: 1fr;
  }

  .page {
    width: min(100vw - 28px, 1680px);
  }

  .page-header h1 {
    max-width: 12ch;
  }

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

@media (max-width: 720px) {
  .page {
    width: min(100vw - 24px, 1680px);
    padding: 10px 0 20px;
  }

  .page-header {
    padding: 2px 0 10px;
  }

  .page-header-topline {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .page-header h1 {
    max-width: none;
    font-size: clamp(1.7rem, 8vw, 2.3rem);
  }

  .page-header p {
    margin-top: 6px;
    max-width: 32ch;
    font-size: 0.9rem;
    line-height: 1.4;
  }

  .product-group-header {
    gap: 4px;
  }

  .product-group-header p {
    text-align: left;
  }

  .top-tabs {
    width: 100%;
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    padding: 4px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .top-tabs::-webkit-scrollbar {
    display: none;
  }

  .top-tab {
    flex: 0 0 auto;
    min-width: max-content;
    padding: 8px 12px;
    font-size: 0.78rem;
  }

  .products-block,
  .org-block,
  .costs-block,
  .registry-block {
    margin-top: 10px;
  }

  .block-title {
    margin-bottom: 10px;
    font-size: clamp(1.3rem, 7vw, 1.7rem);
  }

  .product-group + .product-group,
  .org-section,
  .year-sections,
  .time-distribution-grid {
    margin-top: 16px;
  }

  .registry-grid,
  .group-products-grid,
  .members-grid.cols-2,
  .members-grid.cols-3,
  .cost-summary-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .product-card,
  .member-card,
  .summary-card,
  .year-card,
  .registry-card {
    padding: 13px;
    border-radius: 16px;
  }

  .product-top {
    gap: 10px;
    align-items: flex-start;
  }

  .product-icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
  }

  .product-footer {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .product-action,
  .registry-action {
    width: 100%;
  }

  .registry-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .registry-top {
    flex-direction: column;
    align-items: stretch;
  }

  .registry-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
  }

  .summary-card {
    align-items: flex-start;
    padding: 13px;
  }

  .summary-value {
    font-size: 1rem;
  }

  .org-section-header {
    margin-bottom: 10px;
  }

  .org-section-header h3,
  .year-card h3 {
    font-size: 1.25rem;
  }

  .member-name {
    font-size: 1.08rem;
  }

  .member-role,
  .meta-row,
  .toggle-row,
  .costs-copy,
  .registry-copy p {
    font-size: 0.84rem;
  }

  .backlog ul {
    font-size: 0.82rem;
    line-height: 1.45;
  }

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