:root { --fondo: #0b1020; --panel: #121a30; --panel2: #18223f; --borde: #26335a; --texto: #e8ecf8; --suave: #9fb0d8; --oro: #ffc933; --ok: #3ddc97; --mal: #ff6b6b; --hoy: #3b82f6; color-scheme: dark; }
@media (prefers-color-scheme: light) { :root { --fondo: #f5f7fc; --panel: #ffffff; --panel2: #eef2fb; --borde: #cdd6ee; --texto: #14203f; --suave: #4a5a85; --oro: #8a5a00; --ok: #0a7d4f; --mal: #b3261e; --hoy: #1d4ed8; color-scheme: light; } }
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--fondo); color: var(--texto); font: 15px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; display: flex; flex-direction: column; overflow: hidden; }
.salto { position: absolute; left: -999px; } .salto:focus { left: 8px; top: 8px; z-index: 99; background: var(--panel); padding: 8px; }
button, select, input, textarea { font: inherit; color: var(--texto); }
button { background: var(--panel); border: 1px solid var(--borde); border-radius: 8px; padding: 6px 12px; cursor: pointer; min-height: 36px; }
button:hover { border-color: var(--oro); } button[aria-pressed="true"] { border-color: var(--oro); box-shadow: inset 0 0 0 1px var(--oro); }
button.principal { background: var(--oro); color: #1a1300; border-color: var(--oro); font-weight: 600; } button.peligro { border-color: var(--mal); color: var(--mal); }
button.icono { min-width: 36px; padding: 6px; } button.plano { border-color: transparent; background: transparent; }
:focus-visible { outline: 3px solid var(--oro); outline-offset: 1px; }
input[type=text], input[type=search], input[type=date], input[type=time], input[type=number], select, textarea { background: var(--fondo); border: 1px solid var(--borde); border-radius: 8px; padding: 6px 8px; max-width: 100%; }
textarea { width: 100%; min-height: 70px; }

.ag-cab { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--borde); background: var(--panel); }
.ag-cab h1 { font-size: 1.15rem; margin: 0 8px 0 0; font-weight: 600; white-space: nowrap; } .ag-cab .ag-titulo { font-size: 1.1rem; font-weight: 600; min-width: 120px; }
.ag-cab .esp { flex: 1; } .ag-cab input[type=search] { width: 200px; }
.ag-vistas { display: inline-flex; gap: 0; } .ag-vistas button { border-radius: 0; margin-left: -1px; } .ag-vistas button:first-child { border-radius: 8px 0 0 8px; margin: 0; } .ag-vistas button:last-child { border-radius: 0 8px 8px 0; }
.ag-insignia { background: var(--mal); color: #fff; border-radius: 999px; padding: 0 6px; font-size: .75rem; margin-left: 4px; }

.ag-cuerpo { flex: 1; display: flex; min-height: 0; }
.ag-lateral { width: 250px; flex: none; border-right: 1px solid var(--borde); background: var(--panel); padding: 12px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.ag-lateral h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--suave); margin: 0 0 6px; font-weight: 600; }
.ag-main { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; outline: none; }
.ag-mini table { width: 100%; border-collapse: collapse; text-align: center; font-size: .78rem; } .ag-mini th { color: var(--suave); font-weight: 500; }
.ag-mini td button { width: 100%; min-height: 26px; padding: 0; border: 0; background: transparent; border-radius: 50%; }
.ag-mini td.fuera button { color: var(--suave); opacity: .6; } .ag-mini td.hoy button { background: var(--hoy); color: #fff; } .ag-mini td.sel button { box-shadow: inset 0 0 0 2px var(--oro); } .ag-mini td.semana { background: var(--panel2); }
.ag-mini .cab { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; font-weight: 600; }
.ag-cal { display: flex; align-items: center; gap: 6px; padding: 2px 0; } .ag-cal label { flex: 1; display: flex; align-items: center; gap: 8px; cursor: pointer; min-width: 0; } .ag-cal label span.n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ag-cal input[type=checkbox] { width: 16px; height: 16px; margin: 0; accent-color: var(--c, var(--oro)); } .punto { width: 12px; height: 12px; border-radius: 3px; flex: none; display: inline-block; }
.suave { color: var(--suave); } .ok { color: var(--ok); } .mal { color: var(--mal); }

/* rejilla horaria */
.tg { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.tg-cab { display: grid; border-bottom: 1px solid var(--borde); background: var(--panel); padding-right: 12px; }
.tg-cab .d { text-align: center; padding: 6px 2px; border-left: 1px solid var(--borde); } .tg-cab .d button { border: 0; background: transparent; border-radius: 50%; width: 38px; min-height: 38px; font-size: 1.15rem; padding: 0; } .tg-cab .d.hoy button { background: var(--hoy); color: #fff; }
.tg-cab .d small { display: block; color: var(--suave); text-transform: uppercase; font-size: .7rem; }
.tg-todo { display: grid; border-bottom: 1px solid var(--borde); background: var(--panel); padding-right: 12px; max-height: 120px; overflow-y: auto; }
.tg-todo .c { border-left: 1px solid var(--borde); padding: 2px; min-height: 26px; display: flex; flex-direction: column; gap: 2px; }
.tg-scroll { flex: 1; overflow-y: scroll; position: relative; }
.tg-cuerpo { display: grid; position: relative; }
.tg-horas { position: relative; } .tg-horas div { position: absolute; right: 6px; transform: translateY(-50%); font-size: .7rem; color: var(--suave); }
.tg-col { position: relative; border-left: 1px solid var(--borde); background-image: linear-gradient(to bottom, var(--borde) 1px, transparent 1px); touch-action: pan-y; cursor: cell; }
.tg-col.hoy { background-color: color-mix(in srgb, var(--hoy) 6%, transparent); }
.tg-ev { position: absolute; border-radius: 6px; padding: 2px 5px; font-size: .78rem; color: #fff; overflow: hidden; cursor: pointer; border: 1px solid color-mix(in srgb, #000 30%, transparent); user-select: none; touch-action: none; line-height: 1.2; }
.tg-ev b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .tg-ev small { opacity: .9; }
.tg-ev.solo { cursor: default; background-image: repeating-linear-gradient(135deg, transparent 0 6px, rgba(255,255,255,.14) 6px 12px); }
.tg-ev.arrastrando, .chip.arrastrando { opacity: .75; z-index: 20; box-shadow: 0 6px 18px rgba(0,0,0,.45); cursor: grabbing; }
.tg-ev .rs { position: absolute; left: 0; right: 0; bottom: 0; height: 7px; cursor: ns-resize; }
.tg-sel { position: absolute; left: 2px; right: 2px; background: color-mix(in srgb, var(--hoy) 35%, transparent); border: 1px dashed var(--hoy); border-radius: 6px; pointer-events: none; z-index: 5; }
.tg-ahora { position: absolute; left: 0; right: 0; height: 0; border-top: 2px solid var(--mal); z-index: 6; pointer-events: none; } .tg-ahora::before { content: ''; position: absolute; left: -5px; top: -6px; width: 10px; height: 10px; border-radius: 50%; background: var(--mal); }
.chip { display: block; width: 100%; text-align: left; font-size: .75rem; padding: 1px 6px; border-radius: 5px; color: #fff; border: 0; min-height: 20px; line-height: 1.5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; touch-action: none; }
.chip.solo { background-image: repeating-linear-gradient(135deg, transparent 0 6px, rgba(255,255,255,.14) 6px 12px); cursor: default; }

/* mes */
.mes { flex: 1; min-height: 0; display: grid; grid-template-rows: auto 1fr; }
.mes-cab, .mes-cuad { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); } .mes-cab div { text-align: center; padding: 6px; color: var(--suave); font-size: .8rem; border-bottom: 1px solid var(--borde); }
.mes-cuad { grid-template-rows: repeat(6, minmax(0, 1fr)); overflow-y: auto; }
.cel { border-right: 1px solid var(--borde); border-bottom: 1px solid var(--borde); padding: 2px; display: flex; flex-direction: column; gap: 2px; min-height: 0; overflow: hidden; cursor: cell; }
.cel.fuera { background: var(--panel2); } .cel .num { align-self: center; border: 0; background: transparent; border-radius: 50%; width: 26px; min-height: 26px; height: 26px; padding: 0; font-size: .8rem; flex: none; } .cel.hoy .num { background: var(--hoy); color: #fff; }
.cel .mas { font-size: .72rem; color: var(--suave); background: transparent; border: 0; padding: 0 4px; text-align: left; min-height: 18px; }
/* año */
.anio { flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; padding: 14px; align-content: start; }
.anio table { width: 100%; border-collapse: collapse; text-align: center; font-size: .75rem; } .anio h3 { margin: 0 0 4px; font-size: .95rem; } .anio td button { width: 100%; min-height: 24px; padding: 0; border: 0; background: transparent; border-radius: 50%; } .anio td.hoy button { background: var(--hoy); color: #fff; } .anio td.con button { font-weight: 800; text-decoration: underline var(--oro); } .anio td.fuera { visibility: hidden; }
/* lista */
.lista { flex: 1; overflow-y: auto; padding: 8px 16px; } .lista h3 { margin: 14px 0 4px; font-size: .95rem; border-bottom: 1px solid var(--borde); padding-bottom: 2px; } .lista .fila { display: flex; gap: 10px; align-items: center; padding: 6px 4px; border-radius: 8px; cursor: pointer; width: 100%; border: 0; background: transparent; text-align: left; } .lista .fila:hover { background: var(--panel2); } .lista .h { width: 120px; flex: none; color: var(--suave); font-size: .85rem; }

/* diálogos */
#ag-modales .fondo { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 12px; }
.modal { background: var(--panel); border: 1px solid var(--borde); border-radius: 14px; width: min(560px, 100%); max-height: calc(100vh - 24px); overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; box-shadow: 0 12px 40px rgba(0,0,0,.5); }
.modal h2 { margin: 0; font-size: 1.1rem; } .modal .pie { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-top: 4px; }
.fila { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; } .campo { display: grid; gap: 2px; font-size: .8rem; color: var(--suave); } .campo.crece { flex: 1; min-width: 140px; } .campo input, .campo select { color: var(--texto); }
.modal details { border-top: 1px solid var(--borde); padding-top: 8px; } .modal summary { cursor: pointer; color: var(--suave); margin-bottom: 8px; }
.dias-sem { display: inline-flex; gap: 4px; flex-wrap: wrap; } .dias-sem button { width: 36px; padding: 0; border-radius: 50%; }
.colores { display: inline-flex; gap: 6px; flex-wrap: wrap; } .colores button { width: 28px; min-height: 28px; height: 28px; padding: 0; border-radius: 50%; border: 2px solid transparent; } .colores button[aria-pressed="true"] { border-color: var(--texto); box-shadow: none; }
.ag-aviso { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); background: var(--panel); border: 1px solid var(--ok); border-radius: 10px; padding: 8px 14px; z-index: 80; display: flex; gap: 12px; align-items: center; max-width: calc(100vw - 24px); box-shadow: 0 6px 24px rgba(0,0,0,.5); } .ag-aviso.mal { border-color: var(--mal); }
.det { display: grid; gap: 6px; } .det .l { display: flex; gap: 10px; align-items: baseline; } .det .l > span:first-child { width: 22px; text-align: center; flex: none; }
.col-inv { display: flex; gap: 8px; align-items: center; margin: 2px 0; flex-wrap: wrap; }

@media (max-width: 820px) {
  .ag-lateral { position: fixed; z-index: 40; left: 0; top: 0; bottom: 0; transform: translateX(-100%); transition: transform .2s; width: 280px; } .ag-lateral.abierto { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.6); }
  .ag-cab input[type=search] { width: 120px; } .ag-cab h1 { display: none; } .tg-ev { font-size: .7rem; } .lista .h { width: 84px; }
}
@media (min-width: 821px) { .solo-movil { display: none !important; } }
@media (prefers-reduced-motion: reduce) { .ag-lateral { transition: none; } }
/* el planning pegado */
#pl-texto { min-height: 110px; resize: vertical; font-size: .85rem; }
.pl-vista { display: grid; gap: 8px; max-height: 42vh; overflow-y: auto; }
.pl-dia { display: grid; gap: 2px; } .pl-dia > b { border-bottom: 1px solid var(--borde); } .pl-dia > b::first-letter { text-transform: uppercase; }
.pl-dia > b { display: block; }
.pl-cita { display: flex; gap: 8px; align-items: baseline; cursor: pointer; } .pl-cita input { flex: none; }
.pl-sobran { border: 1px solid var(--borde); border-radius: 8px; padding: 6px 8px; } .pl-sobran ul { margin: 4px 0 0; font-size: .85rem; }
.campo[hidden] { display: none; }
/* la barra sigue en una línea con el botón del planning: el buscador cede sitio */
@media (min-width: 821px) { .ag-cab input[type=search] { flex: 1 1 80px; min-width: 80px; max-width: 200px; } .ag-cab { column-gap: 6px; } }
