.pyw-dialog {
  width: min(1400px, calc(100% - 18px));
  height: min(900px, calc(100dvh - 18px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 30px 100px rgba(4, 18, 38, .46);
  overflow: hidden;
}
.pyw-dialog::backdrop { background: rgba(4, 16, 33, .74); backdrop-filter: blur(7px); }
.pyw-dialog > header { display: flex; align-items: center; justify-content: space-between; padding: 15px 19px; border-bottom: 1px solid var(--line); }
.pyw-dialog > header > div { display: flex; align-items: center; gap: 11px; }
.pyw-dialog > header > div > .material-symbols-rounded { width: 43px; height: 43px; display: grid; place-items: center; border-radius: 13px; background: linear-gradient(135deg, var(--primary, var(--teal)), #7158df); color: #fff; }
.pyw-dialog header small { color: var(--primary, var(--teal2)); font-size: 11px; font-weight: 850; letter-spacing: .11em; }
.pyw-dialog header h2 { margin: 2px 0; font-size: 20px; }
.pyw-dialog header p { margin: 0; color: var(--muted); font-size: 12px; }
.pyw-dialog > main { height: calc(100% - 140px); overflow: auto; padding: 17px 20px; background: color-mix(in srgb, var(--canvas) 62%, var(--surface)); }
.pyw-dialog > footer { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); }
.pyw-dialog > footer > span { margin-right: auto; color: var(--muted); font-size: 12px; }
.pyw-intro, .pyw-review-note { display: flex; align-items: center; gap: 11px; padding: 13px 15px; margin-bottom: 12px; border: 1px solid color-mix(in srgb, var(--primary, var(--teal)) 25%, var(--line)); border-radius: 13px; background: color-mix(in srgb, var(--primary, var(--teal)) 6%, var(--surface)); }
.pyw-intro > .material-symbols-rounded, .pyw-review-note > .material-symbols-rounded { font-size: 25px; color: var(--primary, var(--teal2)); }
.pyw-intro strong, .pyw-review-note strong { font-size: 14px; }
.pyw-intro p, .pyw-review-note p { margin: 3px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.pyw-setup-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.pyw-setup-grid > section, .pyw-step { padding: 15px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.pyw-step { margin-top: 11px; }
.pyw-setup-grid section > header, .pyw-step > header { display: flex; align-items: center; gap: 9px; margin-bottom: 12px; }
.pyw-setup-grid section > header > span, .pyw-step > header > span { width: 29px; height: 29px; display: grid; place-items: center; border-radius: 9px; background: var(--primary, var(--teal)); color: #fff; font-size: 12px; font-weight: 850; }
.pyw-setup-grid h3, .pyw-step h3 { margin: 0; font-size: 15px; }
.pyw-setup-grid header p, .pyw-step header p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.pyw-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.pyw-fields label, .pyw-template-options > label { display: flex; flex-direction: column; gap: 4px; }
.pyw-fields label > span { color: var(--muted); font-size: 12px; font-weight: 700; }
.pyw-year-choices { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.pyw-year-choices > label { position: relative; display: flex; align-items: center; gap: 8px; padding: 11px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); cursor: pointer; }
.pyw-year-choices > label:has(input:checked) { border-color: var(--primary, var(--teal)); background: color-mix(in srgb, var(--primary, var(--teal)) 7%, var(--surface)); }
.pyw-year-choices b, .pyw-year-choices small { display: block; }
.pyw-year-choices b { font-size: 14px; }
.pyw-year-choices small { margin-top: 2px; color: var(--muted); font-size: 11px; }
.pyw-template-options { display: grid; grid-template-columns: 1fr 1fr 230px; gap: 8px; }
.pyw-template-options > label { display: grid; grid-template-columns: 18px 28px 1fr; align-items: center; padding: 10px; border: 1px solid var(--line); border-radius: 11px; cursor: pointer; }
.pyw-template-options > label:has(input:checked) { border-color: var(--primary, var(--teal)); background: color-mix(in srgb, var(--primary, var(--teal)) 7%, var(--surface)); }
.pyw-template-options .material-symbols-rounded { color: var(--primary, var(--teal2)); font-size: 20px; }
.pyw-template-options strong, .pyw-template-options small { display: block; }
.pyw-template-options strong { font-size: 13px; }
.pyw-template-options small { margin-top: 2px; color: var(--muted); font-size: 11px; line-height: 1.4; }
.pyw-summary { position: sticky; top: -17px; z-index: 4; display: flex; align-items: center; gap: 10px; padding: 10px 12px; margin: -5px 0 10px; border: 1px solid var(--line); border-radius: 12px; background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(14px); }
.pyw-summary > div { display: flex; flex: 1; flex-direction: column; }
.pyw-summary small { color: var(--primary, var(--teal2)); font-size: 10px; font-weight: 800; }
.pyw-summary strong { font-size: 14px; }
.pyw-summary > span { padding: 5px 8px; border-radius: 8px; background: var(--canvas); font-size: 12px; }
.pyw-year-heads, .pyw-matrix > article { display: grid; grid-template-columns: minmax(210px, .85fr) repeat(var(--pyw-years, 4), minmax(210px, 1fr)); min-width: max-content; }
.pyw-year-heads { align-items: stretch; }
.pyw-metric-label { display: flex; justify-content: flex-end; flex-direction: column; padding: 12px; }
.pyw-metric-label strong, .pyw-metric-label small { display: block; }
.pyw-metric-label strong { font-size: 14px; }
.pyw-metric-label small { color: var(--muted); font-size: 11px; }
.pyw-year-heads > article { padding: 11px; border: 1px solid var(--line); border-bottom: 0; background: var(--surface); }
.pyw-year-heads > article:first-of-type { border-radius: 12px 0 0; }
.pyw-year-heads > article:last-child { border-radius: 0 12px 0 0; }
.pyw-year-heads article > header { display: flex; align-items: center; gap: 7px; }
.pyw-year-heads article > header span { font-size: 10px; font-weight: 800; color: var(--muted); }
.pyw-year-heads article > header b { font-size: 20px; color: var(--primary, var(--teal2)); }
.pyw-year-heads article > header em { margin-left: auto; padding: 4px 6px; border-radius: 7px; background: #e8f3ff; color: #1765a5; font-size: 10px; font-style: normal; }
.pyw-year-heads article > header em.new { background: #e8f8f1; color: #087651; }
.pyw-year-heads article > .input { width: 100%; margin: 6px 0; font-size: 12px; }
.pyw-year-heads article > div { display: grid; grid-template-columns: 1fr 80px; gap: 6px; }
.pyw-year-heads article label { display: flex; flex-direction: column; gap: 3px; color: var(--muted); font-size: 11px; }
.pyw-year-heads article label .input, .pyw-year-heads article label .select { width: 100%; min-width: 0; }
.pyw-year-heads article > label { margin-top: 7px; }
.pyw-year-heads article > .button { width: 100%; margin-top: 5px; }
.pyw-matrix { overflow: auto; border: 1px solid var(--line); border-radius: 0 0 12px 12px; background: var(--surface); }
.pyw-matrix > article { border-bottom: 1px solid var(--line); }
.pyw-matrix > article:last-child { border-bottom: 0; }
.pyw-matrix article > header { position: sticky; left: 0; z-index: 2; display: grid; grid-template-columns: 30px 1fr; align-items: center; gap: 8px; padding: 12px; background: var(--canvas); border-right: 1px solid var(--line); }
.pyw-matrix article > header > .material-symbols-rounded { width: 29px; height: 29px; display: grid; place-items: center; border-radius: 9px; background: var(--surface); color: var(--primary, var(--teal2)); font-size: 17px; }
.pyw-matrix article > header strong, .pyw-matrix article > header small { display: block; }
.pyw-matrix article > header strong { font-size: 13px; }
.pyw-matrix article > header small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.pyw-metric-cell { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; padding: 10px; border-right: 1px solid var(--line); background: var(--surface); }
.pyw-metric-cell:last-child { border-right: 0; }
.pyw-metric-cell label { display: flex; flex-direction: column; gap: 3px; color: var(--muted); font-size: 11px; }
.pyw-metric-cell .input { width: 100%; min-width: 0; }
.pyw-enabled, .pyw-required { flex-direction: row !important; align-items: center; }
.pyw-enabled span { font-weight: 700; color: var(--ink); }
.pyw-metric-cell.disabled { opacity: .55; }
.pyw-metric-cell.missing { align-items: center; justify-items: start; }
.pyw-metric-cell.missing > span { color: var(--muted); font-size: 12px; }
.pyw-review-note { margin-top: 12px; }
.pyw-review-note div { flex: 1; }
@media (max-width: 900px) {
  .pyw-dialog { width: calc(100% - 8px); height: calc(100dvh - 8px); }
  .pyw-dialog > main { padding: 11px; }
  .pyw-setup-grid { grid-template-columns: 1fr; }
  .pyw-year-choices { grid-template-columns: 1fr 1fr; }
  .pyw-template-options { grid-template-columns: 1fr; }
  .pyw-year-heads, .pyw-matrix > article { grid-template-columns: minmax(170px, .75fr) repeat(var(--pyw-years, 4), minmax(190px, 1fr)); }
  .pyw-dialog > footer { flex-wrap: wrap; padding: 9px 11px; }
  .pyw-dialog > footer > span { width: 100%; }
  .pyw-dialog > footer .button { flex: 1; }
}
@media (max-width: 560px) {
  .pyw-dialog > header { padding: 10px 11px; }
  .pyw-dialog header p { display: none; }
  .pyw-dialog > main { height: calc(100% - 151px); }
  .pyw-fields { grid-template-columns: 1fr; }
  .pyw-year-choices { grid-template-columns: 1fr 1fr; }
  .pyw-summary { top: -11px; align-items: flex-start; flex-wrap: wrap; }
  .pyw-summary > div { order: -1; width: 100%; flex-basis: 100%; }
}
