@import url('fonts.css');

:root {
    --ink: #0a2540;
    --ink-soft: #16324f;
    --foam: #2a9d8f;
    --foam-deep: #1f7a6f;
    --sand: #e8eef4;
    --paper: #ffffff;
    --line: #d0dae4;
    --muted: #5a6f84;
    --danger: #b42318;
    --warn: #9a6700;
    --ok: #0f7a4c;
    --side: #071a2e;
    --shadow: 0 10px 28px rgba(10, 37, 64, 0.08);
    --font-display: "DM Serif Display", Georgia, serif;
    --font-body: "Outfit", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font-body);
    background:
        radial-gradient(ellipse 70% 40% at 100% 0%, rgba(42, 157, 143, 0.12), transparent 50%),
        var(--sand);
    color: var(--ink);
    min-height: 100vh;
}

html[dir="rtl"] body { direction: rtl; text-align: right; }
html[dir="rtl"] .admin-shell { direction: rtl; }
html[dir="rtl"] .side-brand,
html[dir="rtl"] .topbar,
html[dir="rtl"] .topbar-meta,
html[dir="rtl"] .inline-actions { direction: rtl; }
html[dir="rtl"] .nav-count { float: left; }
html[dir="rtl"] input,
html[dir="rtl"] textarea,
html[dir="rtl"] select { text-align: right; }
html[dir="rtl"] input[type="email"],
html[dir="rtl"] input[type="url"],
html[dir="rtl"] input[type="tel"],
html[dir="rtl"] code { direction: ltr; text-align: left; }

a { color: var(--foam-deep); text-decoration: none; }
a:hover { text-decoration: underline; }

.admin-shell {
    display: grid;
    grid-template-columns: 250px 1fr;
    min-height: 100vh;
}

aside {
    background: linear-gradient(180deg, var(--side), #0d2742);
    color: #b7c6d6;
    padding: 1.35rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.side-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-family: var(--font-display);
    font-size: 1.35rem;
    color: #fff;
    margin: 0.25rem 0.4rem 1.4rem;
    line-height: 1.2;
}

.side-logo {
    width: 2.5rem;
    height: 2.5rem;
    object-fit: contain;
    border-radius: 0.4rem;
    background: #fff;
    flex-shrink: 0;
}

.side-brand small {
    display: block;
    font-family: var(--font-body);
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #7f97ad;
    margin-top: 0.25rem;
}

nav { display: grid; gap: 0.25rem; }

nav a {
    color: #b7c6d6;
    padding: 0.75rem 0.85rem;
    border-radius: 0.55rem;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    position: relative;
}

.nav-count {
    float: right;
    min-width: 1.35rem;
    padding: 0.05rem 0.35rem;
    border-radius: 999px;
    background: #e76f51;
    color: #fff;
    font-size: 0.72rem;
    text-align: center;
}

nav a:hover,
nav a.active {
    background: rgba(42, 157, 143, 0.2);
    color: #fff;
    text-decoration: none;
}

nav a.active {
    background: var(--foam);
    color: #04241f;
}

.logout {
    margin-top: auto;
    color: #f0b4ae;
    padding: 0.75rem 0.85rem;
    border: 0;
    background: transparent;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
    width: 100%;
}

.logout:hover { color: #fff; }

.admin-main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
    height: 4.5rem;
    background: rgba(255, 255, 255, 0.86);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--line);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.topbar h1 {
    margin: 0;
    font-family: var(--font-display);
    font-size: 1.45rem;
    font-weight: 400;
}

.topbar-meta {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    color: var(--muted);
    font-size: 0.92rem;
}

.content { padding: 1.5rem; flex: 1; }

.admin-footer {
    padding: 1rem 1.5rem;
    background: rgba(255, 255, 255, 0.7);
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 0.88rem;
}

.welcome {
    padding: 1.75rem;
    background: linear-gradient(125deg, #06182c, var(--ink) 55%, #12405a);
    color: #f4f8fb;
    border-radius: 1rem;
    position: relative;
    overflow: hidden;
}

.welcome::after {
    content: "";
    position: absolute;
    right: -2rem;
    top: -2rem;
    width: 10rem;
    height: 10rem;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.12);
    background: radial-gradient(circle, rgba(42, 157, 143, 0.35), transparent 65%);
}

.welcome h2 {
    margin: 0 0 0.4rem;
    font-family: var(--font-display);
    font-weight: 400;
    font-size: 1.8rem;
}

.welcome p { margin: 0; color: rgba(232, 240, 246, 0.88); max-width: 36rem; }

.welcome .btn {
    position: absolute;
    right: 1.5rem;
    top: 1.75rem;
    z-index: 1;
}

.btn,
button.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    background: var(--foam);
    color: #04241f;
    border: 0;
    border-radius: 0.5rem;
    padding: 0.7rem 1rem;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
}

.btn:hover,
button.btn:hover { background: #34b3a3; text-decoration: none; }

.btn.secondary { background: var(--ink); color: #fff; }
.btn.secondary:hover { background: var(--ink-soft); }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.danger-btn,
.btn.danger {
    background: var(--danger);
    color: #fff;
    margin-top: 1rem;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin: 1.25rem 0;
}

.stat,
.panel {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 0.9rem;
    box-shadow: var(--shadow);
}

.stat { padding: 1.2rem; }
.stat strong { font-size: 1.8rem; display: block; font-family: var(--font-display); font-weight: 400; }
.stat span { color: var(--muted); font-size: 0.9rem; }
.stat a { display: inline-block; margin-top: 0.55rem; font-size: 0.88rem; }

.panel-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.25rem;
}
.panel-grid .panel { margin-bottom: 0; }

.filter-form .filter-date {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin: 0;
    font-size: 0.88rem;
    color: var(--muted);
    font-weight: 500;
}
.filter-form .filter-date input { min-width: 9.5rem; }

.panel { margin-bottom: 1.25rem; overflow: hidden; }

.panel-head,
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding: 1rem 1.2rem;
}

.toolbar { padding: 0 0 1rem; }

.toolbar form {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.toolbar input,
.toolbar select {
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--line);
    border-radius: 0.5rem;
    font: inherit;
    background: #fff;
}

.table-wrap { overflow: auto; }

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

th, td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid #edf1f5;
    text-align: left;
    white-space: nowrap;
}

th {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    background: #f7fafc;
}

.badge,
.status-pill {
    display: inline-block;
    padding: 0.25rem 0.55rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.valid, .active, .found { background: #d9f5e8; color: var(--ok); }
.expired, .pending { background: #fff3cd; color: var(--warn); }
.revoked, .cancelled, .fraudulent, .not_found, .inactive { background: #fde2e1; color: var(--danger); }
.suspended { background: #e8edf2; color: #445566; }
.archived, .duplicate, .replaced { background: #e8edf2; color: #445566; }

.badge.role-super_admin { background: #d9f5e8; color: var(--ok); }
.badge.role-admin { background: #e4eef8; color: #1d4f7a; }
.badge.role-verification_officer { background: #fff3cd; color: var(--warn); }

.form-panel { padding: 1.4rem; max-width: 980px; }

.form-panel h2,
.detail-card h2 {
    font-family: var(--font-display);
    font-weight: 400;
    margin: 0 0 1rem;
}

.record-form label {
    display: block;
    margin: 0.85rem 0;
    font-weight: 600;
    font-size: 0.86rem;
}

.record-form input,
.record-form select,
.record-form textarea {
    width: 100%;
    padding: 0.7rem 0.8rem;
    border: 1px solid var(--line);
    border-radius: 0.5rem;
    margin-top: 0.35rem;
    font: inherit;
    background: #fff;
}

.record-form textarea { min-height: 6rem; resize: vertical; }

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 1rem;
}

.full { grid-column: 1 / -1; }

.detail-card { padding: 1.4rem; }

.details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin: 1.2rem 0;
}

.details div {
    padding: 0.9rem 1rem;
    background: #f3f7fa;
    border-radius: 0.55rem;
}

.details b,
.details span { display: block; }
.details b {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--foam-deep);
}
.details span { margin-top: 0.3rem; font-weight: 500; }

.media-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: flex-start;
    margin: 1rem 0;
}

.media-row img {
    width: 120px;
    height: 120px;
    object-fit: cover;
    border-radius: 0.65rem;
    border: 1px solid var(--line);
}

.pagination {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
    padding: 1rem;
}

.pagination a {
    min-width: 2rem;
    height: 2rem;
    display: grid;
    place-items: center;
    border-radius: 0.4rem;
    border: 1px solid var(--line);
    color: var(--ink);
    text-decoration: none;
    font-size: 0.88rem;
}

.pagination a.active,
.pagination a:hover {
    background: var(--foam);
    border-color: var(--foam);
    color: #04241f;
}

.login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background:
        radial-gradient(ellipse 60% 50% at 20% 20%, rgba(42, 157, 143, 0.25), transparent 55%),
        linear-gradient(145deg, #06182c, #0a2540 50%, #123a52);
    padding: 1rem;
}

.login-card {
    width: min(420px, 100%);
    background: #fff;
    padding: 2rem;
    border-radius: 1rem;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
}
.login-card-wide {
    width: min(520px, 100%);
}

.login-card .form-section-title {
    margin: 1.25rem 0 0.35rem;
    font-size: 1rem;
    color: var(--ink, #0a2540);
    border-bottom: 1px solid var(--line, #d5dde6);
    padding-bottom: 0.35rem;
}

.login-card .help-text {
    display: block;
    margin-top: 0.35rem;
    font-weight: 400;
    font-size: 0.8rem;
    color: var(--muted, #5a6f84);
}

.login-card .stack-form button[type="submit"] {
    width: 100%;
    margin-top: 0.75rem;
}

.login-card h1 {
    margin: 0 0 0.35rem;
    font-family: var(--font-display);
    font-weight: 400;
    font-size: 1.8rem;
}

.login-card .sub {
    color: var(--muted);
    margin: 0 0 1.25rem;
    font-size: 0.92rem;
}

.login-card label {
    display: block;
    margin: 0.9rem 0;
    font-weight: 600;
    font-size: 0.88rem;
}

.login-card input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--line);
    border-radius: 0.5rem;
    margin-top: 0.35rem;
    font: inherit;
}

.login-card button {
    width: 100%;
    margin-top: 0.5rem;
    border: 0;
    border-radius: 999px;
    padding: 0.8rem 1rem;
    background: var(--ink);
    color: #fff;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
.login-card button:hover { background: #12304c; }

.login-links {
    margin: 1.1rem 0 0;
    font-size: 0.9rem;
    text-align: center;
}
.login-links a { color: var(--foam-deep); }

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    margin: 0.85rem 0 1rem;
    font-size: 0.92rem;
    cursor: pointer;
}
.checkbox-row input { width: auto; margin: 0; }

.alert {
    padding: 0.75rem 0.9rem;
    border-radius: 0.5rem;
    margin: 0 0 0.9rem;
    font-size: 0.92rem;
}

.alert.success { background: #d9f5e8; color: var(--ok); }
.alert.danger { background: #fde2e1; color: var(--danger); }
.alert.warning { background: #fff3cd; color: var(--warn); }

.badge.success { background: #d9f5e8; color: var(--ok); }

.recovery-codes {
    list-style: none;
    margin: 0.75rem 0 1rem;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr));
    gap: 0.4rem 0.75rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.totp-setup { margin: 1rem 0; }
.totp-setup-center { text-align: center; }
.totp-setup-center .totp-qr { margin: 0 auto 0.75rem; }
.totp-qr {
    display: inline-block;
    padding: 0.75rem;
    background: #fff;
    border: 1px solid #d7e0ea;
    border-radius: 0.5rem;
}
.setup-steps {
    margin: 0 0 1rem;
    padding-left: 1.2rem;
    color: var(--muted);
    font-size: 0.92rem;
    line-height: 1.45;
}
.login-section-title {
    margin: 1.35rem 0 0.55rem;
    font-size: 1rem;
    font-weight: 600;
}
.trusted-device-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.65rem;
}
.trusted-device-list li {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    align-items: flex-start;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--line, #c5d2de);
    border-radius: 0.5rem;
}

.inline-actions { display: flex; gap: 0.65rem; flex-wrap: wrap; }

.inline-switch-form { display: inline; margin: 0; }
.inline-switch-form .linkish {
    background: none;
    border: 0;
    padding: 0;
    font: inherit;
    color: var(--foam-deep);
    text-decoration: underline;
    cursor: pointer;
}
.inline-switch-form .linkish:hover { color: var(--foam); }
.form-section-title {
  margin: 1.5rem 0 0.35rem;
  font-family: "DM Serif Display", Georgia, serif;
  font-size: 1.25rem;
  font-weight: 400;
  color: var(--ink);
  grid-column: 1 / -1;
}

.history-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    padding: 0 1.2rem 1rem;
    border-bottom: 1px solid var(--line);
}

.history-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.75rem;
    border-radius: 999px;
    background: #f0f5f9;
    color: var(--ink);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
}

.history-tab:hover {
    background: #e4eef8;
}

.history-tab.is-active {
    background: var(--brand);
    color: #fff;
}

.history-tab-count {
    display: inline-block;
    min-width: 1.25rem;
    padding: 0.1rem 0.35rem;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.08);
    font-size: 0.72rem;
    text-align: center;
}

.history-tab.is-active .history-tab-count {
    background: rgba(255, 255, 255, 0.22);
}

.help-text {
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 400;
    margin-top: 0.25rem;
}

.agency-lookup {
    margin-bottom: 1.25rem;
    padding: 1rem;
    border: 1px solid var(--line);
    border-radius: 0.65rem;
    background: var(--surface-soft, #f6f8fb);
}

.agency-lookup-head h3 {
    margin: 0 0 0.25rem;
    font-size: 1rem;
}

.agency-lookup-bar {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.75rem;
    align-items: end;
}

.agency-lookup-status.is-error {
    color: var(--danger, #b42318);
}

.agency-lookup-results {
    display: grid;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.agency-lookup-result {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.15rem;
    width: 100%;
    text-align: left;
    padding: 0.7rem 0.85rem;
    border: 1px solid var(--line);
    border-radius: 0.5rem;
    background: #fff;
    cursor: pointer;
}

.agency-lookup-result:hover,
.agency-lookup-result:focus-visible {
    border-color: var(--brand, #1f7a6f);
}

.agency-lookup-meta {
    color: var(--muted);
    font-size: 0.82rem;
}

@media (max-width: 720px) {
    .agency-lookup-bar {
        grid-template-columns: 1fr;
    }
}

.print-card-grid {
    display: grid;
    grid-template-columns: 1fr 240px;
    gap: 1.5rem;
    align-items: start;
}

.print-org {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--line);
}

.print-org img {
    width: 3.25rem;
    height: 3.25rem;
    object-fit: contain;
    border-radius: 0.4rem;
}

.print-org strong {
    display: block;
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 400;
}

.print-org span {
    color: var(--muted);
    font-size: 0.85rem;
}

.logo-preview {
    margin: 0.25rem 0 1rem;
}

.logo-preview img {
    max-width: 160px;
    max-height: 96px;
    object-fit: contain;
    border: 1px solid var(--line);
    border-radius: 0.5rem;
    padding: 0.5rem;
    background: #fff;
}

.embed-snippets { margin: 0.5rem 0 1rem; }
.embed-snippets .snippet {
    width: 100%;
    font-family: ui-monospace, Consolas, monospace;
    font-size: 0.82rem;
    line-height: 1.45;
    padding: 0.75rem;
    border: 1px solid var(--line);
    border-radius: 0.55rem;
    background: #f4f7fa;
    color: var(--ink);
    resize: vertical;
}

.verify-qr {
    text-align: center;
    padding: 1rem;
    border: 1px dashed var(--line);
    border-radius: 0.75rem;
    background: #f7fafc;
}

.verify-qr img,
.verify-qr canvas {
    width: 220px !important;
    height: 220px !important;
    display: block;
    margin: 0 auto 0.75rem;
}

.qr-box {
    display: inline-block;
    min-height: 220px;
}

.verify-qr p {
    margin: 0 0 0.35rem;
    font-weight: 700;
}

.verify-qr small {
    color: var(--muted);
    word-break: break-all;
    font-size: 0.72rem;
}

/* Certificate design studio */
.studio-shell {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 1rem;
    align-items: start;
}

.studio-sidebar label {
    display: block;
    margin-bottom: 0.65rem;
    font-size: 0.9rem;
}

.studio-sidebar input,
.studio-sidebar select {
    width: 100%;
    margin-top: 0.25rem;
}

.studio-stage-scroll {
    overflow: auto;
    padding: 0.75rem;
    background: #d7dee6;
    border-radius: 10px;
}

.cert-design-canvas {
    margin: 0 auto;
    box-shadow: var(--shadow);
    background-repeat: no-repeat;
    position: relative;
    isolation: isolate;
}

.cert-design-framed {
    --foam: #1f7a6f;
    --gold: #b8953b;
    box-shadow:
        inset 0 0 0 2px var(--foam),
        inset 0 0 0 8px transparent,
        inset 0 0 0 9px rgba(10, 37, 64, 0.28),
        inset 0 0 0 18px transparent,
        inset 0 0 0 19px rgba(184, 149, 59, 0.45),
        var(--shadow);
}

.cert-design-framed::before,
.cert-design-framed::after {
    content: '';
    position: absolute;
    inset: 22px;
    pointer-events: none;
    z-index: 2;
    background:
        linear-gradient(var(--gold), var(--gold)) top left / 26px 3px no-repeat,
        linear-gradient(var(--gold), var(--gold)) top left / 3px 26px no-repeat,
        linear-gradient(var(--gold), var(--gold)) top right / 26px 3px no-repeat,
        linear-gradient(var(--gold), var(--gold)) top right / 3px 26px no-repeat,
        linear-gradient(var(--gold), var(--gold)) bottom left / 26px 3px no-repeat,
        linear-gradient(var(--gold), var(--gold)) bottom left / 3px 26px no-repeat,
        linear-gradient(var(--gold), var(--gold)) bottom right / 26px 3px no-repeat,
        linear-gradient(var(--gold), var(--gold)) bottom right / 3px 26px no-repeat;
}

.cert-design-framed::after {
    inset: 30px;
    opacity: 0.55;
    background:
        linear-gradient(rgba(10, 37, 64, 0.35), rgba(10, 37, 64, 0.35)) top left / 14px 1px no-repeat,
        linear-gradient(rgba(10, 37, 64, 0.35), rgba(10, 37, 64, 0.35)) top left / 1px 14px no-repeat,
        linear-gradient(rgba(10, 37, 64, 0.35), rgba(10, 37, 64, 0.35)) top right / 14px 1px no-repeat,
        linear-gradient(rgba(10, 37, 64, 0.35), rgba(10, 37, 64, 0.35)) top right / 1px 14px no-repeat,
        linear-gradient(rgba(10, 37, 64, 0.35), rgba(10, 37, 64, 0.35)) bottom left / 14px 1px no-repeat,
        linear-gradient(rgba(10, 37, 64, 0.35), rgba(10, 37, 64, 0.35)) bottom left / 1px 14px no-repeat,
        linear-gradient(rgba(10, 37, 64, 0.35), rgba(10, 37, 64, 0.35)) bottom right / 14px 1px no-repeat,
        linear-gradient(rgba(10, 37, 64, 0.35), rgba(10, 37, 64, 0.35)) bottom right / 1px 14px no-repeat;
}

.cert-design-canvas.is-editor .cert-el {
    position: absolute;
    cursor: move;
    outline: 1px dashed transparent;
    user-select: none;
    touch-action: none;
    -webkit-user-select: none;
}

.cert-design-canvas.is-editor .cert-el:hover {
    outline-color: rgba(42, 157, 143, 0.55);
}

.cert-design-canvas.is-editor .cert-el.is-selected {
    outline: 2px solid var(--foam);
    background: rgba(255, 255, 255, 0.12);
}

.cert-el-resize {
    position: absolute;
    inset-inline-end: -6px;
    inset-block-end: -6px;
    width: 18px;
    height: 18px;
    border: 2px solid #fff;
    border-radius: 4px;
    background: var(--foam, #2a9d8f);
    box-shadow: 0 1px 4px rgba(10, 37, 64, 0.35);
    cursor: nwse-resize;
    touch-action: none;
}

.cert-el-qr {
    background: #fff;
    padding: 4px;
    box-sizing: border-box;
}

.cert-preview-wrap {
    overflow: auto;
}

.cert-preview-sheet {
    display: flex;
    justify-content: center;
    padding: 1rem 0;
}

@media print {
    aside,
    .topbar,
    .admin-footer,
    .no-print,
    .alert {
        display: none !important;
    }

    .admin-shell {
        display: block;
    }

    .content {
        padding: 0;
    }

    .print-card {
        box-shadow: none;
        border: 1px solid #ccc;
    }

    .print-card-grid {
        grid-template-columns: 1fr 200px;
    }

    .panel {
        box-shadow: none;
        border: 0;
        background: transparent;
        padding: 0;
    }

    .cert-preview-sheet {
        padding: 0;
    }

    .cert-design-canvas {
        box-shadow: none;
    }
}

@media (max-width: 960px) {
    .studio-shell {
        grid-template-columns: 1fr;
    }
}

.code-block {
    margin: 0;
    padding: 0.85rem 1rem;
    background: #0b1c2c;
    color: #e8eef4;
    border-radius: 10px;
    overflow: auto;
    max-height: 28rem;
    font-size: 0.82rem;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
}

@media (max-width: 960px) {
    .admin-shell { grid-template-columns: 1fr; }
    aside { position: static; }
    .welcome .btn { position: static; margin-top: 1rem; }
    .stat-grid { grid-template-columns: 1fr 1fr; }
    .panel-grid { grid-template-columns: 1fr; }
    .form-grid, .details { grid-template-columns: 1fr; }
    .full { grid-column: auto; }
    .print-card-grid { grid-template-columns: 1fr; }
}

tbody tr.row-warning td {
    background: rgba(214, 158, 46, 0.12);
}

.exec-welcome { margin-bottom: 0.5rem; }
.exec-kpi-grid { grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr)); }
.exec-panel-wide { grid-column: 1 / -1; }

.bi-filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
    gap: .8rem;
    padding: 0 1.2rem 1.2rem;
    align-items: end;
}
.bi-filter-grid label { margin: 0; font-size: .82rem; color: var(--muted); }
.bi-filter-grid input, .bi-filter-grid select { width: 100%; margin-top: .3rem; }
.bi-filter-actions { align-self: end; min-height: 42px; }
.bi-card { min-height: 280px; }
.bi-chart, .bi-ranking, .bi-split, .bi-heat-wrap { padding: .4rem 1.2rem 1.2rem; overflow: auto; }
.bi-svg { display: block; width: 100%; min-width: 420px; height: 250px; }
.bi-legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .8rem; text-transform: capitalize; }
.bi-legend i { display: inline-block; width: .75rem; height: .75rem; border-radius: 50%; margin-right: .3rem; }
.bi-rank { list-style: none; margin: 0; padding: 0; }
.bi-rank li { display: grid; grid-template-columns: minmax(95px, 1.5fr) 2fr auto auto; gap: .65rem; align-items: center; padding: .45rem 0; }
.bi-rank li > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bi-rank li > i { height: .55rem; border-radius: 1rem; background: linear-gradient(90deg, var(--accent) var(--w), var(--line) var(--w)); }
.bi-rank li > strong { font-variant-numeric: tabular-nums; }
.bi-split { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.bi-heat { min-width: 720px; display: grid; grid-template-columns: 44px repeat(24, 1fr); gap: 3px; align-items: center; }
.bi-heat small { text-align: center; font-size: .65rem; }
.bi-heat strong { font-size: .72rem; font-weight: 500; }
.bi-heat i { display: block; aspect-ratio: 1; border-radius: 2px; background: rgba(36, 87, 167, calc(.08 + var(--a) * .92)); }
.bi-drill { border: 0; padding: 0; margin-top: .45rem; background: none; color: var(--accent); cursor: pointer; font: inherit; font-size: .82rem; }
.exec-bar-chart {
    display: flex;
    align-items: flex-end;
    gap: 0.35rem;
    padding: 1rem;
    min-height: 11rem;
}
.exec-bar-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    min-width: 0;
}
.exec-bar {
    width: 100%;
    max-width: 2.5rem;
    height: var(--h, 4%);
    min-height: 4px;
    max-height: 7rem;
    background: var(--foam-deep);
    border-radius: 4px 4px 0 0;
}
.exec-bar-val { font-size: 0.75rem; font-weight: 600; }
.exec-bar-lbl { font-size: 0.65rem; color: var(--muted); text-align: center; }
.analytics-daily-chart {
    overflow-x: auto;
    gap: 0.2rem;
}
.analytics-daily-chart .exec-bar-col { min-width: 1.6rem; }
.analytics-daily-chart .exec-bar-lbl { font-size: 0.58rem; writing-mode: horizontal-tb; }
.analytics-daily-chart .exec-bar-val { font-size: 0.65rem; }
.btn.ghost.active { background: var(--foam-soft, #e8f2f0); color: var(--ink, #0a2540); font-weight: 600; }
.exec-rank-list { list-style: none; margin: 0; padding: 0.75rem 1rem; }
.exec-rank-list li {
    display: grid;
    grid-template-columns: 1fr minmax(4rem, 6rem) 2.5rem;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.45rem;
    font-size: 0.88rem;
}
.exec-rank-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.exec-rank-bar {
    height: 0.45rem;
    background: var(--line);
    border-radius: 999px;
    overflow: hidden;
    position: relative;
}
.exec-rank-bar::after {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--w, 0%);
    background: var(--foam);
    border-radius: inherit;
}
.exec-rank-cnt { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.exec-inline-bar {
    display: inline-block;
    height: 0.35rem;
    width: var(--w, 0%);
    max-width: 8rem;
    background: var(--foam);
    border-radius: 999px;
    vertical-align: middle;
}
.exec-health { padding: 0.75rem 1rem 1rem; }
.exec-health-status { font-weight: 600; margin: 0 0 0.75rem; }
.exec-health-status.ok { color: var(--ok); }
.exec-health-status.bad { color: var(--danger); }
.exec-health-list { list-style: none; margin: 0; padding: 0; }
.exec-health-list li { padding: 0.25rem 0 0.25rem 1.25rem; position: relative; }
.exec-health-list li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.55rem;
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background: var(--danger);
}
.exec-health-list li.ok::before { background: var(--ok); }
.exec-heatmap-wrap { overflow-x: auto; padding: 0 0.5rem 1rem; }
.exec-heatmap { border-collapse: collapse; font-size: 0.65rem; width: 100%; min-width: 36rem; }
.exec-heatmap th, .exec-heatmap td { padding: 0.15rem; text-align: center; }
.exec-heatmap th { color: var(--muted); font-weight: 500; }

.qr-preview-layout {
    display: grid;
    grid-template-columns: minmax(200px, 240px) 1fr;
    gap: 1.25rem;
    align-items: start;
    padding: 0 1rem 1rem;
}
.qr-preview-layout textarea.mono-input {
    width: 100%;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.8rem;
}
.feature-list { margin: 0; padding: 0 1rem 1rem 1.5rem; }
.feature-list li { margin: 0.35rem 0; }
@media (max-width: 720px) {
    .qr-preview-layout { grid-template-columns: 1fr; }
}
.exec-heat-cell {
    width: 1.1rem;
    height: 1.1rem;
    border-radius: 2px;
    background: rgba(42, 157, 143, calc(0.08 + (var(--i, 0) / 100) * 0.85));
    font-size: 0.55rem;
    color: var(--ink-soft);
}

/* Admin shell 2.0 — shared enterprise template */
:root {
    --brand: #0d6670;
    --accent: #13838c;
    --accent-strong: #0b6570;
    --accent-soft: #e5f5f4;
    --navy-950: #06182a;
    --navy-900: #0a2138;
    --navy-800: #12334f;
    --surface: #ffffff;
    --surface-subtle: #f6f8fb;
    --canvas: #eef2f6;
    --line: #d9e1e8;
    --line-strong: #bdcad6;
    --muted: #607386;
    --ink: #102a43;
    --ink-soft: #334e68;
    --shadow: 0 8px 24px rgba(15, 42, 66, 0.07);
    --shadow-lg: 0 18px 50px rgba(5, 24, 42, 0.18);
    --sidebar-width: 286px;
    --sidebar-collapsed: 82px;
    --topbar-height: 76px;
    --radius: 12px;
    --radius-sm: 8px;
}

html { scroll-behavior: smooth; }

body {
    background: var(--canvas);
    line-height: 1.5;
    overflow-x: hidden;
}

button, input, select, textarea { font: inherit; }
button, summary, select { touch-action: manipulation; }
:focus-visible { outline: 3px solid rgba(19, 131, 140, 0.35); outline-offset: 2px; }

.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.skip-link {
    position: fixed;
    z-index: 2000;
    inset-block-start: .5rem;
    inset-inline-start: .5rem;
    transform: translateY(-150%);
    padding: .65rem 1rem;
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--navy-950);
    box-shadow: var(--shadow-lg);
}
.skip-link:focus { transform: translateY(0); }

.ui-icon {
    display: inline-block;
    width: 1.2rem;
    height: 1.2rem;
    flex: 0 0 auto;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    vertical-align: -.18em;
}

.admin-shell {
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    min-height: 100vh;
    transition: grid-template-columns .22s ease;
}

.admin-sidebar {
    position: sticky;
    inset-block-start: 0;
    z-index: 1000;
    height: 100vh;
    min-width: 0;
    padding: 0;
    gap: 0;
    overflow: hidden;
    background:
        radial-gradient(circle at 15% 0%, rgba(28, 155, 158, .18), transparent 28%),
        linear-gradient(180deg, var(--navy-950), var(--navy-900));
    border-inline-end: 1px solid rgba(255, 255, 255, .08);
    box-shadow: 8px 0 30px rgba(5, 24, 42, .08);
}

.side-brand {
    min-height: var(--topbar-height);
    margin: 0;
    padding: .9rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 700;
    min-width: 0;
}
.side-brand-copy { min-width: 0; }
.side-brand-copy > span,
.side-brand small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.side-brand small {
    margin-top: .2rem;
    color: #8fa9be;
    font-size: .66rem;
    font-weight: 500;
}
.side-logo {
    width: 2.6rem;
    height: 2.6rem;
    padding: .2rem;
    border-radius: 10px;
}
.side-logo-mark {
    display: grid;
    place-items: center;
    padding: .55rem;
    background: linear-gradient(145deg, var(--foam), #5bd0c1);
    color: var(--navy-950);
}
.side-logo-mark .ui-icon { width: 1.45rem; height: 1.45rem; }
.sidebar-close {
    display: none;
    margin-inline-start: auto;
    border: 0;
    background: transparent;
    color: #fff;
    font-size: 1.75rem;
    line-height: 1;
    cursor: pointer;
}

.side-nav {
    display: block;
    flex: 1;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    padding: .7rem .65rem 1rem;
    scrollbar-color: rgba(255,255,255,.2) transparent;
    scrollbar-width: thin;
}

.nav-group { margin-bottom: .25rem; }
.nav-group > summary {
    position: relative;
    display: flex;
    align-items: center;
    gap: .7rem;
    min-height: 2.45rem;
    padding: .55rem .65rem;
    border-radius: 8px;
    color: #8fa9be;
    cursor: pointer;
    list-style: none;
    font-size: .69rem;
    font-weight: 700;
    letter-spacing: .085em;
    text-transform: uppercase;
    user-select: none;
}
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-group > summary:hover { background: rgba(255,255,255,.05); color: #d8e4ed; }
.nav-group-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-chevron {
    width: .9rem;
    height: .9rem;
    margin-inline-start: auto;
    transition: transform .18s ease;
}
.nav-group[open] .nav-chevron { transform: rotate(90deg); }
html[dir="rtl"] .nav-group[open] .nav-chevron { transform: rotate(-90deg); }

.nav-group-items {
    display: grid;
    gap: .18rem;
    padding: .15rem 0 .45rem;
}
.side-nav a {
    display: flex;
    align-items: center;
    gap: .75rem;
    min-height: 2.65rem;
    padding: .62rem .7rem .62rem 1.05rem;
    border: 1px solid transparent;
    border-radius: 8px;
    color: #bfd0de;
    font-size: .88rem;
    font-weight: 500;
    white-space: nowrap;
}
html[dir="rtl"] .side-nav a { padding: .62rem 1.05rem .62rem .7rem; }
.side-nav a .ui-icon { width: 1.08rem; height: 1.08rem; color: #80a0b7; }
.side-nav a:hover {
    background: rgba(255,255,255,.07);
    color: #fff;
    text-decoration: none;
}
.side-nav a.active {
    background: linear-gradient(100deg, rgba(26, 151, 151, .28), rgba(26, 151, 151, .12));
    border-color: rgba(91, 208, 193, .22);
    box-shadow: inset 3px 0 0 #4bc6b7;
    color: #fff;
}
html[dir="rtl"] .side-nav a.active { box-shadow: inset -3px 0 0 #4bc6b7; }
.side-nav a.active .ui-icon { color: #62d5c7; }
.nav-item-label { overflow: hidden; text-overflow: ellipsis; }
.nav-count {
    float: none;
    margin-inline-start: auto;
    min-width: 1.3rem;
    background: #d94c56;
    font-variant-numeric: tabular-nums;
}

.sidebar-foot {
    flex: 0 0 auto;
    padding: .6rem;
    border-top: 1px solid rgba(255,255,255,.08);
}
.sidebar-foot form { margin: 0; }
.sidebar-collapse,
.logout {
    display: flex;
    align-items: center;
    gap: .75rem;
    width: 100%;
    margin: 0;
    padding: .65rem .75rem;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #9db3c5;
    font-size: .84rem;
    font-weight: 600;
    cursor: pointer;
    text-align: start;
    white-space: nowrap;
}
.sidebar-collapse:hover, .logout:hover { background: rgba(255,255,255,.06); color: #fff; }
.logout { color: #efa9ad; }

.sidebar-collapsed .admin-shell { grid-template-columns: var(--sidebar-collapsed) minmax(0, 1fr); }
.sidebar-collapsed .side-brand { justify-content: center; padding-inline: .5rem; }
.sidebar-collapsed .side-brand-copy,
.sidebar-collapsed .nav-group-label,
.sidebar-collapsed .nav-chevron,
.sidebar-collapsed .nav-item-label,
.sidebar-collapsed .sidebar-foot span,
.sidebar-collapsed .side-nav .nav-count { display: none; }
.sidebar-collapsed .side-nav { padding-inline: .6rem; overflow: visible; }
.sidebar-collapsed .nav-group > summary { justify-content: center; padding-inline: .5rem; }
.sidebar-collapsed .nav-group-items { padding-block-end: .25rem; }
.sidebar-collapsed .side-nav a {
    justify-content: center;
    padding: .65rem;
    box-shadow: none;
}
.sidebar-collapsed .side-nav a.active { background: rgba(26, 151, 151, .3); box-shadow: inset 0 -2px 0 #4bc6b7; }
.sidebar-collapsed .sidebar-collapse,
.sidebar-collapsed .logout { justify-content: center; padding-inline: .5rem; }
.sidebar-collapsed .sidebar-collapse .ui-icon { transform: rotate(180deg); }
html[dir="rtl"] .sidebar-collapsed .sidebar-collapse .ui-icon { transform: rotate(-180deg); }

.admin-main { min-width: 0; }
.topbar {
    position: sticky;
    inset-block-start: 0;
    z-index: 900;
    min-height: var(--topbar-height);
    height: auto;
    padding: .7rem clamp(1rem, 2vw, 1.75rem);
    gap: 1rem;
    background: rgba(255,255,255,.94);
    box-shadow: 0 1px 0 var(--line), 0 8px 24px rgba(15, 42, 66, .035);
}
@supports (backdrop-filter: blur(12px)) {
    .topbar { background: rgba(255,255,255,.86); backdrop-filter: blur(14px); }
}
.topbar-leading { display: flex; align-items: center; gap: .75rem; min-width: 0; }
.topbar h1 {
    overflow: hidden;
    margin: 0;
    font-family: var(--font-body);
    font-size: clamp(1.15rem, 2vw, 1.4rem);
    font-weight: 700;
    letter-spacing: -.02em;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.breadcrumbs {
    display: flex;
    align-items: center;
    gap: .35rem;
    margin-bottom: .05rem;
    color: var(--muted);
    font-size: .7rem;
}
.breadcrumbs a { color: var(--accent-strong); }
.mobile-menu {
    display: none;
    place-items: center;
    width: 2.55rem;
    height: 2.55rem;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: #fff;
    color: var(--ink);
    cursor: pointer;
}
.topbar-meta { gap: .65rem; min-width: 0; }
.school-switcher,
.school-context {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    max-width: 17rem;
    margin: 0;
    padding: .38rem .55rem;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--surface-subtle);
    color: var(--ink-soft);
    font-size: .82rem;
}
.school-switcher select {
    max-width: 13rem;
    min-width: 7rem;
    padding: .15rem 1.6rem .15rem .15rem;
    border: 0;
    outline: 0;
    background-color: transparent;
    color: var(--ink);
    font-weight: 600;
}
html[dir="rtl"] .school-switcher select { padding: .15rem .15rem .15rem 1.6rem; }
.school-context { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-icon {
    position: relative;
    display: grid;
    place-items: center;
    width: 2.55rem;
    height: 2.55rem;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: #fff;
    color: var(--ink-soft);
}
.topbar-icon:hover { border-color: var(--accent); color: var(--accent-strong); text-decoration: none; }
.topbar-icon .nav-count { position: absolute; inset-block-start: -.3rem; inset-inline-end: -.35rem; }

.user-menu { position: relative; }
.user-menu > summary {
    display: flex;
    align-items: center;
    gap: .55rem;
    padding: .25rem .4rem .25rem .25rem;
    border: 1px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    list-style: none;
}
html[dir="rtl"] .user-menu > summary { padding: .25rem .25rem .25rem .4rem; }
.user-menu > summary::-webkit-details-marker { display: none; }
.user-menu[open] > summary,
.user-menu > summary:hover { border-color: var(--line); background: var(--surface-subtle); }
.avatar {
    display: grid;
    place-items: center;
    width: 2.4rem;
    height: 2.4rem;
    border-radius: 50%;
    background: linear-gradient(145deg, var(--navy-800), var(--accent-strong));
    color: #fff;
    font-size: .74rem;
    font-weight: 700;
    letter-spacing: .03em;
}
.user-identity { display: grid; max-width: 11rem; line-height: 1.25; }
.user-identity strong { overflow: hidden; color: var(--ink); font-size: .82rem; text-overflow: ellipsis; white-space: nowrap; }
.user-identity small { overflow: hidden; color: var(--muted); font-size: .68rem; text-overflow: ellipsis; white-space: nowrap; }
.user-chevron { width: .8rem; height: .8rem; transform: rotate(90deg); }
.user-menu[open] .user-chevron { transform: rotate(-90deg); }
.user-menu-popover {
    position: absolute;
    inset-block-start: calc(100% + .55rem);
    inset-inline-end: 0;
    z-index: 1100;
    width: 220px;
    padding: .45rem;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: #fff;
    box-shadow: var(--shadow-lg);
}
.user-menu-popover a,
.user-menu-popover button {
    display: flex;
    align-items: center;
    gap: .65rem;
    width: 100%;
    padding: .65rem .7rem;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--ink-soft);
    font: inherit;
    font-size: .84rem;
    text-align: start;
    cursor: pointer;
}
.user-menu-popover a:hover,
.user-menu-popover button:hover { background: var(--surface-subtle); color: var(--accent-strong); text-decoration: none; }
.user-menu-popover form { margin: .25rem 0 0; padding-top: .25rem; border-top: 1px solid var(--line); }

.content {
    width: 100%;
    max-width: 1800px;
    margin: 0 auto;
    padding: clamp(1rem, 2.2vw, 2rem);
}
.admin-footer { padding: 1rem clamp(1rem, 2.2vw, 2rem); background: transparent; }

/* Common route components */
.welcome {
    padding: clamp(1.35rem, 3vw, 2rem);
    border: 1px solid rgba(91,208,193,.2);
    border-radius: 14px;
    background:
        radial-gradient(circle at 90% 10%, rgba(75,198,183,.25), transparent 25%),
        linear-gradient(120deg, var(--navy-950), #103954 70%, #0d6670);
    box-shadow: 0 14px 34px rgba(5,24,42,.16);
}
.welcome::after { width: 13rem; height: 13rem; border-color: rgba(255,255,255,.1); }
.welcome h2 { font-family: var(--font-body); font-size: clamp(1.4rem, 3vw, 1.9rem); font-weight: 700; letter-spacing: -.025em; }

.stat-grid, .stats-grid { gap: 1rem; }
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
    margin: 1.25rem 0;
}
.stat, .stat-card, .panel {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.stat, .stat-card {
    position: relative;
    min-width: 0;
    padding: 1.2rem;
    overflow: hidden;
    background: var(--surface);
}
.stat::before, .stat-card::before {
    content: "";
    position: absolute;
    inset-block: 0;
    inset-inline-start: 0;
    width: 3px;
    background: linear-gradient(var(--accent), #55c8ba);
}
.stat strong, .stat-card strong {
    display: block;
    margin-bottom: .2rem;
    color: var(--ink);
    font-family: var(--font-body);
    font-size: clamp(1.55rem, 3vw, 2rem);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.stat span, .stat-card span { color: var(--muted); font-size: .79rem; font-weight: 600; text-transform: uppercase; letter-spacing: .045em; }
.stat a { font-weight: 600; }

.panel { background: var(--surface); overflow: hidden; }
.panel > h2, .panel > h3, .panel > p, .panel > form:not(.flush) { margin-inline: 1.2rem; }
.panel > h2, .panel > h3 { margin-block-start: 1.2rem; }
.panel-head { min-height: 3.7rem; padding: .9rem 1.2rem; border-bottom: 1px solid var(--line); background: linear-gradient(#fff, #fbfcfd); }
.panel-head h2, .panel-head h3 { margin: 0; color: var(--ink); font-family: var(--font-body); font-size: 1rem; font-weight: 700; }

.toolbar {
    min-height: 3.5rem;
    margin-bottom: 1rem;
    padding: .75rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(255,255,255,.78);
    box-shadow: 0 4px 14px rgba(15,42,66,.035);
}
.toolbar form { min-width: 0; }
.toolbar-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .55rem;
    align-items: center;
    margin-inline-start: auto;
}
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: .55rem;
    align-items: center;
    padding: .75rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(255,255,255,.7);
}
.filter-bar input,
.filter-bar select {
    min-height: 2.5rem;
    min-width: 10rem;
    flex: 1 1 10rem;
}

.btn, button.btn, .button, button:not([class]):not(.logout):not(.sidebar-close):not(.sidebar-collapse):not(.mobile-menu) {
    min-height: 2.5rem;
    padding: .58rem .9rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: var(--accent-strong);
    color: #fff;
    font-weight: 650;
    box-shadow: 0 2px 5px rgba(11,101,112,.12);
}
.button { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.btn:hover, button.btn:hover, .button:hover, button:not([class]):hover {
    background: #084f58;
    color: #fff;
    text-decoration: none;
}
.btn.secondary, .button.secondary { background: var(--navy-800); color: #fff; }
.btn.ghost {
    border-color: var(--line-strong);
    background: #fff;
    color: var(--ink-soft);
    box-shadow: none;
}
.btn.ghost:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-strong); }
.danger-btn, .btn.danger, button.danger { background: var(--danger); color: #fff; }
.actions { display: flex; align-items: center; gap: .55rem; flex-wrap: wrap; margin: 1rem 1.2rem; }

input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
select, textarea {
    max-width: 100%;
    min-height: 2.55rem;
    padding: .58rem .72rem;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--ink);
    transition: border-color .15s, box-shadow .15s;
}
input:not([type="checkbox"]):not([type="radio"]):focus,
select:focus, textarea:focus {
    border-color: var(--accent);
    outline: 0;
    box-shadow: 0 0 0 3px rgba(19,131,140,.13);
}
input:disabled, select:disabled, textarea:disabled { background: #edf1f4; color: #718394; cursor: not-allowed; }
.record-form input, .record-form select, .record-form textarea { padding: .63rem .75rem; border-color: var(--line-strong); }
.record-form label { color: var(--ink-soft); }

.table-wrap {
    max-width: 100%;
    overflow: auto;
    overscroll-behavior-inline: contain;
    scrollbar-color: #a9b9c7 #edf2f5;
    scrollbar-width: thin;
}
.table-wrap table { min-width: max-content; }
table { font-size: .86rem; }
th, td { padding: .75rem .9rem; border-bottom-color: #e7edf2; }
th {
    position: sticky;
    inset-block-start: 0;
    z-index: 1;
    background: #f3f6f9;
    color: #52697d;
    font-size: .68rem;
    font-weight: 700;
}
tbody tr { transition: background .12s; }
tbody tr:hover td { background: #f7fafb; }
tbody tr:last-child td { border-bottom: 0; }
td code { padding: .16rem .3rem; border-radius: 4px; background: #edf2f6; color: var(--navy-800); }

.badge, .status-pill {
    border: 1px solid currentColor;
    border-color: color-mix(in srgb, currentColor 18%, transparent);
    font-size: .66rem;
    line-height: 1.35;
}
.pagination { justify-content: flex-end; border-top: 1px solid var(--line); }
.pagination a { border-radius: 7px; background: #fff; }

.alert {
    position: relative;
    padding: .8rem 1rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    line-height: 1.45;
}
.alert.success { border-color: #a9dbc4; background: #e8f7ef; }
.alert.danger { border-color: #efb6b2; background: #fff0ef; }
.alert.warning { border-color: #efd48e; background: #fff8df; }

.history-tabs { gap: .5rem; padding-top: .75rem; }
.history-tab { border: 1px solid var(--line); background: #fff; }
.history-tab.is-active { border-color: var(--brand); background: var(--brand); }
details:not(.nav-group):not(.user-menu) { border-radius: var(--radius-sm); }
details:not(.nav-group):not(.user-menu) > summary { cursor: pointer; font-weight: 650; }
dialog, .modal {
    max-width: min(640px, calc(100vw - 2rem));
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
    box-shadow: var(--shadow-lg);
}
dialog::backdrop, .modal-backdrop { background: rgba(5,24,42,.62); backdrop-filter: blur(2px); }
.empty-state, td[colspan] {
    color: var(--muted);
}
.empty-state { padding: 2.5rem 1.25rem; text-align: center; }

.form-panel { padding: 1.5rem; }
.details div { border: 1px solid #e2e9ef; background: var(--surface-subtle); }
.code-block { border: 1px solid #173952; background: var(--navy-950); }

@media (max-width: 1280px) {
    :root { --sidebar-width: 265px; }
    .stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .user-identity { display: none; }
}

@media (max-width: 1100px) {
    .admin-shell, .sidebar-collapsed .admin-shell { grid-template-columns: minmax(0, 1fr); }
    .admin-sidebar {
        position: fixed;
        inset-block: 0;
        inset-inline-start: 0;
        width: min(320px, calc(100vw - 3.5rem));
        height: 100dvh;
        transform: translateX(-105%);
        transition: transform .24s ease;
        box-shadow: var(--shadow-lg);
    }
    html[dir="rtl"] .admin-sidebar { transform: translateX(105%); }
    .sidebar-open .admin-sidebar { transform: translateX(0); }
    .sidebar-open { overflow: hidden; }
    .sidebar-backdrop {
        position: fixed;
        z-index: 990;
        inset: 0;
        background: rgba(5,24,42,.58);
        backdrop-filter: blur(2px);
    }
    .sidebar-backdrop[hidden] { display: none; }
    .sidebar-close { display: block; }
    .sidebar-collapse { display: none; }
    .sidebar-collapsed .side-brand-copy,
    .sidebar-collapsed .nav-group-label,
    .sidebar-collapsed .nav-chevron,
    .sidebar-collapsed .nav-item-label,
    .sidebar-collapsed .sidebar-foot span,
    .sidebar-collapsed .side-nav .nav-count { display: block; }
    .sidebar-collapsed .side-nav { padding: .7rem .65rem 1rem; overflow-y: auto; }
    .sidebar-collapsed .nav-group > summary,
    .sidebar-collapsed .side-nav a,
    .sidebar-collapsed .logout { justify-content: flex-start; padding-inline: .7rem; }
    .sidebar-collapsed .side-nav a.active { box-shadow: inset 3px 0 0 #4bc6b7; }
    html[dir="rtl"] .sidebar-collapsed .side-nav a.active { box-shadow: inset -3px 0 0 #4bc6b7; }
    .mobile-menu { display: grid; }
    .topbar { padding-inline: 1rem; }
    .topbar-meta { margin-inline-start: auto; }
}

@media (max-width: 760px) {
    :root { --topbar-height: 68px; }
    .content { padding: 1rem; }
    .breadcrumbs { display: none; }
    .topbar h1 { font-size: 1.08rem; }
    .school-switcher--topbar { max-width: 10rem; }
    .school-switcher--topbar .ui-icon { display: none; }
    .school-switcher--topbar select { max-width: 8.5rem; font-size: .76rem; }
    .school-context { display: none; }
    .user-menu > summary { padding: .15rem; }
    .user-chevron { display: none; }
    .topbar-icon { width: 2.35rem; height: 2.35rem; }
    .avatar { width: 2.25rem; height: 2.25rem; }
    .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .toolbar { align-items: stretch; }
    .toolbar form { width: 100%; }
    .toolbar input, .toolbar select, .toolbar .btn { flex: 1 1 9rem; }
    .panel-head { align-items: flex-start; }
    .form-panel { padding: 1rem; }
    .welcome .btn { position: static; margin-top: 1rem; }
    .actions { margin-inline: 1rem; }
}

@media (max-width: 480px) {
    .topbar { gap: .4rem; }
    .topbar-leading { gap: .45rem; }
    .mobile-menu { width: 2.3rem; height: 2.3rem; }
    .school-switcher--topbar { display: none; }
    .stat-grid { grid-template-columns: 1fr; }
    .stat, .stat-card { padding: 1rem; }
    .panel-grid { gap: .75rem; }
    .inline-actions { width: 100%; }
    .inline-actions .btn { flex: 1 1 auto; }
    .user-menu-popover { position: fixed; inset-inline: 1rem; inset-block-start: 4.25rem; width: auto; }
}

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

@media print {
    body { background: #fff !important; color: #000; }
    .admin-sidebar, .sidebar-backdrop, .topbar, .admin-footer, .toolbar, .pagination, .no-print,
    .admin-connectivity-banner { display: none !important; }
    .admin-shell, .sidebar-collapsed .admin-shell { display: block; }
    .content { max-width: none; padding: 0; }
    .panel, .stat, .stat-card { break-inside: avoid; box-shadow: none; border: 1px solid #bbb; }
    .table-wrap { overflow: visible; }
    .table-wrap table { min-width: 0; }
    th { position: static; }
    a { color: #000; text-decoration: none; }
}

/* —— v2.1 mobile admin: connectivity, school switch, list cards —— */
.admin-connectivity-banner {
    display: none;
    position: sticky;
    inset-block-start: 0;
    z-index: 1200;
    padding: .55rem 1rem;
    background: #16324f;
    color: #f7fafc;
    text-align: center;
    font-size: .9rem;
    font-weight: 600;
}
body.is-offline .admin-connectivity-banner { display: block; }
body.is-offline .admin-connectivity-banner[hidden] { display: block; }

body.is-offline form[method="post"] button[type="submit"]:disabled,
body.is-offline form[method="post"] input[type="submit"]:disabled,
body.is-offline button.btn.danger:disabled,
body.is-offline [data-requires-online]:disabled {
    opacity: .55;
    cursor: not-allowed;
}

.sidebar-school-switch {
    display: none;
    margin: 0 .85rem .35rem;
    padding: .75rem;
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 10px;
    background: rgba(255, 255, 255, .05);
}
.sidebar-school-label {
    margin: 0 0 .45rem;
    color: rgba(255, 255, 255, .72);
    font-size: .72rem;
    font-weight: 650;
    letter-spacing: .04em;
    text-transform: uppercase;
}
.sidebar-school-context {
    display: none;
    align-items: center;
    gap: .5rem;
    color: #e8eef4;
    font-size: .88rem;
    font-weight: 600;
}
.school-switcher--drawer {
    display: flex;
    max-width: none;
    width: 100%;
    padding: .45rem .55rem;
    border-color: rgba(255, 255, 255, .18);
    background: rgba(7, 28, 48, .55);
    color: #fff;
}
.school-switcher--drawer select {
    flex: 1;
    max-width: none;
    min-width: 0;
    width: 100%;
    color: #fff;
    font-size: .92rem;
}
.school-switcher--drawer select option { color: #0a2540; }
.school-switcher--drawer .ui-icon { color: #4bc6b7; flex-shrink: 0; }

@media (max-width: 1100px) {
    .sidebar-school-switch,
    .sidebar-school-context { display: block; }
    .sidebar-school-context { display: flex; }
    .school-switcher--drawer { display: flex; }
}

@media (min-width: 1101px) {
    .sidebar-school-switch,
    .sidebar-school-context { display: none !important; }
}

@media (max-width: 760px) {
    .school-switcher--topbar {
        max-width: min(11rem, 38vw);
    }
    .school-switcher--topbar select {
        max-width: 9rem;
        font-size: .78rem;
    }
    .admin-list-cards thead { display: none; }
    .admin-list-cards table,
    .admin-list-cards tbody,
    .admin-list-cards tr,
    .admin-list-cards td {
        display: block;
        width: 100%;
    }
    .admin-list-cards .table-wrap,
    .table-wrap.admin-list-cards {
        overflow: visible;
    }
    .admin-list-cards table { min-width: 0; border-collapse: separate; border-spacing: 0; }
    .admin-list-cards tr {
        margin-bottom: .8rem;
        padding: .7rem .8rem;
        border: 1px solid var(--line);
        border-radius: 12px;
        background: #fff;
        box-shadow: 0 6px 18px rgba(15, 42, 66, .04);
    }
    .admin-list-cards td {
        display: grid;
        grid-template-columns: minmax(5.5rem, 34%) 1fr;
        gap: .55rem;
        align-items: start;
        padding: .4rem 0;
        border: 0;
        border-bottom: 1px solid rgba(15, 42, 66, .06);
    }
    .admin-list-cards td:last-child { border-bottom: 0; }
    .admin-list-cards td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: .72rem;
        font-weight: 700;
        letter-spacing: .03em;
        text-transform: uppercase;
    }
    .admin-list-cards td.inline-actions,
    .admin-list-cards td[data-label="Actions"] {
        display: flex;
        flex-wrap: wrap;
        gap: .55rem;
        padding-top: .65rem;
    }
    .admin-list-cards td.inline-actions::before,
    .admin-list-cards td[data-label="Actions"]::before { display: none; }
    .admin-list-cards td[data-label="Select"] {
        grid-template-columns: auto 1fr;
        align-items: center;
    }
    .admin-list-cards td[colspan] {
        display: block;
        text-align: center;
        color: var(--muted);
    }
    .admin-list-cards td[colspan]::before { display: none; }
}

@media (max-width: 480px) {
    .studio-stage-scroll {
        margin-inline: -.35rem;
        padding: .5rem;
        -webkit-overflow-scrolling: touch;
    }
    .cert-el-resize {
        width: 22px;
        height: 22px;
    }
}


.studio-layer-row.is-active {
    background: rgba(31, 122, 111, 0.08);
    border-radius: 4px;
}

.cert-preview-sheet .cert-design-canvas + .cert-design-canvas {
    margin-top: 1.5rem;
}

.studio-stage-scroll #studio-zoom-wrap {
    display: inline-block;
}
