/* WEBAPP · estilos. Tres aspectos: studio (oscuro, estilo edición de vídeo/foto), calma (claro, minimalista) y clasico (práctico). */

/* ============ Temas ============ */
:root, [data-theme="studio"] {
  --bg: #141518; --bg-img: none; --surface: #1d1f23; --surface-2: #25282d; --surface-3: #2e3238;
  --text: #e7e9ec; --muted: #8f949d; --border: #33363c; --accent: #4c8dff; --accent-fg: #fff; --accent-2: #f59e0b; --accent-soft: rgba(76, 141, 255, .16);
  --danger: #ef5b5b; --ok: #3ecf8e; --warn: #f5a524; --amarillo: #f0c419;
  --side-bg: #0f1013; --side-text: #a5aab3; --side-on: #fff; --top-bg: #181a1e; --top-text: var(--text);
  --radius: 6px; --radius-lg: 8px; --gap: 16px; --pad: 14px; --fs: 13px; --blur: 0px; --shadow: 0 8px 30px rgba(0, 0, 0, .45);
  --font: "Inter", "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, sans-serif;
  --card-bg: var(--surface); --card-border: 1px solid var(--border); --row-h: 34px;
  color-scheme: dark;
}
[data-theme="calma"] {
  --bg: #eef1f6; --bg-img: radial-gradient(1200px 700px at 8% -10%, #dfe8ff 0%, transparent 60%), radial-gradient(900px 600px at 100% 0%, #ffe9df 0%, transparent 55%), linear-gradient(#f4f6fb, #eef1f6);
  --surface: rgba(255, 255, 255, .62); --surface-2: rgba(255, 255, 255, .55); --surface-3: rgba(120, 130, 160, .12);
  --text: #2a2f3a; --muted: #6f7686; --border: rgba(110, 120, 150, .18); --accent: #5f7cf5; --accent-fg: #fff; --accent-2: #f2a48d; --accent-soft: rgba(95, 124, 245, .12);
  --danger: #d9534f; --ok: #2fb27a; --warn: #d98f1f; --amarillo: #b98f00;
  --side-bg: rgba(255, 255, 255, .45); --side-text: #5c6475; --side-on: #2a2f3a; --top-bg: rgba(255, 255, 255, .5); --top-text: var(--text);
  --radius: 14px; --radius-lg: 22px; --gap: 26px; --pad: 22px; --fs: 15px; --blur: 18px; --shadow: 0 10px 40px rgba(70, 80, 120, .12);
  --font: "Inter", "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
  --card-bg: var(--surface); --card-border: 1px solid rgba(255, 255, 255, .75); --row-h: 46px;
  color-scheme: light;
}
[data-theme="clasico"] {
  --bg: #eceff3; --bg-img: none; --surface: #ffffff; --surface-2: #f4f6f9; --surface-3: #e6eaf0;
  --text: #1f2933; --muted: #647081; --border: #c7ced8; --accent: #1f5fa8; --accent-fg: #fff; --accent-2: #c77a0a; --accent-soft: #e3eefb;
  --danger: #b42318; --ok: #1a7f4b; --warn: #a15c07; --amarillo: #8a6900;
  --side-bg: #2b3440; --side-text: #c4ccd8; --side-on: #fff; --top-bg: #1f5fa8; --top-text: #fff;
  --radius: 3px; --radius-lg: 4px; --gap: 14px; --pad: 12px; --fs: 13.5px; --blur: 0px; --shadow: 0 2px 10px rgba(0, 0, 0, .2);
  --font: Arial, "Segoe UI", Helvetica, sans-serif;
  --card-bg: var(--surface); --card-border: 1px solid var(--border); --row-h: 30px;
  color-scheme: light;
}

/* ============ Base ============ */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: var(--fs)/1.45 var(--font); color: var(--text); background: var(--bg) var(--bg-img) fixed; min-height: 100vh; }
a { color: var(--accent); text-decoration: none; } a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.6em; font-weight: 650; display: flex; align-items: center; gap: .5em; }
.ico { width: 1.15em; height: 1.15em; flex: none; stroke-width: 1.8; vertical-align: -.2em; }
.muted { color: var(--muted); } .spacer { flex: 1; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
::selection { background: var(--accent); color: var(--accent-fg); }
.count { font-size: .6em; font-weight: 600; background: var(--accent-soft); color: var(--accent); padding: .15em .6em; border-radius: 99px; }
.count:empty { display: none; }

/* Botones y campos */
.btn { display: inline-flex; align-items: center; gap: .45em; border: 1px solid var(--border); background: var(--surface-2); padding: .5em .9em; border-radius: var(--radius);
  cursor: pointer; min-height: 38px; transition: background .15s, border-color .15s, transform .1s; text-decoration: none !important; color: var(--text); }
.btn:hover { background: var(--surface-3); } .btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); } .btn.primary:hover { filter: brightness(1.1); }
.btn.danger { color: var(--danger); } .btn.block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { display: grid; place-items: center; width: 38px; height: 38px; border: 0; background: transparent; border-radius: var(--radius); cursor: pointer; color: inherit; }
.icon-btn:hover { background: var(--accent-soft); }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: .5em .65em; min-height: 38px; width: 100%; }
input:focus, select:focus, textarea:focus, button:focus-visible, .tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input[type=checkbox] { width: 20px; height: 20px; min-height: 0; accent-color: var(--accent); }
select { padding-right: 1.6em; } textarea { resize: vertical; }
.field { display: flex; flex-direction: column; gap: .3em; min-width: 0; }
.field > span { font-size: .82em; color: var(--muted); font-weight: 600; letter-spacing: .01em; } .field em { color: var(--danger); font-style: normal; }
.field small { font-size: .8em; }
/* Etiquetas de estado con color: gris, verde, rojo y amarillo */
.chip.chip-verde { background: color-mix(in srgb, var(--ok) 20%, transparent); color: var(--ok); }
.chip.chip-rojo { background: color-mix(in srgb, var(--danger) 18%, transparent); color: var(--danger); }
.chip.chip-amarillo { background: color-mix(in srgb, var(--amarillo) 22%, transparent); color: var(--amarillo); }
.chip.chip-gris { background: var(--surface-3); color: var(--muted); }
table.dataTable td .chip { font-size: .85em; white-space: nowrap; }
.chip { font-size: .7em; padding: .15em .6em; border-radius: 99px; background: var(--accent-soft); color: var(--accent); font-weight: 600; vertical-align: middle; }
.alert { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); padding: .6em .8em; border-radius: var(--radius); margin: 0 0 1em; }

/* Tarjetas */
.card { background: var(--card-bg); border: var(--card-border); border-radius: var(--radius-lg); padding: var(--pad); box-shadow: var(--shadow); backdrop-filter: blur(var(--blur)); -webkit-backdrop-filter: blur(var(--blur)); }
[data-theme="studio"] .card, [data-theme="clasico"] .card { box-shadow: none; }

/* ============ Estructura ============ */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; transition: grid-template-columns .25s ease; }
html.side-off .shell { grid-template-columns: 68px 1fr; }
.sidebar { background: var(--side-bg); color: var(--side-text); position: sticky; top: 0; height: 100vh; overflow: auto; border-right: 1px solid var(--border); backdrop-filter: blur(var(--blur)); -webkit-backdrop-filter: blur(var(--blur)); display: flex; flex-direction: column; view-transition-name: wap-side; }
.brand { display: flex; align-items: center; gap: .7em; padding: 14px 16px; color: var(--side-on); font-weight: 700; letter-spacing: .02em; height: 56px; text-decoration: none !important; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; flex: none; border-radius: calc(var(--radius) + 2px); background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; font-weight: 800; font-size: .95em; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; } .brand-text small { font-weight: 400; color: var(--side-text); font-size: .75em; }
.brand.big { height: auto; padding: 0 0 1.4em; color: var(--text); } .brand.big small { color: var(--muted); }
.nav { padding: 6px 10px 20px; display: flex; flex-direction: column; gap: 2px; }
.nav-title { text-transform: uppercase; font-size: .68em; letter-spacing: .12em; padding: 16px 10px 6px; opacity: .65; white-space: nowrap; overflow: hidden; }
.nav-item { display: flex; align-items: center; gap: .8em; padding: .6em .7em; color: var(--side-text); border-radius: var(--radius); white-space: nowrap; text-decoration: none !important; min-height: 40px; transition: background .15s, color .15s; }
.nav-item:hover { background: var(--accent-soft); color: var(--side-on); }
.nav-item.on { background: var(--accent); color: var(--accent-fg); }
html.side-off .brand-text, html.side-off .nav-item span, html.side-off .nav-title { display: none; }
html.side-off .nav-item { justify-content: center; } html.side-off .nav-title { padding: 6px 0; } html.side-off .brand { justify-content: center; padding: 14px 0; }
.main-col { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 10px; height: 56px; padding: 0 var(--gap); background: var(--top-bg); color: var(--top-text);
  border-bottom: 1px solid var(--border); backdrop-filter: blur(var(--blur)); -webkit-backdrop-filter: blur(var(--blur)); view-transition-name: wap-top; }
.search { position: relative; flex: 1; max-width: 520px; display: flex; align-items: center; }
.search > .ico { position: absolute; left: 11px; opacity: .6; pointer-events: none; }
.search input { padding-left: 2.3em; border-radius: 99px; background: color-mix(in srgb, var(--surface-2) 85%, transparent); }
[data-theme="clasico"] .search input { color: var(--text); background: #fff; border-color: transparent; border-radius: var(--radius); }
[data-theme="clasico"] .search > .ico { color: #667; }
.search-res { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); max-height: 70vh; overflow: auto; z-index: 50; backdrop-filter: blur(var(--blur)); }
[data-theme="calma"] .search-res { background: rgba(255, 255, 255, .9); }
.sr-title { font-size: .7em; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); padding: 10px 14px 4px; }
.sr-item { display: flex; flex-direction: column; padding: 8px 14px; color: var(--text); text-decoration: none !important; } .sr-item:hover { background: var(--accent-soft); }
.sr-item span { color: var(--muted); font-size: .85em; } .sr-all, .sr-empty { display: block; padding: 11px 14px; text-align: center; color: var(--muted); border-top: 1px solid var(--border); }
.usermenu { position: relative; }
.avatar { width: 38px; height: 38px; border-radius: 50%; border: 2px solid transparent; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; font-weight: 700; cursor: pointer; }
.avatar:hover { border-color: var(--accent-soft); }
.pop { position: absolute; right: 0; top: calc(100% + 8px); width: 320px; max-width: calc(100vw - 24px); background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 8px; z-index: 60; animation: pop-in .16s ease-out; }
[data-theme="calma"] .pop { background: rgba(255, 255, 255, .92); backdrop-filter: blur(18px); }
.pop-head { padding: 8px 10px 10px; display: flex; flex-direction: column; } .pop-head span { color: var(--muted); font-size: .85em; }
.pop-sec { text-transform: uppercase; font-size: .68em; letter-spacing: .1em; color: var(--muted); padding: 10px 10px 4px; }
.pop-link { display: flex; align-items: center; gap: .6em; width: 100%; padding: .6em .7em; border: 0; background: none; color: var(--text); border-radius: var(--radius); cursor: pointer; text-align: left; text-decoration: none !important; }
.pop-link:hover { background: var(--accent-soft); } .pop-link.danger { color: var(--danger); }
.themes { display: grid; grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); gap: 6px; padding: 0 4px 4px; }
.theme-btn { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 8px 4px; font-size: .82em; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); cursor: pointer; }
.theme-btn.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.sw { width: 100%; height: 26px; border-radius: 5px; border: 1px solid rgba(128, 128, 128, .3); }
.sw-studio { background: linear-gradient(90deg, #141518 60%, #4c8dff 60%); } .sw-calma { background: linear-gradient(135deg, #dfe8ff, #ffe9df); } .sw-clasico { background: linear-gradient(90deg, #1f5fa8 30%, #eceff3 30%); }
.langs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 0 4px 4px; }
.lang-btn { text-align: center; padding: .45em .3em; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); color: var(--text); text-decoration: none !important; font-size: .9em; }
.lang-btn:hover { background: var(--accent-soft); } .lang-btn.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; font-weight: 600; }
.lang-switch { position: fixed; top: 12px; right: 14px; display: flex; gap: 6px; z-index: 5; }
.lang-switch a { padding: .35em .7em; border-radius: 99px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font-size: .85em; text-decoration: none !important; }
.lang-switch a.on { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.logs { list-style: none; margin: 0; padding: 0 6px; max-height: 190px; overflow: auto; font-size: .85em; } .logs.wide { max-height: none; font-size: 1em; padding: 0; }
.logs li { padding: 4px 4px; border-bottom: 1px dashed var(--border); } .logs time { color: var(--muted); margin-right: .4em; font-variant-numeric: tabular-nums; } .logs b { color: var(--accent); font-weight: 600; }

.content { padding: var(--gap); flex: 1; min-width: 0; view-transition-name: wap-content; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: var(--gap); }
.page-head p { flex-basis: 100%; margin: 0; }
.head-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; } .head-actions select { width: auto; }
.sec-title { font-size: 1.05em; margin: calc(var(--gap) * 1.2) 0 10px; display: flex; align-items: center; gap: .5em; color: var(--muted); font-weight: 650; text-transform: uppercase; letter-spacing: .06em; font-size: .85em; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: var(--gap); }
.tile { display: flex; align-items: center; gap: .8em; color: var(--text); text-decoration: none !important; transition: transform .18s, border-color .18s; } .tile:hover { transform: translateY(-2px); border-color: var(--accent); } .tile .ico { color: var(--accent); width: 1.6em; height: 1.6em; }
.narrow-page { max-width: 820px; } .empty, .empty-state { text-align: center; color: var(--muted); padding: 2.5em 1em; } .empty-state h1 { justify-content: center; margin-bottom: .5em; }
.list-card { padding: 4px; } .result { display: flex; justify-content: space-between; gap: 12px; padding: .7em .8em; color: var(--text); border-radius: var(--radius); text-decoration: none !important; } .result:hover { background: var(--accent-soft); }

/* Formularios en rejilla */
.fgrid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 14px; }
.fgrid .field { grid-column: span 6; } .fgrid .w-wide { grid-column: span 8; } .fgrid .w-narrow { grid-column: span 3; } .fgrid .w-full { grid-column: span 12; }
.fgroup { grid-column: 1 / -1; font-size: .78em; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); border-bottom: 1px solid var(--border); padding: 12px 0 6px; margin-top: 4px; }
.field.t-bool { flex-direction: row; align-items: center; gap: .6em; }
.form-actions { display: flex; gap: 8px; margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--border); }
.modal .form-actions { position: sticky; bottom: -1px; background: var(--surface); padding-bottom: 10px; margin-bottom: -4px; }
[data-theme="calma"] .modal .form-actions { background: rgba(255, 255, 255, .9); }
.rec-form { min-width: 0; }
.rec-card { max-width: 1000px; }

/* Cuadros de mando */
.perfiles { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); align-items: start; } .perfil-form h2 { margin-bottom: .8em; font-size: 1.1em; }
.check { display: flex; align-items: center; gap: .6em; padding: .35em 0; cursor: pointer; }
.kpis { margin-bottom: var(--gap); } .kpi { display: flex; flex-direction: column; gap: 4px; } .kpi span { color: var(--muted); font-weight: 600; font-size: .85em; } .kpi strong { font-size: 1.7em; font-variant-numeric: tabular-nums; } .kpi small { color: var(--muted); }
.warn { color: var(--warn); } .neg { color: var(--danger); } .pos { color: var(--ok); }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: var(--gap); } .chart-card h3 { font-size: .95em; margin-bottom: 10px; } .chart { position: relative; height: 260px; }
table.plain { width: 100%; border-collapse: collapse; } table.plain th, table.plain td { padding: .6em .8em; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; } table.plain th { color: var(--muted); font-size: .8em; text-transform: uppercase; letter-spacing: .05em; }
table.plain .num, .num { text-align: right; font-variant-numeric: tabular-nums; } table.plain tr.sel td { background: var(--accent-soft); } .scroll-x { overflow-x: auto; } .table-card.scroll-x { padding: 0; }
.import-list { list-style: none; margin: 0; padding: 0; } .import-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: .6em 0; border-bottom: 1px solid var(--border); }

/* ============ Pestañas, modal ============ */
/* La barra de pestañas se queda fija bajo la cabecera al bajar por una ficha larga */
.tabs { display: flex; gap: 2px; overflow-x: auto; overflow-y: hidden; margin-bottom: 12px; border-bottom: 1px solid var(--border); scrollbar-width: thin;
  position: sticky; top: 56px; z-index: 25; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.tab { display: inline-flex; align-items: center; gap: .5em; padding: .55em .9em; border: 0; background: transparent; color: var(--muted); cursor: pointer; white-space: nowrap; border-radius: var(--radius) var(--radius) 0 0; border-bottom: 2px solid transparent; margin-bottom: -1px; max-width: 260px; min-height: 40px; }
.tab:hover { color: var(--text); background: var(--accent-soft); } .tab.on { color: var(--text); border-bottom-color: var(--accent); background: var(--surface); font-weight: 600; }
.tab-t { overflow: hidden; text-overflow: ellipsis; }
.tab.dirty .tab-t::after, .modal.dirty #modal-title::after { content: " ●"; color: var(--accent-2); } .tab-x { width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; flex: none; } .tab-x:hover { background: var(--danger); color: #fff; }
.pane { display: none; } .pane.on { display: block; animation: wipe-in .2s ease-out; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; } .seg button { border: 0; background: var(--surface-2); padding: .5em .8em; cursor: pointer; min-height: 38px; } .seg button.on { background: var(--accent); color: var(--accent-fg); }
.modal { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 0; background: var(--surface); color: var(--text); box-shadow: var(--shadow); width: min(720px, calc(100vw - 24px)); max-height: calc(100dvh - 32px); overflow: hidden; }
[data-theme="calma"] .modal { background: rgba(255, 255, 255, .88); backdrop-filter: blur(22px); }
.modal[open] { display: flex; flex-direction: column; animation: wipe-in .2s ease-out; } .modal.closing { animation: wipe-out .16s ease-in forwards; }
.modal::backdrop { background: rgba(8, 10, 16, .5); backdrop-filter: blur(3px); animation: fade-in .2s; }
.modal[data-size="l"] { width: min(1100px, calc(100vw - 24px)); } .modal[data-size="f"] { width: calc(100vw - 24px); height: calc(100dvh - 24px); max-height: none; }
.modal-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--border); } .modal-bar h2 { font-size: 1.05em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-tools { display: flex; gap: 2px; } .modal-body { padding: var(--pad); overflow: auto; flex: 1; }
/* Editor de texto enriquecido */
.editor { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); overflow: hidden; transition: border-color .15s, box-shadow .15s; }
.editor:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.editor-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: 4px; border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--surface-3) 55%, transparent); }
.editor-bar button { display: grid; place-items: center; width: 32px; height: 32px; border: 0; border-radius: calc(var(--radius) - 1px); background: transparent; color: var(--muted); cursor: pointer; }
.editor-bar button:hover { background: var(--accent-soft); color: var(--text); }
.editor-bar button.on { background: var(--accent); color: var(--accent-fg); }
.editor-bar .sep { width: 1px; height: 18px; margin: 0 4px; background: var(--border); }
.editor-area { min-height: 120px; max-height: 320px; overflow-y: auto; padding: .6em .75em; outline: 0; resize: vertical; line-height: 1.5; }
.editor-grande .editor-area { min-height: 320px; max-height: 70vh; }
.editor-area table, .editor-area table td { border-collapse: collapse; }
.editor-area table { width: 100%; margin: 0 0 .6em; }
.editor-area table td { border: 1px solid var(--border); padding: .35em .55em; vertical-align: top; }
.editor-area table.valoracion td.importe, .editor-area td.importe { text-align: right; white-space: nowrap; width: 1%; font-variant-numeric: tabular-nums; }
.editor-area table tr.total td { font-weight: 700; background: var(--accent-soft); }
.editor-area h3 { margin: .8em 0 .35em; font-size: 1.05em; } .editor-area h4 { margin: .7em 0 .3em; font-size: 1em; }
.editor-area p.nota { padding: .5em .7em; border-left: 3px solid var(--accent); background: var(--surface-3); }
.editor-area p { margin: 0 0 .5em; } .editor-area p:last-child { margin-bottom: 0; }
.editor-area ul, .editor-area ol { margin: 0 0 .5em; padding-left: 1.4em; }
.editor-area a { color: var(--accent); text-decoration: underline; }
.editor-area blockquote { margin: 0 0 .5em; padding-left: .8em; border-left: 3px solid var(--border); color: var(--muted); }
/* Desplegable con buscador */
.combo { position: relative; }
.combo-btn { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; min-height: 38px; padding: .5em .65em; text-align: left; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); font: inherit; }
.combo-btn:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.combo-btn[aria-expanded="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.combo-val { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combo-btn.is-empty .combo-val { color: var(--muted); }
.combo-btn .ico { width: 1em; height: 1em; color: var(--muted); transition: transform .15s; }
.combo-btn[aria-expanded="true"] .ico { transform: rotate(180deg); }
.combo-pop { inset: auto; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); color: var(--text);
  box-shadow: var(--shadow); overflow: hidden; flex-direction: column; min-width: 0; }
.combo-pop:popover-open { display: flex; animation: wipe-in .14s ease-out; }
[data-theme="calma"] .combo-pop { background: rgba(255, 255, 255, .94); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); }
.combo-search { padding: 8px; border-bottom: 1px solid var(--border); }
.combo-search input { min-height: 34px; border-radius: var(--radius); background: var(--surface-2); }
.combo-list { list-style: none; margin: 0; padding: 4px; overflow-y: auto; overscroll-behavior: contain; }
.combo-opt { padding: .5em .7em; border-radius: calc(var(--radius) - 1px); cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combo-opt.on { background: var(--accent-soft); }
.combo-opt.sel { color: var(--accent); font-weight: 600; }
.combo-opt mark { background: transparent; color: inherit; font-weight: 700; text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 2px; }
.combo-more, .combo-vacio { padding: .6em .7em; color: var(--muted); font-size: .88em; text-align: center; }
.combo-pop.hoja { left: 8px; right: 8px; bottom: 8px; top: auto; width: auto; max-height: 65dvh; }
.filters { margin-bottom: 12px; }
.valores-items { margin-top: 18px; }
.items-tabla input { width: 100%; min-width: 7ch; min-height: 34px; }
.items-tabla td:first-child input { width: 8ch; }
.items-tabla td { padding: .3em .4em; white-space: normal; }
.items-acc { white-space: nowrap; text-align: right; }
.items-acc .icon-btn[disabled] { opacity: .3; cursor: not-allowed; }
.valores-items .btn { margin-top: 10px; }
.filtros-pie { margin-top: 12px; display: flex; justify-content: flex-end; }
#btn-filters.activo { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
#btn-filters .count { font-size: .8em; background: var(--accent); color: #fff; }
.fgrid .combo-btn { min-height: 36px; }
.msel-opt { display: flex; align-items: center; gap: 8px; }
.msel-opt input { pointer-events: none; accent-color: var(--accent); }
.msel-todos { color: var(--muted); border-bottom: 1px solid var(--border); border-radius: 0; margin-bottom: 2px; }
.msel-todos.sel { color: var(--accent); }
.filtro-activo { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; padding: 10px 14px; background: var(--accent-soft); }
.filtro-acciones { display: flex; gap: 8px; flex-wrap: wrap; }
.form-actions .btn .count { font-size: .8em; margin-left: .2em; }
.tool.en-ficha #btn-filters, .tool.en-ficha .seg { display: none; }

/* ============ DataTables ============ */
.table-card { padding: 0; overflow: hidden; }
table.dataTable { width: 100% !important; border-collapse: collapse; }
.dt-container { padding: 10px 12px 12px; }
.dt-layout-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; margin: 4px 0; } .dt-layout-cell { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.dt-layout-cell.dt-layout-end { margin-left: auto; justify-content: flex-end; }
.dt-layout-table { display: block; margin: 8px 0; } .dt-layout-table .dt-layout-cell { display: block; overflow: auto; width: 100%; overscroll-behavior: contain; }
.dt-search { display: flex; align-items: center; gap: 6px; } .dt-search input { width: 190px; } .dt-length { display: flex; align-items: center; gap: 6px; } .dt-length select { width: auto; }
.dt-length label, .dt-search label { display: none; }
.dt-buttons { display: flex; flex-wrap: wrap; gap: 6px; } .dt-button { border: 1px solid var(--border); background: var(--surface-2); color: var(--text); padding: .4em .8em; border-radius: var(--radius); cursor: pointer; min-height: 34px; } .dt-button:hover { background: var(--surface-3); }
.dt-button-collection, div.dt-button-collection { position: absolute; z-index: 90; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 6px; display: flex; flex-direction: column; gap: 2px; min-width: 180px; }
.dt-button-collection .dt-button { border: 0; background: transparent; text-align: left; } .dt-button-collection .dt-button.dt-button-active { background: var(--accent-soft); font-weight: 600; } .dt-button-background { position: fixed; inset: 0; z-index: 80; }
table.dataTable thead th { position: sticky; top: 0; z-index: 2; box-shadow: inset 0 -1px 0 var(--border); text-align: left; padding: 0 12px; height: var(--row-h); font-size: .78em; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 650; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; cursor: pointer; user-select: none; }
table.dataTable thead th.dt-orderable-none { cursor: default; }
table.dataTable thead th .dt-column-header { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.dt-column-order { display: inline-flex; flex-direction: column; font-size: 8px; line-height: 7px; opacity: .45; } .dt-column-order::before { content: "▲"; } .dt-column-order::after { content: "▼"; }
th.dt-ordering-asc .dt-column-order, th.dt-ordering-desc .dt-column-order { opacity: 1; color: var(--accent); }
th.dt-ordering-asc .dt-column-order::after { opacity: .25; } th.dt-ordering-desc .dt-column-order::before { opacity: .25; }
/* Columnas numéricas: el icono de ordenar va detrás del título (no delante), para no confundirlo con el de la columna anterior */
table.dataTable thead th.dt-right .dt-column-header { justify-content: flex-end; }
table.dataTable tbody td { padding: 0 12px; height: var(--row-h); border-bottom: 1px solid var(--border); max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.dataTable tfoot td { position: sticky; bottom: 0; z-index: 2; height: var(--row-h); padding: 0 12px; font-weight: 650; white-space: nowrap; background: var(--surface-2); box-shadow: inset 0 1px 0 var(--border); font-variant-numeric: tabular-nums; }
table.dataTable tbody tr { cursor: pointer; transition: background .12s; } table.dataTable tbody tr:hover { background: var(--accent-soft); }
table.dataTable td.dt-right, table.dataTable th.dt-right { text-align: right; font-variant-numeric: tabular-nums; } td.col-id { color: var(--muted); width: 60px; } td.col-date { white-space: nowrap; font-variant-numeric: tabular-nums; }
td.col-tag { color: var(--text); } .dtr-hidden { display: none !important; }
.dt-empty { text-align: center; padding: 2em !important; color: var(--muted); }
.dt-info { color: var(--muted); font-size: .9em; }
.dt-paging nav { display: flex; gap: 3px; } .dt-paging-button { border: 1px solid transparent; background: transparent; padding: .35em .7em; border-radius: var(--radius); cursor: pointer; min-width: 34px; min-height: 34px; }
.dt-paging-button:hover:not(.disabled) { background: var(--accent-soft); } .dt-paging-button.current { background: var(--accent); color: var(--accent-fg); } .dt-paging-button.disabled { opacity: .35; cursor: default; } .dt-paging .ellipsis { padding: .4em; }
.dt-processing { display: none; }

/* ============ Avisos ============ */
.toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 200; align-items: center; }
.toast { background: var(--text); color: var(--bg); padding: .6em 1.1em; border-radius: 99px; box-shadow: var(--shadow); animation: toast-in .25s ease-out; } .toast.err { background: var(--danger); color: #fff; } .toast.out { opacity: 0; transition: opacity .4s; }

/* ============ Acceso ============ */
body.auth { display: grid; place-items: center; }
.auth-wrap { width: 100%; padding: 20px; display: grid; place-items: center; min-height: 100vh; }
.login-card { width: min(400px, 100%); background: var(--card-bg); border: var(--card-border); border-radius: var(--radius-lg); padding: 30px; box-shadow: var(--shadow); backdrop-filter: blur(var(--blur)); display: flex; flex-direction: column; gap: 14px; animation: wipe-in .25s ease-out; }

/* ============ Animaciones y transiciones de página ============ */
@view-transition { navigation: auto; }
::view-transition-group(wap-side), ::view-transition-group(wap-top) { animation-duration: 0s; }
::view-transition-old(wap-side), ::view-transition-new(wap-side), ::view-transition-old(wap-top), ::view-transition-new(wap-top) { animation: none; mix-blend-mode: normal; }
/* Cambio de herramienta: cortinilla rápida de izquierda a derecha sobre el contenido */
::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
/* La página anterior desaparece al instante: el nuevo contenido se va descubriendo sobre el fondo, sin superponerse a ella */
::view-transition-old(wap-content) { animation: none; opacity: 0; mix-blend-mode: normal; }
::view-transition-new(wap-content) { animation: wipe-in .22s ease-out both; mix-blend-mode: normal; }
/* Cambios dentro de la misma página (tema, filtros): fundido breve */
html.vt-local::view-transition-old(root), html.vt-local::view-transition-old(wap-content) { animation: vt-fade-out .14s both; }
html.vt-local::view-transition-new(root), html.vt-local::view-transition-new(wap-content) { animation: vt-fade-in .14s both; }
@keyframes vt-fade-out { to { opacity: 0; } } @keyframes vt-fade-in { from { opacity: 0; } }
@keyframes wipe-in { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes wipe-out { from { clip-path: inset(0 0 0 0); } to { clip-path: inset(0 0 0 100%); } }
@keyframes pop-in { from { opacity: 0; transform: translateY(-6px) scale(.98); } } @keyframes fade-in { from { opacity: 0; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }
@media (prefers-reduced-motion: reduce) { *, ::before, ::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } @view-transition { navigation: none; } }

/* ============ Móvil ============ */
.scrim { display: none; }
@media (max-width: 900px) {
  .shell, html.side-off .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 70; left: 0; width: 280px; transform: translateX(-102%); transition: transform .25s ease; box-shadow: var(--shadow); background: var(--surface); }
  [data-theme="studio"] .sidebar { background: var(--side-bg); } [data-theme="clasico"] .sidebar { background: var(--side-bg); }
  [data-theme="calma"] .sidebar { background: rgba(250, 251, 254, .96); }
  body.side-open .sidebar { transform: none; } body.side-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 65; animation: fade-in .2s; }
  html.side-off .brand-text, html.side-off .nav-item span, html.side-off .nav-title { display: revert; } html.side-off .nav-item { justify-content: flex-start; }
  :root, [data-theme] { --gap: 12px; }
  [data-theme="calma"] { --gap: 16px; }
  h1 { font-size: 1.3em; }
  .fgrid .field, .fgrid .w-wide, .fgrid .w-narrow { grid-column: span 12; }
  .fgrid .w-narrow { grid-column: span 6; }
  .modal, .modal[data-size] { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; margin: 0; }
  .dt-search input { width: 100%; } .dt-layout-row { flex-direction: column; align-items: stretch; } .dt-layout-cell { justify-content: space-between; }
  .head-actions .btn span { display: none; } .head-actions #btn-new span { display: inline; }
  .search { max-width: none; } .pop { position: fixed; right: 8px; left: 8px; top: 62px; width: auto; max-width: none; }
  .grid-2 { grid-template-columns: 1fr; }
}

/* Gráficas del listado */
.graficas-barra { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 10px; }
.graficas .seg button { white-space: nowrap; }
.grafico-caja { position: relative; height: 340px; margin: 6px 0 14px; }
.graficas table.plain tfoot td { font-weight: 700; border-top: 2px solid var(--border); border-bottom: 0; }
.graficas .check { margin: 0; }
@media (max-width: 900px) { .graficas-barra .seg { flex-wrap: wrap; } }

/* Agenda: vistas de calendario */
.cal[hidden], .table-card[hidden] { display: none; }
.cal { padding: 12px; }
.cal-barra { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.cal-barra select { width: auto; flex: none; min-height: 38px; } .cal-barra .btn { flex: none; min-width: 38px; }
.cal-mes { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); grid-template-rows: auto repeat(var(--filas), minmax(104px, auto)); border-top: 1px solid var(--border); border-left: 1px solid var(--border); }
.cal-dow { padding: 6px; text-align: center; font-weight: 600; color: var(--muted); background: var(--surface-2); border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.cal-dia { padding: 4px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cal-dia.fuera { background: var(--surface-2); } .cal-dia.fuera .cal-num { opacity: .5; }
.cal-num { font-size: .85em; color: var(--muted); align-self: flex-end; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; }
.cal-dia.hoy .cal-num { background: var(--accent); color: var(--accent-fg); font-weight: 700; }
.cal-extra { display: flex; flex-direction: column; gap: 2px; } .cal-extra[hidden] { display: none; }
.cal-ev { display: block; width: 100%; text-align: left; border: 0; border-left: 3px solid var(--c, var(--accent)); border-radius: 4px; padding: 2px 6px; cursor: pointer; font: inherit; font-size: .82em; color: var(--text);
  background: color-mix(in srgb, var(--c, var(--accent)) 16%, var(--surface)); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-ev:hover { background: color-mix(in srgb, var(--c, var(--accent)) 30%, var(--surface)); }
.cal-ev.largo { border-left-style: dashed; } .cal-ev.medio { opacity: .75; }
.cal-mas { border: 0; background: transparent; color: var(--accent); cursor: pointer; font-size: .8em; text-align: left; padding: 0 6px; }
.cal-anios { display: flex; flex-direction: column; gap: 22px; }
.cal-anio h3 { margin: 0 0 8px; }
.cal-meses { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.cal-mini-t { border: 0; background: transparent; font: inherit; font-weight: 600; cursor: pointer; color: var(--text); padding: 2px 0; } .cal-mini-t:hover { color: var(--accent); }
.cal-mini-g { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; font-size: .78em; }
.cal-mini-g .dow { color: var(--muted); }
.cal-d { border: 0; background: transparent; color: var(--text); border-radius: 4px; padding: 3px 0; cursor: pointer; font: inherit; font-size: 1em; }
.cal-d:hover { background: var(--accent-soft); }
.cal-d.hay { font-weight: 700; background: color-mix(in srgb, var(--accent) 22%, var(--surface)); }
.cal-d.n2 { background: color-mix(in srgb, var(--accent) 38%, var(--surface)); } .cal-d.n3 { background: color-mix(in srgb, var(--accent) 55%, var(--surface)); } .cal-d.n4 { background: var(--accent); color: var(--accent-fg); }
.cal-d.hoy { outline: 2px solid var(--accent-2, var(--accent)); outline-offset: -1px; }
@media (max-width: 700px) { .cal-mes { grid-template-rows: auto repeat(var(--filas), minmax(70px, auto)); } .cal-ev { font-size: .7em; padding: 1px 3px; } .cal-dow { padding: 4px 0; font-size: .8em; } }

/* Listados: columnas con ancho ajustable */
table.dataTable thead th { position: sticky; }
.col-res { position: absolute; top: 0; right: 0; bottom: 0; width: 9px; cursor: col-resize; touch-action: none; z-index: 3; }
.col-res::after { content: ""; position: absolute; top: 25%; bottom: 25%; right: 3px; width: 2px; border-radius: 1px; background: var(--border); transition: background .12s; }
.col-res:hover::after, .col-res.arrastrando::after { background: var(--accent); }
table.dataTable.fijo { table-layout: fixed; min-width: 100%; }

.rango-fechas { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; } .rango-fechas label { display: flex; flex-direction: column; gap: 2px; min-width: 0; } .rango-fechas small { color: var(--muted); } .rango-fechas input { min-width: 0; }

.dt-button.btn-ico { display: inline-flex; align-items: center; justify-content: center; padding: 0; width: 38px; min-height: 38px; }
.dt-button-collection [role=menu] { display: flex; flex-direction: column; gap: 2px; } .dt-button-collection .dt-button { width: 100%; }
.dt-button.btn-ico .dt-button-down-arrow { display: none; }

table.dataTable tfoot tr.relleno td { position: static; padding: 0; border: 0; box-shadow: none; background: transparent; height: 0; }

/* ficha de factura: líneas vacías ocultas y totales alineados a la derecha */
.fgrid .field.lin[hidden] { display: none; }
.btn-add-linea { grid-column: 1 / -1; justify-self: start; }
.fgrid .w-tot-tipo { grid-column: 7 / span 3; }
.fgrid .w-tot-imp { grid-column: 10 / span 3; }
.fgrid .w-tot-tipo input, .fgrid .w-tot-imp input { text-align: right; }
.fgrid .w-tot-tipo > span, .fgrid .w-tot-imp > span { text-align: right; display: block; }
.fgrid .tot-total { margin-top: 6px; padding-top: 10px; border-top: 2px solid var(--border); }
.fgrid .tot-total > span { font-weight: 700; color: var(--text, inherit); }
.fgrid .tot-total input { font-size: 1.5em; font-weight: 700; padding-top: 8px; padding-bottom: 8px; }
@media (max-width: 900px) { .fgrid .w-tot-tipo { grid-column: span 6; } .fgrid .w-tot-imp { grid-column: span 6; } }

/* importes con € al final y justificados a la derecha */
.eur-wrap { position: relative; display: block; }
.eur-wrap input { width: 100%; text-align: right; padding-right: 26px; -moz-appearance: textfield; appearance: textfield; }
.eur-wrap input::-webkit-outer-spin-button, .eur-wrap input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.eur-wrap::after { content: '€'; position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.fgrid .field.lin.t-money > span:first-child { text-align: right; display: block; }
.fgrid .tot-total .eur-wrap input { padding-right: 34px; }
.fgrid .tot-total .eur-wrap::after { font-size: 1.5em; font-weight: 700; color: inherit; }

/* agenda (mes): número del día enorme, a modo de marca de agua detrás de las anotaciones; lo que se sale de la caja se recorta */
.cal-dia { position: relative; overflow: hidden; }
.cal-dia > *:not(.cal-num) { position: relative; z-index: 1; }
.cal-dia .cal-num { position: absolute; right: -2px; bottom: -.16em; z-index: 0; width: auto; height: auto; display: block; border-radius: 0; align-self: auto;
  font-size: 5.6em; font-weight: 800; line-height: 1; letter-spacing: -.04em; color: var(--text); opacity: .1; pointer-events: none; user-select: none; }
.cal-dia.fuera .cal-num { opacity: .045; }
.cal-dia.hoy .cal-num { background: transparent; color: var(--accent); opacity: .3; }
@media (max-width: 700px) { .cal-dia .cal-num { font-size: 3.6em; } }
/* el tamaño del número sigue al ancho de la casilla (dos cifras caben incluso en casillas estrechas) */
.cal-dia { container-type: inline-size; }
.cal-dia .cal-num { font-size: clamp(2.6em, 64cqw, 7em); }
@media (max-width: 700px) { .cal-dia .cal-num { font-size: clamp(2.2em, 64cqw, 5em); } }

.cal-dia[data-fecha] { cursor: pointer; }
.cal-dia[data-fecha]:hover { background: color-mix(in srgb, var(--accent) 7%, transparent); }

/* agenda: sábados, domingos y fiestas nacionales en rojo suave */
.cal-dia.finde, .cal-dia.festivo { background: color-mix(in srgb, var(--danger) 8%, transparent); }
.cal-dia.festivo { background: color-mix(in srgb, var(--danger) 13%, transparent); }
.cal-dia.fuera.finde, .cal-dia.fuera.festivo { background: color-mix(in srgb, var(--danger) 5%, var(--surface-2)); }
.cal-dia.finde .cal-num, .cal-dia.festivo .cal-num { color: var(--danger); opacity: .22; }
.cal-dia.fuera.finde .cal-num, .cal-dia.fuera.festivo .cal-num { opacity: .1; }
.cal-dia.hoy.finde .cal-num, .cal-dia.hoy.festivo .cal-num { color: var(--accent); opacity: .3; }
.cal-fiesta { font-size: .7em; line-height: 1.2; color: color-mix(in srgb, var(--danger) 80%, var(--text)); font-weight: 600; padding: 0 2px; }
.cal-dow:nth-child(6), .cal-dow:nth-child(7) { color: color-mix(in srgb, var(--danger) 70%, var(--muted)); }
.cal-d.finde { color: color-mix(in srgb, var(--danger) 85%, var(--text)); background: color-mix(in srgb, var(--danger) 9%, transparent); }
.cal-d.festivo { color: var(--danger); font-weight: 700; background: color-mix(in srgb, var(--danger) 18%, transparent); }
.cal-d.finde.hay, .cal-d.festivo.hay { color: var(--text); }
.cal-d.n4.finde, .cal-d.n4.festivo { color: var(--accent-fg); }
.cal-d[data-fecha] { cursor: pointer; }

/* fecha con hora opcional */
.fh-wrap { display: flex; gap: 8px; align-items: center; }
.fh-wrap input[type=date] { flex: 1 1 auto; min-width: 0; } .fh-wrap input[type=time] { flex: 0 0 8.5em; }
.fh-wrap .btn-ico { flex: none; min-width: 38px; } .fh-wrap .btn-ico[hidden] { display: none; }

/* campos condicionales */
.fgrid .field[hidden] { display: none; }

/* imágenes adjuntas */
.imagenes { margin-top: 6px; }
.img-zona { display: flex; align-items: center; justify-content: center; gap: 10px; text-align: center; padding: 18px 14px; border: 2px dashed var(--border); border-radius: var(--radius); color: var(--muted); cursor: pointer; transition: background .15s, border-color .15s; }
.img-zona:hover, .img-zona:focus-visible, .img-zona.sobre { border-color: var(--accent); background: var(--accent-soft); color: var(--text); outline: none; }
.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; margin-top: 10px; }
.img-it { position: relative; margin: 0; aspect-ratio: 4 / 3; border-radius: calc(var(--radius) - 2px); overflow: hidden; background: var(--surface-2); border: 1px solid var(--border); }
.img-it a, .img-it img { display: block; width: 100%; height: 100%; } .img-it img { object-fit: cover; }
.img-it.pend { border-style: dashed; display: grid; place-items: center; }
.img-it.pend img { position: absolute; inset: 0; opacity: .45; }
.img-pend { position: relative; font-size: .78em; color: var(--text); background: color-mix(in srgb, var(--surface) 80%, transparent); padding: 2px 8px; border-radius: 99px; text-align: center; }
.img-x { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 50%; border: 0; cursor: pointer; line-height: 1; font-size: 16px; color: #fff; background: rgba(0, 0, 0, .55); opacity: 0; transition: opacity .15s; }
.img-it:hover .img-x, .img-x:focus-visible { opacity: 1; } .img-x:hover { background: var(--danger); }
@media (hover: none) { .img-x { opacity: 1; } }

/* tareas dentro de la ficha */
.tareas-emb { margin-top: 6px; }
.tareas-tabla input { width: 100%; min-width: 0; }
.tareas-tabla td.t-concepto { min-width: 220px; } .tareas-tabla input[type=date] { min-width: 9.5em; }
.tareas-tabla input.num { width: 5em; text-align: right; } .tareas-tabla th.num { text-align: right; }
.tareas-tabla tfoot td { border-top: 1px solid var(--border); padding-top: 8px; }

/* vista Bloques */
.bloques { padding: 14px; }
.blq-n { margin: 0 0 10px; }
.blq-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.blq { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; cursor: pointer; transition: transform .12s, box-shadow .12s, border-color .12s; }
.blq:hover, .blq:focus-visible { border-color: var(--accent); box-shadow: 0 4px 16px rgba(0, 0, 0, .18); transform: translateY(-2px); outline: none; }
.blq-img { aspect-ratio: 16 / 10; background: var(--surface-2); display: grid; place-items: center; overflow: hidden; }
.blq-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.blq-sin { color: var(--muted); font-size: .8em; opacity: .7; }
.blq-cuerpo { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.blq-cuerpo h3 { margin: 0; font-size: 1em; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.blq-cuerpo p { margin: 0; } .blq-cli { color: var(--muted); font-size: .88em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.blq-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; } .blq-tipo { font-size: .8em; color: var(--muted); }
.blq-meta { font-size: .78em; color: var(--muted); } .blq-imp { font-size: .85em; }
.blq-mas { display: flex; justify-content: center; margin-top: 16px; }

/* agenda: fin de contratos */
.cal-opt { display: inline-flex; align-items: center; gap: 6px; margin-left: 8px; cursor: pointer; font-size: .9em; color: var(--muted); }
.cal-ev.contrato { border-left-style: double; border-left-width: 4px; --c: var(--warn); background: color-mix(in srgb, var(--warn) 18%, var(--surface)); }
.cal-ev.contrato:hover { background: color-mix(in srgb, var(--warn) 32%, var(--surface)); }

/* sitios web */
.col-portada { width: 64px; } .mini-portada { display: block; width: 56px; height: 35px; object-fit: cover; border-radius: 4px; border: 1px solid var(--border); background: var(--surface-2); }
.blq.inactivo { opacity: .6; }
#btn-estado.trabajando .ico { animation: giro 1.2s linear infinite; } @keyframes giro { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { #btn-estado.trabajando .ico { animation: none; } }
.est-prog { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; } .est-prog progress { flex: 1 1 220px; height: 10px; accent-color: var(--accent); }
.est-tabla td { vertical-align: top; } .est-tabla .est-det { max-width: 28em; color: var(--muted); font-size: .9em; }
.historial { margin-top: 6px; } .hist-grafica svg { width: 100%; height: auto; display: block; }
.hg-rej { stroke: var(--border); stroke-width: 1; } .hg-txt { fill: var(--muted); font-size: 11px; }
.hg-linea { stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; } .hg-area { fill: color-mix(in srgb, var(--accent) 14%, transparent); stroke: none; } .hg-pt { fill: var(--accent); stroke: var(--surface); stroke-width: 1.5; }
.hist-tabla { margin-top: 10px; } .hist-tabla summary { cursor: pointer; color: var(--muted); margin-bottom: 6px; }

/* sitios web: botón de actualizar en cada caja */
.blq-img { position: relative; }
.blq-act { position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; display: grid; place-items: center; border: 0; border-radius: 50%; cursor: pointer; color: #fff; background: rgba(0, 0, 0, .55); opacity: 0; transition: opacity .15s, background .15s; }
.blq:hover .blq-act, .blq-act:focus-visible, .blq-act.girando { opacity: 1; } .blq-act:hover { background: var(--accent); }
.blq-act.girando .ico { animation: giro 1.2s linear infinite; } @media (hover: none) { .blq-act { opacity: 1; } }

/* listado: la portada se reescala al ancho de su columna (las capturas son 5:4) */
.col-portada { min-width: 64px; }
.mini-portada { width: 100%; height: auto; aspect-ratio: 5 / 4; object-fit: cover; }

/* sitios web: marco de 1280×1024 donde este navegador muestra unos segundos la home de cada sitio para capturarla */
.cap-marco { position: fixed; inset: 0; width: 100vw; height: 100vh; margin: 0; padding: 0; border: 0; overflow: hidden; background: #0b0b0b; color: #fff; }
.cap-barra { height: 28px; padding: 0 12px; font: 13px/28px system-ui, sans-serif; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cap-iframe { position: absolute; left: 0; border: 0; background: #fff; transform-origin: 0 0; pointer-events: none; }

/* logo de 7ymedia en lugar del cuadro «7y»: con la barra lateral plegada solo se ve el emblema */
.brand-logo { display: block; flex: none; height: 38px; color: inherit; } .brand-logo .logo-svg { display: block; height: 100%; width: auto; }
.brand.big .brand-logo { height: 64px; } .brand.big { gap: 1em; }
html.side-off .brand-logo { width: 34px; overflow: hidden; } html.side-off .brand-logo .logo-svg { height: 38px; margin-left: -2px; }
@media (max-width: 900px) { html.side-off .brand-logo { width: auto; overflow: visible; } html.side-off .brand-logo .logo-svg { margin-left: 0; } }
