/* Certificates overlay on the shared UNEB + Gadgets shell. */

.cert-app { --cert: #d97706; --cert-soft: rgba(217, 119, 6, 0.14); }
.cert-app textarea { height: auto; min-height: 84px; padding: 10px 12px; line-height: 1.5; resize: vertical; }
.cert-app code { font-size: 0.92em; padding: 1px 5px; border-radius: 5px; background: var(--surface-2); color: var(--text); }
.cert-app .lede code { font-size: 13px; }
.cert-app svg.cert-doc { display: block; width: 100%; height: auto; }
.cert-app .btn svg { flex: none; }
.cert-app .fine { font-size: 12.5px; line-height: 1.5; }
.cert-app .muted { color: var(--text-3); }
.cert-app [hidden] { display: none !important; }

/* Landing */
body.portal.cert-app {
    background:
        radial-gradient(900px 420px at 12% -8%, rgba(217, 119, 6, 0.16), transparent 58%),
        radial-gradient(720px 380px at 92% 0%, rgba(219, 39, 119, 0.08), transparent 52%),
        var(--bg);
}
.cert-hero-art { position: relative; margin: 0; min-height: 300px; }
.cert-hero-doc { position: absolute; border-radius: 10px; overflow: hidden; box-shadow: var(--shadow-lg); background: #fff; }
.cert-hero-main { top: 0; left: 0; width: 88%; transform: rotate(-2deg); }
.cert-hero-card { right: 0; bottom: 0; width: 52%; transform: rotate(4deg); border: 4px solid #fff; }
.cert-occasions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.cert-occasions article { padding: 12px; border-radius: 16px; border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow); }
.cert-occasions b { display: block; margin: 10px 2px 2px; }
.cert-occasions span { display: block; margin: 0 2px; color: var(--text-2); font-size: 13px; line-height: 1.5; }
.cert-mini { border-radius: 10px; overflow: hidden; background: #fff; border: 1px solid var(--border); }

/* Desk */
.cert-brief { background: radial-gradient(480px 200px at 100% 0%, rgba(217, 119, 6, 0.18), transparent 62%), var(--surface); }
.cert-brief .desk-kicker { color: var(--cert); }
.cert-quick { display: flex; flex-direction: column; gap: 8px; }
.cert-quick .btn { justify-content: center; }
.rank { display: block; color: inherit; text-decoration: none; }
a.rank:hover .rank-top span { color: var(--primary); }
.rank-top small { color: var(--text-3); font-weight: 600; margin-left: 4px; }
.batch-list { display: grid; gap: 6px; }
.batch-card {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid var(--border);
    color: inherit;
    text-decoration: none;
    background: color-mix(in srgb, var(--bg) 50%, transparent);
}
.batch-card:hover { border-color: var(--border-strong); background: var(--surface-hover); }
.batch-card strong { display: block; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.batch-card small { color: var(--text-3); font-size: 12px; }
.batch-kind { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--amber-soft); color: var(--amber); }
.batch-kind.card { background: var(--violet-soft); color: var(--violet); }
.batch-kind svg { width: 18px; height: 18px; }
.cert-starts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.cert-starts a { display: block; padding: 12px; border-radius: 12px; border: 1px solid var(--border); text-decoration: none; color: inherit; background: color-mix(in srgb, var(--bg) 50%, transparent); }
.cert-starts a:hover { border-color: var(--cert); background: var(--cert-soft); }
.cert-starts b { display: block; font-size: 13.5px; margin-bottom: 3px; }
.cert-starts span { color: var(--text-2); font-size: 12px; line-height: 1.45; }

/* People */
.list-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; margin-bottom: 14px; }
.list-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface);
    text-decoration: none;
    color: inherit;
    min-width: 0;
}
.list-card.on { border-color: var(--cert); box-shadow: 0 0 0 1px var(--cert) inset; }
.list-open { color: inherit; text-decoration: none; min-width: 0; }
.list-card strong { display: block; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-card small { display: block; color: var(--text-3); font-size: 12px; margin-top: 2px; }
.list-actions { display: flex; gap: 12px; }
.list-actions a, .list-actions button { padding: 0; border: 0; background: none; color: var(--primary); font: inherit; font-size: 12px; font-weight: 700; text-decoration: none; cursor: pointer; }
.list-strip.compact { margin: 0; }
.cert-filter { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; align-items: center; }
.cert-filter input { flex: 1 1 240px; width: auto; }
.cert-filter select { flex: 0 1 180px; width: auto; }
.bulk-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 10px;
    margin-bottom: 8px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface);
    position: sticky;
    top: calc(var(--topbar-h) + 6px);
    z-index: 4;
}
.bulk-bar.has-pick { border-color: color-mix(in srgb, var(--cert) 50%, var(--border)); background: color-mix(in srgb, var(--cert-soft) 60%, var(--surface)); }
.bulk-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.bulk-actions form { display: flex; gap: 6px; margin: 0; }
.bulk-bar:not(.has-pick) .bulk-actions { opacity: 0.55; }
.cert-table th.pick, .cert-table td.pick { width: 36px; padding-right: 0; }
.cert-table td.pick input, .cert-table th.pick input { width: 16px; height: 16px; accent-color: var(--cert); }
.cert-table td small { display: block; color: var(--text-3); font-size: 11.5px; font-weight: 600; margin-top: 2px; }
.cert-table td small.inline { display: inline; }
.cert-table td small.warn { display: inline; color: var(--danger); }
.cert-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.cert-table tr.is-revoked td { opacity: 0.55; }
.cert-table tr.is-revoked td:nth-child(3) { text-decoration: line-through; }
.cert-table .msg-cell { max-width: 280px; color: var(--text-2); font-size: 12.5px; line-height: 1.45; }
button.name-link { padding: 0; border: 0; background: none; font: inherit; cursor: pointer; text-align: left; color: var(--primary); font-weight: 700; }
.muted-link { color: var(--text-2); text-decoration: none; }
.muted-link:hover { color: var(--primary); }
.share-cell { white-space: nowrap; }
.share-cell .wa { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; color: var(--text-3); vertical-align: middle; }
.share-cell .wa svg { width: 18px; height: 18px; }
.share-cell .wa.has-number { color: #16a34a; background: rgba(22, 163, 74, 0.12); }
.share-cell button { padding: 4px 8px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2); font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; }
.row-actions button.name-link { font-size: inherit; }
.badge.cat-student { border-color: transparent; background: var(--sky-soft); color: var(--sky); }
.badge.cat-staff { border-color: transparent; background: var(--success-soft); color: var(--success); }
.badge.cat-prospect { border-color: transparent; background: var(--amber-soft); color: var(--amber); }
.badge.cat-other { border-color: transparent; background: var(--violet-soft); color: var(--violet); }
.badge svg { width: 12px; height: 12px; margin-right: 3px; }
.cert-pager { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; margin: 14px 0; }
.cert-pager a, .cert-pager span { min-width: 34px; height: 34px; padding: 0 8px; display: inline-grid; place-items: center; border-radius: 9px; font-size: 13px; font-weight: 700; color: var(--text-2); text-decoration: none; border: 1px solid var(--border); background: var(--surface); }
.cert-pager a.on { background: var(--cert); border-color: var(--cert); color: #fff; }
.cert-pager span { border: 0; background: none; }
.cert-danger { margin-top: 16px; padding: 14px; border-radius: 12px; border: 1px solid; }
.cert-danger p { margin: 0 0 10px; font-size: 13px; color: var(--text-2); }

/* Import */
.map-grid { display: grid; gap: 8px; }
.map-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(150px, 0.9fr); gap: 10px; align-items: center; margin: 0; padding: 8px 10px; border-radius: 10px; background: var(--surface-2); }
.map-head { min-width: 0; }
.map-head strong { display: block; color: var(--text); font-size: 13px; }
.map-head small { display: block; color: var(--text-3); font-size: 11.5px; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cert-check { display: flex; align-items: center; gap: 8px; margin: 0; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font-size: 13px; font-weight: 650; cursor: pointer; }
.cert-check input { width: 16px; height: 16px; margin: 0; accent-color: var(--cert); }
.cert-foot { gap: 8px; margin: 4px 0 16px; }
.cert-drop { display: block; margin-bottom: 12px; }
.cert-drop .dz-text svg { width: 20px; height: 20px; }

/* Designs */
.design-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.design-card { display: flex; flex-direction: column; border-radius: 16px; border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow); overflow: hidden; }
.design-thumb { display: grid; place-items: center; padding: 14px; background: repeating-linear-gradient(45deg, var(--surface-2), var(--surface-2) 10px, color-mix(in srgb, var(--surface-2) 70%, var(--bg)) 10px, color-mix(in srgb, var(--surface-2) 70%, var(--bg)) 20px); aspect-ratio: 4 / 3; }
.design-thumb svg.cert-doc { max-height: 100%; width: auto; max-width: 100%; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25); border-radius: 3px; }
.design-meta { padding: 12px 14px 6px; flex: 1; }
.design-meta strong { display: block; font-size: 14px; }
.design-meta small { display: block; color: var(--text-3); font-size: 12px; margin-top: 2px; }
.design-meta p { margin: 6px 0 0; color: var(--text-2); font-size: 12.5px; line-height: 1.45; }
.design-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.design-tags .badge + .badge { margin-left: 0; }
.design-actions { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 14px 14px; }
.design-actions form { margin: 0; }

.design-editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 0.95fr); gap: 14px; align-items: start; }
.design-fields { display: grid; gap: 12px; min-width: 0; }
.design-fields .panel h2 { margin-bottom: 10px; }
.design-preview { position: sticky; top: calc(var(--topbar-h) + 12px); display: grid; gap: 10px; }
.preview-frame { display: grid; place-items: center; min-height: 240px; padding: 16px; border-radius: 16px; border: 1px solid var(--border); background: repeating-linear-gradient(45deg, var(--surface-2), var(--surface-2) 10px, color-mix(in srgb, var(--surface-2) 70%, var(--bg)) 10px, color-mix(in srgb, var(--surface-2) 70%, var(--bg)) 20px); transition: opacity 0.15s; }
.preview-frame svg.cert-doc { max-height: 70vh; width: auto; max-width: 100%; box-shadow: 0 10px 28px rgba(0, 0, 0, 0.3); border-radius: 3px; }
.preview-frame.is-loading { opacity: 0.65; }
.preview-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.preview-actions .btn { flex: 1 1 auto; justify-content: center; }
.preview-actions.minor .btn { flex: 0 0 auto; }
.seg-toggle { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); width: fit-content; max-width: 100%; }
.seg-toggle label { margin: 0; cursor: pointer; }
.seg-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.seg-toggle span { display: inline-flex; align-items: center; height: 32px; padding: 0 12px; border-radius: 8px; color: var(--text-2); font-size: 12.5px; font-weight: 700; }
.seg-toggle input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow); outline: 1px solid var(--border-strong); }
.seg-toggle input:focus-visible + span { box-shadow: var(--ring); }
.field > span { display: block; margin-bottom: 6px; }
.color-pair { display: flex; gap: 6px; align-items: center; }
.color-pair input[type="color"] { width: 44px; flex: none; padding: 3px; cursor: pointer; }
.color-pair input:not([type="color"]) { text-transform: lowercase; font-family: ui-monospace, Consolas, monospace; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.chip-btn { height: 28px; padding: 0 9px; border-radius: 8px; border: 1px dashed var(--border-strong); background: var(--surface-2); color: var(--text-2); font: inherit; font-size: 12px; font-weight: 700; font-family: ui-monospace, Consolas, monospace; cursor: pointer; }
.chip-btn:hover { border-color: var(--cert); color: var(--cert); background: var(--cert-soft); }
.toggle-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }

/* Messages */
.msg-tabs a { gap: 7px; }
.tone-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--tone); display: inline-block; }
.msg-hint { margin: 0; color: var(--text-2); font-size: 13.5px; }
.msg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.msg-card { position: relative; display: flex; flex-direction: column; gap: 8px; padding: 16px 16px 12px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow); overflow: hidden; }
.msg-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--tone); }
.msg-card blockquote { margin: 0; font-family: var(--serif); font-size: 15px; line-height: 1.55; color: var(--text); }
.msg-card mark { background: var(--cert-soft); color: var(--cert); border-radius: 4px; padding: 0 3px; font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; }
.msg-card cite { color: var(--text-3); font-size: 12.5px; font-style: normal; font-weight: 700; }
.msg-card footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; padding-top: 8px; border-top: 1px solid var(--border); }
.msg-card.is-off { opacity: 0.5; }
.msg-tag { color: var(--text-3); font-size: 11px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.msg-actions { display: flex; gap: 10px; align-items: center; }
.msg-actions form { margin: 0; }
.msg-actions button { padding: 0; border: 0; background: none; color: var(--primary); font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; }
.msg-actions .danger-link { color: var(--danger); }

/* Generate */
.gen-form { display: grid; gap: 12px; padding-bottom: 80px; }
.step-no { display: inline-grid; place-items: center; width: 24px; height: 24px; margin-right: 6px; border-radius: 50%; background: var(--cert); color: #fff; font-size: 12px; vertical-align: 1px; }
.gen-designs { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(170px, 200px); gap: 10px; overflow-x: auto; padding: 4px 2px 10px; scroll-snap-type: x proximity; }
.gen-design { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 8px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); cursor: pointer; scroll-snap-align: start; }
.gen-design input { position: absolute; opacity: 0; pointer-events: none; }
.gen-design:has(input:checked) { border-color: var(--cert); box-shadow: 0 0 0 2px var(--cert); background: var(--cert-soft); }
.gen-thumb { display: grid; place-items: center; aspect-ratio: 4 / 3; }
.gen-thumb svg.cert-doc { max-height: 100%; width: auto; max-width: 100%; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25); border-radius: 2px; }
.gen-name { color: var(--text); font-size: 12.5px; font-weight: 700; line-height: 1.3; }
.gen-sources { margin: 8px 0 14px; }
.gen-count { margin: 10px 0 0; color: var(--text-2); font-size: 13px; }
.gen-count b { color: var(--text); font-size: 16px; }
.picked-names { display: flex; flex-wrap: wrap; gap: 6px; }
.picked-names span { padding: 5px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-size: 12.5px; font-weight: 650; }
.picked-names small { color: var(--text-3); }
.gen-submit {
    position: sticky;
    bottom: 12px;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 14px;
    padding: 10px 12px;
    border-radius: 14px;
    border: 1px solid var(--border-strong);
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: blur(12px);
    box-shadow: var(--shadow-lg);
}
.gen-submit p { margin: 0 auto 0 4px; color: var(--text-2); font-size: 13px; font-weight: 650; }
.gen-submit .btn { min-width: 220px; justify-content: center; }

/* Batch */
.batch-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin: -6px 0 12px; }
.batch-facts { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; color: var(--text-2); font-size: 13px; }
.batch-facts span:not(.badge) + span::before { content: none; }
.batch-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.cert-danger-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 18px 0; }
.cert-danger-row form { margin: 0; }
.cert-danger-row .fine { margin: 0; }

/* School details */
.sub-h { margin-top: 18px !important; }
.serial-sample { height: 40px; display: flex; align-items: center; padding: 0 12px; border-radius: 10px; border: 1px dashed var(--border-strong); color: var(--text); }
.sign-grid { display: grid; gap: 8px; }
.sign-row { display: grid; grid-template-columns: 24px 1fr 1fr; gap: 8px; align-items: center; }
.sign-row b { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--surface-2); color: var(--text-3); font-size: 12px; }
.image-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.image-slot { display: flex; gap: 12px; padding: 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); }
.image-preview { width: 84px; height: 84px; flex: none; border-radius: 10px; display: grid; place-items: center; overflow: hidden; background: #fff; border: 1px solid var(--border); }
.image-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.image-preview.is-empty { background: repeating-linear-gradient(45deg, var(--surface), var(--surface) 6px, var(--surface-2) 6px, var(--surface-2) 12px); }
.image-preview.is-empty span { color: var(--text-3); font-size: 10.5px; font-weight: 700; text-align: center; padding: 4px; }
.image-copy { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.image-copy strong { font-size: 13px; }
.image-copy small { color: var(--text-3); font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
.image-copy form { margin: 0; }
.image-form input[type="file"] { font-size: 12px; padding: 6px 8px; }

@media (max-width: 1100px) {
    .design-editor { grid-template-columns: 1fr; }
    .design-preview { position: static; order: -1; }
    .preview-frame svg.cert-doc { max-height: 46vh; }
}
@media (max-width: 720px) {
    .cert-occasions, .cert-starts { grid-template-columns: 1fr; }
    .cert-hero-art { min-height: 220px; }
    .map-row { grid-template-columns: 1fr; }
    .sign-row { grid-template-columns: 24px 1fr; }
    .sign-row input:last-child { grid-column: 2; }
    .gen-submit { flex-direction: column; align-items: stretch; bottom: 70px; }
    .gen-submit .btn { min-width: 0; }
    .bulk-bar { position: static; }
    .cert-filter select { flex: 1 1 140px; }
}
