  :root {
    --bg: #f5f5f7;
    --surface: #ffffff;
    --surface-2: #fafafa;
    --border: #e5e5ea;
    --border-strong: #d1d1d6;
    --text: #1d1d1f;
    --text-muted: #6e6e73;
    --text-faint: #98989d;
    --primary: #003b71;       /* Azul UANDES */
    --primary-dark: #002a52;
    --primary-light: #1a5a99;
    --accent: #c8a951;        /* Dorado UANDES */
    --success: #34c759;
    --warning: #ff9500;
    --danger: #ff3b30;
    --info: #007aff;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow: 0 2px 8px rgba(0,0,0,0.06);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.08);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
  }
  * { box-sizing: border-box; margin: 0; padding: 0; }
  body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    padding-bottom: env(safe-area-inset-bottom);
  }
  button, input, select { font-family: inherit; font-size: inherit; }
  button { cursor: pointer; border: none; background: none; color: inherit; }

  /* ====== LOGIN ====== */
  .login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  }
  .login-box {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 40px 32px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
  }
  .login-logo {
    text-align: center;
    margin-bottom: 24px;
  }
  .login-logo .seal {
    font-size: 48px;
    margin-bottom: 8px;
  }
  .login-logo h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--primary);
  }
  .login-logo p {
    font-size: 14px;
    color: var(--text-muted);
    margin-top: 4px;
  }
  .form-group {
    margin-bottom: 16px;
  }
  .form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 6px;
  }
  .form-group input, .form-group select {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s;
  }
  .form-group input:focus, .form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0,59,113,0.12);
  }
  .btn {
    padding: 11px 18px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 14px;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
  }
  .btn-primary {
    background: var(--primary);
    color: white;
    width: 100%;
  }
  .btn-primary:hover { background: var(--primary-dark); }
  .btn-secondary {
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
  }
  .btn-secondary:hover { background: var(--border); }
  .btn-danger {
    background: var(--danger);
    color: white;
  }
  .btn-danger:hover { opacity: 0.9; }
  .btn-ghost {
    color: var(--primary);
    padding: 6px 10px;
  }
  .btn-ghost:hover { background: rgba(0,59,113,0.06); }
  .btn-google {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border-strong);
    width: 100%;
    font-weight: 500;
  }
  .btn-google:hover {
    background: var(--surface-2);
    border-color: var(--text-muted);
  }
  .btn-google svg {
    flex-shrink: 0;
  }
  .divider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 14px 0;
    color: var(--text-faint);
    font-size: 12px;
  }
  .divider::before,
  .divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
  }
  .btn-icon {
    padding: 6px;
    border-radius: 6px;
    color: var(--text-muted);
  }
  .btn-icon:hover {
    background: var(--border);
    color: var(--text);
  }
  .toggle-link {
    text-align: center;
    margin-top: 16px;
    font-size: 13px;
    color: var(--text-muted);
  }
  .toggle-link a {
    color: var(--primary);
    cursor: pointer;
    font-weight: 500;
    text-decoration: none;
  }
  .toggle-link a:hover { text-decoration: underline; }
  .error-msg {
    background: #ffeaea;
    color: var(--danger);
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 12px;
  }

  /* ====== APP LAYOUT ====== */
  .app { display: none; min-height: 100vh; }
  .app.active { display: block; }
  header.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: calc(12px + env(safe-area-inset-top)) 20px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
  }
  .topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
  }
  .topbar-logo {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
  }
  .topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
  }
  .user-chip {
    font-size: 13px;
    color: var(--text-muted);
    padding: 6px 10px;
    background: var(--surface-2);
    border-radius: 6px;
  }
  /* Visor de guardado general (no confundir con el de Calendar, que es por evento).
     Vacío/oculto cuando está todo guardado y no hay nada que avisar. */
  .save-status {
    font-size: 12px;
    padding: 5px 9px;
    border-radius: 6px;
    display: none;
    white-space: nowrap;
  }
  .save-status.show { display: inline-block; }
  .save-status.saving { background: var(--surface-2); color: var(--text-muted); }
  .save-status.offline,
  .save-status.error { background: #fff1f0; color: var(--danger); }
  .save-status.saved { background: #e6f7ea; color: var(--success); }
  main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 20px;
  }

  /* ====== NAVIGATION TABS ====== */
  .topbar-nav {
    display: flex;
    gap: 4px;
    margin-left: 20px;
  }
  .nav-tab {
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    border-radius: 6px;
    transition: all 0.15s;
  }
  .nav-tab:hover { background: var(--surface-2); color: var(--text); }
  .nav-tab.active {
    background: var(--primary);
    color: white;
  }
  .nav-tab.active:hover {
    background: var(--primary-dark);
    color: white;
  }
  .view { display: none; }
  .view.active { display: block; }

  /* ====== CALCULATOR ====== */
  .calc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
  }
  .calc-header h2 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
  }
  .calc-grid {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 16px;
  }
  @media (max-width: 900px) {
    .calc-grid { grid-template-columns: 1fr; }
  }
  .card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 16px 18px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    margin-bottom: 14px;
  }
  .card:last-child { margin-bottom: 0; }
  .card-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
  }
  .calc-result-card {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
  }
  .calc-result-card .card-title {
    color: rgba(255,255,255,0.8);
  }
  .result-item {
    padding: 6px 0;
  }
  .result-label {
    font-size: 12px;
    color: rgba(255,255,255,0.75);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    font-weight: 500;
    margin-bottom: 4px;
  }
  .result-value {
    font-size: 32px;
    font-weight: 700;
    color: white;
    line-height: 1;
  }
  .result-value.success { color: #7be58e; }
  .result-value.warning { color: #ffd591; }
  .result-value.danger { color: #ff9d9d; }
  .result-value.impossible { color: #ff9d9d; text-decoration: line-through; }
  .result-sub {
    font-size: 12px;
    color: rgba(255,255,255,0.7);
    margin-top: 4px;
  }
  .result-divider {
    height: 1px;
    background: rgba(255,255,255,0.15);
    margin: 12px 0;
  }
  .info-list {
    list-style: none;
    padding: 0;
  }
  .info-list li {
    padding: 6px 0;
    font-size: 13px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
  }
  .info-list li:last-child { border-bottom: none; }
  .info-list strong { color: var(--text); }

  /* ====== CALCULATOR — NEW LAYOUT ====== */
  .calc-config-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
  }
  .calc-config-grid .form-group input {
    padding: 10px 12px;
    font-size: 15px;
    font-weight: 600;
  }
  .calc-config-grid .hint {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
  }
  .pill {
    display: inline-block;
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 6px;
    text-transform: none;
    letter-spacing: 0;
    border: 1px solid var(--border);
  }
  .btn-sm {
    padding: 6px 10px;
    font-size: 12px;
  }
  /* .btn-primary es width:100% (pensado para formularios). Dentro de un título en flex
     eso lo estira de lado a lado y aplasta el texto del título — acá va al ancho justo. */
  .card-title .btn,
  .eval-section h3 .btn {
    width: auto;
    flex-shrink: 0;
  }

  /* Evaluación cards (instead of table) */
  .eval-card {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 8px;
    display: grid;
    grid-template-columns: 1fr 80px 90px auto;
    gap: 8px;
    align-items: center;
  }
  .eval-card.has-grade {
    background: #f0f7f0;
    border-color: #c8e0c8;
  }
  .eval-card.pending {
    background: #fffaf0;
    border-color: #f5d990;
  }
  .eval-card-name input {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    font-size: 13px;
    font-weight: 500;
  }
  .eval-card-weight input,
  .eval-card-grade input {
    width: 100%;
    padding: 7px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    font-size: 13px;
    text-align: center;
    font-weight: 600;
  }
  .eval-card input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(0,59,113,0.1);
  }
  .eval-card-grade input {
    color: var(--primary);
  }
  .eval-card-actions {
    display: flex;
    gap: 4px;
    align-items: center;
  }
  .eval-card-needed {
    font-size: 12px;
    color: var(--text-muted);
    padding: 2px 8px;
    border-radius: 6px;
    background: white;
    white-space: nowrap;
    font-weight: 600;
  }
  .eval-card-needed.danger { color: var(--danger); background: #ffeaea; }
  .eval-card-needed.warning { color: var(--warning); background: #fff7e6; }
  .eval-card-needed.success { color: var(--success); background: #e6f7ea; }
  .eval-card-needed.impossible {
    color: var(--danger);
    background: #ffeaea;
    text-decoration: line-through;
  }
  .eval-card-needed.done {
    color: var(--success);
    background: #e6f7ea;
  }
  .eval-card-headers {
    display: grid;
    grid-template-columns: 1fr 80px 90px auto;
    gap: 8px;
    padding: 0 12px 4px;
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
  }
  .eval-card-headers > div { text-align: center; }
  .eval-card-headers > div:first-child { text-align: left; }
  .eval-card-subnotas { margin-top: 4px; }
  .subnotas-toggle {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    padding: 2px 0;
  }
  .subnotas-toggle:hover { text-decoration: underline; }
  .subnotas-list {
    margin-top: 6px;
    padding: 8px 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
  }
  .subnota-row {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 4px 0;
    flex-wrap: wrap;
  }
  .subnota-row .subnota-nombre { flex: 1; min-width: 100px; }
  .subnota-row .subnota-fecha { width: 140px; flex-shrink: 0; }
  .subnota-row .subnota-hora-inicio,
  .subnota-row .subnota-hora-fin { width: 82px; flex-shrink: 0; }
  .subnota-row .subnota-sala { width: 70px; flex-shrink: 0; }
  .subnota-row .subnota-peso { width: 55px; flex-shrink: 0; }
  .subnota-row .subnota-nota { width: 70px; flex-shrink: 0; }
  .subnota-row input {
    padding: 6px 8px;
    font-size: 13px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-2);
    color: var(--text);
  }
  .empty-evals {
    padding: 24px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    background: var(--surface-2);
    border-radius: 10px;
    border: 2px dashed var(--border);
  }

  /* Exam row */
  .exam-row {
    display: flex;
    gap: 12px;
    align-items: stretch;
  }
  .exam-row .form-group input {
    padding: 10px 12px;
    font-size: 16px;
    font-weight: 600;
  }
  .exam-needed-box {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 14px;
    min-width: 130px;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }
  .exam-needed-label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    font-weight: 600;
    margin-bottom: 4px;
  }
  .exam-needed-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--primary);
  }
  .exam-needed-value.danger { color: var(--danger); }
  .exam-needed-value.warning { color: var(--warning); }
  .exam-needed-value.success { color: var(--success); }
  .exam-needed-value.impossible { color: var(--danger); text-decoration: line-through; }

  /* Status alert in results */
  .calc-status-card {
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 14px;
    border: 2px solid;
    display: flex;
    align-items: flex-start;
    gap: 12px;
  }
  .calc-status-card.danger {
    background: #ffeaea;
    border-color: var(--danger);
    color: #5c0000;
  }
  .calc-status-card.warning {
    background: #fff7e6;
    border-color: var(--warning);
    color: #5c3c00;
  }
  .calc-status-card.success {
    background: #e6f7ea;
    border-color: var(--success);
    color: #003c0c;
  }
  .calc-status-card .icon {
    font-size: 24px;
    line-height: 1;
  }
  .calc-status-card .title {
    font-weight: 700;
    font-size: 14px;
    margin-bottom: 2px;
  }
  .calc-status-card .desc {
    font-size: 13px;
    opacity: 0.9;
  }

  /* Top banner */
  .calc-banner {
    border-radius: var(--radius);
    padding: 14px 18px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    font-weight: 600;
  }
  .calc-banner.danger {
    background: linear-gradient(135deg, #ff3b30 0%, #c41e3a 100%);
    color: white;
    box-shadow: 0 4px 16px rgba(255,59,48,0.3);
  }
  .calc-banner.warning {
    background: linear-gradient(135deg, #ff9500 0%, #ff6f00 100%);
    color: white;
    box-shadow: 0 4px 16px rgba(255,149,0,0.25);
  }
  .calc-banner.info {
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary) 100%);
    color: white;
    box-shadow: 0 4px 16px rgba(0,59,113,0.25);
  }
  .calc-banner .banner-icon {
    font-size: 28px;
    flex-shrink: 0;
  }
  .calc-banner .banner-text {
    flex: 1;
    line-height: 1.4;
  }
  .calc-banner .banner-title {
    font-size: 16px;
    font-weight: 700;
  }
  .calc-banner .banner-sub {
    font-size: 13px;
    opacity: 0.95;
    font-weight: 500;
    margin-top: 2px;
  }

  @media (max-width: 600px) {
    .calc-config-grid { grid-template-columns: 1fr; }
    .eval-card { grid-template-columns: 1fr; gap: 6px; }
    .eval-card-headers { display: none; }
    .exam-row { flex-direction: column; }
  }

  /* Asignatura banner (compact alert inside an asignatura) */
  .asig-banner {
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 500;
    border: 1px solid;
  }
  .asig-banner.danger {
    background: #ffeaea;
    border-color: #ffcfcf;
    color: #8a0000;
  }
  .asig-banner.warning {
    background: #fff7e6;
    border-color: #ffd591;
    color: #6b3f00;
  }
  .asig-banner.success {
    background: #e6f7ea;
    border-color: #c3e9cb;
    color: #0a5022;
  }
  .asig-banner .banner-icon {
    font-size: 22px;
    flex-shrink: 0;
  }
  .asig-banner .banner-text { flex: 1; line-height: 1.35; }
  .asig-banner .banner-title { font-size: 13px; font-weight: 700; }
  .asig-banner .banner-sub { font-size: 12px; opacity: 0.85; margin-top: 1px; }

  /* ====== GLOBAL STATS ====== */
  .global-stats-wrapper { margin-bottom: 24px; }
  .global-stats-wrapper .stats-grid { margin-top: 12px; margin-bottom: 0; }
  .stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
  }
  .stat-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 14px 16px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
  }
  .stat-card .label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    font-weight: 500;
    margin-bottom: 4px;
  }
  .stat-card .value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
  }
  .stat-card .sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
  }
  .stat-card.warning .value { color: var(--warning); }
  .stat-card.danger .value { color: var(--danger); }
  .stat-card.success .value { color: var(--success); }

  /* ====== SEMESTER TABS ====== */
  .semester-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    padding-bottom: 0;
  }
  .semester-tab {
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    transition: all 0.15s;
  }
  .semester-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
  }
  .semester-tab:hover:not(.active) {
    color: var(--text);
  }
  .add-semester-btn {
    padding: 8px 12px;
    font-size: 13px;
    color: var(--primary);
    border: 1px dashed var(--border-strong);
    border-radius: 6px;
    margin-left: auto;
    align-self: center;
  }
  .add-semester-btn:hover {
    background: rgba(0,59,113,0.06);
    border-color: var(--primary);
  }

  /* ====== SEMESTER PANEL ====== */
  .semester-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
  }
  .semester-header h2 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
  }
  .semester-actions {
    display: flex;
    gap: 8px;
    align-items: center;
  }

  /* ====== ASIGNATURAS ====== */
  .asignaturas {
    display: grid;
    gap: 16px;
  }
  .asignatura {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    overflow: hidden;
  }
  .asig-head {
    padding: 14px 18px;
    background: linear-gradient(to right, var(--surface), var(--surface-2));
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    gap: 12px;
    flex-wrap: wrap;
  }
  .asig-head-left {
    flex: 1;
    min-width: 200px;
  }
  .asig-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
  }
  .asig-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
  }
  .asig-grades {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
  }
  .grade-pill {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    padding: 4px 10px;
    min-width: 60px;
  }
  .grade-pill .grade-label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    font-weight: 500;
  }
  .grade-pill .grade-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
  }
  .grade-pill .grade-value.success { color: var(--success); }
  .grade-pill .grade-value.warning { color: var(--warning); }
  .grade-pill .grade-value.danger { color: var(--danger); }
  .grade-pill .grade-value.muted { color: var(--text-faint); }

  .asig-body {
    padding: 16px 18px;
    display: none;
  }
  .asignatura.open .asig-body { display: block; }
  .asignatura.open .asig-toggle { transform: rotate(180deg); }
  .asig-toggle {
    transition: transform 0.2s;
    color: var(--text-muted);
    font-size: 18px;
  }

  /* ====== CONFIG ROW ====== */
  .config-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    padding-bottom: 14px;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--border);
  }
  .config-row .form-group {
    margin: 0;
  }
  .config-row label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    font-weight: 500;
  }
  .config-row input {
    padding: 7px 10px;
    font-size: 13px;
  }

  /* ====== EVALUACIONES TABLE ====== */
  .eval-section h3 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  .eval-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    margin-bottom: 14px;
  }
  .eval-table th {
    text-align: left;
    padding: 8px 10px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
  }
  .eval-table th.numeric, .eval-table td.numeric { text-align: right; }
  .eval-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
  }
  .eval-table tr:last-child td { border-bottom: none; }
  .eval-table input {
    padding: 6px 8px;
    font-size: 13px;
    border: 1px solid var(--border);
    border-radius: 6px;
    width: 100%;
    background: var(--surface);
  }
  .eval-table input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(0,59,113,0.1);
  }
  .eval-table input.numeric-input {
    text-align: right;
    width: 80px;
  }
  .eval-table input.weight-input {
    text-align: right;
    width: 70px;
  }
  .needed-cell {
    font-weight: 600;
    font-size: 13px;
  }
  .needed-cell.danger { color: var(--danger); }
  .needed-cell.warning { color: var(--warning); }
  .needed-cell.success { color: var(--success); }
  .needed-cell.impossible {
    color: var(--danger);
    text-decoration: line-through;
  }

  .eval-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: var(--surface-2);
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 14px;
  }
  .eval-summary .label { color: var(--text-muted); }
  .eval-summary .value {
    font-weight: 600;
  }
  .weight-warn {
    font-size: 12px;
    color: var(--warning);
    margin-top: 4px;
  }

  /* ====== HORARIO EDITOR (dentro de la asignatura) ====== */
  .horario-editor-box {
    margin-top: 14px;
    padding: 12px;
    background: var(--surface-2);
    border-radius: 8px;
  }
  .horario-editor-box h4 {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 8px;
    font-weight: 600;
  }
  /* ====== SEMESTER DATE RANGE ====== */
  .sem-dates-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: end;
    padding: 12px 14px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
  }
  .sem-dates-row .form-group { margin: 0; min-width: 160px; }
  .sem-dates-row .hint { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

  /* ====== HORARIO ====== */
  .horario-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
  .horario-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
  }
  .horario-row select,
  .horario-row input[type="time"],
  .horario-row input[type="text"] {
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    font-size: 13px;
  }
  .horario-row select { flex: 1; min-width: 110px; }
  .horario-row input[type="time"] { width: 100px; }
  .horario-row input.horario-sala { width: 90px; }
  .horario-sep { color: var(--text-muted); font-size: 12px; }

  /* ====== EVAL DATE ====== */
  .eval-card-date {
    margin-top: 5px;
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
  }
  .eval-card-date input {
    padding: 4px 6px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    font-size: 11px;
    color: var(--text-muted);
  }
  .eval-card-date .eval-sala { width: 78px; }
  .eval-card-date .eval-notas { width: 100px; flex: 1; min-width: 80px; }
  .eval-card-date .eval-hora-inicio,
  .eval-card-date .eval-hora-fin { width: 82px; }

  /* Visor de sincronización con Calendar — ⏳ pendiente / ✓ sincronizado / ⚠️ error.
     Vacío (sin clase de estado) cuando no hay nada que mostrar todavía. */
  .calsync-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    font-size: 12px;
    flex-shrink: 0;
    cursor: default;
  }
  .calsync-badge.pendiente { animation: calsync-pulse 1.2s ease-in-out infinite; }
  .calsync-badge.sincronizado { color: var(--success); }
  .calsync-badge.error { color: var(--danger); cursor: pointer; }
  @keyframes calsync-pulse { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }

  /* ====== ATTENDANCE SUMMARY ====== */
  .att-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
    margin-top: 12px;
  }
  .att-summary-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
  }
  .att-summary-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 2px;
  }
  .att-summary-value { font-size: 20px; font-weight: 700; color: var(--text); }
  .att-summary-value.success { color: var(--success); }
  .att-summary-value.warning { color: var(--warning); }
  .att-summary-value.danger { color: var(--danger); }
  .att-summary-value.muted { color: var(--text-faint); }

  .att-legend {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 11px;
    color: var(--text-muted);
    margin: 10px 0 6px;
  }
  .att-legend span { display: inline-flex; align-items: center; gap: 4px; }
  .att-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
  .att-dot.att-pendiente { background: var(--border-strong); }
  .att-dot.att-presente { background: var(--success); }
  .att-dot.att-ausente { background: var(--danger); }
  .att-dot.att-cancelada { background: var(--text-faint); }

  .att-chip-grid { display: flex; flex-wrap: wrap; gap: 6px; }
  .att-chip {
    padding: 6px 9px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 7px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text-muted);
    transition: all 0.12s;
  }
  .att-chip:hover { filter: brightness(0.97); }
  .att-chip.att-pendiente { background: var(--surface); color: var(--text-muted); border-color: var(--border-strong); }
  .att-chip.att-presente { background: #e6f7ea; color: #0a5022; border-color: #c3e9cb; }
  .att-chip.att-ausente { background: #ffeaea; color: #8a0000; border-color: #ffcfcf; }
  .att-dot.att-sinlista { background: #9db7d5; }
  .att-dot.att-fuera-presente { background: transparent; border: 2px solid var(--success); }
  .att-dot.att-fuera-ausente { background: transparent; border: 2px solid var(--danger); }
  .att-chip.att-sinlista { background: #eef3f9; color: #3b5675; border: 1px dashed #9db7d5; }
  .att-chip.att-fuera-presente { background: transparent; color: #0a5022; border: 1px dashed var(--success); }
  .att-chip.att-fuera-ausente { background: transparent; color: #8a0000; border: 1px dashed var(--danger); }
  .att-chip.att-extra::before { content: '↻ '; font-weight: 700; }
  .att-rp-input { width: 100%; padding: 6px 8px; font: inherit; font-size: 13px; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--surface); }
  .att-rp-btns { display: flex; gap: 8px; margin-top: 10px; justify-content: flex-end; }
  .att-chip.att-tema::after { content: ' ✎'; font-size: 10px; opacity: 0.7; }
  .att-temas { padding: 0 12px 12px; display: flex; flex-direction: column; gap: 4px; }
  .att-tema-row { display: flex; gap: 10px; font-size: 12px; color: var(--text); line-height: 1.4; white-space: pre-line; }
  .att-tema-fecha { flex: none; min-width: 52px; font-weight: 700; color: var(--text-muted); text-transform: capitalize; }
  .att-menu-tema { border-top: 1px solid var(--border); margin-top: 4px; padding: 8px 10px 4px; }
  .att-menu-tema label { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px; color: var(--text-muted); margin-bottom: 4px; }
  .att-menu-tema textarea { width: 100%; resize: vertical; padding: 6px 8px; font: inherit; font-size: 13px; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--surface); }
  .hoy-tema { grid-column: 1 / -1; }
  .hoy-tema-input { width: 100%; padding: 6px 9px; font-size: 13px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); }
  .att-menu-backdrop { position: fixed; inset: 0; z-index: 999; }
  .att-menu {
    position: fixed; z-index: 1000; min-width: 230px; max-width: calc(100vw - 16px);
    background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius);
    box-shadow: 0 10px 30px rgba(0,0,0,0.2); padding: 6px;
  }
  .att-menu-title { display: flex; flex-direction: column; gap: 1px; padding: 6px 10px 8px; border-bottom: 1px solid var(--border); margin-bottom: 4px; font-size: 12px; color: var(--text-muted); }
  .att-menu-title strong { font-size: 13px; color: var(--text); }
  .att-menu-item { display: block; width: 100%; text-align: left; padding: 9px 10px; font-size: 14px; border-radius: 7px; background: transparent; color: var(--text); }
  .att-menu-item:hover { background: var(--surface-2); }
  .att-menu-item.on { font-weight: 700; background: #f1f6fc; }
  .att-todo-extra .att-todo-btn { font-size: 11px; padding: 3px 8px; }
  .att-todo-btn.sinlista:hover { background: #eef3f9; color: #3b5675; border-color: #9db7d5; }
  .att-todo-btn.fuera:hover { background: #fff; border-style: dashed; }
  .hoy-att-extra .hoy-att-btn { font-size: 11px; padding: 3px 8px; }
  .hoy-att-btn.on.sinlista { background: #eef3f9; color: #3b5675; border-color: #9db7d5; }
  .hoy-att-btn.on.fuera-presente { background: #e6f7ea; color: #0a5022; border: 1px dashed var(--success); }
  .hoy-att-btn.on.fuera-ausente { background: #ffeaea; color: #8a0000; border: 1px dashed var(--danger); }
  .att-chip.att-cancelada { background: var(--surface-2); color: var(--text-faint); border-color: var(--border); text-decoration: line-through; }
  .att-chip.att-futura { opacity: 0.55; }
  .att-chip.att-sinmarcar { border-style: dashed; border-color: var(--warning); color: #8a5300; background: #fff7e8; }
  .att-chip.att-hoy { box-shadow: 0 0 0 2px var(--primary); opacity: 1; }

  .att-progress { margin: 14px 0 4px; }
  .att-progress-bar {
    position: relative;
    height: 10px;
    border-radius: 6px;
    background: var(--border);
    overflow: visible;
  }
  .att-progress-max, .att-progress-sure {
    position: absolute; left: 0; top: 0; bottom: 0;
    border-radius: 6px;
  }
  .att-progress-max { background: #c8ebd1; }
  .att-progress-sure { background: var(--success); }
  .att-progress-sure.warning { background: var(--warning); }
  .att-progress-sure.danger { background: var(--danger); }
  .att-progress-min {
    position: absolute; top: -3px; bottom: -3px; width: 2px;
    background: var(--text); border-radius: 1px;
  }
  .att-progress-label { font-size: 11px; color: var(--text-muted); margin-top: 6px; }
  .att-section-title {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px;
    color: var(--text-muted); margin: 14px 0 6px;
  }
  .att-todo {
    border: 1px solid #ffd89a; background: #fffaf0;
    border-radius: var(--radius-sm); padding: 4px 12px 10px; margin-top: 10px;
  }
  .att-todo-list { max-height: 280px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
  .att-todo-row {
    display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
    padding: 7px 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 7px;
  }
  .att-todo-date { font-size: 13px; font-weight: 600; color: var(--text); }
  .att-todo-btns { display: flex; gap: 6px; flex-wrap: wrap; }
  .att-todo-btn {
    padding: 5px 10px; font-size: 12px; font-weight: 600; border-radius: 7px;
    border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-muted);
  }
  .att-todo-btn.presente:hover { background: #e6f7ea; color: #0a5022; border-color: #c3e9cb; }
  .att-todo-btn.ausente:hover { background: #ffeaea; color: #8a0000; border-color: #ffcfcf; }
  .att-todo-btn.cancelada:hover { background: var(--surface-2); color: var(--text-faint); }
  .att-alday {
    margin-top: 10px; padding: 8px 12px; font-size: 13px; font-weight: 600;
    color: #0a5022; background: #e6f7ea; border: 1px solid #c3e9cb; border-radius: var(--radius-sm);
  }
  .att-mes { border: 1px solid var(--border); border-radius: var(--radius-sm); margin-top: 6px; background: var(--surface); }
  .att-mes summary {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 8px 12px; cursor: pointer; list-style: none; font-size: 13px;
  }
  .att-mes summary::-webkit-details-marker { display: none; }
  .att-mes summary::before { content: '▸'; color: var(--text-faint); margin-right: 6px; }
  .att-mes[open] summary::before { content: '▾'; }
  .att-mes-name { font-weight: 700; color: var(--text); flex: 1; }
  .att-mes-stats { font-size: 11px; color: var(--text-muted); font-weight: 600; }
  .att-mes .att-chip-grid { padding: 0 12px 12px; }

  .clase-hint {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    width: 100%; margin: 4px 0; padding: 5px 8px; font-size: 12px; color: var(--text-muted);
    background: #f1f6fc; border: 1px dashed var(--primary-light); border-radius: 7px;
  }
  .clase-hint strong { color: var(--text); }
  .clase-hint .clase-usar { padding: 3px 8px; font-size: 11px; }
  .orden-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 14px; }
  .orden-row label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.3px; }
  .orden-row select { padding: 6px 10px; font-size: 13px; border: 1px solid var(--border-strong); border-radius: 7px; background: var(--surface); }
  .asig-move-btns { display: inline-flex; gap: 2px; margin-right: 6px; }
  .asig-move-btns .btn-icon { font-size: 15px; padding: 2px 7px; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--surface); }

  .exp-overlay { display: none; position: fixed; inset: 0; z-index: 2500; background: #fff; flex-direction: column; }
  .exp-overlay.active { display: flex; }
  .exp-bar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); flex-wrap: wrap; }
  #exp-frame { flex: 1; width: 100%; border: 0; background: #fff; }
  /* ====== DESTACADORES ====== */
  .dst-barra { display: flex; flex-wrap: wrap; gap: 6px 14px; border-bottom: 2px solid var(--text); padding-bottom: 6px; margin-bottom: 16px; }
  .dst-tab { font-weight: 600; font-size: 14px; color: var(--text); background: transparent; padding: 3px 12px; transform: skewX(-8deg); }
  .dst-tab > span { display: inline-block; transform: skewX(8deg); }
  .dst-tab.on { background: #fff23a; color: #23232e; }
  .dst-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
  .dst-chip { font-size: 13px; color: var(--text); background: transparent; border: 1px solid var(--border-strong); padding: 4px 10px; border-radius: 4px; }
  .dst-chip.on { background: var(--text); color: var(--surface); border-color: var(--text); }
  .dst-grupo { margin-bottom: 20px; }
  .dst-cabeza { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding-bottom: 8px; border-bottom: 1px solid var(--text); }
  .dst-cabeza h3 { font-size: 15px; margin: 0; }
  .dst-cant { font-size: 12.5px; color: var(--text-muted); }
  .dst-tag { font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); border: 1px solid var(--border-strong); padding: 0 5px; }
  .dst-todos { margin-left: auto; font-size: 13px; color: var(--primary); background: none; text-decoration: underline; padding: 2px 0; }
  .dst-lista, .dst-grupo ul { list-style: none; margin: 0; padding: 0; }
  .dst-item { display: grid; grid-template-columns: 11rem minmax(0, 1fr) 6rem; gap: 4px 14px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
  .dst-id { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; overflow-wrap: anywhere; }
  .dst-id small { display: block; font-family: inherit; font-size: 11.5px; color: var(--text-muted); }
  .dst-color { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; min-width: 0; }
  .dst-marca { background: var(--c); color: #23232e; font-weight: 600; padding: 1px 9px; transform: skewX(-8deg); display: inline-block; }
  .dst-marca > span { display: inline-block; transform: skewX(8deg); }
  .dst-marca.oscura { color: #fff; box-shadow: 0 0 0 1px var(--text-muted); }
  .dst-oficial { font-size: 12.5px; color: var(--text-muted); }
  .dst-dudoso { font-size: 11.5px; color: var(--text-muted); }
  .dst-item .dst-uso-fila { grid-column: 1 / -1; }
  .dst-btn { font-size: 13px; min-height: 34px; padding: 4px 8px; color: var(--primary); background: transparent; border: 1px solid var(--primary); border-radius: 4px; }
  .dst-btn.on { background: var(--primary); color: #fff; }
  .dst-mio { display: grid; grid-template-columns: minmax(0, 1fr) 11rem minmax(0, 13rem) 5rem; gap: 6px 14px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
  .dst-vida { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; font-size: 12.5px; color: var(--text-muted); }
  .dst-vida label { display: inline-flex; align-items: center; gap: 6px; }
  .dst-vida input[type=date] { padding: 3px 6px; font-size: 13px; border: 1px solid var(--border-strong); border-radius: 5px; background: var(--surface); }
  .dst-cambio-caja { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
  .dst-vida-txt { flex-basis: 100%; color: var(--text); }
  .dst-materia { width: 100%; min-width: 0; font-size: 15px; color: var(--text); background: transparent; border: 0; border-bottom: 1px solid var(--text-muted); border-radius: 0; padding: 4px 2px; }
  .dst-materia:focus { outline: none; border-bottom: 2px solid var(--primary); }
  .dst-resumen { display: flex; flex-wrap: wrap; gap: 8px 26px; margin-bottom: 12px; }
  .dst-resumen > div { display: inline-flex; align-items: center; gap: 4px 10px; }
  .dst-tiras { display: flex; flex-wrap: wrap; gap: 3px; }
  .dst-tiras i { width: 20px; height: 12px; background: var(--c); transform: skewX(-14deg); display: block; }
  .dst-vacio { padding: 20px 0; max-width: 56ch; }
  .dst-notas { margin-top: 24px; font-size: 13px; max-width: 70ch; }
  .dst-notas p { margin: 0 0 6px; }
  @media (max-width: 640px) {
    .dst-item { grid-template-columns: minmax(0, 1fr) 5.5rem; grid-template-areas: "color accion" "id accion"; }
    .dst-item { grid-template-areas: "color accion" "id accion" "uso uso"; }
    .dst-item .dst-color { grid-area: color; } .dst-item .dst-id { grid-area: id; } .dst-item .dst-btn { grid-area: accion; } .dst-item .dst-uso-fila { grid-area: uso; grid-column: auto; }
    .dst-mio { grid-template-columns: minmax(0, 1fr) 4.75rem; grid-template-areas: "color accion" "id id" "materia materia" "vida vida"; }
    .dst-mio .dst-vida { grid-area: vida; grid-column: auto; }
    .dst-mio .dst-color { grid-area: color; } .dst-mio .dst-id { grid-area: id; } .dst-mio .dst-materia { grid-area: materia; } .dst-mio .dst-btn { grid-area: accion; }
  }
  .calc-subs { margin: -6px 0 12px 16px; padding: 8px 10px; border-left: 3px solid var(--primary-light); background: #f7f9fc; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
  .calc-sub-row { display: grid; grid-template-columns: 1fr 64px 76px 24px; gap: 6px; margin-bottom: 5px; align-items: center; }
  .calc-sub-row input { padding: 6px 8px; font-size: 13px; min-width: 0; }
  .calc-subs-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
  .calc-import { background: #f1f6fc; border: 1px solid #cfe0f3; border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 14px; }
  .calc-import label { display: block; font-size: 12.5px; font-weight: 700; color: var(--primary); margin-bottom: 6px; }
  .calc-import select { width: 100%; padding: 8px 10px; font-size: 14px; border: 1px solid var(--border-strong); border-radius: 7px; background: var(--surface); }
  .adm-check { display: flex; align-items: center; gap: 8px; margin: 10px 0; font-size: 13px; color: var(--text-muted); cursor: pointer; }
  .adm-check input { width: auto; }
  .adm-user { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 8px; background: var(--surface); }
  .adm-user-info { flex: 1; min-width: 180px; }
  .adm-user-nombre { font-size: 14px; font-weight: 700; color: var(--text); }
  .adm-user-sub { font-size: 12px; color: var(--text-muted); word-break: break-all; }
  .adm-badge { display: inline-block; margin-left: 6px; padding: 1px 7px; font-size: 10px; font-weight: 700; text-transform: uppercase; border-radius: 10px; background: var(--primary); color: #fff; }
  .adm-user-btns { display: flex; gap: 6px; flex-wrap: wrap; }
  .onb-backdrop { display: none; position: fixed; inset: 0; z-index: 2000; background: rgba(0,0,0,0.5); align-items: center; justify-content: center; padding: 16px; }
  .onb-backdrop.active { display: flex; }
  .onb-modal { background: var(--surface); border-radius: var(--radius-lg); width: 100%; max-width: 520px; max-height: 90vh; display: flex; flex-direction: column; padding: 18px 20px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); }
  .onb-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
  .onb-progreso { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px; color: var(--text-faint); }
  .onb-modal h3 { font-size: 19px; margin: 4px 0 10px; color: var(--text); }
  .onb-body { overflow-y: auto; font-size: 14px; line-height: 1.55; color: var(--text); flex: 1; min-height: 120px; }
  .onb-body p { margin: 0 0 8px; }
  .onb-body ul, .onb-body ol { margin: 0 0 8px 20px; }
  .onb-body li { margin-bottom: 4px; }
  .onb-body code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; font-size: 12.5px; }
  .onb-body .onb-nota { background: #f1f6fc; border: 1px solid #cfe0f3; border-radius: 8px; padding: 8px 10px; font-size: 13px; margin: 8px 0; }
  .onb-body .onb-go { margin-top: 6px; }
  .onb-dots { display: flex; gap: 5px; justify-content: center; margin: 12px 0 10px; flex-wrap: wrap; }
  .onb-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--border-strong); }
  .onb-dot.on { background: var(--primary); }
  .onb-foot { display: flex; gap: 8px; justify-content: space-between; }
  .onb-foot .btn { flex: 1; }
  .tutorial summary { cursor: pointer; font-size: 15px; font-weight: 700; color: var(--text); list-style: none; }
  .tutorial summary::-webkit-details-marker { display: none; }
  .tutorial summary::before { content: '▸'; color: var(--text-faint); margin-right: 8px; }
  .tutorial[open] summary::before { content: '▾'; }
  .tutorial-body { margin-top: 12px; font-size: 13.5px; line-height: 1.55; color: var(--text); }
  .tutorial-body h4 { margin: 16px 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.3px; color: var(--primary); }
  .tutorial-body p { margin: 0 0 8px; }
  .tutorial-body ul, .tutorial-body ol { margin: 0 0 8px 20px; }
  .tutorial-body li { margin-bottom: 4px; }
  .tutorial-body code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; font-size: 12px; }
  .app-version { text-align: center; font-size: 11px; color: var(--text-faint); padding: 18px 0 8px; }
  .app-version a { color: inherit; text-decoration: underline; }

  /* ====== RELOJ + ESTA SEMANA ====== */
  .reloj-vivo {
    font-size: 12px; font-weight: 600; color: var(--text-muted);
    font-variant-numeric: tabular-nums; white-space: nowrap;
  }
  .card.semana-card, .card.hoy-card { margin-bottom: 18px; } /* .card:last-child lo dejaba en 0 (cada una es hija única de su contenedor) */
  .semana-card .card-title { text-transform: none; letter-spacing: normal; font-size: 15px; color: var(--text); flex-wrap: wrap; gap: 4px 12px; }
  .semana-rango { font-size: 12px; font-weight: 500; color: var(--text-muted); margin-left: 6px; }
  .semana-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; }
  .semana-item {
    border: 1px solid var(--border); border-left: 3px solid var(--primary);
    border-radius: var(--radius-sm); background: var(--surface); padding: 7px 10px;
  }
  .semana-item.hoy { background: #f1f6fc; border-color: var(--primary); }
  .semana-item.paso { opacity: 0.65; }
  .semana-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
  .semana-ramo { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.3px; min-width: 0; }
  .semana-nombre { font-size: 14px; font-weight: 700; color: var(--text); margin: 1px 0 2px; }
  .semana-meta { font-size: 12px; color: var(--text-muted); line-height: 1.35; }
  .semana-badge {
    display: inline-block; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px;
    padding: 1px 7px; border-radius: 10px; white-space: nowrap;
    background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border);
  }
  .semana-badge.hoy { background: var(--primary); color: #fff; border-color: var(--primary); }
  .semana-badge.pronto { background: #fff7e8; color: #8a5300; border-color: #ffd89a; }
  .semana-need { margin-top: 5px; padding: 3px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; background: var(--surface-2); }
  .semana-temario { font-size: 12px; color: var(--text); line-height: 1.4; margin-top: 4px; white-space: pre-line; }
  .temario-input {
    width: 100%; min-height: 40px; resize: vertical; padding: 6px 8px;
    font: inherit; font-size: 13px; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--surface);
  }
  .semana-todo-ok { font-size: 13px; font-weight: 600; color: #0a5022; background: #e6f7ea; border: 1px solid #c3e9cb; border-radius: 7px; padding: 8px 12px; }
  .semana-rendidas { margin-top: 10px; }
  .semana-rendidas-t { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px; color: var(--text-faint); margin-bottom: 4px; }
  .semana-rendida {
    display: flex; align-items: center; gap: 10px; padding: 3px 8px; font-size: 12px; color: var(--text-muted);
    border-radius: 6px; background: var(--surface-2);
  }
  .semana-rendida + .semana-rendida { margin-top: 3px; }
  .semana-r-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .semana-r-fecha { white-space: nowrap; }
  .semana-r-nota { font-weight: 700; color: #0a5022; white-space: nowrap; }
  .semana-r-nota input { width: 44px; padding: 1px 4px; font-size: 12px; font-weight: 700; text-align: center; border: 1px solid transparent; border-radius: 5px; background: transparent; color: #0a5022; }
  .semana-r-nota input:hover, .semana-r-nota input:focus { border-color: var(--border-strong); background: var(--surface); }
  .semana-nota { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 12px; font-weight: 600; color: var(--text-muted); }
  .semana-nota input { width: 64px; padding: 4px 8px; font-size: 13px; font-weight: 700; text-align: center; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--surface); }
  .semana-need.success { background: #e6f7ea; color: #0a5022; }
  .semana-need.warning { background: #fff7e8; color: #8a5300; }
  .semana-need.danger { background: #ffeaea; color: #8a0000; }

  /* ====== HOY ====== */
  .hoy-card .card-title { text-transform: none; letter-spacing: normal; font-size: 15px; color: var(--text); }
  .hoy-now {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 14px; margin-bottom: 12px;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary) 100%);
    color: #fff;
  }
  .hoy-now.libre { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
  .hoy-now .hoy-now-icon { font-size: 26px; flex-shrink: 0; }
  .hoy-now .hoy-now-title { font-size: 15px; font-weight: 700; }
  .hoy-now .hoy-now-sub { font-size: 13px; opacity: 0.92; margin-top: 2px; }
  .hoy-now.libre .hoy-now-sub { color: var(--text-muted); opacity: 1; }
  .hoy-list { display: flex; flex-direction: column; gap: 8px; }
  .hoy-row {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 6px 12px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
  }
  .hoy-row.ahora { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary) inset; background: #f1f6fc; }
  .hoy-row.termino { opacity: 0.6; }
  .hoy-time { font-size: 12px; font-weight: 700; color: var(--text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
  .hoy-name { font-size: 14px; font-weight: 600; color: var(--text); min-width: 0; }
  .hoy-sala { font-size: 12px; font-weight: 500; color: var(--text-muted); margin-left: 6px; }
  .hoy-badge {
    font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px;
    padding: 3px 8px; border-radius: 10px; white-space: nowrap;
    background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border);
  }
  .hoy-badge.ahora { background: var(--primary); color: #fff; border-color: var(--primary); }
  .hoy-badge.proxima { background: #fff7e8; color: #8a5300; border-color: #ffd89a; }
  .hoy-att { grid-column: 1 / -1; display: flex; gap: 6px; flex-wrap: wrap; }
  .hoy-att-btn {
    padding: 5px 10px; font-size: 12px; font-weight: 600;
    border-radius: 7px; border: 1px solid var(--border-strong);
    background: var(--surface); color: var(--text-muted);
  }
  .hoy-att-btn.on.presente { background: #e6f7ea; color: #0a5022; border-color: #c3e9cb; }
  .hoy-att-btn.on.ausente { background: #ffeaea; color: #8a0000; border-color: #ffcfcf; }
  .hoy-att-btn.on.cancelada { background: var(--surface-2); color: var(--text-faint); text-decoration: line-through; }

  /* ====== WEEKLY HORARIO GRID ====== */
  .horario-week {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
  }
  .horario-week-header, .horario-week-body { display: flex; }
  .horario-week-header {
    border-bottom: 1px solid var(--border);
  }
  .horario-week-timecol, .horario-week-timecol-body {
    width: 46px;
    flex-shrink: 0;
    position: relative;
  }
  .horario-week-daycol-header {
    flex: 1;
    min-width: 84px;
    text-align: center;
    padding: 8px 4px;
    font-weight: 700;
    font-size: 12px;
    color: var(--text);
    border-left: 1px solid var(--border);
  }
  .horario-week-body { position: relative; overflow-x: auto; }
  .horario-hour-label {
    position: absolute;
    left: 0; right: 6px;
    text-align: right;
    font-size: 10px;
    color: var(--text-muted);
    transform: translateY(-50%);
  }
  .horario-week-daycol {
    flex: 1;
    min-width: 84px;
    position: relative;
    border-left: 1px solid var(--border);
    background-image: repeating-linear-gradient(to bottom, var(--border) 0, var(--border) 1px, transparent 1px, transparent 48px);
  }
  .horario-block {
    position: absolute;
    left: 3px; right: 3px;
    border-radius: 8px;
    padding: 5px 7px;
    color: white;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.3;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
  }
  .horario-block { cursor: pointer; }
  .horario-block:hover { filter: brightness(1.06); }
  .horario-block.actual { outline: 3px solid #1d1d1f; outline-offset: 1px; z-index: 2; }
  .asignatura.flash { animation: asig-flash 1.8s ease-out; }
  @keyframes asig-flash {
    0%, 60% { box-shadow: 0 0 0 3px var(--primary); }
    100% { box-shadow: 0 0 0 3px transparent; }
  }
  .horario-block .sala { font-weight: 500; opacity: 0.9; font-size: 10px; margin-top: 1px; }
  .horario-empty, .calmes-empty {
    padding: 30px 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
  }

  /* ====== PESTAÑA ASISTENCIA ====== */
  .asistencia-card { margin-bottom: 16px; }
  .asistencia-card:last-child { margin-bottom: 0; }
  .asistencia-card .card-title { text-transform: none; letter-spacing: normal; font-size: 15px; color: var(--text); }
  .asistencia-card .card-title .att-minimo {
    width: 64px;
    padding: 5px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    text-transform: none;
  }
  .asist-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 8px;
    vertical-align: middle;
  }

  /* ====== MONTHLY EVALUACIONES CALENDAR ====== */
  .calmes-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
  }
  .calmes-nav .label { font-weight: 700; font-size: 15px; }
  .calmes-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
  }
  .calmes-dow {
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    padding-bottom: 4px;
  }
  .calmes-day {
    min-height: 64px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 4px;
    background: var(--surface);
  }
  .calmes-day.outside { background: var(--surface-2); opacity: 0.5; }
  .calmes-day.today { border-color: var(--primary); border-width: 2px; }
  .calmes-day .num { font-size: 11px; color: var(--text-muted); font-weight: 600; }
  .calmes-eval {
    margin-top: 2px;
    padding: 2px 4px;
    border-radius: 5px;
    font-size: 10px;
    font-weight: 600;
    color: white;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  @media (max-width: 700px) {
    .calmes-day { min-height: 46px; }
    .calmes-eval { font-size: 9px; }
  }

  /* ====== ADD BUTTONS ====== */
  .add-row {
    display: flex;
    gap: 8px;
    margin-top: 8px;
  }
  .add-row button {
    font-size: 12px;
    padding: 6px 10px;
    color: var(--primary);
    border: 1px dashed var(--border-strong);
    border-radius: 6px;
  }
  .add-row button:hover {
    background: rgba(0,59,113,0.06);
    border-color: var(--primary);
  }

  /* ====== EMPTY STATE ====== */
  .empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
  }
  .empty .icon { font-size: 48px; margin-bottom: 12px; }
  .empty h3 { font-size: 18px; color: var(--text); margin-bottom: 6px; }
  .empty p { font-size: 14px; margin-bottom: 16px; }

  /* ====== MODAL ====== */
  .modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 100;
    align-items: center;
    justify-content: center;
    padding: 20px;
  }
  .modal-backdrop.active { display: flex; }
  .modal {
    background: var(--surface);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 420px;
    padding: 24px;
    box-shadow: var(--shadow-lg);
    /* El modal de evento tiene varios campos: que scrollee sólo si no cabe. */
    max-height: calc(100vh - 40px);
    overflow-y: auto;
  }
  .modal h3 {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 16px;
  }
  .modal p {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 18px;
  }
  .modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
  }
  .eventinfo-body { margin-bottom: 18px; }
  .eventinfo-row {
    display: flex;
    gap: 10px;
    padding: 7px 0;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
  }
  .eventinfo-row:last-child { border-bottom: none; }
  .eventinfo-row .k {
    color: var(--text-muted);
    min-width: 90px;
    flex-shrink: 0;
  }
  .eventinfo-row .v { font-weight: 500; word-break: break-word; }
  .eventinfo-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
  }

  /* ====== TOAST ====== */
  .toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--text);
    color: white;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 13px;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transition: all 0.2s;
    pointer-events: none;
    z-index: 200;
  }
  .toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
  }
  .toast.error { background: var(--danger); }
  .toast.success { background: var(--success); }

  /* ====== UTILITY ====== */
  .row-flex { display: flex; gap: 10px; align-items: center; }
  .text-muted { color: var(--text-muted); font-size: 12px; }
  .alert-banner {
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 16px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
  }
  .alert-banner.warning { background: #fff7e6; color: #8a5a00; border: 1px solid #ffd591; }
  .alert-banner.danger { background: #ffeaea; color: #a00; border: 1px solid #ffcfcf; }
  .alert-banner .icon { font-size: 16px; }

  /* Loading */
  .loading-screen {
    position: fixed;
    inset: 0;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
  }
  .spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
  }
  @keyframes spin { to { transform: rotate(360deg); } }

  @media (max-width: 600px) {
    main { padding: 16px 12px; }
    .asig-head { flex-direction: column; align-items: stretch; }
    .asig-grades { justify-content: space-around; }
    header.topbar { padding: calc(10px + env(safe-area-inset-top)) 12px 10px; gap: 8px; }
    .topbar-logo { font-size: 15px; white-space: nowrap; flex-shrink: 0; }
    .user-chip { display: none; }

    /* En el celular el menú pasa a una segunda fila a todo el ancho, con pestañas más grandes
       y scroll horizontal si no entran. */
    header.topbar { flex-wrap: wrap; row-gap: 8px; }
    .topbar-left { display: contents; }
    .topbar-logo { order: 1; }
    .topbar-right { order: 2; flex-shrink: 0; margin-left: auto; }
    .topbar-nav {
      order: 3;
      flex: 0 0 100%;
      margin-left: 0;
      gap: 6px;
      overflow-x: auto;
      -webkit-overflow-scrolling: touch;
      scrollbar-width: none;
      min-width: 0;
    }
    .topbar-nav::-webkit-scrollbar { display: none; }
    .nav-tab { flex-shrink: 0; white-space: nowrap; padding: 9px 14px; font-size: 15px; background: var(--surface-2); }
    .nav-tab.active { background: var(--primary); }
  }

img[src*="/media/"]{-webkit-user-drag:none;user-drag:none;-webkit-user-select:none;user-select:none;-webkit-touch-callout:none}

  /* Marca notasapp: logotipo desde /media/ (protegido) */
  .brand-login { display: block; margin: 0 auto 10px; max-width: 80%; height: auto; }
  .brand-top { display: block; height: 24px; width: auto; }
  @media (max-width: 700px) { .brand-top { height: 20px; } }
