:root {
    --bg: #f7efd8;
    --panel: rgba(255, 253, 246, 0.84);
    --panel-strong: rgba(255, 255, 250, 0.94);
    --ink: #0d2e38;
    --muted: #55737a;
    --line: rgba(14, 99, 122, 0.16);
    --brand: #0a9fb0;
    --brand-deep: #08687b;
    --sky: #28b8c8;
    --mint: #4d9b75;
    --sand: #e7bc75;
    --coral: #f17859;
    --foam: #fffdf5;
    --shadow: 0 24px 56px rgba(12, 87, 105, 0.16);
    --radius: 22px;
}

* { box-sizing: border-box; }

.locked-field {
    background: rgba(85, 115, 122, 0.1);
    color: var(--brand-deep);
    cursor: not-allowed;
    font-weight: 800;
}

body {
    margin: 0;
    min-height: 100vh;
    position: relative;
    background:
        radial-gradient(circle at 12% 8%, rgba(255, 255, 255, 0.78), transparent 18rem),
        radial-gradient(circle at 84% 12%, rgba(38, 166, 184, 0.22), transparent 22rem),
        linear-gradient(180deg, #c9f0ee 0%, #e9f7ef 35%, #f7efd8 78%, #efd7a6 100%);
    background-attachment: fixed;
    color: var(--ink);
    font-family: "Trebuchet MS", "Segoe UI", sans-serif;
}

body::before {
    content: "";
    position: fixed;
    inset: auto 0 0 0;
    height: 16rem;
    z-index: 0;
    pointer-events: none;
    background:
        radial-gradient(80% 75% at 20% 100%, rgba(255, 255, 255, 0.55), transparent 58%),
        radial-gradient(72% 90% at 80% 100%, rgba(10, 159, 176, 0.18), transparent 62%),
        repeating-linear-gradient(-8deg, rgba(255, 255, 255, 0.24) 0 2px, transparent 2px 18px);
    opacity: 0.75;
}

body.auth-pending .shell {
    display: none;
}

.shell {
    width: min(1920px, calc(100% - clamp(1rem, 2.2vw, 3rem)));
    margin: 0 auto;
    padding: 1.4rem 0 2rem;
    position: relative;
    z-index: 1;
}

.hero, .panel, .stat-card, .banner {
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow);
}

.hero {
    display: grid;
    grid-template-columns: minmax(0, 1.8fr) minmax(220px, 0.8fr);
    gap: 1rem;
    background:
        linear-gradient(135deg, rgba(8, 104, 123, 0.95), rgba(10, 159, 176, 0.82)),
        radial-gradient(circle at 78% 22%, rgba(255, 253, 245, 0.42), transparent 13rem);
    color: var(--foam);
    border-radius: 30px;
    padding: 2rem;
    overflow: hidden;
    position: relative;
}

.hero::before {
    content: "";
    position: absolute;
    inset: auto 0 0 0;
    height: 42%;
    background:
        radial-gradient(120% 70% at 10% 100%, rgba(255, 255, 255, 0.18), transparent 48%),
        repeating-linear-gradient(-10deg, rgba(255, 255, 255, 0.18) 0 2px, transparent 2px 26px);
    pointer-events: none;
}

.hero::after {
    content: "";
    position: absolute;
    inset: auto -6rem -6rem auto;
    width: 18rem;
    height: 18rem;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 216, 138, 0.5), transparent 68%);
    pointer-events: none;
}

.hero-copy, .hero-aside {
    position: relative;
    z-index: 1;
}

.eyebrow, .section-kicker, .stat-label {
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: 0.72rem;
}

.hero h1, .panel-header h2, .form-card h3, .table-headline h3 {
    font-family: Georgia, "Times New Roman", serif;
}

.hero h1 {
    margin: 0.4rem 0 0.8rem;
    font-size: clamp(2rem, 4vw, 3.45rem);
    line-height: 0.98;
}

.hero-text {
    max-width: 46rem;
    margin: 0;
    color: rgba(255, 253, 245, 0.88);
    font-size: 1.02rem;
}

.hero-aside {
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
    gap: 0.8rem;
    flex-wrap: wrap;
}

.session-card {
    display: grid;
    gap: 0.2rem;
    min-width: 180px;
    padding: 0.9rem 1rem;
    border-radius: 18px;
    background: rgba(255, 253, 245, 0.18);
    color: var(--foam);
    border: 1px solid rgba(255, 255, 255, 0.18);
}

.session-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    opacity: 0.75;
}

.hero-button {
    display: inline-flex;
    align-items: center;
}

.hero-link, button {
    border: none;
    border-radius: 999px;
    text-decoration: none;
    cursor: pointer;
    transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
    padding: 0.85rem 1.2rem;
    font-weight: 700;
    font-size: 0.92rem;
}

.hero-link { color: var(--ink); background: #fff8df; box-shadow: 0 12px 24px rgba(8, 104, 123, 0.15); }
.hero-link:hover, button:hover { transform: translateY(-1px); }

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

.stat-card {
    background:
        linear-gradient(135deg, rgba(255, 255, 250, 0.94), rgba(231, 248, 244, 0.76));
    border-radius: var(--radius);
    padding: 1.2rem 1.3rem;
    border: 1px solid rgba(255, 255, 255, 0.76);
}

.stat-value {
    display: block;
    margin-top: 0.35rem;
    font-size: clamp(1.8rem, 3vw, 2.8rem);
    line-height: 1;
}

.accent-sand { border-left: 8px solid var(--sand); }
.accent-sky { border-left: 8px solid var(--sky); }
.accent-mint { border-left: 8px solid var(--mint); }
.accent-coral { border-left: 8px solid var(--coral); }

.banner {
    margin-bottom: 1rem;
    padding: 1rem 1.2rem;
    border-radius: 18px;
    font-weight: 700;
}

.banner.success { background: rgba(77, 155, 117, 0.16); color: #1f5f42; }
.banner.error { background: rgba(241, 120, 89, 0.16); color: #8d321d; }

button:disabled {
    cursor: wait;
    opacity: 0.64;
    transform: none;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: clamp(300px, 24vw, 430px) minmax(0, 1fr);
    gap: 1rem;
    align-items: start;
    min-width: 0;
}

.resident-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.panel {
    background:
        linear-gradient(180deg, rgba(255, 253, 246, 0.9), rgba(241, 250, 247, 0.78));
    border-radius: 28px;
    padding: 1.25rem;
    border: 1px solid rgba(255, 255, 255, 0.82);
    min-width: 0;
}

.panel-forms {
    position: sticky;
    top: 0.75rem;
    max-height: calc(100dvh - 1.5rem);
    overflow-y: auto;
    scrollbar-gutter: stable;
}

.panel-forms,
.panel-monitor,
.table-stack,
.form-stack {
    min-width: 0;
}

.panel-header {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.panel-header h2 { margin: 0.15rem 0 0; font-size: 1.7rem; }
.section-kicker { color: var(--coral); margin: 0; }
.form-stack, .table-stack { display: grid; gap: 1rem; }

.management-menu {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.55rem;
    margin-bottom: 1rem;
}

.menu-button {
    margin: 0;
    padding: 0.72rem 0.8rem;
    border-radius: 10px;
    background: rgba(255, 248, 229, 0.82);
    color: var(--ink);
    box-shadow: none;
    text-align: left;
}

.menu-button.active {
    background: linear-gradient(135deg, var(--brand), var(--sky));
    color: var(--foam);
}

.form-card, .table-card {
    background:
        linear-gradient(180deg, rgba(255, 255, 250, 0.96), rgba(255, 250, 239, 0.88));
    border-radius: 22px;
    padding: 1rem;
    border: 1px solid var(--line);
    min-width: 0;
}

.table-card {
    overflow: hidden;
}

.form-card h3, .table-headline h3 { margin: 0 0 0.8rem; font-size: 1.15rem; }
.accent-card { background: linear-gradient(135deg, rgba(10, 159, 176, 0.12), rgba(255, 248, 229, 0.95)); }

.field-grid { display: grid; gap: 0.8rem; }
.two-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.full-row { grid-column: 1 / -1; }

label {
    display: grid;
    gap: 0.35rem;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--muted);
}

input, select {
    width: 100%;
    min-width: 0;
    border: 1px solid rgba(14, 99, 122, 0.18);
    border-radius: 14px;
    padding: 0.8rem 0.9rem;
    font: inherit;
    color: var(--ink);
    background: var(--foam);
}

input[type="datetime-local"] {
    font-size: 0.82rem;
    padding-inline: 0.7rem;
}

.datetime-field {
    grid-column: 1 / -1;
}

input:focus, select:focus {
    outline: 2px solid rgba(10, 159, 176, 0.22);
    border-color: rgba(10, 159, 176, 0.48);
}

.photo-upload {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 0.8rem;
    align-items: center;
}

.resident-photo-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0.8rem;
    align-items: center;
}

.photo-guide {
    display: grid;
    gap: 0.35rem;
    margin: 0;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 800;
    text-align: center;
    justify-items: center;
}

.photo-guide img {
    display: block;
    border: 1px solid rgba(14, 99, 122, 0.2);
    border-radius: 14px;
    box-shadow: 0 8px 16px rgba(8, 104, 123, 0.12);
}

.photo-guide img[hidden] { display: none; }

.photo-field {
    display: grid;
    gap: 0.5rem;
}

.field-label {
    margin: 0;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 800;
}

.resident-photo-guide img,
.resident-photo-guide .photo-guide-empty {
    width: 190px;
    aspect-ratio: 7 / 8;
}

.resident-photo-guide img {
    object-fit: cover;
    object-position: top;
}

.photo-guide-empty {
    display: grid;
    place-items: center;
    border: 2px dashed rgba(14, 99, 122, 0.28);
    border-radius: 14px;
    background: rgba(85, 115, 122, 0.08);
    color: var(--muted);
    font-size: 1rem;
    font-weight: 900;
}

.photo-guide-empty[hidden] { display: none; }

.vehicle-photo-guide img,
.vehicle-photo-guide .photo-guide-empty {
    width: min(280px, 100%);
    aspect-ratio: 16 / 10;
}

.vehicle-photo-guide img {
    object-fit: contain;
    background: #fff;
}

.photo-preview, .resident-thumb, .access-photo img {
    object-fit: cover;
}

.photo-preview {
    width: 92px;
    aspect-ratio: 1;
    display: grid;
    place-items: center;
    overflow: hidden;
    border-radius: 18px;
    background: linear-gradient(135deg, #d8f2ef, #fff1d4);
    color: var(--muted);
    border: 1px dashed rgba(14, 99, 122, 0.26);
    font-size: 0.78rem;
    text-align: center;
}

.photo-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.clickable-photo-preview {
    cursor: pointer;
    transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.clickable-photo-preview:hover,
.clickable-photo-preview:focus-visible {
    border-color: var(--brand);
    box-shadow: 0 0 0 4px rgba(10, 159, 176, 0.12);
    outline: none;
    transform: translateY(-1px);
}

.no-photo-button {
    margin: 0;
    padding: 0;
    box-shadow: none;
    font: inherit;
}

.camera-tools {
    display: grid;
    gap: 0.7rem;
}

.camera-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.camera-preview {
    width: 100%;
    max-height: 260px;
    border-radius: 18px;
    border: 1px solid var(--line);
    background: #0d2e38;
    object-fit: cover;
}

.resident-thumb {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: linear-gradient(135deg, #d8f2ef, #fff1d4);
    transition: transform 180ms ease, box-shadow 180ms ease;
    transform-origin: left center;
}

.resident-thumb:not(.resident-thumb-empty):hover {
    transform: scale(3.8);
    box-shadow: 0 18px 36px rgba(22, 37, 47, 0.26);
    z-index: 20;
    position: relative;
}

.resident-thumb-empty {
    display: inline-grid;
    place-items: center;
    color: var(--ink);
    font-weight: 800;
    font-size: 0.78rem;
}

.space-code-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.space-code-list span {
    display: inline-flex;
    padding: 0.28rem 0.5rem;
    border-radius: 999px;
    background: rgba(40, 184, 200, 0.14);
    color: var(--sky);
    font-weight: 800;
    font-size: 0.78rem;
}

.checkbox-field {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding-top: 1.6rem;
}

.checkbox-field input { width: 1rem; height: 1rem; }

button {
    margin-top: 0.95rem;
    background: linear-gradient(135deg, var(--brand), var(--brand-deep));
    color: var(--foam);
    box-shadow: 0 14px 24px rgba(8, 104, 123, 0.22);
}

.inline-button {
    margin-top: 0;
}

.secondary-button { margin: 0; background: #fff1ce; color: var(--ink); box-shadow: none; }
.toolbar { display: flex; justify-content: flex-end; margin-bottom: 1rem; }
.form-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-top: 0.95rem; }
.manual-relay-panel {
    display: grid;
    gap: 0.65rem;
    margin-top: 1rem;
    padding-top: 0.95rem;
    border-top: 1px solid rgba(15, 65, 77, 0.14);
}

.manual-relay-row {
    display: grid;
    grid-template-columns: minmax(72px, 1fr) repeat(2, minmax(82px, auto));
    gap: 0.55rem;
    align-items: center;
}

.manual-relay-row span {
    font-weight: 900;
    color: var(--ink);
}

.manual-relay-row button {
    min-height: 40px;
    white-space: nowrap;
}
.report-filters {
    display: grid;
    grid-template-columns: repeat(2, minmax(170px, 220px)) auto;
    gap: 0.75rem;
    align-items: end;
    margin: 0 0 1rem;
}

.report-filters button {
    margin-top: 0;
    white-space: nowrap;
}

.table-headline { display: flex; justify-content: space-between; gap: 1rem; align-items: center; margin-bottom: 0.8rem; }
.table-headline span { color: var(--muted); font-size: 0.9rem; }
.table-wrap {
    max-width: 100%;
    min-width: 0;
    overflow: auto;
    max-height: min(72dvh, 820px);
    overscroll-behavior: contain;
    scrollbar-gutter: stable both-edges;
}

table {
    width: 100%;
    min-width: 760px;
    border-collapse: collapse;
    font-size: 0.92rem;
    table-layout: auto;
}

th, td {
    padding: 0.7rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid rgba(22, 37, 47, 0.08);
    vertical-align: middle;
    white-space: normal;
    overflow-wrap: anywhere;
}
th {
    color: var(--muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    white-space: nowrap;
    overflow-wrap: normal;
    word-break: normal;
}
td { position: relative; }

th:first-child,
td:first-child,
td:nth-child(6),
td:nth-child(7),
td:nth-child(9),
.action-group,
.status-chip {
    overflow-wrap: normal;
    white-space: nowrap;
}

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

.visitors-table {
    width: 100%;
    min-width: 0;
    table-layout: fixed;
}

.visitors-table th,
.visitors-table td {
    white-space: normal;
    vertical-align: middle;
}

.visitors-table th:nth-child(1),
.visitors-table td:nth-child(1) {
    width: 22%;
}

.visitors-table th:nth-child(2),
.visitors-table td:nth-child(2) {
    width: 20%;
}

.visitors-table th:nth-child(3),
.visitors-table td:nth-child(3) {
    width: 23%;
}

.visitors-table th:nth-child(4),
.visitors-table td:nth-child(4),
.visitors-table th:nth-child(5),
.visitors-table td:nth-child(5) {
    width: 10%;
}

.visitors-table th:nth-child(6),
.visitors-table td:nth-child(6) {
    width: 15%;
}

.stacked-cell {
    line-height: 1.35;
    color: var(--muted);
    font-size: 0.84rem;
}

.stacked-cell.strong-line {
    color: var(--ink);
    font-weight: 800;
    font-size: 0.94rem;
}

.visitors-table .action-group {
    flex-wrap: wrap;
}

.events-table th:nth-child(2),
.events-table td:nth-child(2),
.events-table th:nth-child(5),
.events-table td:nth-child(5) {
    width: 1%;
    white-space: nowrap;
    overflow-wrap: normal;
}

.status-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    border-radius: 999px;
    padding: 0.24rem 0.62rem;
    font-size: 0.77rem;
    font-weight: 700;
}

.status-active, .status-approved, .status-authorized, .status-assigned, .status-additional, .status-visitor {
    background: rgba(77, 155, 117, 0.16);
    color: #1f5f42;
}

.status-blocked, .status-denied, .status-cancelled {
    background: rgba(241, 120, 89, 0.16);
    color: #8d321d;
}

.status-inactive, .status-expired {
    background: rgba(95, 109, 116, 0.14);
    color: #48575d;
}

.wide-card { grid-column: 1 / -1; }

.qr-usb-station {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    padding: 1rem;
    border: 1px solid rgba(10, 159, 176, 0.3);
    border-radius: 18px;
    background: linear-gradient(110deg, rgba(220, 248, 245, 0.9), rgba(255, 244, 211, 0.86));
}

.qr-usb-icon {
    width: 58px;
    aspect-ratio: 1;
    display: grid;
    place-items: center;
    border-radius: 16px;
    background: var(--brand-deep);
    color: white;
    font-weight: 900;
    letter-spacing: 0.06em;
}

.qr-usb-copy { min-width: 0; }
.qr-usb-copy h3, .qr-usb-copy p { margin: 0; }
.qr-usb-copy p { margin-top: 0.2rem; color: var(--muted); font-size: 0.88rem; }
.qr-usb-titleline { display: flex; align-items: center; gap: 0.7rem; }

.qr-usb-direction {
    display: grid;
    grid-template-columns: max-content minmax(130px, 180px);
    align-items: center;
    gap: 0.55rem;
    margin-top: 0.65rem;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 800;
}

.qr-usb-direction select {
    height: 36px;
    padding: 0.35rem 0.65rem;
    border-radius: 12px;
    border: 1px solid rgba(10, 159, 176, 0.28);
    background: rgba(255, 252, 245, 0.9);
    color: var(--ink);
    font-weight: 900;
}

.qr-usb-status {
    padding: 0.25rem 0.55rem;
    border-radius: 999px;
    background: rgba(77, 155, 117, 0.18);
    color: #246145;
    font-size: 0.72rem;
    font-weight: 900;
    text-transform: uppercase;
}

.qr-usb-status.reading { background: rgba(40, 184, 200, 0.18); color: var(--brand-deep); }
.qr-usb-status.error { background: rgba(241, 120, 89, 0.2); color: #91351f; }
.qr-usb-status.locked { background: var(--brand-deep); color: white; }
.qr-usb-station.locked { border: 2px solid var(--brand); box-shadow: 0 0 0 4px rgba(10, 159, 176, 0.1); }

#qr-usb-input {
    width: 100%;
    height: 38px;
    margin-top: 0.65rem;
    font-family: ui-monospace, "Cascadia Code", monospace;
    font-size: 0.82rem;
}

.qr-usb-activate { white-space: nowrap; }
.empty-state { color: var(--muted); font-style: italic; padding: 1rem 0.4rem; }

.action-group {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.4rem;
    width: max-content;
    max-width: 100%;
    overflow-x: auto;
    padding-bottom: 0.1rem;
}

.action-button {
    margin: 0;
    padding: 0.45rem 0.7rem;
    font-size: 0.74rem;
    box-shadow: none;
    background: #fff0cf;
    color: var(--ink);
}

.action-button.success {
    background: rgba(77, 155, 117, 0.18);
    color: #1f5f42;
}

.action-button.danger {
    background: rgba(241, 120, 89, 0.18);
    color: #8d321d;
}

.action-button.info {
    background: rgba(40, 184, 200, 0.18);
    color: #075b68;
}

.empty-actions {
    color: var(--muted);
    font-size: 0.82rem;
}

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1rem;
}

.login-card {
    width: min(620px, 100%);
    background:
        linear-gradient(180deg, rgba(255, 253, 246, 0.94), rgba(231, 248, 244, 0.84));
    border-radius: 28px;
    padding: 2rem;
    border: 1px solid rgba(255, 255, 255, 0.72);
    box-shadow: var(--shadow);
}

.login-logo {
    display: block;
    width: min(500px, 100%);
    height: auto;
    margin: -0.35rem auto 1.25rem;
    filter: drop-shadow(0 12px 18px rgba(8, 104, 123, 0.14));
}

.login-card h1 {
    margin: 0.3rem 0 0.9rem;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(2rem, 5vw, 3rem);
}

.login-form {
    display: grid;
    gap: 0.9rem;
    margin-top: 1.4rem;
}

.login-form small {
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 600;
    line-height: 1.35;
}

.password-limit-note {
    display: block;
    margin-top: 0.4rem;
    padding: 0.55rem 0.7rem;
    border-left: 4px solid #e8902c;
    border-radius: 8px;
    background: #fff0c9;
    color: #7a3f08 !important;
    font-size: 0.82rem !important;
    font-weight: 800 !important;
}

.login-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
    align-items: stretch;
    margin-top: 0.2rem;
}

.login-actions.has-create-account {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.login-actions button {
    width: 100%;
    height: 3.75rem;
    min-width: 0;
    margin: 0;
    padding: 0 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(0.94rem, 2vw, 1.08rem);
    letter-spacing: 0.01em;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
}

.login-actions .create-account-button,
.login-actions #login-submit {
    background: linear-gradient(135deg, var(--brand), #05758a);
    color: white;
    box-shadow: 0 14px 30px rgba(0, 139, 156, 0.24);
}

.login-actions button[hidden] {
    display: none;
}

.resident-register-prompt {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
    justify-content: center;
    margin-top: 1rem;
    color: var(--muted);
    font-weight: 800;
}

.resident-register-prompt[hidden],
.resident-register-form[hidden] {
    display: none;
}

.link-button {
    margin: 0;
    padding: 0;
    border-radius: 0;
    background: transparent;
    color: var(--brand-deep);
    box-shadow: none;
    text-decoration: underline;
    text-underline-offset: 0.18em;
}

.link-button:hover {
    transform: none;
    color: var(--brand);
}

.resident-register-form {
    margin-top: 1.25rem;
    padding: 1.15rem;
    border: 1px solid var(--line);
    border-radius: 22px;
    background:
        radial-gradient(circle at 90% 0%, rgba(40, 184, 200, 0.16), transparent 10rem),
        rgba(255, 253, 246, 0.68);
}

.resident-register-form h2 {
    margin: 0;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.35rem;
}

.register-subsection {
    display: grid;
    gap: 0.85rem;
    padding: 1rem;
    border: 1px solid rgba(14, 99, 122, 0.14);
    border-radius: 18px;
    background: rgba(255, 255, 250, 0.58);
}

.subsection-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.inline-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.subsection-title h3 {
    margin: 0;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.05rem;
}

.compact-title h3 {
    font-size: 0.98rem;
}

.compact-button {
    padding: 0.48rem 0.72rem;
    font-size: 0.78rem;
}

.dynamic-list {
    display: grid;
    gap: 0.8rem;
}

.dynamic-card {
    display: grid;
    gap: 0.75rem;
    padding: 0.9rem;
    border-radius: 16px;
    border: 1px solid rgba(14, 99, 122, 0.13);
    background: rgba(231, 248, 244, 0.45);
}

.register-checkbox {
    padding-top: 0;
}

.access-popup {
    position: fixed;
    right: 1.4rem;
    bottom: 1.4rem;
    z-index: 50;
    display: grid;
    grid-template-columns: 128px minmax(0, 1fr);
    gap: 1rem;
    width: min(680px, calc(100vw - 2rem));
    padding: 1rem;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.72);
    background: rgba(255, 253, 246, 0.97);
    box-shadow: 0 24px 54px rgba(8, 104, 123, 0.24);
}

.access-media-grid {
    display: grid;
    gap: 0.65rem;
}

.access-media-grid figure {
    margin: 0;
    display: grid;
    gap: 0.28rem;
}

.access-media-grid figure > span {
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 900;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.access-popup[hidden] {
    display: none;
}

.access-popup.approved {
    border-left: 8px solid var(--mint);
}

.access-popup.denied {
    border-left: 8px solid var(--coral);
}

.access-photo {
    width: 128px;
    aspect-ratio: 1;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: linear-gradient(135deg, #d8f2ef, #fff1d4);
    color: var(--ink);
    font-size: 2rem;
    font-weight: 800;
    border: 1px solid var(--line);
    overflow: hidden;
}

.access-photo img {
    width: 100%;
    height: 100%;
}

.access-content {
    min-width: 0;
}

.access-topline {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    color: var(--muted);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.access-popup h3 {
    margin: 0.25rem 0 0.65rem;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.35rem;
}

.access-popup dl {
    display: grid;
    gap: 0.45rem;
    margin: 0;
}

.access-popup dl div {
    display: grid;
    grid-template-columns: 82px minmax(0, 1fr);
    gap: 0.5rem;
}

.access-popup dt {
    color: var(--muted);
    font-weight: 700;
    font-size: 0.78rem;
}

.access-popup dd {
    margin: 0;
    min-width: 0;
    overflow-wrap: anywhere;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: grid;
    place-items: center;
    padding: 1rem;
    background: rgba(7, 72, 86, 0.42);
    backdrop-filter: blur(5px);
}

.modal-backdrop[hidden] {
    display: none;
}

.modal-card {
    width: min(520px, 100%);
    display: grid;
    gap: 1rem;
    padding: 1.5rem;
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.72);
    background: rgba(255, 253, 246, 0.98);
    box-shadow: 0 28px 70px rgba(8, 104, 123, 0.28);
}

.modal-card h3 {
    margin: -0.4rem 0 0;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.7rem;
}

.modal-summary {
    margin: 0;
    color: var(--muted);
    line-height: 1.45;
}

.modal-warning {
    margin: 0;
    padding: 0.8rem 0.9rem;
    border-radius: 14px;
    background: rgba(241, 120, 89, 0.14);
    color: #8d321d;
    font-weight: 700;
}

.modal-hint {
    max-width: 34rem;
    margin: 0;
    padding: 0.75rem 0.9rem;
    border-radius: 14px;
    background: rgba(32, 151, 172, 0.12);
    color: #0d5666;
    font-size: 0.9rem;
    font-weight: 700;
    line-height: 1.45;
}

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

.qr-frame {
    display: grid;
    place-items: center;
    width: min(360px, 100%);
    aspect-ratio: 4 / 5;
    padding: 1rem;
    border-radius: 22px;
    background: #fff;
    border: 1px solid var(--line);
    box-shadow: 0 16px 34px rgba(8, 104, 123, 0.16);
}

.qr-frame img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    cursor: zoom-in;
}

#visitor-qr-modal.qr-plain-mode .qr-card {
    width: min(92vw, 780px);
    min-height: min(92vh, 880px);
    justify-content: center;
    padding: 1.25rem;
}

#visitor-qr-modal.qr-plain-mode .section-kicker,
#visitor-qr-modal.qr-plain-mode #visitor-qr-title,
#visitor-qr-modal.qr-plain-mode #visitor-qr-summary,
#visitor-qr-modal.qr-plain-mode .modal-hint {
    display: none;
}

#visitor-qr-modal.qr-plain-mode .qr-frame {
    width: min(82vw, 680px);
    aspect-ratio: 1 / 1;
    padding: 1.25rem;
    border-radius: 18px;
    background: #ffffff;
}

#visitor-qr-modal.qr-plain-mode .qr-frame img {
    cursor: zoom-out;
}

.qr-security-backdrop {
    z-index: 120;
    background: rgba(3, 45, 57, 0.7);
}

.qr-security-card {
    width: min(860px, 100%);
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    padding: clamp(1.2rem, 3vw, 2rem);
    border: 2px solid rgba(41, 178, 190, 0.55);
}

.qr-security-heading,
.qr-security-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.qr-security-status {
    padding: 0.55rem 0.85rem;
    border-radius: 999px;
    background: rgba(63, 143, 106, 0.16);
    color: #236747;
    font-weight: 900;
    text-transform: uppercase;
}

.qr-security-status.invalid {
    background: rgba(216, 83, 57, 0.16);
    color: #963621;
}

.qr-security-alert {
    margin: 0;
    padding: 0.85rem 1rem;
    border-radius: 14px;
    background: linear-gradient(90deg, rgba(32, 151, 172, 0.14), rgba(242, 193, 78, 0.16));
    color: var(--ink);
    font-weight: 800;
}

.qr-security-grid {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 1.25rem;
}

.qr-security-person {
    display: grid;
    justify-items: center;
    align-content: center;
    gap: 0.45rem;
    padding: 1.1rem;
    border-radius: 20px;
    background: linear-gradient(145deg, #dff6f3, #fff0cf);
    text-align: center;
}

.qr-security-person h4,
.qr-security-person p { margin: 0; }
.qr-security-person h4 { font: 700 1.35rem Georgia, "Times New Roman", serif; }
.qr-security-type { color: var(--brand-deep); font-weight: 900; text-transform: uppercase; }

.qr-security-avatar {
    width: 94px;
    aspect-ratio: 1;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--brand-deep);
    color: white;
    font-size: 2rem;
    font-weight: 900;
}

.qr-security-details {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.7rem;
    margin: 0;
}

.qr-security-details div {
    padding: 0.75rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.55);
}

.qr-security-details dt { color: var(--muted); font-size: 0.72rem; font-weight: 900; text-transform: uppercase; }
.qr-security-details dd { margin: 0.22rem 0 0; font-weight: 800; overflow-wrap: anywhere; }
.qr-security-details .qr-security-notes { grid-column: 1 / -1; }

.qr-security-actions button {
    flex: 1 1 0;
    min-height: 58px;
    font-size: 1.05rem;
}

.qr-parking-notice {
    margin: -0.35rem 0 0;
    padding: 0.8rem 0.95rem;
    border-radius: 14px;
    font-weight: 800;
}

.qr-parking-notice.available { background: rgba(77, 155, 117, 0.15); color: #225f42; }
.qr-parking-notice.warning { background: rgba(231, 188, 117, 0.24); color: #75501e; }
.qr-parking-notice.unavailable { background: rgba(241, 120, 89, 0.17); color: #8d321d; }

.resident-event-denied td { background: rgba(241, 120, 89, 0.08); }
.resident-event-denied .resident-event-reason { color: #8d321d; font-weight: 800; }

.uhf-parking-photos {
    grid-template-columns: repeat(2, 150px);
    justify-content: center;
}

.uhf-parking-photos .access-photo { width: 150px; }

.qr-authorize-button { background: #27855d; }
.qr-deny-button { background: #c84d37; }

.site-footer {
    width: min(1920px, calc(100% - clamp(1rem, 2.2vw, 3rem)));
    margin: 1.2rem auto 1.6rem;
    padding: 0.95rem 1rem;
    border: 1px solid rgba(14, 99, 122, 0.12);
    border-radius: 18px;
    background: rgba(255, 252, 244, 0.72);
    color: var(--muted);
    text-align: center;
    font-size: 0.84rem;
    font-weight: 700;
    box-shadow: 0 12px 28px rgba(8, 104, 123, 0.08);
}

@media (max-width: 1080px) {
    .dashboard-grid, .resident-grid, .hero, .stats-grid { grid-template-columns: 1fr; }
    .panel-forms {
        position: static;
        max-height: none;
        overflow: visible;
    }
}

@media (max-width: 700px) {
    .shell { width: calc(100% - 1rem); padding-top: 0.8rem; }
    .site-footer { width: calc(100% - 1rem); margin-block: 0.8rem 1rem; font-size: 0.76rem; }
    .hero, .panel, .stat-card { border-radius: 22px; }
    .two-cols { grid-template-columns: 1fr; }
    .report-filters { grid-template-columns: 1fr; }
    .checkbox-field { padding-top: 0.2rem; }
    .management-menu { grid-template-columns: 1fr; }
    .access-popup {
        left: 0.5rem;
        right: 0.5rem;
        bottom: 0.5rem;
        width: auto;
        grid-template-columns: 1fr;
    }
    .access-media-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .access-photo { width: 100%; font-size: 1.4rem; }
    .qr-security-grid { grid-template-columns: 1fr; }
    .qr-security-details { grid-template-columns: 1fr; }
    .qr-security-details .qr-security-notes { grid-column: auto; }
    .qr-security-heading, .qr-security-actions { align-items: stretch; flex-direction: column; }
    .qr-usb-station { grid-template-columns: auto minmax(0, 1fr); }
    .qr-usb-direction { grid-template-columns: 1fr; }
    .qr-usb-activate { grid-column: 1 / -1; width: 100%; }

    .login-shell {
        place-items: start center;
        padding: 0.55rem;
    }

    .login-card {
        width: 100%;
        padding: 1rem;
        border-radius: 20px;
    }

    .login-logo {
        width: min(290px, 100%);
        margin: 0 auto 0.85rem;
    }

    .login-card h1 {
        font-size: clamp(1.7rem, 9vw, 2.15rem);
    }

    .resident-register-form {
        padding: 0.8rem;
        border-radius: 16px;
    }

    .photo-guide {
        text-align: center;
    }

    .resident-photo-guide img,
    .resident-photo-guide .photo-guide-empty {
        width: 156px;
    }

    .camera-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .camera-actions .compact-button,
    .subsection-title .compact-button {
        width: 100%;
        min-width: 0;
        padding-inline: 0.55rem;
    }

    .subsection-title {
        align-items: stretch;
        flex-wrap: wrap;
    }

    .subsection-title > h3 {
        width: 100%;
    }
}

@media (max-width: 390px) {
    .photo-upload {
        grid-template-columns: 76px minmax(0, 1fr);
    }

    .photo-preview {
        width: 76px;
        border-radius: 14px;
    }

    .resident-photo-guide img,
    .resident-photo-guide .photo-guide-empty {
        width: 138px;
    }

    .camera-actions {
        grid-template-columns: 1fr;
    }

    .inline-actions {
        width: 100%;
    }

    .inline-actions .compact-button {
        flex: 1;
    }
}
