/* ==========================================================================
   Diseño de hoja de cálculo (cuadrícula, menús, barra de herramientas).
   Se carga después de app.css: las pantallas de acceso y los diálogos siguen
   usando app.css; aquí solo se redibuja el área de trabajo.
   ========================================================================== */

.gs{
  --gs-bg:#f9fbfd; --gs-line:#e2e3e3; --gs-head:#f8f9fa; --gs-head-line:#c4c7c5;
  --gs-text:#1f1f1f; --gs-muted:#5f6368; --gs-blue:#1a73e8; --gs-blue-dark:#0b57d0;
  --gs-sel:rgba(14,101,235,.1); --gs-hl:#d3e3fd; --gs-hover:#e9eef6; --gs-green:#188038;
  height:100dvh; min-height:480px; display:flex; flex-direction:column;
  background:var(--gs-bg); color:var(--gs-text);
  font-family:Roboto,"Segoe UI",Arial,sans-serif; font-size:14px;
}
.gs button{font:inherit;color:inherit}
.gs svg.i{width:18px;height:18px}
.gs svg.i-sm{width:15px;height:15px}

/* ---------- Barra de título y menús ---------- */
.gs-titlebar{display:flex;align-items:center;gap:10px;padding:8px 16px 4px 12px;flex-shrink:0}
.gs-logo{width:40px;height:40px;flex:none;display:grid;place-items:center;border-radius:6px;background:var(--gs-green);color:#fff}
.gs-logo svg.i{width:24px;height:24px}
.gs-doc{flex:1;min-width:0}
.gs-docname{display:flex;align-items:center;gap:10px;min-width:0}
.gs-docname h1{all:unset;font-size:18px;line-height:24px;color:var(--gs-text);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;padding:0 6px;border-radius:4px}
.gs-saved{display:inline-flex;align-items:center;gap:6px;font-size:12px;color:var(--gs-muted);white-space:nowrap}
.gs-saved svg.i{width:16px;height:16px}
.gs-saved.pending{color:#b06000}
.gs-saved.error{color:#c5221f}
.gs-menubar{display:flex;flex-wrap:wrap;gap:0;margin-top:1px}
.gs-menubar>button{border:0;background:none;padding:2px 7px;border-radius:4px;font-size:14px;line-height:22px;color:var(--gs-text);cursor:pointer}
.gs-menubar>button:hover,.gs-menubar>button.open{background:#e1e5ea}
.gs-right{display:flex;align-items:center;gap:10px;flex:none}
.gs-share{display:inline-flex;align-items:center;gap:8px;height:40px;padding:0 18px 0 14px;border:0;border-radius:20px;background:#c2e7ff;color:#001d35;font-size:14px;font-weight:500;cursor:pointer}
.gs-share:hover{background:#b3dcf6;box-shadow:0 1px 2px #3c404326}
.gs-avatar{width:34px;height:34px;border-radius:50%;border:0;background:#0b8043;color:#fff;font-weight:500;font-size:15px;display:grid;place-items:center;cursor:pointer;text-transform:uppercase}
.gs-avatar:hover{box-shadow:0 0 0 4px #e1e5ea}

/* ---------- Barra de herramientas ---------- */
.gs-toolbar{display:flex;align-items:center;gap:2px;margin:4px 8px 8px;padding:0 8px;min-height:40px;background:#edf2fa;border-radius:24px;flex-shrink:0;overflow-x:auto;scrollbar-width:none}
.gs-toolbar::-webkit-scrollbar{display:none}
.gs-tb{position:relative;flex:none;min-width:28px;height:28px;padding:0 4px;display:inline-flex;align-items:center;justify-content:center;gap:4px;border:0;border-radius:4px;background:none;color:#444746;cursor:pointer}
.gs-tb:hover{background:#dfe3eb}
.gs-tb.on{background:var(--gs-hl);color:#041e49}
.gs-tb:disabled{opacity:.38;cursor:default;background:none}
.gs-tb .gs-swatch{position:absolute;left:5px;right:5px;bottom:3px;height:3px;border-radius:1px}
.gs-tb.color svg.i{margin-bottom:4px}
.gs-tb-label{font-size:13px;padding:0 4px}
.gs-sep{flex:none;width:1px;height:20px;background:#c7c7c7;margin:0 5px}
.gs-search{margin-left:auto;flex:none;display:flex;align-items:center;gap:6px;height:30px;width:230px;padding:0 10px;background:#fff;border:1px solid transparent;border-radius:15px;color:var(--gs-muted)}
.gs-search:focus-within{border-color:var(--gs-blue)}
.gs-search input{flex:1;min-width:0;border:0;outline:none;background:none;font-size:13px;color:var(--gs-text)}
.gs-search button{border:0;background:none;display:flex;padding:0;color:var(--gs-muted);cursor:pointer}

/* ---------- Cuadro de nombre y barra de fórmulas ---------- */
.gs-formula{display:flex;align-items:stretch;height:30px;background:#fff;border-top:1px solid var(--gs-line);border-bottom:1px solid var(--gs-line);flex-shrink:0}
.gs-namebox{width:100px;flex:none;border:0;border-right:1px solid var(--gs-line);padding:0 10px;font-size:13px;color:var(--gs-text);outline:none;background:#fff}
.gs-namebox:focus{box-shadow:inset 0 0 0 2px var(--gs-blue)}
.gs-fx{flex:none;display:grid;place-items:center;width:38px;color:#80868b;font-style:italic;font-family:Georgia,serif;font-size:15px;border-right:1px solid var(--gs-line)}
.gs-formula-input{flex:1;min-width:0;border:0;outline:none;resize:none;padding:6px 10px 0;font:13px Arial,sans-serif;color:var(--gs-text);line-height:17px;background:#fff;overflow:hidden;white-space:nowrap}
.gs-formula-input:read-only{color:#5f6368}
.gs.no-formula .gs-formula{display:none}

/* ---------- Cuadrícula ---------- */
.gs-grid{position:relative;flex:1;min-height:0;overflow:auto;background:#fff;outline:none;font:13px Arial,sans-serif;color:var(--gs-text)}
.gs-table{table-layout:fixed;border-collapse:separate;border-spacing:0;user-select:none}
.gs-table th,.gs-table td{border-right:1px solid var(--gs-line);border-bottom:1px solid var(--gs-line);padding:0;overflow:hidden}
.gs.no-gridlines .gs-table td.gs-cell{border-color:transparent}
.gs-table thead th{position:sticky;top:0;z-index:6;height:24px;background:var(--gs-head);color:#444746;font:500 11px Arial,sans-serif;text-align:center;border-color:var(--gs-head-line);cursor:default}
.gs-table thead th.gs-col{cursor:s-resize}
.gs-table thead th.gs-col:hover{background:#eef0f2}
.gs-table thead th.gs-corner{left:0;z-index:8;border-right:4px solid #c4c7c5;border-bottom:4px solid #c4c7c5;background:var(--gs-head);cursor:pointer}
.gs-table .gs-rownum{position:sticky;left:0;z-index:4;width:46px;background:var(--gs-head);color:#444746;font:11px Arial,sans-serif;text-align:center;border-color:var(--gs-head-line);cursor:e-resize}
.gs-table th.hl,.gs-table td.gs-rownum.hl{background:var(--gs-hl);color:#041e49;font-weight:700}
.gs-table th.full,.gs-table td.gs-rownum.full{background:var(--gs-blue-dark);color:#fff}
.gs-resize{position:absolute;top:0;right:-3px;width:7px;height:100%;cursor:col-resize;z-index:2}
.gs-resize:hover,.gs-resize.drag{background:var(--gs-blue)}
.gs-table thead th{position:sticky}
.gs-table thead th.gs-col{position:sticky}

/* Fila 1: nombres de las columnas, inmovilizada como encabezado. */
.gs-headrow td{position:sticky;top:25px;z-index:5;height:26px;background:#fff;font-weight:700;padding:0 6px;white-space:nowrap;border-bottom:2px solid #c4c7c5}
.gs-headrow td.gs-rownum{z-index:7;font-weight:400}

.gs-cell{height:28px;padding:3px 6px!important;vertical-align:bottom;background:#fff;white-space:pre-wrap;word-break:break-word;line-height:17px;cursor:cell}
.gs-cell.t-date,.gs-cell.t-text,.gs-cell.t-link{white-space:nowrap;text-overflow:ellipsis}
.gs-cell.t-date{text-align:right}
.gs-cell.t-long{min-width:0}
.gs-cell.t-image,.gs-cell.t-actions,.gs-cell.t-status,.gs-cell.t-area{vertical-align:middle;white-space:nowrap}
.gs-cell.t-actions{text-align:center;padding:0 2px!important}
.gs-cell.ro{color:#5f6368}
.gs-table tr.archived-row .gs-cell{color:#80868b}
.gs-filler td{height:22px;background:#fff}
.gs-filler td.gs-rownum{cursor:default}
.gs-empty td{height:120px!important;text-align:center;color:#5f6368;background:#fff;vertical-align:middle;white-space:normal}
.gs-empty strong{display:block;color:#3c4043;font-size:14px;margin:8px 0 4px}
.gs-empty svg.i{width:26px;height:26px;color:#9aa0a6}

/* Selección */
.gs-selbox,.gs-active,.gs-copybox{position:absolute;pointer-events:none;display:none}
.gs-selbox{z-index:3;background:var(--gs-sel);border:1px solid var(--gs-blue)}
.gs-active{z-index:3;border:2px solid var(--gs-blue)}
.gs-active .gs-handle{position:absolute;right:-5px;bottom:-5px;width:7px;height:7px;background:var(--gs-blue);border:1px solid #fff;border-radius:1px}
.gs-copybox{z-index:3;border:2px dashed var(--gs-blue);animation:gs-ants 1s linear infinite}
@keyframes gs-ants{50%{border-color:#7baaf7}}
.gs-grid.editing .gs-active .gs-handle{display:none}
.row-flash td.gs-cell{animation:row-flash 3s ease}

/* Editor de celda (se coloca encima de la celda) */
.gs-editor{position:absolute;z-index:9;margin:0;border:2px solid var(--gs-blue);box-shadow:0 2px 6px #3c40434d;padding:2px 5px;font:13px Arial,sans-serif;line-height:17px;color:var(--gs-text);background:#fff;outline:none;resize:none;overflow:hidden;white-space:pre-wrap;word-break:break-word}
input.gs-editor{padding:2px 5px}

/* Contenido especial de algunas celdas */
.gs-chip{display:inline-flex;align-items:center;gap:5px;max-width:100%;height:22px;padding:0 9px;border:0;border-radius:11px;font:12px Arial,sans-serif;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;cursor:pointer;vertical-align:middle}
.gs-dd{background:var(--chip-bg,#e8eaed);color:var(--chip-fg,#3c4043);cursor:cell;padding-right:5px}
.gs-dd svg.i{width:14px;height:14px;opacity:.7}
.gs-ddarrow{float:right;display:none;color:#5f6368}
.gs-cell.t-area:hover .gs-ddarrow,.gs-cell.t-area.is-active .gs-ddarrow{display:inline-flex}
.gs-photos{background:#e6f4ea;color:#137333}
.gs-photos:hover{background:#ceead6}
.gs-photos svg.i{width:15px;height:15px}
.gs-addphoto{position:relative;display:inline-flex;align-items:center;gap:5px;height:22px;padding:0 8px;border-radius:11px;color:#80868b;font-size:12px;opacity:0;cursor:pointer}
.gs-addphoto svg.i{width:15px;height:15px}
.gs-addphoto input{position:absolute;inset:0;width:100%;height:100%;opacity:0;cursor:pointer}
.gs-addphoto .busy-text{display:none}
.gs-addphoto:has(input.htmx-request){opacity:1;color:var(--gs-blue)}
.gs-addphoto:has(input.htmx-request) .idle-text{display:none}
.gs-addphoto:has(input.htmx-request) .busy-text{display:inline}
.gs-cell.t-image:hover .gs-addphoto,.gs-cell.t-image.is-active .gs-addphoto,tr.dragging .gs-addphoto{opacity:1}
.gs-addphoto:hover{background:#f1f3f4;color:var(--gs-blue)}
tr.dragging td.gs-cell{background:#e8f0fe!important}
.gs-iconbtn{display:inline-grid;place-items:center;width:26px;height:24px;border:0;border-radius:4px;background:none;color:#80868b;cursor:pointer;vertical-align:middle}
.gs-iconbtn:hover{background:#f1f3f4;color:#c5221f}
.gs-iconbtn.folio-action:hover,.gs-iconbtn.folio-action.has-folio{color:var(--gs-green)}
.gs-iconbtn svg.i{width:16px;height:16px}
.gs-link{color:#1155cc;text-decoration:underline;cursor:pointer}
.gs-status{background:#e8eaed;color:#3c4043}
.gs-status.completado{background:#d4edbc;color:#11734b}
.gs-status:hover{filter:brightness(.96)}

/* ---------- Dashboard dentro del área de trabajo ---------- */
.gs-dashboard{flex:1;min-height:0;overflow:auto;background:#fff;border-top:1px solid var(--gs-line)}

/* ---------- Barra inferior: hojas ---------- */
.gs-bottom{display:flex;align-items:center;gap:4px;height:40px;padding:0 12px 0 8px;background:var(--gs-bg);border-top:1px solid var(--gs-line);flex-shrink:0}
.gs-sheets-btn{width:32px;height:32px;border:0;border-radius:50%;background:none;display:grid;place-items:center;color:#444746;cursor:pointer}
.gs-sheets-btn:hover{background:#e1e5ea}
.gs-tabs{display:flex;align-items:center;gap:2px;overflow-x:auto;scrollbar-width:none;min-width:0}
.gs-tabs::-webkit-scrollbar{display:none}
.gs-tab{display:inline-flex;align-items:center;gap:7px;height:32px;padding:0 14px;border-radius:4px;color:#444746;font-size:14px;text-decoration:none;white-space:nowrap}
.gs-tab:hover{background:#e1e5ea}
.gs-tab.active{background:#e1e9f7;color:var(--gs-blue-dark);font-weight:500}
.gs-tab svg.i{width:16px;height:16px}
.gs-tab .tab-count{font-size:11px;padding:1px 6px;border-radius:9px;background:#d3e3fd;color:#041e49}
.gs-status-bar{margin-left:auto;display:flex;align-items:center;gap:14px;font-size:12px;color:var(--gs-muted);white-space:nowrap}
.gs-status-bar b{font-weight:500;color:#3c4043}
.gs-recount{display:inline-flex;align-items:center;height:28px;padding:0 10px;border-radius:4px;background:#fff;border:1px solid var(--gs-line);color:#3c4043}
.gs-clear-history{display:inline-flex;align-items:center;gap:6px;height:28px;padding:0 10px;border:1px solid #dadce0;border-radius:4px;background:#fff;color:#c5221f;font-size:12px;cursor:pointer}
.gs-clear-history:hover{background:#fce8e6}

/* ---------- Menús desplegables y paleta ---------- */
.gs-menu{position:fixed;z-index:300;min-width:240px;max-width:340px;max-height:calc(100dvh - 20px);overflow-y:auto;padding:6px 0;background:#fff;border-radius:4px;box-shadow:0 2px 6px 2px #3c404326,0 1px 2px #3c40434d;font-size:14px;color:var(--gs-text)}
.gs-menu button.gs-mi{display:flex;align-items:center;gap:12px;width:100%;height:32px;padding:0 16px 0 12px;border:0;background:none;text-align:left;cursor:pointer;font:14px Roboto,"Segoe UI",Arial,sans-serif;color:var(--gs-text)}
.gs-menu button.gs-mi:hover,.gs-menu button.gs-mi.kbd-focus{background:#f1f3f4}
.gs-menu button.gs-mi:disabled{color:#a8abaf;cursor:default;background:none}
.gs-mi .gs-mi-ic{width:20px;display:grid;place-items:center;color:#444746}
.gs-mi .gs-mi-label{flex:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.gs-mi .gs-mi-kbd{color:#80868b;font-size:13px}
.gs-mi .gs-mi-dot{width:14px;height:14px;border-radius:3px;border:1px solid #0000001f}
.gs-menu hr{border:0;border-top:1px solid #e3e3e3;margin:6px 0}
.gs-menu .gs-mi-head{padding:6px 16px 8px;font-size:13px;color:var(--gs-muted);border-bottom:1px solid #e3e3e3;margin-bottom:6px;word-break:break-all}
.gs-palette{padding:10px 12px}
.gs-palette .gs-reset{display:flex;align-items:center;gap:8px;width:100%;border:0;background:none;padding:6px 4px;margin-bottom:6px;border-radius:4px;cursor:pointer;font-size:14px}
.gs-palette .gs-reset:hover{background:#f1f3f4}
.gs-swatches{display:grid;grid-template-columns:repeat(10,18px);gap:4px}
.gs-swatches.top{margin-bottom:10px}
.gs-swatches button{width:18px;height:18px;padding:0;border-radius:50%;border:1px solid #0000001a;cursor:pointer}
.gs-swatches button:hover{box-shadow:0 0 0 2px #fff,0 0 0 4px #9aa0a6}
.gs-swatches button.on{box-shadow:0 0 0 2px #fff,0 0 0 4px var(--gs-blue)}

/* ---------- Atajos ---------- */
.gs-keys{width:100%;border-collapse:collapse;font-size:13px}
.gs-keys td{padding:6px 4px;border-bottom:1px solid #eef0f2}
.gs-keys td:last-child{text-align:right;white-space:nowrap}
.gs-keys kbd{font:12px Consolas,monospace;background:#f1f3f4;border:1px solid #dadce0;border-radius:4px;padding:1px 5px}

/* ---------- Pantallas chicas ---------- */
@media(max-width:900px){
  .gs-titlebar{padding:6px 8px 2px}
  .gs-docname h1{font-size:16px}
  .gs-share span{display:none}
  .gs-share{padding:0 11px;height:36px}
  .gs-search{width:160px}
  .gs-status-bar .opt{display:none}
}
@media(max-width:600px){
  .gs-saved em{display:none}
  .gs-menubar>button{padding:2px 5px;font-size:13px}
  .gs-search{width:130px}
}

/* Ajustes sobre reglas generales de app.css */
.gs label:focus-within,.gs button:focus-visible{outline:none}
.gs .gs-tb:focus-visible,.gs .gs-menubar>button:focus-visible,.gs .gs-tab:focus-visible{outline:2px solid var(--gs-blue);outline-offset:-2px}
.row-flash td.gs-rownum{animation:none}
.gs-cell.t-area .gs-dd{cursor:pointer}
.gs-view .dashboard{padding:24px}
/* Receptor de teclado: invisible, junto a la celda activa. */
.gs-sink{position:absolute;width:2px;height:2px;padding:0;border:0;margin:0;opacity:0;resize:none;overflow:hidden;pointer-events:none;z-index:0}
@media(max-width:600px){.gs-status-bar{display:none}}
