:root {
  --ink: #17211c;
  --muted: #66716b;
  --line: #dce3de;
  --paper: #f6f7f5;
  --white: #fff;
  --green: #176b50;
  --green-soft: #dceee4;
  --amber: #a96800;
  --amber-soft: #fff0ce;
  --gray-soft: #eef1ef;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--paper); font-family: var(--font); }
button, input, select { font: inherit; }
.matrix-header { height: 68px; padding: 0 24px; border-bottom: 1px solid var(--line); background: var(--white); display: flex; align-items: center; justify-content: space-between; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.brand-logo { display: block; width: 180px; height: 30px; flex: 0 0 180px; overflow: hidden; }
.brand-logo img { display: block; width: 192.5px; max-width: none; height: auto; transform: translate(-5.8px, -11.3px); }
.back-link { color: var(--green); font-size: 13px; font-weight: 700; text-decoration: none; }
main { width: min(1800px, calc(100% - 32px)); margin: 34px auto 70px; }
.page-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.page-title p { margin: 0 0 8px; color: var(--green); font-size: 12px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
h1 { margin: 0; font-size: clamp(30px, 4vw, 48px); line-height: 1.05; letter-spacing: -.035em; }
.legend { display: flex; flex-wrap: wrap; gap: 12px 22px; margin-top: 18px; color: var(--muted); font-size: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.merge-note { max-width: 900px; margin: 12px 0 0 !important; color: var(--muted) !important; font-size: 11px !important; font-weight: 500 !important; letter-spacing: 0 !important; line-height: 1.45; text-transform: none !important; }
.total-card { flex: 0 0 170px; padding: 17px 19px; border: 1px solid var(--line); border-radius: 14px; background: white; }
.total-card strong, .total-card span { display: block; }
.total-card strong { font-size: 28px; }
.total-card span { margin-top: 3px; color: var(--muted); font-size: 11px; }
.toolbar { display: grid; grid-template-columns: minmax(250px, 1.5fr) minmax(210px, 1.2fr) repeat(3, minmax(140px, 1fr)); gap: 10px; margin-bottom: 14px; }
.toolbar label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 10px; font-weight: 700; }
.toolbar input, .toolbar select { min-height: 44px; width: 100%; padding: 0 12px; border: 1px solid var(--line); border-radius: 9px; background: white; color: var(--ink); outline: none; }
.toolbar input:focus, .toolbar select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(23, 107, 80, .1); }
.summary { margin: 12px 0; color: var(--muted); font-size: 12px; }
.table-scroll { max-height: calc(100vh - 275px); overflow: auto; border: 1px solid var(--line); border-radius: 12px; background: white; }
.matrix-table { width: max-content; min-width: 100%; border-collapse: separate; border-spacing: 0; font-size: 11px; }
.matrix-table th { position: sticky; top: 0; z-index: 3; width: 175px; min-width: 175px; max-width: 175px; padding: 11px 10px; border-right: 1px solid #e4e9e5; border-bottom: 1px solid var(--line); background: #f0f3f0; color: #53605a; text-align: left; font-size: 10px; vertical-align: top; }
.matrix-table th.condition-column { left: 0; z-index: 5; width: 420px; min-width: 420px; max-width: 420px; }
.program-heading strong, .program-heading small { display: block; }
.program-heading strong { color: var(--ink); font-size: 11px; line-height: 1.35; }
.program-heading small { margin-top: 5px; color: var(--muted); font-weight: 500; }
.program-heading a { display: inline-block; margin-top: 6px; color: var(--green); text-decoration: none; }
.matrix-table td { width: 175px; min-width: 175px; max-width: 175px; height: 47px; padding: 9px 10px; border-right: 1px solid #edf0ed; border-bottom: 1px solid #edf0ed; vertical-align: middle; text-align: center; }
.matrix-table tbody tr:hover td { background: #fafcf9; }
.matrix-table td.condition-cell { position: sticky; left: 0; z-index: 2; width: 420px; min-width: 420px; max-width: 420px; background: white; text-align: left; }
.condition-cell strong { display: block; font-size: 11px; line-height: 1.4; }
.condition-kind { display: inline-block; margin-bottom: 4px; padding: 3px 6px; border-radius: 5px; background: var(--gray-soft); color: var(--muted); font-size: 8px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.mark { width: 24px; height: 24px; display: inline-grid; place-items: center; border-radius: 7px; font-style: normal; font-weight: 850; }
.mark.required { color: var(--green); background: var(--green-soft); }
.mark.alternative { color: var(--amber); background: var(--amber-soft); }
.mark.absent { color: #89928d; background: var(--gray-soft); }
.mark.unknown { color: #8a5c00; background: var(--amber-soft); }
.empty-row td { padding: 34px; color: var(--muted); text-align: center; }
.matrix-pagination { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 14px; }
.matrix-pagination button { min-height: 38px; padding: 0 14px; border: 1px solid var(--line); border-radius: 8px; background: white; color: var(--green); font-size: 11px; font-weight: 750; cursor: pointer; }
.matrix-pagination button:disabled { color: #9aa39e; cursor: default; }
.matrix-pagination span { min-width: 110px; color: var(--muted); text-align: center; font-size: 11px; }

@media (max-width: 900px) {
  main { width: calc(100% - 20px); margin-top: 22px; }
  .page-title { display: block; }
  .total-card { width: 170px; margin-top: 16px; }
  .toolbar { grid-template-columns: 1fr 1fr; }
  .search { grid-column: 1 / -1; }
  .table-scroll { max-height: calc(100vh - 355px); }
  .matrix-table th.condition-column, .matrix-table td.condition-cell { width: 300px; min-width: 300px; max-width: 300px; }
}
