
  :root{
    --purple:#4B2E6F;
    --purple-dark:#341f4d;
    --gold:#C9A227;
    --gold-light:#F4E9C8;
    --bg:#FAF9F6;
    --ink:#2B2B2B;
    --muted:#6b6660;
    --line:#E4DFD3;
    --white:#ffffff;
    --red:#9E2A2A;
    --green:#2E7D53;
  }
  *{box-sizing:border-box;}
  body{
    margin:0; background:var(--bg); color:var(--ink);
    font-family: 'Georgia', 'Iowan Old Style', serif;
  }
  .ui{ font-family: -apple-system, Segoe UI, Helvetica, Arial, sans-serif; }
  #app{ max-width:920px; margin:0 auto; padding:28px 20px 80px; }
  h1,h2,h3{ font-family:'Georgia', serif; color:var(--purple-dark); margin:0 0 6px; }
  .topbar{
    display:grid; grid-template-columns:1fr auto 1fr; align-items:center; gap:14px;
    padding:16px 20px; background:var(--purple); color:#fff;
    font-family:-apple-system, Segoe UI, Helvetica, Arial, sans-serif;
  }
  .topbar .brand{ font-weight:700; letter-spacing:.02em; font-size:15px; text-align:center; }
  .topbar .brand small{ display:block; font-weight:400; opacity:.75; font-size:11px; margin-top:2px;}
  .topbar button{
    background:transparent; border:1px solid rgba(255,255,255,.4); color:#fff;
    padding:7px 14px; border-radius:6px; cursor:pointer; font-size:13px;
  }
  .topbar button:hover{ background:rgba(255,255,255,.12); }
  .top-left{ display:flex; align-items:center; justify-content:flex-start; }
  .top-right{ display:flex; align-items:center; justify-content:flex-end; }
  .m365-badge{ font-size:12px; opacity:.92; border:1px solid rgba(255,255,255,.35); padding:5px 9px; border-radius:999px; max-width:260px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
  .user-menu{ position:relative; display:flex; align-items:center; }
  .user-menu .m365-badge{ cursor:pointer; background:transparent; color:#fff; }
  .user-dropdown{
    display:none; position:absolute; right:0; top:calc(100% + 8px); min-width:190px;
    background:#fff; color:var(--ink); border:1px solid var(--line); border-radius:9px;
    box-shadow:0 8px 24px rgba(0,0,0,.18); padding:8px; z-index:1000;
  }
  .user-dropdown.show{ display:block; }
  .user-dropdown button{
    width:100%; text-align:left; border:none; background:transparent; color:var(--purple-dark);
    padding:9px 10px; border-radius:7px; cursor:pointer; font-weight:600;
  }
  .user-dropdown button:hover{ background:var(--gold-light); }
  .m365-panel{ border-left:4px solid var(--gold); }
  .m365-muted{ color:var(--muted); font-size:12.5px; margin-top:6px; }

  .top-left{ gap:8px; flex-wrap:wrap; }
  .top-left button.active{ background:rgba(255,255,255,.18); border-color:rgba(255,255,255,.75); }
  .admin-section{ margin-bottom:22px; }
  .admin-section-title{ display:flex; align-items:flex-end; justify-content:space-between; gap:12px; margin:0 0 10px; }
  .admin-section-title h3{ margin:0; }
  .admin-subtitle{ color:var(--muted); font-family:-apple-system, Segoe UI, Helvetica, Arial, sans-serif; font-size:13px; line-height:1.45; margin-top:4px; }
  .admin-card-title{ font-family:-apple-system, Segoe UI, Helvetica, Arial, sans-serif; font-size:15px; font-weight:800; color:var(--purple-dark); margin:0 0 6px; }
  .admin-actions{ display:flex; gap:10px; flex-wrap:wrap; align-items:center; margin-top:14px; }
  .admin-grid{ display:grid; grid-template-columns:minmax(280px,.9fr) minmax(360px,1.4fr); gap:16px; align-items:start; }
  .assignment-panel-stack{ display:grid; gap:16px; }
  .assignment-step-card{ padding:24px; }
  .assignment-table-full{ margin-top:16px; }
  .assignment-row-card{ padding:0; overflow:hidden; }
  .assignment-row-grid{ display:grid; grid-template-columns:minmax(280px,.9fr) minmax(360px,1.4fr); align-items:stretch; }
  .assignment-row-grid > .assignment-cell{ padding:24px; min-width:0; }
  .assignment-row-grid > .assignment-cell + .assignment-cell{ border-left:1px solid var(--line); }
  .assignment-bottom-grid{ align-items:start; }
  .assignment-bottom-grid .table-scroll{ margin:0; }
  .assignment-upload-cell .file-input-wrap{ margin-top:0 !important; }
  .assignment-upload-cell .admin-actions{ margin-top:14px; }
  .mini-kpis{ display:grid; grid-template-columns:repeat(3,minmax(110px,1fr)); gap:10px; margin:12px 0 14px; }
  .mini-kpi{ border:1px solid var(--line); border-radius:9px; padding:10px 12px; background:#fff; }
  .mini-kpi .v{ font-size:20px; font-weight:800; color:var(--purple-dark); font-family:-apple-system, Segoe UI, Helvetica, Arial, sans-serif; }
  .mini-kpi .l{ color:var(--muted); font-size:12px; font-family:-apple-system, Segoe UI, Helvetica, Arial, sans-serif; margin-top:2px; }
  .file-input-wrap{ border:1px dashed var(--line); border-radius:9px; padding:12px; background:#FBFAF7; }
  .file-input-wrap input[type=file]{ max-width:100%; }
  .leader-toolbar{ display:flex; gap:10px; margin-bottom:18px; flex-wrap:wrap; align-items:center; }
  .leader-toolbar input{ margin-bottom:0 !important; flex:1; min-width:260px; }
  .table-scroll{ overflow-x:auto; }
  .table-scroll table{ min-width:760px; }
  @media (max-width:850px){ .admin-grid{ grid-template-columns:1fr; } .mini-kpis{ grid-template-columns:1fr; } .assignment-row-grid{ grid-template-columns:1fr; } .assignment-row-grid > .assignment-cell + .assignment-cell{ border-left:none; border-top:1px solid var(--line); } }

  @media (max-width:720px){
    .topbar{ grid-template-columns:1fr; align-items:flex-start; gap:10px; }
    .topbar .brand{ text-align:left; }
    .top-right{ justify-content:flex-start; }
  }
  .card{
    background:var(--white); border:1px solid var(--line); border-radius:10px;
    padding:24px; margin-bottom:18px;
  }
  .lead{ color:var(--muted); font-family:-apple-system, Segoe UI, Helvetica, Arial, sans-serif; font-size:15px; line-height:1.55;}
  .choice-grid{ display:grid; grid-template-columns:1fr 1fr; gap:16px; margin-top:22px; }
  @media (max-width:640px){ .choice-grid{ grid-template-columns:1fr; } }
  .choice{
    border:2px solid var(--line); border-radius:10px; padding:22px; cursor:pointer;
    text-align:left; background:var(--white); transition:.15s;
    font-family:-apple-system, Segoe UI, Helvetica, Arial, sans-serif;
  }
  .choice:hover{ border-color:var(--gold); box-shadow:0 2px 10px rgba(75,46,111,.08); }
  .choice h3{ margin-bottom:6px; color:var(--purple-dark); font-family:inherit;}
  .choice p{ color:var(--muted); font-size:13.5px; margin:0; }
  .btn{
    font-family:-apple-system, Segoe UI, Helvetica, Arial, sans-serif;
    background:var(--purple); color:#fff; border:none; padding:11px 20px;
    border-radius:7px; cursor:pointer; font-size:14px; font-weight:600;
  }
  .btn:hover{ background:var(--purple-dark); }
  .btn.gold{ background:var(--gold); color:#3a2e08; }
  .btn.gold:hover{ background:#b58f1e; }
  .btn.ghost{ background:transparent; color:var(--purple); border:1px solid var(--purple); }
  .btn.ghost:hover{ background:var(--gold-light); }
  .btn:disabled{ opacity:.45; cursor:not-allowed; }
  .btn.small{ padding:6px 12px; font-size:12.5px; }
  label{ font-family:-apple-system, Segoe UI, Helvetica, Arial, sans-serif; font-size:13px; font-weight:600; color:var(--purple-dark); display:block; margin-bottom:6px; }
  input[type=text], select{
    width:100%; padding:10px 12px; border:1px solid var(--line); border-radius:7px;
    font-size:14px; font-family:-apple-system, Segoe UI, Helvetica, Arial, sans-serif;
    margin-bottom:16px; background:#fff;
  }
  .radio-row{ display:flex; flex-direction:column; gap:8px; margin-bottom:16px; }
  input[type=text][readonly]{ background:var(--gold-light); color:var(--purple-dark); cursor:not-allowed; }
  .radio-opt{
    display:flex; align-items:center; gap:10px; border:1px solid var(--line); border-radius:7px;
    padding:10px 12px; cursor:pointer; font-family:-apple-system, Segoe UI, Helvetica, Arial, sans-serif; font-size:14px;
  }
  .radio-opt.active{ border-color:var(--purple); background:var(--gold-light); }
  .progress-wrap{
    position:sticky; top:0; z-index:5; background:var(--bg); padding:12px 0 8px;
    font-family:-apple-system, Segoe UI, Helvetica, Arial, sans-serif;
  }
  .progress-track{ height:8px; background:var(--line); border-radius:5px; overflow:hidden; }
  .progress-fill{ height:100%; background:var(--gold); transition:.25s; }
  .progress-label{ font-size:12.5px; color:var(--muted); margin-top:6px; }
  .comp-card{ border:1px solid var(--line); border-radius:10px; margin-bottom:14px; background:#fff; overflow:hidden;}
  .comp-head{
    display:flex; justify-content:space-between; align-items:center; padding:16px 20px; cursor:pointer;
    font-family:-apple-system, Segoe UI, Helvetica, Arial, sans-serif; background:var(--gold-light);
  }
  .comp-head h3{ font-size:16px; margin:0; color:var(--purple-dark); }
  .comp-head .count{ font-size:12px; color:var(--muted); }
  .comp-body{ padding:6px 20px 18px; }
  .comp-def{ font-size:13px; color:var(--muted); font-family:-apple-system, Segoe UI, Helvetica, Arial, sans-serif; margin:6px 0 16px; line-height:1.5;}
  .behavior{ padding:14px 0; border-top:1px solid var(--line); }
  .behavior:first-child{ border-top:none; }
  .behavior-text{ font-family:-apple-system, Segoe UI, Helvetica, Arial, sans-serif; font-size:14px; margin-bottom:10px; color:var(--ink); }
  .scale{ display:flex; gap:8px; flex-wrap:wrap; }
  .scale button{
    flex:1; min-width:52px; padding:10px 4px; border-radius:7px; border:1.5px solid var(--line);
    background:#fff; cursor:pointer; font-family:-apple-system, Segoe UI, Helvetica, Arial, sans-serif;
    font-size:13px; font-weight:700; color:var(--muted); transition:.12s;
  }
  .scale button:hover{ border-color:var(--gold); }
  .scale button.sel{ background:var(--purple); border-color:var(--purple); color:#fff; }
  .legend{
    font-family:-apple-system, Segoe UI, Helvetica, Arial, sans-serif; font-size:12px; color:var(--muted);
    display:flex; flex-wrap:wrap; gap:6px 16px; margin:10px 0 4px;
  }
  .legend span b{ color:var(--purple-dark); }
  .footer-nav{ display:flex; justify-content:space-between; align-items:center; margin-top:20px; gap:12px;}
  .badge{ display:inline-block; padding:3px 10px; border-radius:20px; font-size:11.5px; font-weight:700; font-family:-apple-system, Segoe UI, Helvetica, Arial, sans-serif;}
  .badge.auto{ background:#E4DFF4; color:#4B2E6F;}
  .badge.lider{ background:#F4E9C8; color:#7a5c0a;}
  .badge.pares{ background:#DCEEE4; color:#1f6b47;}
  .badge.equipo{ background:#F6DCE0; color:#94214a;}
  table{ width:100%; border-collapse:collapse; font-family:-apple-system, Segoe UI, Helvetica, Arial, sans-serif; font-size:13px; }
  th,td{ padding:9px 10px; border-bottom:1px solid var(--line); text-align:left; }
  th{ background:var(--purple); color:#fff; font-size:12px; }
  tr:nth-child(even) td{ background:#FBFAF7; }
  .num{ text-align:center; }
  .pill-list{ display:flex; flex-wrap:wrap; gap:8px; margin-top:10px;}
  .pill{
    background:var(--gold-light); border:1px solid var(--gold); border-radius:20px; padding:5px 12px;
    font-size:12.5px; font-family:-apple-system, Segoe UI, Helvetica, Arial, sans-serif; display:flex; align-items:center; gap:8px;
  }
  .pill button{ border:none; background:none; color:var(--red); cursor:pointer; font-weight:700; }
  .empty{ text-align:center; padding:40px 20px; color:var(--muted); font-family:-apple-system, Segoe UI, Helvetica, Arial, sans-serif; }
  .toast{
    position:fixed; bottom:24px; left:50%; transform:translateX(-50%); background:var(--purple);
    color:#fff; padding:12px 22px; border-radius:8px; font-family:-apple-system, Segoe UI, Helvetica, Arial, sans-serif;
    font-size:14px; box-shadow:0 6px 20px rgba(0,0,0,.2); z-index:50; opacity:0; transition:.25s; pointer-events:none;
  }
  .toast.show{ opacity:1; }
  .score-hero{ display:flex; align-items:center; gap:24px; flex-wrap:wrap; }
  .score-num{ font-size:52px; font-weight:700; color:var(--purple-dark); font-family:Georgia, serif; }
  .score-max{ font-size:20px; color:var(--muted); }
  .source-grid{ display:grid; grid-template-columns:repeat(4,1fr); gap:12px; margin:18px 0; }
  @media (max-width:640px){ .source-grid{ grid-template-columns:1fr 1fr; } }
  .source-box{ border:1px solid var(--line); border-radius:8px; padding:12px; text-align:center; font-family:-apple-system, Segoe UI, Helvetica, Arial, sans-serif;}
  .source-box .v{ font-size:22px; font-weight:700; color:var(--purple-dark);}
  .source-box .l{ font-size:11.5px; color:var(--muted); margin-top:2px;}
  .pending-box{ font-family:-apple-system, Segoe UI, Helvetica, Arial, sans-serif; font-size:12px; color:var(--muted); line-height:1.35; }
  .pending-box summary{ cursor:pointer; color:var(--purple); font-weight:700; }
  .pending-box.ok{ color:var(--green); font-weight:700; }
  .danger-outline{ color:var(--red) !important; border-color:var(--red) !important; }
  @page { size: letter; margin: 10mm; }
  @media print{
    html, body{ background:#fff !important; margin:0 !important; padding:0 !important; }
    body *{ visibility:hidden !important; }
    #pdfExportRoot, #pdfExportRoot *{ visibility:visible !important; }
    #pdfExportRoot{ position:absolute !important; left:0 !important; top:0 !important; width:100% !important; max-width:none !important; margin:0 !important; padding:0 !important; background:#fff !important; }
    #app{ max-width:none !important; padding:0 !important; margin:0 !important; }
    .topbar, .no-print{ display:none !important; }
    .card{ border:1px solid #E4DFD3 !important; border-radius:8px !important; padding:14px !important; margin:0 0 12px 0 !important; break-inside:avoid; page-break-inside:avoid; }
    h1,h2,h3{ break-after:avoid; page-break-after:avoid; }
    canvas{ max-width:100% !important; height:auto !important; }
    table{ break-inside:auto; page-break-inside:auto; }
    tr{ break-inside:avoid; page-break-inside:avoid; }
  }

  /* Distribución definitiva de la matriz: Paso 1 y Paso 2 en tarjetas independientes */
  .assignment-panel-stack{ display:flex !important; flex-direction:column !important; gap:18px !important; }
  .assignment-panel-stack > .assignment-step-card{ width:100% !important; margin:0 !important; }
  .assignment-step-card .assignment-table-full{ width:100%; margin-top:16px; }
  .assignment-step-card .table-scroll{ width:100%; }
  @media (max-width:640px){
    .assignment-step-card{ padding:18px !important; }
    .assignment-step-card .file-input-wrap{ max-width:none !important; }
  }

/* Administración del formulario */
textarea{width:100%;padding:10px 12px;border:1px solid var(--line);border-radius:7px;font-size:14px;font-family:-apple-system,Segoe UI,Helvetica,Arial,sans-serif;background:#fff;resize:vertical;}
.form-admin-summary360{display:grid;gap:14px;}
.form-kpis360{margin:0;grid-template-columns:repeat(3,minmax(130px,1fr));}
.form-preview-note360{font-size:13px;color:var(--muted);margin:0 0 14px;font-family:-apple-system,Segoe UI,Helvetica,Arial,sans-serif;}
.form-preview-head360{cursor:default;}
.form-editor-card360 input[type=text]{margin-bottom:14px;}
.form-editor-card360 textarea{margin-bottom:14px;}
.form-editor-title-row360{display:flex;justify-content:space-between;gap:14px;align-items:flex-start;flex-wrap:wrap;margin-bottom:12px;}
.form-scale-editor360{display:grid;gap:12px;margin-top:14px;}
.form-scale-row360{display:grid;grid-template-columns:48px minmax(220px,.8fr) minmax(300px,1.2fr);gap:12px;align-items:start;border-top:1px solid var(--line);padding-top:12px;}
.form-scale-row360:first-child{border-top:none;padding-top:0;}
.form-scale-number360{width:38px;height:38px;border-radius:50%;display:grid;place-items:center;background:var(--purple);color:#fff;font-weight:800;margin-top:22px;}
.form-behavior-row360{display:grid;grid-template-columns:38px minmax(260px,1fr) auto;gap:10px;align-items:start;border-top:1px solid var(--line);padding:12px 0;}
.form-behavior-number360{width:30px;height:30px;border-radius:50%;display:grid;place-items:center;background:var(--gold-light);color:var(--purple-dark);font-weight:800;margin-top:4px;}
.form-inactive360{opacity:.58;background:#FBFAF7;}
.form-change-list360{display:grid;gap:10px;}
.form-change-item360{border:1px solid var(--line);border-radius:8px;padding:12px;background:#FBFAF7;line-height:1.45;}
.form-change-item360 div{margin-top:6px;font-size:13px;word-break:break-word;}
.form-change-item360 span{font-weight:700;color:var(--purple-dark);}
@media(max-width:760px){.form-scale-row360{grid-template-columns:42px 1fr;}.form-scale-row360>div:last-child{grid-column:2;}.form-behavior-row360{grid-template-columns:34px 1fr;}.form-behavior-row360>button{grid-column:2;justify-self:start;}.form-kpis360{grid-template-columns:1fr;}}
