/* Termogama – Portal de descargas. Todo va bajo .tgd-portal para no chocar con el tema. */
.tgd-portal {
	--tgd-accent: #005D90;
	--tgd-accent-2: #78B5E4;
	--tgd-accent-soft: color-mix(in srgb, var(--tgd-accent) 10%, #fff);
	--tgd-side: #0B2A40;
	--tgd-side-2: #143A55;
	--tgd-side-text: #eef4f9;
	--tgd-side-muted: #8DA9BF;
	--tgd-ink: #13212d;
	--tgd-muted: #5f6f7e;
	--tgd-line: #e3e8ee;
	--tgd-bg: #f4f7fa;
	--tgd-radius: 12px;
	--tgd-surface: #fff;
	--tgd-line-strong: #cfd8e1;
	--tgd-shadow: rgba(10,40,64,.08);
	display: grid;
	grid-template-columns: 290px 1fr;
	min-height: 78vh;
	font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-size: 15px;
	line-height: 1.45;
	color: var(--tgd-ink);
	background: var(--tgd-surface);
	border: 1px solid var(--tgd-line);
	border-radius: var(--tgd-radius);
	overflow: hidden;
	position: relative;
	text-align: left;
}
.tgd-portal *, .tgd-portal *::before, .tgd-portal *::after { box-sizing: border-box; }
.tgd-portal button { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: pointer; box-shadow: none; text-transform: none; letter-spacing: normal; }
.tgd-portal a { color: inherit; text-decoration: none; box-shadow: none; }
.tgd-portal svg { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tgd-portal ul { list-style: none; margin: 0; padding: 0; }
.tgd-portal h1, .tgd-portal h2 { margin: 0; padding: 0; border: 0; }
.tgd-boot { padding: 48px; color: var(--tgd-muted); grid-column: 1 / -1; }

/* ---------- Barra lateral ---------- */
.tgd-side {
	background: var(--tgd-side);
	color: var(--tgd-side-text);
	padding: 26px 16px 32px;
	overflow-y: auto;
	max-height: 100vh;
	position: sticky;
	top: 0;
}
.tgd-brand { display: flex; flex-direction: column; gap: 10px; padding: 0 4px 26px; }
.tgd-brand-logo { background: #fff; border-radius: 10px; padding: 12px 14px; display: block; }
.tgd-brand-logo img { display: block; width: 100%; max-height: 56px; object-fit: contain; }
.tgd-brand-sub { padding-left: 6px; }
.tgd-brand-name { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 22px; letter-spacing: .02em; color: #fff; }
.tgd-brand-name .tgd-ring { width: 30px; height: 30px; border-radius: 50%; border: 3px solid var(--tgd-accent); border-right-color: transparent; transform: rotate(-30deg); }
.tgd-brand-sub { color: var(--tgd-side-muted); font-size: 14px; }

.tgd-nav-item {
	display: flex; align-items: center; gap: 12px;
	width: 100%; padding: 10px 10px; border-radius: 8px;
	font-weight: 600; color: var(--tgd-side-text);
}
.tgd-nav-item:hover { background: var(--tgd-side-2); }
.tgd-nav-item.is-active { background: var(--tgd-side-2); color: #fff; box-shadow: inset 3px 0 0 var(--tgd-accent-2); }
.tgd-nav-item .tgd-badge { margin-left: auto; font-size: 12px; font-weight: 600; color: var(--tgd-side-muted); }
.tgd-side-label { margin: 24px 10px 8px; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--tgd-side-muted); }

.tgd-tree .tgd-node-row { display: flex; align-items: center; border-radius: 8px; }
.tgd-tree .tgd-node-row:hover { background: var(--tgd-side-2); }
.tgd-tree .tgd-node-row.is-active { background: var(--tgd-side-2); box-shadow: inset 3px 0 0 var(--tgd-accent-2); }
.tgd-tree .tgd-node-row.is-active .tgd-node-link svg { color: var(--tgd-accent-2); }
.tgd-tree .tgd-node-row.is-active .tgd-node-link { color: #fff; }
.tgd-chev { width: 26px; height: 32px; display: grid; place-items: center; color: var(--tgd-side-muted); }
.tgd-chev svg { width: 15px; height: 15px; transition: transform .15s; }
.tgd-chev.is-open svg { transform: rotate(90deg); }
.tgd-chev.is-leaf { visibility: hidden; }
.tgd-node-link { flex: 1; min-width: 0; display: flex; align-items: center; gap: 9px; padding: 6px 8px 6px 0; color: #cfd4da; font-size: 14.5px; }
.tgd-node-link svg { width: 18px; height: 18px; color: var(--tgd-side-muted); }
.tgd-node-link span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tgd-node-count { margin-left: auto; padding-right: 10px; font-size: 12px; color: var(--tgd-side-muted); }
.tgd-tree ul ul { padding-left: 16px; }

/* ---------- Zona principal ---------- */
.tgd-main { min-width: 0; display: flex; flex-direction: column; background: var(--tgd-surface); }
.tgd-top { padding: 22px 32px 18px; border-bottom: 1px solid var(--tgd-line); display: flex; flex-direction: column; gap: 14px; }
.tgd-top-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.tgd-chip { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border: 1px solid var(--tgd-line); border-radius: 999px; font-weight: 600; font-size: 14px; background: var(--tgd-surface); }
.tgd-chip svg { color: var(--tgd-accent); width: 18px; height: 18px; }
.tgd-search { margin-left: auto; position: relative; flex: 0 1 320px; }
.tgd-search input {
	width: 100%; height: 40px; padding: 0 14px 0 38px; margin: 0;
	border: 1px solid var(--tgd-line); border-radius: 999px; background: var(--tgd-bg);
	font: inherit; font-size: 14px; color: var(--tgd-ink); outline: none; box-shadow: none;
}
.tgd-search input:focus { border-color: var(--tgd-accent); background: var(--tgd-surface); }
.tgd-search svg { position: absolute; left: 12px; top: 10px; width: 18px; height: 18px; color: var(--tgd-muted); }
.tgd-menu-btn { display: none; width: 40px; height: 40px; border-radius: 8px; border: 1px solid var(--tgd-line) !important; place-items: center; }

.tgd-crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: 17px; }
.tgd-crumbs a { color: var(--tgd-muted); }
.tgd-crumbs a:hover { color: var(--tgd-accent); }
.tgd-crumbs .is-current { font-weight: 600; color: var(--tgd-ink); }
.tgd-crumbs a:not(:first-child) { font-weight: 600; color: var(--tgd-ink); }
.tgd-crumbs svg { width: 16px; height: 16px; color: var(--tgd-muted); }

.tgd-body { padding: 28px 32px 48px; flex: 1; }
.tgd-head { display: flex; align-items: center; gap: 20px; margin-bottom: 28px; }
.tgd-head-icon { width: 76px; height: 76px; border-radius: 14px; background: var(--tgd-accent-soft); color: var(--tgd-accent); display: grid; place-items: center; flex: none; }
.tgd-head-icon svg { width: 32px; height: 32px; }
.tgd-head h1 { font-size: 30px; font-weight: 800; line-height: 1.15; letter-spacing: -.01em; color: var(--tgd-ink); }
.tgd-head p { margin: 4px 0 0; color: var(--tgd-muted); font-size: 17px; }
.tgd-head-actions { margin-left: auto; }

.tgd-section-title { font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--tgd-muted); margin: 8px 0 12px; }
.tgd-grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); margin-bottom: 30px; }

/* Tarjetas de carpeta */
.tgd-folder {
	display: flex; align-items: center; gap: 14px; padding: 16px;
	border: 1px solid var(--tgd-line); border-radius: var(--tgd-radius); background: var(--tgd-surface);
	transition: border-color .15s, box-shadow .15s, transform .15s;
}
.tgd-folder:hover { border-color: var(--tgd-accent); box-shadow: 0 6px 20px var(--tgd-shadow); transform: translateY(-1px); }
.tgd-folder-icon { width: 46px; height: 46px; border-radius: 10px; background: var(--tgd-accent-soft); color: var(--tgd-accent); display: grid; place-items: center; flex: none; }
.tgd-folder-name { font-weight: 700; font-size: 15px; line-height: 1.25; word-break: break-word; }
.tgd-folder-meta { color: var(--tgd-muted); font-size: 13px; margin-top: 2px; }

/* Tarjetas de archivo */
.tgd-file {
	display: flex; flex-direction: column; border: 1px solid var(--tgd-line); border-radius: var(--tgd-radius);
	overflow: hidden; background: var(--tgd-surface); transition: box-shadow .15s, border-color .15s;
}
.tgd-file:hover { box-shadow: 0 8px 24px var(--tgd-shadow); border-color: var(--tgd-line-strong); }
.tgd-thumb { aspect-ratio: 4 / 3; background: var(--tgd-bg); border-bottom: 1px solid var(--tgd-line); position: relative; overflow: hidden; display: block; }
.tgd-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }
.tgd-ph { position: absolute; inset: 0; display: grid; place-items: center; }
.tgd-ph-doc { width: 74px; height: 94px; border-radius: 6px; background: var(--tgd-surface); border: 1px solid var(--tgd-line); box-shadow: 0 4px 12px rgba(0,0,0,.06); position: relative; display: grid; place-items: end center; padding-bottom: 12px; }
.tgd-ph-doc::before { content: ""; position: absolute; left: 12px; right: 12px; top: 16px; height: 34px; background: repeating-linear-gradient(#eceef1 0 4px, transparent 4px 9px); }
.tgd-ph-ext { font-weight: 800; font-size: 12px; color: #fff; padding: 2px 7px; border-radius: 4px; background: var(--tgd-ext, #8f98a3); letter-spacing: .03em; }
.tgd-file-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.tgd-file-name { font-weight: 600; font-size: 14px; line-height: 1.3; word-break: break-word; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tgd-file-meta { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--tgd-muted); }
.tgd-ext { font-weight: 700; font-size: 11px; padding: 1px 6px; border-radius: 4px; color: #fff; background: var(--tgd-ext, #8f98a3); }
.tgd-file-actions { display: flex; align-items: center; gap: 8px; margin-top: auto; }
.tgd-btn {
	display: inline-flex; align-items: center; justify-content: center; gap: 7px;
	height: 36px; padding: 0 14px; border-radius: 8px; font-weight: 600; font-size: 14px;
	background: var(--tgd-accent); color: #fff !important; flex: 1;
}
.tgd-btn:hover { filter: brightness(1.12); }
.tgd-btn svg { width: 17px; height: 17px; }
.tgd-btn-ghost { background: var(--tgd-surface); color: var(--tgd-ink) !important; border: 1px solid var(--tgd-line) !important; flex: none; }
.tgd-icon-btn { width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--tgd-line) !important; display: grid; place-items: center; color: var(--tgd-muted); flex: none; }
.tgd-icon-btn:hover { color: var(--tgd-accent); border-color: var(--tgd-accent) !important; }
.tgd-icon-btn.is-on { color: var(--tgd-accent); }
.tgd-icon-btn.is-on svg { fill: var(--tgd-accent); }
.tgd-file-path { font-size: 12px; color: var(--tgd-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.tgd-empty { padding: 48px 20px; text-align: center; color: var(--tgd-muted); border: 1px dashed var(--tgd-line); border-radius: var(--tgd-radius); }
.tgd-error { padding: 16px 18px; border-radius: 10px; background: #fdecea; color: #8a1c12; }
.tgd-skel { height: 220px; border-radius: var(--tgd-radius); background: linear-gradient(90deg, #f1f2f4 25%, #f8f9fa 50%, #f1f2f4 75%); background-size: 200% 100%; animation: tgd-sh 1.2s infinite; }
@keyframes tgd-sh { to { background-position: -200% 0; } }

/* ---------- Usuario (arriba a la derecha) ---------- */
.tgd-user { display: flex; align-items: center; gap: 8px; }
.tgd-user-id { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; max-width: 190px; margin-right: 4px; }
.tgd-user-id strong { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.tgd-user-id span { font-size: 12px; color: var(--tgd-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; text-transform: uppercase; }
.tgd-search { margin-left: auto; }

/* ---------- Portada: bienvenida + tarjetas de sección ---------- */
.tgd-welcome { margin-bottom: 26px; }
.tgd-welcome h1 { font-size: 30px; font-weight: 800; letter-spacing: -.01em; color: var(--tgd-ink); }
.tgd-welcome p { margin: 6px 0 0; color: var(--tgd-muted); font-size: 16px; }
.tgd-sections { display: grid; gap: 22px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.tgd-section {
	display: flex; flex-direction: column; border: 1px solid var(--tgd-line); border-radius: 14px; overflow: hidden;
	background: var(--tgd-surface); transition: transform .18s, box-shadow .18s, border-color .18s;
}
.tgd-section:hover { transform: translateY(-3px); box-shadow: 0 14px 34px var(--tgd-shadow); border-color: var(--tgd-line-strong); }
.tgd-cover { aspect-ratio: 16 / 9; overflow: hidden; position: relative; background: var(--tgd-bg); }
.tgd-cover img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .4s; }
.tgd-section:hover .tgd-cover img { transform: scale(1.04); }
.tgd-cover.is-fallback {
	background:
		radial-gradient(120% 90% at 85% 10%, color-mix(in srgb, var(--tgd-accent-2) 55%, transparent) 0, transparent 60%),
		linear-gradient(135deg, var(--tgd-accent) 0%, #0B2A40 100%);
	display: grid; place-items: center;
}
.tgd-cover-icon { width: 86px; height: 86px; border-radius: 22px; background: rgba(255,255,255,.14); color: #fff; display: grid; place-items: center; backdrop-filter: blur(2px); position: relative; z-index: 1; }
.tgd-cover-icon svg { width: 44px; height: 44px; stroke-width: 1.5; }
.tgd-section-body { padding: 18px 20px 20px; }
.tgd-section-body h2 { font-size: 18px; font-weight: 800; color: var(--tgd-ink); }
.tgd-section-body p { margin: 6px 0 0; font-size: 14px; color: var(--tgd-muted); }
.tgd-section-stats { margin-top: 12px; font-size: 13px; font-weight: 600; color: var(--tgd-accent); }

/* ---------- Modo oscuro ---------- */
.tgd-portal.tgd-dark {
	--tgd-surface: #121c26;
	--tgd-bg: #0d151d;
	--tgd-ink: #e8eef4;
	--tgd-muted: #93a4b4;
	--tgd-line: #223241;
	--tgd-line-strong: #2f4558;
	--tgd-shadow: rgba(0,0,0,.35);
	--tgd-accent-soft: color-mix(in srgb, var(--tgd-accent-2) 16%, #121c26);
	--tgd-side: #08131c;
	--tgd-side-2: #13212d;
}
.tgd-portal.tgd-dark .tgd-head-icon, .tgd-portal.tgd-dark .tgd-folder-icon, .tgd-portal.tgd-dark .tgd-section-stats { color: var(--tgd-accent-2); }
.tgd-portal.tgd-dark .tgd-ph-doc { background: #1a2734; }
.tgd-portal.tgd-dark .tgd-ph-doc::before { background: repeating-linear-gradient(#2a3a4a 0 4px, transparent 4px 9px); }
.tgd-portal.tgd-dark .tgd-btn { background: #1673ad; }

/* ---------- Pantalla de acceso ---------- */
.tgd-gate {
	display: grid; grid-template-columns: 1fr 1.1fr; min-height: 640px; border-radius: 16px; overflow: hidden;
	border: 1px solid #e3e8ee; background: #fff; color: #13212d; text-align: left;
	font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; font-size: 15px; line-height: 1.45;
}
.tgd-gate *, .tgd-gate *::before, .tgd-gate *::after { box-sizing: border-box; }
.tgd-gate-brand {
	padding: 44px 40px; color: #eaf2f8; position: relative; overflow: hidden;
	background: radial-gradient(90% 70% at 100% 0%, rgba(120,181,228,.35) 0, transparent 60%), linear-gradient(160deg, var(--tgd-accent, #005D90) 0%, #0B2A40 85%);
}
.tgd-gate-logo { background: #fff; border-radius: 12px; padding: 14px 18px; display: inline-block; max-width: 280px; }
.tgd-gate-logo img { display: block; width: 100%; height: auto; max-height: 64px; object-fit: contain; }
.tgd-gate-brand h2 { color: #fff; font-size: 30px; font-weight: 800; margin: 36px 0 10px; padding: 0; border: 0; line-height: 1.15; }
.tgd-gate-brand p { color: #cfe0ee; margin: 0 0 24px; font-size: 16px; }
.tgd-gate-brand ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.tgd-gate-brand li { padding-left: 30px; position: relative; color: #eaf2f8; margin: 0; }
.tgd-gate-brand li::before { content: ""; position: absolute; left: 0; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #78B5E4 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230B2A40' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 12 4 4 8-8'/%3E%3C/svg%3E") center / 12px no-repeat; }
.tgd-gate-card { padding: 40px 44px; display: flex; flex-direction: column; justify-content: center; }
.tgd-gate-card h3 { font-size: 22px; margin: 0 0 10px; }
.tgd-gate-tabs { display: flex; gap: 6px; padding: 5px; background: #f1f5f9; border-radius: 12px; margin-bottom: 22px; }
.tgd-gate-tabs label { flex: 1; text-align: center; padding: 10px; border-radius: 9px; font-weight: 700; cursor: pointer; color: #5f6f7e; margin: 0; }
#tgd-tab-login:checked ~ .tgd-gate-tabs label[for="tgd-tab-login"],
#tgd-tab-register:checked ~ .tgd-gate-tabs label[for="tgd-tab-register"] { background: #fff; color: var(--tgd-accent, #005D90); box-shadow: 0 1px 4px rgba(10,40,64,.12); }
.tgd-gate-form { display: none; flex-direction: column; gap: 14px; }
#tgd-tab-login:checked ~ .tgd-form-login, #tgd-tab-register:checked ~ .tgd-form-register { display: flex; }
.tgd-gate-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; font-weight: 600; color: #34495a; margin: 0; }
.tgd-gate-form small { font-weight: 400; color: #5f6f7e; }
.tgd-gate-form input[type=email], .tgd-gate-form input[type=password], .tgd-gate-form input[type=text], .tgd-gate-form input[type=tel], .tgd-gate-form input:not([type]) {
	height: 44px; padding: 0 14px; border: 1px solid #d5dee7; border-radius: 10px; font: inherit; font-weight: 400; color: #13212d; background: #fff; width: 100%; margin: 0; box-shadow: none;
}
.tgd-gate-form input:focus { outline: none; border-color: var(--tgd-accent, #005D90); box-shadow: 0 0 0 3px rgba(0,93,144,.15); }
.tgd-gate-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.tgd-span2 { grid-column: 1 / -1; }
.tgd-gate-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13.5px; }
.tgd-gate .tgd-check { flex-direction: row !important; align-items: center; gap: 8px !important; font-weight: 500 !important; }
.tgd-gate a { color: var(--tgd-accent, #005D90); }
.tgd-gate-btn { display: inline-flex; justify-content: center; align-items: center; height: 46px; border-radius: 10px; border: 0; background: var(--tgd-accent, #005D90); color: #fff !important; font: inherit; font-weight: 700; cursor: pointer; text-decoration: none; margin-top: 4px; }
.tgd-gate-btn:hover { filter: brightness(1.12); }
.tgd-gate-note { font-size: 13px; color: #5f6f7e; margin: 0; }
.tgd-gate-msg { padding: 12px 14px; border-radius: 10px; margin-bottom: 16px; font-size: 14px; }
.tgd-gate-msg.is-ok { background: #e6f4ea; color: #1d5b2c; }
.tgd-gate-msg.is-error { background: #fdecea; color: #8a1c12; }
.tgd-hp { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; overflow: hidden; }
@media (max-width: 860px) {
	.tgd-gate { grid-template-columns: 1fr; }
	.tgd-gate-brand { padding: 28px 24px; }
	.tgd-gate-brand h2 { margin-top: 22px; font-size: 24px; }
	.tgd-gate-card { padding: 28px 22px; }
	.tgd-gate-grid { grid-template-columns: 1fr; }
}

/* ---------- Móvil ---------- */
.tgd-scrim { display: none; }
@media (max-width: 900px) {
	.tgd-portal { grid-template-columns: 1fr; }
	.tgd-side { position: absolute; z-index: 30; inset: 0 auto 0 0; width: 290px; max-height: none; transform: translateX(-100%); transition: transform .2s; }
	.tgd-portal.is-menu .tgd-side { transform: none; }
	.tgd-portal.is-menu .tgd-scrim { display: block; position: absolute; inset: 0; background: rgba(0,0,0,.35); z-index: 20; }
	.tgd-menu-btn { display: grid; }
	.tgd-top, .tgd-body { padding-left: 18px; padding-right: 18px; }
	.tgd-search { flex: 1 1 100%; order: 3; margin-left: 0; }
	.tgd-user { margin-left: auto; }
	.tgd-user-id { display: none; }
	.tgd-welcome h1 { font-size: 24px; }
	.tgd-sections { grid-template-columns: 1fr; }
	.tgd-head h1 { font-size: 24px; }
	.tgd-head-icon { width: 58px; height: 58px; }
	.tgd-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
}
