:root {
    --ink: #101828;
    --muted: #667085;
    --line: #d6dde8;
    --surface: #ffffff;
    --soft: #f5f7fb;
    --primary: #123c69;
    --primary-dark: #0b294a;
    --danger: #b42318;
    --warning: #b7791f;
    --success: #0f7a3a;
    --gold: #b68a3a;
    --shadow: 0 18px 48px rgba(16, 24, 40, 0.09);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--ink);
    background:
        linear-gradient(180deg, #eef3f8 0%, #f8fafc 44%, #eef3f8 100%);
    font-family: Arial, Helvetica, sans-serif;
}

a {
    color: var(--primary-dark);
    text-decoration: none;
}

input,
select,
textarea,
button {
    font: inherit;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 18px clamp(18px, 4vw, 56px);
    background: rgba(255, 255, 255, 0.92);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 8px 24px rgba(16, 24, 40, 0.04);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: var(--ink);
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    color: #fff;
    background: linear-gradient(135deg, var(--primary), #2077a7);
    font-weight: 700;
}

.brand small {
    display: block;
    margin-top: 2px;
    color: var(--muted);
}

.nav {
    display: flex;
    gap: 14px;
}

.nav a {
    color: #344054;
    font-weight: 700;
}

.page {
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
    padding: 34px 0 48px;
}

.lookup {
    min-height: calc(100vh - 180px);
    display: grid;
    align-items: center;
}

.lookup::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(135deg, rgba(18, 60, 105, 0.08), transparent 36%),
        linear-gradient(315deg, rgba(182, 138, 58, 0.12), transparent 32%);
}

.lookup-panel,
.result-card,
.auth-card,
.form-card,
.table-wrap {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.lookup-panel {
    max-width: 760px;
    padding: clamp(26px, 5vw, 52px);
    position: relative;
    overflow: hidden;
}

.lookup-panel::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 5px;
    background: linear-gradient(90deg, var(--primary), #2396c9, var(--gold));
}

.eyebrow {
    margin: 0 0 10px;
    color: var(--primary-dark);
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

h1 {
    margin: 0;
    font-size: clamp(30px, 5vw, 48px);
    line-height: 1.08;
    color: #0b1f35;
}

h2 {
    margin: 0 0 8px;
    font-size: 20px;
}

.lead {
    max-width: 720px;
    color: var(--muted);
    font-size: 18px;
    line-height: 1.55;
}

.lookup-form,
.auth-card,
.form-card {
    display: grid;
    gap: 16px;
}

.compact-search {
    border-top: 1px solid var(--line);
    margin-top: 22px;
    padding-top: 22px;
}

label {
    display: grid;
    gap: 7px;
    color: #2d3748;
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 12px 13px;
    color: var(--ink);
    background: #fff;
    outline: none;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.input-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
}

button,
.button-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    border: 0;
    border-radius: 6px;
    padding: 12px 18px;
    color: #fff;
    background: linear-gradient(135deg, var(--primary), #196c9b);
    cursor: pointer;
    font-weight: 700;
}

.linkedin-link {
    background: #0a66c2;
}

.linkedin-share-link {
    color: #0a66c2;
    background: #e8f2fc;
}

button:hover,
.button-link:hover {
    background: var(--primary-dark);
}

.linkedin-link:hover,
.linkedin-share-link:hover {
    color: #fff;
    background: #084b91;
}

.ghost-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 10px 14px;
    color: var(--ink);
    background: #fff;
    font-weight: 700;
}

.result-page,
.auth-wrap {
    display: grid;
    justify-items: center;
}

.result-card,
.auth-card,
.form-card {
    width: 100%;
    padding: clamp(22px, 4vw, 38px);
}

.result-card,
.auth-card {
    max-width: 920px;
}

.status-line,
.admin-head,
.admin-actions,
.form-actions,
.searchbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.estado-valido {
    color: var(--success);
    background: #e9f8ef;
}

.estado-expirado {
    color: var(--warning);
    background: #fff5dd;
}

.estado-revocado {
    color: var(--danger);
    background: #fdebea;
}

.details-grid,
.stats,
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.certificate-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 28px;
}

.certificate-brand span {
    display: grid;
    place-items: center;
    min-width: 76px;
    height: 54px;
    border-radius: 6px;
    color: #fff;
    background: linear-gradient(135deg, var(--brand-color), #2298c8);
    font-weight: 800;
}

.certificate-brand img {
    max-width: 120px;
    max-height: 64px;
    object-fit: contain;
}

.certificate-brand small {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-weight: 700;
}

.details-grid {
    margin: 26px 0;
}

.details-grid div,
.stats div {
    border: 1px solid #e4e9f2;
    border-radius: 6px;
    padding: 14px;
    background: #fbfcff;
}

dt {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

dd {
    margin: 5px 0 0;
    font-weight: 800;
}

.description {
    border-top: 1px solid var(--line);
    margin-top: 22px;
    padding-top: 22px;
}

.verification-card {
    padding: 0;
    overflow: hidden;
}

.verification-shell {
    border-top: 6px solid var(--brand-color);
    padding: clamp(24px, 4vw, 42px);
    background:
        linear-gradient(135deg, rgba(18, 60, 105, 0.06), transparent 42%),
        linear-gradient(315deg, rgba(182, 138, 58, 0.16), transparent 34%),
        #ffffff;
}

.verification-title {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
}

.verification-card > .details-grid,
.verification-card > .description,
.verification-card > .signature-panel,
.verification-card > .button-link {
    margin-left: clamp(24px, 4vw, 42px);
    margin-right: clamp(24px, 4vw, 42px);
}

.verification-card > .button-link {
    margin-bottom: 12px;
}

.verification-card > .button-link:last-child {
    margin-bottom: clamp(24px, 4vw, 42px);
}

.signature-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    border: 1px solid #e4e9f2;
    border-left: 4px solid var(--gold);
    border-radius: 6px;
    margin-top: 22px;
    margin-bottom: 24px;
    padding: 18px 20px;
    background: #fffdf8;
}

.signature-panel img {
    max-width: 220px;
    max-height: 92px;
    object-fit: contain;
}

.signature-panel span,
.signature-panel small {
    display: block;
    color: var(--muted);
    font-weight: 700;
}

.signature-panel strong {
    display: block;
    margin: 4px 0;
    color: #0b1f35;
    font-size: 18px;
}

.signature-preview {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    border: 1px solid #e4e9f2;
    border-radius: 6px;
    padding: 12px 14px;
    background: #fbfcff;
}

.signature-preview span {
    color: var(--muted);
    font-weight: 700;
}

.signature-preview img {
    max-width: 180px;
    max-height: 72px;
    object-fit: contain;
}

.auth-card {
    margin-top: 24px;
}

.alert {
    border-radius: 6px;
    padding: 12px 14px;
    font-weight: 700;
}

.alert-error {
    color: var(--danger);
    background: #fdebea;
}

.alert-success {
    color: var(--success);
    background: #e9f8ef;
}

.admin-head {
    margin-bottom: 20px;
}

.admin-head h1 {
    font-size: clamp(28px, 4vw, 42px);
}

.stats {
    margin-bottom: 18px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.stats strong {
    display: block;
    font-size: 26px;
}

.stats span {
    color: var(--muted);
    font-weight: 700;
}

.searchbar {
    margin-bottom: 18px;
}

.searchbar input {
    flex: 1;
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 14px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

th {
    color: var(--muted);
    font-size: 13px;
    text-transform: uppercase;
}

td small {
    color: var(--muted);
}

.actions-cell {
    white-space: nowrap;
}

.actions-cell a {
    margin-right: 10px;
    font-weight: 700;
}

.color-dot {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 1px solid var(--line);
    border-radius: 50%;
    margin-right: 8px;
    vertical-align: middle;
}

.empty {
    color: var(--muted);
    text-align: center;
}

.public-search {
    margin: 20px 0;
}

.public-results {
    display: grid;
    gap: 12px;
}

.public-result {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 16px;
    background: #fbfdff;
}

.public-result h2 {
    margin-top: 10px;
}

.public-result p {
    margin: 6px 0 0;
    color: var(--muted);
}

.footer {
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
    padding: 18px 0 28px;
    color: var(--muted);
    font-size: 14px;
}

.certificate-page {
    min-height: 100vh;
    padding: 20px;
    background: #eef1f5;
}

.certificate-toolbar {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin: 0 auto 18px;
    width: min(1120px, 100%);
}

.certificate-sheet {
    position: relative;
    width: min(1120px, 100%);
    aspect-ratio: 1.5 / 1;
    margin: 0 auto;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 22px 60px rgba(16, 24, 40, 0.18);
}

.generated-certificate-image {
    display: block;
    width: min(1120px, 100%);
    margin: 0 auto 18px;
    background: #fff;
    box-shadow: 0 22px 60px rgba(16, 24, 40, 0.18);
}

.generated-certificate-frame {
    display: block;
    width: min(1120px, 100%);
    height: min(760px, 72vw);
    min-height: 520px;
    margin: 0 auto 18px;
    border: 0;
    background: #fff;
    box-shadow: 0 22px 60px rgba(16, 24, 40, 0.18);
}

.certificate-html-preview {
    display: none;
}

.certificate-bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.certificate-content {
    position: absolute;
    inset: 0;
    color: #061f4a;
    text-align: center;
    font-family: Georgia, "Times New Roman", serif;
}

.certificate-cover {
    position: absolute;
    background: rgba(255, 255, 255, 0.94);
}

.cover-name {
    left: 31%;
    right: 31%;
    top: 39%;
    height: 8%;
}

.cover-course {
    left: 16%;
    right: 16%;
    top: 55%;
    height: 14%;
}

.cover-hours {
    left: 34%;
    right: 34%;
    top: 70.5%;
    height: 4%;
}

.cover-date {
    right: 13%;
    top: 76%;
    width: 24%;
    height: 4%;
}

.cover-signer {
    left: 31%;
    right: 31%;
    bottom: 8.5%;
    height: 10%;
}

.certificate-name {
    position: absolute;
    left: 22%;
    right: 22%;
    top: 40%;
    color: #061f4a;
    font-family: "Brush Script MT", "Segoe Script", cursive;
    font-size: clamp(26px, 5vw, 68px);
    line-height: 1;
}

.certificate-course {
    position: absolute;
    left: 17%;
    right: 17%;
    top: 56%;
    color: #061f4a;
    font-size: clamp(20px, 3.4vw, 52px);
    font-weight: 800;
    line-height: 1.12;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.certificate-hours {
    position: absolute;
    left: 30%;
    right: 30%;
    top: 71.5%;
    color: #061f4a;
    font-size: clamp(16px, 2.1vw, 30px);
}

.certificate-date {
    position: absolute;
    right: 15%;
    top: 77%;
    color: #061f4a;
    font-size: clamp(12px, 1.5vw, 19px);
    font-weight: 800;
    text-transform: uppercase;
}

.certificate-code {
    position: absolute;
    left: 50%;
    bottom: 3.2%;
    transform: translateX(-50%);
    color: rgba(6, 31, 74, 0.8);
    font-family: Arial, Helvetica, sans-serif;
    font-size: clamp(9px, 1vw, 12px);
    font-weight: 700;
}

.certificate-signature {
    position: absolute;
    left: 42%;
    bottom: 13.7%;
    width: 18%;
    max-height: 11%;
    object-fit: contain;
}

.certificate-signer {
    position: absolute;
    left: 38%;
    right: 38%;
    bottom: 8%;
    color: #061f4a;
    font-size: clamp(10px, 1.2vw, 16px);
    text-transform: uppercase;
}

.certificate-signer strong,
.certificate-signer span {
    display: block;
}

.template-consulteg .certificate-name {
    top: 31%;
}

.template-consulteg .cover-name {
    left: 30%;
    right: 30%;
    top: 29.5%;
    height: 8%;
}

.template-consulteg .certificate-course {
    top: 45%;
    left: 18%;
    right: 12%;
    color: #050505;
    font-size: clamp(20px, 3.1vw, 46px);
}

.template-consulteg .cover-course {
    left: 17%;
    right: 10%;
    top: 43.5%;
    height: 16%;
}

.template-consulteg .certificate-hours {
    top: 63%;
    color: #050505;
}

.template-consulteg .cover-hours {
    left: 36%;
    right: 36%;
    top: 62%;
    height: 4%;
}

.template-consulteg .certificate-date {
    top: 71%;
    right: 13%;
    color: #050505;
}

.template-consulteg .cover-date {
    right: 10%;
    top: 70%;
    width: 30%;
    height: 4%;
}

.template-consulteg .certificate-signature {
    left: 42%;
    bottom: 17%;
}

.template-consulteg .certificate-code {
    bottom: 1.8%;
}

.template-consulteg .cover-signer {
    left: 37%;
    right: 34%;
    bottom: 8%;
    height: 13%;
}

@media print {
    body.certificate-page {
        padding: 0;
        background: #fff;
    }

    .certificate-toolbar {
        display: none;
    }

    .certificate-sheet {
        width: 100vw;
        max-width: none;
        box-shadow: none;
    }
}

@media (max-width: 760px) {
    .topbar,
    .admin-head,
    .status-line,
    .verification-title,
    .searchbar,
    .public-result,
    .signature-panel {
        align-items: stretch;
        flex-direction: column;
    }

    .nav,
    .admin-actions,
    .form-actions {
        width: 100%;
        flex-wrap: wrap;
    }

    .input-row,
    .details-grid,
    .stats,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .button-link,
    button,
    .ghost-link {
        width: 100%;
    }

    .certificate-page {
        padding: 10px;
    }

    .certificate-toolbar {
        flex-direction: column;
    }
}
