:root {
    --app-bg: #f3f4f6;
    --app-bg-soft: #f8fafc;
    --app-surface: #ffffff;
    --app-surface-strong: #ffffff;
    --app-ink: #22323d;
    --app-muted: #61717e;
    --app-border: rgba(34, 50, 61, 0.12);
    --app-border-strong: rgba(34, 50, 61, 0.18);
    --app-shadow: none;
    --app-accent: #a45420;
    --app-accent-dark: #853d12;
    --app-link: #0f6572;
    --app-success: #287458;
    --app-warning: #a86508;
    --app-danger: #b94c43;
    --app-radius-xl: 0;
    --app-radius-lg: 0;
    --app-radius-md: 0;
    --app-radius-sm: 0;
    --app-shell-width: 1180px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    color: var(--app-ink);
    font-family: "Aptos", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    background: var(--app-bg);
    line-height: 1.6;
}

a {
    color: var(--app-link);
    transition: color 0.18s ease, opacity 0.18s ease;
}

a:hover {
    color: #0a4f59;
}

img {
    max-width: 100%;
}

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

::placeholder {
    color: #8d9aa4;
}

:focus-visible {
    outline: 3px solid rgba(15, 101, 114, 0.2);
    outline-offset: 2px;
}

.app-frame {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-main {
    flex: 1;
    padding: 0 0 32px;
}

.app-shell {
    width: min(calc(100% - 32px), var(--app-shell-width));
    margin: 0 auto;
}

.app-surface,
.app-empty-state {
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius-xl);
    box-shadow: var(--app-shadow);
}

.app-surface {
    padding: 20px;
    margin-bottom: 16px;
}

.app-content-muted,
.app-content-muted p,
.app-card-text,
.app-page-subtitle,
.app-empty-state-text,
.app-field-help {
    color: var(--app-muted);
}

.app-card-heading {
    margin-bottom: 12px;
}

.app-card-kicker {
    margin: 0 0 6px;
    font-size: 0.8rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--app-accent);
}

.app-card-text {
    margin: 0;
}

.app-form-section + .app-form-section {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--app-border);
}

.app-field-help {
    margin: 0;
    font-size: 0.86rem;
}

.app-inline-feedback {
    margin-top: 6px;
    font-weight: 600;
}

.app-pagination {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 10px;
    align-items: center;
    margin: 14px 0 20px;
}

.app-pagination-summary {
    color: var(--app-muted);
    font-size: 0.94rem;
}

.app-pagination-links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.app-pagination-gap {
    padding: 0 4px;
    color: var(--app-muted);
    font-weight: 700;
}

.event-card {
    margin-bottom: 14px;
}

.event-card-top {
    display: flex;
    justify-content: space-between;
    gap: 14px;
}

.event-card-heading {
    flex: 1;
    min-width: 0;
}

.event-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}

.event-card-title {
    margin: 0;
    font-size: 1.25rem;
    line-height: 1.25;
}

.event-card-subtitle {
    margin: 4px 0 0;
    color: var(--app-muted);
    font-weight: 600;
}

.event-card-admin-action {
    display: flex;
    align-items: flex-start;
}

.event-card-meta-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin: 16px 0 14px;
}

.event-meta-item {
    padding: 10px 12px;
    border-radius: 0;
    background: #f8fafc;
    border: 1px solid rgba(34, 50, 61, 0.1);
}

.event-meta-label {
    display: block;
    margin-bottom: 4px;
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--app-muted);
}

.event-meta-value {
    color: var(--app-ink);
}

.event-card-description {
    margin: 0;
    color: var(--app-muted);
}

.event-card-footer {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid rgba(34, 50, 61, 0.08);
}

.event-card-support {
    min-width: 0;
}

.event-card-actions {
    justify-content: flex-end;
    margin: 0;
}

.app-qr-display {
    display: grid;
    gap: 16px;
    justify-items: center;
    text-align: center;
}

.app-qr-code {
    display: inline-block;
    padding: 10px;
    border-radius: 0;
    border: 1px solid rgba(34, 50, 61, 0.14);
    background: #ffffff;
}

.app-qr-code table.qr {
    border-collapse: collapse;
    table-layout: fixed;
}

.app-qr-code table.qr td {
    width: 6px;
    height: 6px;
    padding: 0;
    border: 0;
    font-size: 0;
    line-height: 0;
}

.app-qr-code table.qr td.on {
    background: #000000;
}

.app-qr-code table.qr td.off {
    background: #ffffff;
}

.app-qr-code-large table.qr td {
    width: 10px;
    height: 10px;
}

.app-qr-details {
    width: 100%;
    min-width: 0;
}

.app-editable {
    display: inline-block;
    margin-top: 4px;
    padding: 5px 8px;
    min-width: 210px;
    border-radius: 0;
    border: 1px dashed rgba(15, 101, 114, 0.22);
    background: rgba(15, 101, 114, 0.05);
    color: var(--app-link);
    transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease;
    cursor: text;
}

.app-editable:hover,
.app-editable:focus {
    background: rgba(15, 101, 114, 0.08);
    border-color: rgba(15, 101, 114, 0.4);
}

.app-editable.app-editable-saving {
    color: var(--app-muted);
    background: rgba(34, 50, 61, 0.06);
    border-color: rgba(34, 50, 61, 0.22);
}

.app-editable.app-editable-success {
    color: var(--app-success);
    background: rgba(40, 116, 88, 0.08);
    border-color: rgba(40, 116, 88, 0.24);
}

.app-editable.app-editable-error {
    color: var(--app-danger);
    background: rgba(185, 76, 67, 0.08);
    border-color: rgba(185, 76, 67, 0.24);
}

.app-feedback-zone {
    margin-bottom: 12px;
}

.app-notification {
    border-radius: 0;
    box-shadow: none;
    border: 1px solid rgba(34, 50, 61, 0.08);
}

.app-notification + .app-notification {
    margin-top: 8px;
}

.app-notification-content {
    padding-right: 16px;
}

.app-empty-state {
    padding: 24px 20px;
    text-align: center;
}

.app-empty-state-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 12px;
    border-radius: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    color: var(--app-accent);
    background: rgba(164, 84, 32, 0.1);
}

.app-empty-state-action {
    margin-top: 14px;
}

.app-toast-stack {
    position: fixed;
    top: 14px;
    right: 14px;
    z-index: 40;
    width: min(360px, calc(100vw - 24px));
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.app-toast {
    pointer-events: auto;
    margin: 0;
    border-radius: 0;
    box-shadow: none;
    animation: app-toast-slide 0.2s ease;
}

.app-toast.app-is-closing,
.app-notification.app-is-closing {
    opacity: 0;
    transform: translateY(-6px);
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.app-scroll-top {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 25;
    display: none;
    box-shadow: none;
}

.app-footer {
    padding: 0 0 18px;
}

.app-footer-content {
    padding: 16px 18px;
    border-radius: var(--app-radius-lg);
    border: 1px solid rgba(34, 50, 61, 0.08);
    background: #ffffff;
    box-shadow: none;
}

.app-footer-brand {
    margin: 0 0 4px;
    font-weight: 800;
}

.app-footer-copy {
    margin: 0;
    color: var(--app-muted);
}

.app-state-block {
    padding: 10px 12px;
    border-radius: 0;
    border: 1px solid rgba(34, 50, 61, 0.08);
    background: #ffffff;
}

[data-certificate-template-editor],
[data-certificate-signature-editor] {
    min-width: 0;
    max-width: 100%;
}

[data-certificate-template-editor] > section,
[data-certificate-signature-editor] > section,
[data-certificate-template-editor] [data-certificate-preview-card],
[data-certificate-template-editor] [data-certificate-block-sidebar],
[data-certificate-template-editor] [data-certificate-block-panel],
[data-certificate-template-editor] [data-certificate-preview-scroll],
[data-certificate-template-editor] [data-certificate-preview-viewport],
[data-certificate-template-editor] [data-certificate-stage],
[data-certificate-signature-editor] [data-certificate-signature-source-panel] {
    min-width: 0;
    max-width: 100%;
}

[data-certificate-template-editor] [data-certificate-preview-scroll] {
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
}

[data-certificate-template-editor] [data-certificate-stage] {
    overflow: hidden;
}

@keyframes app-toast-slide {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media screen and (max-width: 1023px) {
    .event-card-top,
    .event-card-footer {
        grid-template-columns: 1fr;
        display: grid;
    }

    .event-card-actions {
        justify-content: flex-start;
    }

    .event-card-meta-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media screen and (max-width: 768px) {
    .app-shell {
        width: min(calc(100% - 24px), var(--app-shell-width));
    }

    .app-main {
        padding-bottom: 24px;
    }

    .app-surface,
    .app-empty-state {
        padding: 16px;
    }

    .event-card-actions,
    .app-pagination {
        flex-direction: column;
        align-items: stretch;
    }

    .event-card-meta-grid {
        grid-template-columns: 1fr;
    }

    .app-toast-stack {
        left: 12px;
        right: 12px;
        top: 12px;
        width: auto;
    }

    .app-scroll-top {
        right: 16px;
        bottom: 16px;
    }

    [data-certificate-template-editor] [data-certificate-preview-scroll] {
        padding: 8px;
    }
}

@media screen and (max-width: 560px) {
    .event-meta-item {
        width: 100%;
    }

    .app-qr-code {
        padding: 8px;
    }

    .app-qr-code table.qr td,
    .app-qr-code-large table.qr td {
        width: 5px;
        height: 5px;
    }

    .app-editable {
        min-width: 0;
        width: 100%;
    }

    .app-footer-content {
        padding: 18px 20px;
    }
}
