:root {
    --bg: #f4f7fb;
    --panel: #ffffff;
    --ink: #172033;
    --muted: #68758a;
    --line: #dce3ee;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #0f9f6e;
    --warning: #b7791f;
    --danger: #dc2626;
    --shadow: 0 20px 50px rgba(23, 32, 51, 0.10);
    --radius: 18px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--ink);
    background: var(--bg);
}

a {
    color: inherit;
}

code {
    display: inline-block;
    padding: 0.2rem 0.45rem;
    border-radius: 8px;
    background: #eef3fb;
    color: #1f3a5f;
    font-size: 0.86rem;
    word-break: break-all;
}

.admin-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 28px;
    display: flex;
    flex-direction: column;
    gap: 28px;
    background: #111827;
    color: #fff;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    font-weight: 800;
}

.brand-large {
    justify-content: center;
    margin-bottom: 20px;
}

.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 14px;
    background: linear-gradient(135deg, #3b82f6, #14b8a6);
    color: #fff;
    font-weight: 900;
}

.nav {
    display: grid;
    gap: 8px;
}

.nav a,
.ghost-button,
.secondary-button,
.primary-button,
.danger-button {
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 0;
    border-radius: 12px;
    padding: 0.75rem 1rem;
    font: inherit;
    font-weight: 750;
    text-decoration: none;
    cursor: pointer;
    transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.nav a {
    justify-content: flex-start;
    color: #cbd5e1;
}

.nav a:hover,
.ghost-button:hover {
    background: rgba(255, 255, 255, 0.08);
}

.logout-form {
    margin-top: auto;
}

.ghost-button {
    background: transparent;
    color: inherit;
    border: 1px solid var(--line);
}

.sidebar .ghost-button {
    width: 100%;
    border-color: rgba(255, 255, 255, 0.18);
    color: #fff;
}

.primary-button {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 12px 24px rgba(37, 99, 235, 0.24);
}

.primary-button:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.secondary-button {
    background: #e8eef8;
    color: #1f3a5f;
}

.danger-button {
    background: var(--danger);
    color: #fff;
}

.full-width {
    width: 100%;
}

.main-panel {
    padding: 34px;
}

.page-header {
    margin-bottom: 24px;
}

.page-header h1,
.verify-card h1,
.login-card h1 {
    margin: 0;
    font-size: clamp(2rem, 4vw, 3.25rem);
    line-height: 1.05;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--primary);
    font-size: 0.75rem;
    font-weight: 900;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.muted {
    color: var(--muted);
    line-height: 1.65;
}

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

.stat-card,
.card,
.login-card,
.verify-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.stat-card {
    padding: 22px;
}

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

.stat-card strong {
    display: block;
    margin-top: 8px;
    font-size: 2.35rem;
}

.stat-card.valid {
    border-color: rgba(15, 159, 110, 0.28);
}

.stat-card.warning {
    border-color: rgba(183, 121, 31, 0.32);
}

.stat-card.danger {
    border-color: rgba(220, 38, 38, 0.28);
}

.card {
    padding: 24px;
    margin-bottom: 18px;
}

.split-card,
.section-heading,
.button-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.section-heading h2,
.card h2 {
    margin: 0;
    font-size: 1.35rem;
}

.detail-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.75fr);
    gap: 18px;
}

.narrow-card {
    max-width: 760px;
}

.form-stack,
.form-grid {
    display: grid;
    gap: 16px;
}

.form-grid {
    margin-top: 18px;
}

label span {
    display: block;
    margin-bottom: 8px;
    color: #334155;
    font-size: 0.92rem;
    font-weight: 800;
}

input,
textarea {
    width: 100%;
    min-height: 46px;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 0.85rem 0.95rem;
    color: var(--ink);
    background: #fff;
    font: inherit;
}

input:focus,
textarea:focus {
    outline: 3px solid rgba(37, 99, 235, 0.16);
    border-color: var(--primary);
}

.search-row,
.token-form {
    display: flex;
    gap: 10px;
    margin: 18px 0;
}

.search-row input,
.token-form input {
    flex: 1;
}

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

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 760px;
}

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

th {
    color: #475569;
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    border-radius: 999px;
    padding: 0.25rem 0.75rem;
    font-size: 0.78rem;
    font-weight: 900;
}

.badge-valid {
    background: rgba(15, 159, 110, 0.12);
    color: var(--success);
}

.badge-invalid,
.badge-not_found {
    background: rgba(183, 121, 31, 0.14);
    color: var(--warning);
}

.badge-revoked {
    background: rgba(220, 38, 38, 0.12);
    color: var(--danger);
}

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

.alert-success {
    background: rgba(15, 159, 110, 0.12);
    color: #047857;
}

.alert-error {
    background: rgba(220, 38, 38, 0.12);
    color: #b91c1c;
}

.alert-warning {
    background: rgba(183, 121, 31, 0.14);
    color: #92400e;
}

.text-link {
    color: var(--primary);
    font-weight: 850;
    text-decoration: none;
}

.text-link:hover {
    text-decoration: underline;
}

.break-link {
    overflow-wrap: anywhere;
}

.detail-list {
    display: grid;
    gap: 14px;
    margin: 22px 0;
}

.detail-list div {
    padding-bottom: 14px;
    border-bottom: 1px solid var(--line);
}

.detail-list dt {
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.detail-list dd {
    margin: 6px 0 0;
    font-weight: 760;
}

.qr-card {
    text-align: center;
}

.qr-preview {
    width: min(280px, 100%);
    height: auto;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: #fff;
}

.centered {
    justify-content: center;
}

.file-drop {
    display: grid;
    place-items: center;
    gap: 10px;
    min-height: 180px;
    padding: 24px;
    border: 2px dashed #b8c4d8;
    border-radius: 18px;
    background: #f8fbff;
    text-align: center;
}

.file-drop input {
    max-width: 340px;
}

.login-page,
.public-page {
    min-height: 100vh;
    background:
        radial-gradient(circle at top left, rgba(20, 184, 166, 0.22), transparent 32rem),
        radial-gradient(circle at bottom right, rgba(37, 99, 235, 0.18), transparent 30rem),
        #eef4fb;
}

.login-card,
.verify-card {
    width: min(92vw, 520px);
    padding: 34px;
}

.login-card {
    position: absolute;
    inset: 50% auto auto 50%;
    transform: translate(-50%, -50%);
}

.verify-hero {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 28px;
}

.verify-card {
    width: min(96vw, 760px);
    text-align: center;
}

.verification-result {
    position: relative;
    overflow: hidden;
}

.status-orb {
    width: 78px;
    height: 78px;
    margin: 0 auto 20px;
    border-radius: 999px;
}

.status-valid {
    background: radial-gradient(circle, #34d399, #059669);
}

.status-invalid,
.status-not_found {
    background: radial-gradient(circle, #fbbf24, #b45309);
}

.status-revoked {
    background: radial-gradient(circle, #fb7185, #dc2626);
}

.success-copy {
    color: #047857;
    font-weight: 850;
}

.warning-copy {
    color: #92400e;
    font-weight: 850;
}

.danger-copy {
    color: #b91c1c;
    font-weight: 850;
}

.public-details {
    max-width: 620px;
    margin-left: auto;
    margin-right: auto;
    text-align: left;
}

.not-found-box {
    display: grid;
    gap: 8px;
    margin: 22px auto;
    max-width: 520px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #f8fbff;
}

.not-found-box span {
    color: var(--muted);
    font-weight: 800;
}

.pdf-preview {
    width: 100%;
    min-height: 640px;
    margin-top: 22px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
}

.empty-state {
    padding: 26px;
    border-radius: 14px;
    background: #f8fbff;
    color: var(--muted);
    text-align: center;
    font-weight: 760;
}

.setup-checks {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin: 22px 0;
    text-align: left;
}

.setup-checks div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #f8fbff;
}

.setup-checks span {
    color: var(--muted);
    font-weight: 800;
}

.setup-checks strong {
    color: var(--primary);
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
    transform: none;
}

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

    .sidebar {
        position: static;
        height: auto;
        padding: 18px;
    }

    .nav {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .logout-form {
        margin-top: 0;
    }

    .stats-grid,
    .detail-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 700px) {
    .main-panel {
        padding: 18px;
    }

    .stats-grid,
    .detail-grid,
    .nav {
        grid-template-columns: 1fr;
    }

    .split-card,
    .section-heading,
    .button-row,
    .search-row,
    .token-form {
        align-items: stretch;
        flex-direction: column;
    }

    .login-card,
    .verify-card {
        padding: 24px;
    }

    .login-card {
        position: static;
        transform: none;
        margin: 30px auto;
    }

    .pdf-preview {
        min-height: 420px;
    }

    .setup-checks {
        grid-template-columns: 1fr;
    }
}
