:root {
    color-scheme: light dark;
    --ink: #102a35;
    --muted: #506872;
    --paper: #f5f8f7;
    --surface: #ffffff;
    --line: #cbd8d8;
    --deep: #124559;
    --accent: #e77728;
    --mint: #c8eee0;
    --focus: #0768a9;
    --shadow: 0 18px 50px rgba(18, 69, 89, .11);
}

* { box-sizing: border-box; }
html { min-width: 320px; scroll-behavior: smooth; }
body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font: 400 1rem/1.6 system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: inherit; }
.shell { width: min(1120px, calc(100% - 32px)); margin-inline: auto; }
.skip-link { position: fixed; inset: 8px auto auto 8px; z-index: 10; padding: 10px 14px; background: var(--ink); color: white; transform: translateY(-150%); }
.skip-link:focus { transform: translateY(0); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; }

.masthead { border-bottom: 1px solid var(--line); }
.masthead__inner { min-height: 80px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { min-height: 48px; display: inline-flex; align-items: center; gap: 12px; text-decoration: none; font-weight: 750; letter-spacing: -.02em; }
.brand svg { width: 32px; fill: var(--deep); }
.status { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: .875rem; }
.status i { width: 9px; height: 9px; border-radius: 50%; background: #198754; box-shadow: 0 0 0 4px rgba(25, 135, 84, .14); }

.intro { position: relative; padding: clamp(64px, 10vw, 124px) 0 clamp(48px, 7vw, 88px); border-bottom: 1px solid var(--line); }
.intro::after { content: "//"; position: absolute; right: 0; top: clamp(56px, 9vw, 112px); color: var(--mint); font: 800 clamp(5rem, 14vw, 11rem)/1 Georgia, serif; letter-spacing: -.16em; z-index: -1; }
.eyebrow { margin: 0 0 18px; color: var(--deep); font: 700 .75rem/1.2 ui-monospace, "Cascadia Code", monospace; letter-spacing: .16em; text-transform: uppercase; }
h1 { max-width: 780px; margin: 0; font: 750 clamp(3rem, 8vw, 6.8rem)/.91 system-ui, sans-serif; letter-spacing: -.07em; }
h1 em { color: var(--deep); font-family: Georgia, "Times New Roman", serif; font-weight: 400; }
.lede { max-width: 620px; margin: 34px 0 0; color: var(--muted); font-size: clamp(1rem, 2vw, 1.18rem); }
.count { margin: 28px 0 0; font-size: .9rem; color: var(--muted); }
.count strong { display: inline-grid; place-items: center; min-width: 36px; height: 36px; margin-right: 8px; border-radius: 50%; background: var(--deep); color: white; }

.portal-catalog { --pap-columns: repeat(2, minmax(0, 1fr)); --pap-surface: var(--surface); --pap-border: var(--line); --pap-accent: var(--deep); --pap-muted: var(--muted); --pap-icon-background: var(--mint); --pap-radius: 18px; padding: 40px 0 72px; }
.portal-catalog .pap-module__card { min-height: 174px; padding: 28px; align-items: start; }
.portal-catalog .pap-module__icon { width: 56px; height: 56px; border-radius: 15px; font-family: Georgia, serif; font-size: 1.45rem; }
.portal-catalog .pap-module__host { margin-top: 22px; font-family: ui-monospace, monospace; font-weight: 600; }
.portal-catalog .pap-module__arrow { align-self: end; }
.portal-catalog .pap-module__empty { padding: 32px; background: var(--surface); }
.app-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; padding: 40px 0 72px; }
.app-card { position: relative; min-height: 190px; display: grid; grid-template-columns: auto 1fr auto; align-items: start; gap: 20px; padding: 28px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); text-decoration: none; transition: border-color .2s ease, box-shadow .2s ease, background .2s ease; }
.app-card:hover { border-color: var(--deep); box-shadow: var(--shadow); }
.app-card__number { position: absolute; top: 18px; right: 20px; color: var(--muted); font: 600 .7rem/1 ui-monospace, monospace; }
.app-card__icon { width: 56px; height: 56px; display: grid; place-items: center; border-radius: 15px; overflow: hidden; background: var(--mint); color: var(--deep); font: 700 1.45rem/1 Georgia, serif; }
.app-card__icon img { width: 100%; height: 100%; object-fit: cover; }
.app-card__content { display: flex; min-width: 0; flex-direction: column; padding-top: 2px; }
.app-card__content strong { padding-right: 26px; font-size: 1.18rem; letter-spacing: -.02em; }
.app-card__content > span { margin-top: 7px; color: var(--muted); }
.app-card__content small { margin-top: 22px; color: var(--deep); font: 600 .75rem/1.4 ui-monospace, monospace; overflow-wrap: anywhere; }
.app-card__arrow { align-self: end; width: 24px; fill: none; stroke: var(--deep); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; transition: transform .2s ease; }
.app-card:hover .app-card__arrow { transform: translateX(4px); }
.empty { display: flex; gap: 24px; align-items: center; margin: 40px 0 72px; padding: 32px; border: 1px dashed var(--line); border-radius: 18px; background: var(--surface); }
.empty svg { flex: 0 0 48px; fill: none; stroke: var(--deep); stroke-width: 1.5; }
.empty h2 { margin: 0; font-size: 1.2rem; }
.empty p { margin: 4px 0 0; color: var(--muted); }
footer { padding-block: 24px 44px; border-top: 1px solid var(--line); color: var(--muted); font: 600 .72rem/1.4 ui-monospace, monospace; text-transform: uppercase; letter-spacing: .08em; }
.admin-link { min-height: 44px; display: inline-flex; align-items: center; color: var(--deep); font-weight: 700; }
.admin-actions { display: flex; align-items: center; gap: 16px; }
.admin-actions form { margin: 0; }
.admin-main { padding-block: clamp(48px, 8vw, 88px); }
.admin-heading { display: flex; justify-content: space-between; align-items: end; gap: 32px; padding-bottom: 32px; border-bottom: 1px solid var(--line); }
.admin-heading h1 { font-size: clamp(2.6rem, 7vw, 5rem); }
.admin-heading p:not(.eyebrow) { max-width: 680px; margin: 20px 0 0; color: var(--muted); }
.button { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; padding: 10px 18px; border: 1px solid var(--deep); border-radius: 9px; background: var(--deep); color: var(--paper); font: inherit; font-weight: 750; text-decoration: none; cursor: pointer; }
.button:hover { filter: brightness(1.08); }
.button--secondary { flex: 0 0 auto; background: transparent; color: var(--deep); }
.button--quiet { min-height: 40px; padding: 7px 12px; background: transparent; color: var(--deep); }
.login-shell { min-height: 100vh; display: grid; place-items: center; width: min(100% - 32px, 480px); margin-inline: auto; padding-block: 48px; }
.login-card { width: 100%; padding: clamp(28px, 7vw, 48px); border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: var(--shadow); }
.login-card h1 { font-size: clamp(2.8rem, 12vw, 5rem); }
.login-card > p:not(.eyebrow, .form-error) { margin: 20px 0 0; color: var(--muted); }
.login-form { display: grid; gap: 10px; margin-top: 30px; }
.login-form label { margin-top: 8px; font-size: .85rem; font-weight: 750; }
.login-form input[type="text"],
.login-form input[type="password"] { width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); color: var(--ink); font: inherit; }
.login-form .button { margin-top: 14px; }
.password-field { position: relative; display: block; }
.password-field input[type="password"],
.password-field input[type="text"] { padding-right: 48px; }
.password-toggle { position: absolute; top: 50%; right: 3px; width: 40px; height: 40px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 7px; background: transparent; color: var(--muted); cursor: pointer; transform: translateY(-50%); }
.password-toggle:hover { color: var(--deep); background: color-mix(in srgb, var(--deep) 9%, transparent); }
.password-toggle svg { width: 21px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.form-error { margin: 22px 0 0; padding: 12px 14px; border-left: 4px solid #b42318; background: color-mix(in srgb, #b42318 9%, var(--surface)); color: var(--ink); }
.notice { margin: 24px 0 0; padding: 14px 18px; border-left: 4px solid #198754; background: var(--surface); }
.registry-list { display: grid; gap: 12px; padding-top: 28px; }
.registry-row { display: flex; justify-content: space-between; align-items: center; gap: 24px; padding: 22px 24px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.registry-row h2 { margin: 7px 0 0; font-size: 1.15rem; }
.registry-row p { margin: 2px 0 0; color: var(--muted); font: .78rem/1.5 ui-monospace, monospace; overflow-wrap: anywhere; }
.registry-row form { flex: 0 0 auto; }
.registry-row input[type="hidden"] { display: none; }
.visibility { display: inline-block; padding: 3px 8px; border-radius: 99px; font-size: .7rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.visibility--on { background: #d9f5e4; color: #155b32; }
.visibility--off { background: #e2e7e9; color: #46585f; }

@media (max-width: 720px) {
    .shell { width: min(100% - 24px, 1120px); }
    .masthead__inner { min-height: 68px; }
    .status { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    .intro::after { top: 70px; right: 8px; }
    .app-grid, .portal-catalog { --pap-columns: 1fr; grid-template-columns: 1fr; }
    .app-card { min-height: 174px; padding: 22px; gap: 16px; }
    .empty { align-items: flex-start; padding: 24px; }
    .admin-heading, .registry-row { align-items: stretch; flex-direction: column; }
    .registry-row form, .registry-row .button { width: 100%; }
}

@media (prefers-color-scheme: dark) {
    :root { --ink: #e7f1ef; --muted: #a8bfbd; --paper: #09191f; --surface: #102831; --line: #31505a; --deep: #75d2c0; --accent: #f19a5b; --mint: #194a4a; --focus: #78c9ff; --shadow: 0 18px 50px rgba(0, 0, 0, .28); }
    .count strong { color: #082129; }
    .visibility--on { background: #174f32; color: #b9f1cf; }
    .visibility--off { background: #34474e; color: #dce6e8; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { transition-duration: .01ms !important; }
}

/* Panel de botones y edición de fichas */
:root { --paper: #edf1f7; --surface: #ffffff; --ink: #132033; --muted: #5d6a7e; --line: #bdc8d8; --deep: #2b59ff; --focus: #ffbf19; }
body { line-height: 1.5; }
.shell { width: min(1380px, calc(100% - 40px)); }
.masthead { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--paper) 95%, transparent); backdrop-filter: blur(12px); }
.masthead__inner { min-height: 68px; }
.brand svg { width: 30px; fill: var(--deep); }
.intro { padding: clamp(46px, 7vw, 88px) 0 28px; border: 0; }
.intro::after { display: none; }
h1 { max-width: none; font-size: clamp(3.1rem, 7vw, 5.8rem); line-height: .92; letter-spacing: -.065em; }
.lede { max-width: 620px; margin-top: 24px; font-size: 1.1rem; }
.count { margin-top: 22px; }
.count strong { border-radius: 8px; background: var(--ink); }
.portal-catalog { --pap-columns: repeat(auto-fill, minmax(min(100%, 235px), 1fr)); --pap-surface: var(--surface); --pap-border: var(--ink); --pap-accent: var(--deep); --pap-muted: var(--muted); --pap-icon-background: #edf2ff; --pap-radius: 12px; padding: 10px 0 72px; }
.portal-catalog .pap-module__card { min-height: 102px; padding: 15px; align-items: center; }
.portal-catalog .pap-module__icon { width: 48px; height: 48px; border-radius: 10px; font-family: ui-monospace, "Cascadia Code", monospace; font-size: 1.1rem; }
.portal-catalog .pap-module__host { margin-top: 5px; }
.portal-catalog .pap-module__arrow { align-self: center; }
footer { padding-top: 22px; }

.notice--error { border-left-color: #b42318; }
.registry-list { gap: 18px; }
.registry-row { display: grid; grid-template-columns: minmax(240px, .75fr) minmax(460px, 1.25fr); align-items: start; gap: 32px; padding: 24px; }
.registry-row__summary { display: grid; grid-template-columns: 48px minmax(0, 1fr); align-items: center; gap: 15px; min-width: 0; }
.registry-icon { position: relative; width: 48px; height: 48px; display: grid; place-items: center; overflow: hidden; border-radius: 10px; background: #edf2ff; color: var(--deep); font: 900 18px/1 ui-monospace, monospace; }
.registry-icon > * { grid-area: 1 / 1; }
.registry-icon img { z-index: 1; width: 100%; height: 100%; padding: 5px; background: #edf2ff; object-fit: contain; }
.registry-icon img[hidden] { display: none; }
.registry-row__controls { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 12px; }
.metadata-form { min-width: 0; display: grid; grid-template-columns: minmax(150px, .75fr) minmax(210px, 1.25fr) auto; align-items: end; gap: 10px; }
.metadata-field { min-width: 0; display: grid; gap: 6px; color: var(--muted); font-size: .76rem; font-weight: 800; }
.metadata-field > span { display: block; }
.metadata-form input[type="text"] { width: 100%; min-width: 0; min-height: 44px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); color: var(--ink); font: inherit; }
.metadata-form input[type="text"]:focus { border-color: var(--deep); }
.metadata-form small { min-height: 1em; color: var(--muted); font-size: .7rem; font-weight: 500; }
.metadata-form .button { min-height: 44px; margin-bottom: calc(1em + 6px); white-space: nowrap; }
.visibility-form { margin: 0; }
.registry-row .visibility-form .button { width: auto; white-space: nowrap; }

@media (max-width: 1050px) {
    .registry-row { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
    .shell { width: min(100% - 24px, 1380px); }
    .intro { padding-top: 38px; }
    .registry-row { display: grid; }
    .registry-row__controls { grid-template-columns: 1fr; }
    .metadata-form { grid-template-columns: 1fr; }
    .metadata-form .button { margin: 0; }
    .registry-row .visibility-form .button { width: 100%; }
}

@media (max-width: 560px) {
    .masthead--public .brand > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    .masthead--public .admin-actions { gap: 8px; }
}

@media (prefers-color-scheme: dark) {
    :root { --paper: #0d1521; --surface: #152235; --ink: #edf3ff; --muted: #aebbd0; --line: #40506a; --deep: #8ba5ff; --focus: #ffd35a; }
    .portal-catalog { --pap-shadow: #050911; --pap-icon-background: #253452; }
    .pap-module__card:nth-child(5n + 2), .pap-module__card:nth-child(5n + 3), .pap-module__card:nth-child(5n + 4), .pap-module__card:nth-child(5n) { --pap-icon-background: #253452; }
    .pap-module__card:hover { background: #1a2940; box-shadow: 0 8px 0 #050911; }
    .registry-icon, .registry-icon img { background: #253452; }
}

/* Tema elegido y controles de administración */
:root[data-theme="light"] { color-scheme: light; --paper: #edf1f7; --surface: #fff; --ink: #132033; --muted: #5d6a7e; --line: #bdc8d8; --deep: #2b59ff; --focus: #8a5a00; --shadow: 0 18px 50px rgba(19,32,51,.1); }
:root[data-theme="dark"] { color-scheme: dark; --paper: #0d1521; --surface: #152235; --ink: #edf3ff; --muted: #aebbd0; --line: #40506a; --deep: #8ba5ff; --focus: #ffd35a; --shadow: 0 18px 50px rgba(0,0,0,.3); }
:root[data-theme="light"] .count strong { color: #fff; }
:root[data-theme="dark"] .count strong { color: #0d1521; }
:root[data-theme="light"] .visibility--on { background: #d9f5e4; color: #155b32; }
:root[data-theme="light"] .visibility--off { background: #e2e7e9; color: #46585f; }
:root[data-theme="dark"] .visibility--on { background: #174f32; color: #b9f1cf; }
:root[data-theme="dark"] .visibility--off { background: #34474e; color: #dce6e8; }
:root[data-theme="dark"] .portal-catalog { --pap-shadow: #050911; --pap-icon-background: #253452; }
:root[data-theme="dark"] .pap-module__card:hover { background: #1a2940; box-shadow: 0 8px 0 #050911; }
:root[data-theme="dark"] .registry-icon,
:root[data-theme="dark"] .registry-icon img { background: #253452; }

.icon-action { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 9px; padding: 8px 13px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--ink); font: inherit; font-size: .88rem; font-weight: 750; line-height: 1; text-decoration: none; white-space: nowrap; cursor: pointer; transition: border-color .18s ease, background .18s ease, color .18s ease; }
.icon-action:hover { border-color: var(--deep); color: var(--deep); }
.icon-action:active { background: color-mix(in srgb, var(--deep) 10%, var(--surface)); }
.icon-action:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.icon-action svg { flex: 0 0 20px; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-action--primary { border-color: var(--deep); background: var(--deep); color: var(--paper); }
.icon-action--primary:hover { color: var(--paper); filter: brightness(1.08); }
.theme-icon { display: none; }
:root[data-theme="light"] .theme-icon--light,
:root[data-theme="dark"] .theme-icon--dark { display: block; }
.login-actions { display: flex; justify-content: space-between; gap: 12px; margin: -12px 0 30px; }

.registry-list { gap: 14px; padding-top: 32px; }
.registry-row { display: block; padding: 0; overflow: clip; border-radius: 14px; }
.registry-row__summary { min-height: 88px; display: grid; grid-template-columns: 48px minmax(0, 1fr) auto 24px; align-items: center; gap: 16px; padding: 19px 22px; list-style: none; cursor: pointer; }
.registry-row__summary::-webkit-details-marker { display: none; }
.registry-row__summary:hover { background: color-mix(in srgb, var(--deep) 6%, var(--surface)); }
.registry-row__summary:focus-visible { outline: 3px solid var(--focus); outline-offset: -4px; }
.registry-identity { min-width: 0; display: grid; gap: 4px; }
.registry-identity strong { overflow: hidden; font-size: 1.05rem; text-overflow: ellipsis; white-space: nowrap; }
.registry-identity small { overflow: hidden; color: var(--muted); font: .75rem/1.4 ui-monospace, "Cascadia Code", monospace; text-overflow: ellipsis; white-space: nowrap; }
.registry-chevron { width: 22px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform .18s ease; }
.registry-row[open] .registry-chevron { transform: rotate(180deg); }
.registry-row__controls { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 24px; padding: 24px 22px 26px 86px; border-top: 1px solid var(--line); background: color-mix(in srgb, var(--paper) 55%, var(--surface)); }
.metadata-form { display: grid; grid-template-columns: minmax(160px, .8fr) minmax(240px, 1.2fr) auto; align-items: end; gap: 16px; }
.metadata-form .icon-action { margin: 0 0 calc(1em + 6px); }
.registry-row__side-actions { display: flex; align-items: center; gap: 10px; padding-bottom: calc(1em + 6px); }
.visibility-form { margin: 0; padding: 0; }
.detect-icon-form { margin: 0; }
.registry-row .visibility-form .icon-action { min-width: 112px; }

@media (max-width: 900px) {
    .registry-row__controls { grid-template-columns: 1fr; padding-left: 22px; }
    .registry-row__side-actions { justify-content: flex-end; padding: 0; }
}

@media (max-width: 720px) {
    .masthead .admin-actions { gap: 8px; }
    .masthead .admin-actions .icon-action > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    .metadata-form { grid-template-columns: 1fr; }
    .metadata-form .icon-action { width: 100%; margin: 0; }
    .registry-row__side-actions { display: grid; grid-template-columns: 1fr 1fr; }
    .registry-row__side-actions .icon-action { width: 100%; }
}

@media (max-width: 520px) {
    .masthead .brand > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    .registry-row__summary { grid-template-columns: 44px minmax(0, 1fr) 22px; gap: 12px; padding: 16px; }
    .registry-row__summary .visibility { grid-column: 2; justify-self: start; }
    .registry-chevron { grid-column: 3; grid-row: 1 / 3; }
    .registry-row__controls { padding: 20px 16px; }
    .login-actions { margin-top: -4px; }
}
