* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    margin: 0;
    font-family: "Nunito Sans", "Segoe UI", Arial, sans-serif;
    background: linear-gradient(160deg, #0b3f61, #0f7ca3);
    min-height: 100vh;
    color: #1c3442;
    overflow-x: hidden;
}

.public-qr-page {
    width: min(680px, 94vw);
    margin: 0 auto;
    padding: 26px 0;
    display: grid;
    gap: 14px;
}

.public-qr-hero {
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.96);
    padding: 18px;
    box-shadow: 0 18px 36px rgba(5, 31, 52, 0.3);
}

.public-qr-eyebrow {
    margin: 0 0 6px;
    color: #457089;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

.public-qr-hero h1 {
    margin: 0;
    color: #103b53;
    font-size: 30px;
    line-height: 1.2;
}

.public-qr-hero p {
    margin: 9px 0 0;
    color: #406276;
    font-size: 15px;
}

.public-qr-alert {
    border-radius: 12px;
    padding: 12px 14px;
    border: 1px solid transparent;
    font-size: 14px;
    font-weight: 800;
    background: #ffffff;
}

.public-qr-alert-ok {
    color: #0f6d43;
    border-color: #9ad7b8;
}

.public-qr-alert-error {
    color: #a13049;
    border-color: #efb2c0;
}

.public-qr-meta {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.public-qr-meta div {
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid #d0e4ef;
    padding: 10px 12px;
}

.public-qr-meta span {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: #58798c;
    margin-bottom: 4px;
}

.public-qr-meta strong {
    color: #143f57;
    font-size: 16px;
}

.public-qr-card {
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.88);
    border: 1px solid #d0e5f1;
    box-shadow: 0 14px 30px rgba(9, 39, 62, 0.22);
    padding: 18px;
    backdrop-filter: blur(3px);
}

.public-qr-form {
    display: grid;
    gap: 10px;
}

.public-qr-site-gate-form h2 {
    margin: 0;
    color: #103b53;
    font-size: 24px;
    line-height: 1.2;
}

.public-qr-site-gate-note {
    margin: 0;
    color: #3f6277;
    font-size: 14px;
    font-weight: 700;
}

.public-qr-manager-btn {
    height: 58px;
    border-radius: 12px;
    border: 0;
    background: linear-gradient(125deg, #0f9ab3, #1365a0);
    color: #ffffff;
    font-size: 20px;
    font-weight: 900;
    letter-spacing: 0.02em;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    padding: 0 18px;
}

.public-qr-manager-card {
    display: grid;
    gap: 12px;
}

.public-qr-manager-auth-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border-radius: 12px;
    border: 1px solid #bfd6e4;
    background: #f2f8fc;
    padding: 10px 12px;
}

.public-qr-manager-auth-meta p {
    margin: 0;
    color: #1f4e66;
    font-size: 14px;
    font-weight: 700;
}

.public-qr-manager-logout-btn {
    height: 36px;
    border: 1px solid #bfd6e4;
    border-radius: 10px;
    background: #ffffff;
    color: #1f4e66;
    font-size: 13px;
    font-weight: 800;
    padding: 0 12px;
    cursor: pointer;
}

.public-qr-manager-auth-meta a.public-qr-manager-logout-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.public-qr-manager-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.public-qr-manager-site-btn {
    min-height: 88px;
    border-radius: 14px;
    border: 1px solid #bfd6e4;
    background: #f2f8fc;
    padding: 12px;
    text-decoration: none;
    color: #173f54;
    display: grid;
    align-content: center;
    gap: 3px;
    box-shadow: 0 6px 14px rgba(9, 39, 62, 0.08);
}

.public-qr-manager-site-btn strong {
    font-size: 20px;
}

.public-qr-manager-site-btn span {
    font-size: 14px;
    color: #3f6277;
    font-weight: 700;
}

.public-qr-mode-fieldset {
    margin: 0;
    padding: 0;
    border: 0;
    display: grid;
    gap: 8px;
}

.public-qr-mode-fieldset legend {
    padding: 0;
    font-size: 14px;
    font-weight: 800;
    color: #35586c;
}

.public-qr-mode-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.public-qr-mode-option {
    position: relative;
    border-radius: 12px;
    border: 1px solid #bfd6e4;
    background: #f2f8fc;
    min-height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 800;
    color: #1f4e66;
    cursor: pointer;
}

.public-qr-mode-option input {
    position: absolute;
    inset: 0;
    opacity: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    cursor: pointer;
}

.public-qr-mode-option:has(input:checked) {
    border-color: #0d8f7b;
    background: linear-gradient(130deg, #ddf8ef, #d4f1fb);
    box-shadow: 0 0 0 2px rgba(13, 143, 123, 0.14);
    color: #0a5e4f;
}

.public-qr-scan-btn {
    height: 52px;
    border: 0;
    border-radius: 12px;
    background: linear-gradient(125deg, #0f7a4f, #0a6e8f);
    color: #ffffff;
    font-size: 17px;
    font-weight: 800;
    cursor: pointer;
}

.public-qr-camera-wrap {
    border-radius: 12px;
    border: 1px solid #bfd6e4;
    background: #eef7fc;
    padding: 10px;
}

.public-qr-camera-wrap.is-hidden {
    display: none;
}

.public-qr-video {
    width: 100%;
    border-radius: 10px;
    background: #0f2f41;
    min-height: 220px;
    object-fit: cover;
}

.public-qr-camera-meta {
    margin-top: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    color: #2f5368;
    font-size: 13px;
    font-weight: 700;
}

.public-qr-camera-meta strong {
    font-size: 16px;
}

.public-qr-form label {
    font-size: 14px;
    font-weight: 800;
    color: #35586c;
}

.public-qr-form input {
    height: 62px;
    border-radius: 12px;
    border: 1px solid #bfd6e4;
    padding: 0 14px;
    font-size: 21px;
    color: #14374b;
}

.public-qr-form select {
    height: 62px;
    border-radius: 12px;
    border: 1px solid #bfd6e4;
    padding: 0 14px;
    font-size: 18px;
    color: #14374b;
    background: #ffffff;
}

.public-qr-form input:focus {
    outline: 0;
    border-color: #1f85bb;
    box-shadow: 0 0 0 3px rgba(31, 133, 187, 0.16);
}

.public-qr-form select:focus {
    outline: 0;
    border-color: #1f85bb;
    box-shadow: 0 0 0 3px rgba(31, 133, 187, 0.16);
}

.public-qr-form button {
    height: 64px;
    border: 0;
    border-radius: 12px;
    background: linear-gradient(125deg, #0f9ab3, #1365a0);
    color: #ffffff;
    font-size: 22px;
    font-weight: 900;
    cursor: pointer;
    letter-spacing: 0.02em;
}

.public-qr-field-error {
    margin: 0;
    font-size: 13px;
    font-weight: 700;
    color: #b1324f;
}

.public-qr-logs-card {
    margin-top: 10px;
}

.public-qr-logs-head {
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.public-qr-logs-title {
    margin: 0;
    font-size: 18px;
    color: #123a51;
}

.public-qr-clear-logs-btn {
    height: 34px;
    padding: 0 12px;
    border-radius: 10px;
    border: 1px solid #bfd6e4;
    background: #f2f8fc;
    color: #1f4e66;
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
}

.public-qr-logs-wrap {
    overflow-x: auto;
}

.public-qr-logs-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.public-qr-logs-table th {
    text-align: left;
    border-bottom: 1px solid #d2e2ec;
    padding: 6px 4px;
    color: #36576a;
}

.public-qr-logs-table td {
    padding: 6px 4px;
    border-bottom: 1px solid #edf4f8;
    color: #203b4a;
}

.public-qr-hours-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.public-qr-hours-grid > div {
    display: grid;
    gap: 8px;
}

.public-qr-hours-entry-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid #b9d5e6;
    background: rgba(230, 244, 251, 0.88);
}

.public-qr-hours-entry-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.public-qr-hours-edit-btn,
.public-qr-hours-delete-btn {
    height: 42px;
    border-radius: 11px;
    padding: 0 11px;
    font-size: 16px;
    font-weight: 800;
    cursor: pointer;
}

.public-qr-hours-edit-btn {
    border: 1px solid #bfd6e4;
    background: #eef7fc;
    color: #1f4e66;
}

.public-qr-hours-delete-btn {
    border: 1px solid #efb2c0;
    background: #fff3f6;
    color: #a13049;
}

.public-qr-hours-entry-note {
    margin: 0;
    min-height: auto;
    width: 100%;
    font-size: 18px;
    line-height: 1.2;
    font-weight: 800;
    color: #2a5a74;
}

.public-qr-hours-entry-header {
    margin-bottom: 8px;
}

.public-qr-hours-entry-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 8px;
    border: 1px solid #b9d5e6;
    background: rgba(255, 255, 255, 0.6);
    font-size: 16px;
    font-weight: 700;
}

.public-qr-hours-entry-item-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.public-qr-hours-action-btn {
    width: 34px;
    min-width: 34px;
    height: 30px;
    border: 1px solid #b9d5e6;
    border-radius: 8px;
    background: #f3fbff;
    color: #1f4e66;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
}

.public-qr-hours-entry-item + .public-qr-hours-entry-item {
    margin-top: 6px;
}

.public-qr-hours-submit-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.public-qr-hours-submit-row.is-editing {
    grid-template-columns: 1fr 170px;
}

.public-qr-hours-cancel-btn {
    height: 64px;
    border: 1px solid #bfd6e4 !important;
    border-radius: 12px;
    background: #f2f8fc !important;
    color: #1f4e66 !important;
    font-size: 20px !important;
    font-weight: 800 !important;
}

.public-qr-icon-btn {
    width: 42px;
    min-width: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.public-qr-icon-btn span {
    line-height: 1;
}

@media (max-width: 640px) {
    .public-qr-hero h1 {
        font-size: 24px;
    }

    .public-qr-manager-grid {
        grid-template-columns: 1fr;
    }

    .public-qr-video {
        min-height: 180px;
    }

    .public-qr-clear-logs-btn {
        height: 32px;
        padding: 0 10px;
        font-size: 12px;
    }

    .public-qr-hours-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .public-qr-hours-entry-actions {
        flex-wrap: wrap;
    }

    .public-qr-hours-entry-row {
        align-items: flex-start;
        flex-direction: column;
    }

    .public-qr-hours-entry-note {
        font-size: 16px;
    }

    .public-qr-hours-entry-item {
        font-size: 14px;
    }

    .public-qr-hours-submit-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) and (max-height: 820px) {
    .public-qr-page {
        width: min(680px, 96vw);
        padding: 8px 0;
        gap: 8px;
    }

    .public-qr-hero,
    .public-qr-card {
        border-radius: 12px;
        padding: 10px;
    }

    .public-qr-alert {
        padding: 8px 10px;
        font-size: 13px;
    }

    .public-qr-hero h1 {
        font-size: 18px;
    }

    .public-qr-hero p {
        margin-top: 4px;
        font-size: 13px;
    }

    .public-qr-site-gate-form h2 {
        font-size: 18px;
    }

    .public-qr-site-gate-note {
        font-size: 12px;
    }

    .public-qr-manager-btn {
        height: 44px;
        border-radius: 10px;
        font-size: 16px;
    }

    .public-qr-manager-grid {
        gap: 7px;
    }

    .public-qr-manager-auth-meta {
        border-radius: 10px;
        padding: 8px 10px;
    }

    .public-qr-manager-auth-meta p {
        font-size: 12px;
    }

    .public-qr-manager-logout-btn {
        height: 30px;
        border-radius: 8px;
        font-size: 12px;
    }

    .public-qr-manager-site-btn {
        min-height: 64px;
        border-radius: 10px;
        padding: 9px 10px;
    }

    .public-qr-manager-site-btn strong {
        font-size: 17px;
    }

    .public-qr-manager-site-btn span {
        font-size: 12px;
    }

    .public-qr-meta {
        gap: 6px;
    }

    .public-qr-meta div {
        border-radius: 10px;
        padding: 7px 10px;
    }

    .public-qr-meta span {
        font-size: 11px;
        margin-bottom: 2px;
    }

    .public-qr-meta strong {
        font-size: 13px;
    }

    .public-qr-form {
        gap: 7px;
    }

    .public-qr-mode-grid {
        gap: 6px;
    }

    .public-qr-mode-option {
        min-height: 38px;
        font-size: 13px;
        border-radius: 10px;
    }

    .public-qr-scan-btn {
        height: 42px;
        font-size: 14px;
        border-radius: 10px;
    }

    .public-qr-camera-wrap {
        padding: 7px;
    }

    .public-qr-video {
        min-height: 160px;
        max-height: 160px;
    }

    .public-qr-camera-meta {
        margin-top: 4px;
        font-size: 12px;
    }

    .public-qr-form label {
        font-size: 13px;
    }

    .public-qr-form input {
        height: 42px;
        border-radius: 10px;
        padding: 0 8px;
        font-size: 17px;
    }

    .public-qr-form button {
        height: 42px;
        border-radius: 10px;
        font-size: 17px;
    }
}

/* ── LIVE LOGS ───────────────────────────────────────────── */
.public-qr-live-logs-card { padding: 14px 16px; }
.public-qr-live-logs-title { margin: 0 0 10px; font-size: 16px; color: #103b53; }
.public-qr-live-logs-list { display: grid; gap: 6px; }
.public-qr-live-log-row {
    display: grid;
    grid-template-columns: 64px 1fr auto;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border-radius: 10px;
    border: 1px solid #b9d5e6;
    background: rgba(255,255,255,0.7);
    font-size: 14px;
    font-weight: 700;
    color: #1a3f54;
    animation: live-log-in 0.25s ease;
}
@keyframes live-log-in {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.public-qr-live-log-time { color: #457089; font-size: 13px; font-variant-numeric: tabular-nums; }
.public-qr-live-log-name { font-weight: 800; }
.public-qr-live-log-mode {
    font-size: 12px; font-weight: 800; padding: 2px 8px;
    border-radius: 6px; background: #ddf8ef; color: #0a5e4f;
    white-space: nowrap;
}

/* ── TRYB CIAGLY ─────────────────────────────────────────── */
[data-qr-mode="ciagly"] [data-qr-scan-start] { display: none; }
[data-qr-mode="ciagly"] [data-qr-countdown] { display: none; }
[data-qr-mode="ciagly"] .public-qr-mode-fieldset { display: none; }
[data-qr-mode="ciagly"] label[for="qr_payload"] { display: none; }
[data-qr-mode="ciagly"] #qr_payload { display: none; }
[data-qr-mode="ciagly"] button[type="submit"] { display: none; }
[data-qr-mode="ciagly"] .public-qr-camera-wrap { background: #e4f4ff; border-color: #0d8f7b; }

/* ── ADAPTIVE VIEWS ──────────────────────────────────────── */
body.view-mobile .public-qr-page {
    width: 98vw;
    padding: 8px 4px;
}
body.view-mobile .public-qr-manager-grid {
    grid-template-columns: 1fr;
}

body.view-desktop .public-qr-page {
    width: 680px;
}
body.view-desktop .public-qr-manager-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}
