:root {
    --bg: #eef4ff;
    --bg-soft: #f8fafc;
    --panel: rgba(255, 255, 255, 0.9);
    --panel-strong: #ffffff;
    --ink: #10213d;
    --muted: #5b6b86;
    --line: rgba(140, 163, 197, 0.3);
    --primary: #1d4ed8;
    --primary-strong: #173ea7;
    --shadow: 0 18px 48px rgba(15, 23, 42, 0.12);
    --radius-xl: 28px;
    --radius-lg: 22px;
    --radius-md: 16px;
    --font-sans: "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    font-family: var(--font-sans);
    background:
        radial-gradient(circle at top left, rgba(29, 78, 216, 0.16), transparent 28rem),
        linear-gradient(180deg, #f5f8ff 0%, #eef4ff 45%, #f8fbff 100%);
    color: var(--ink);
}

body {
    line-height: 1.55;
}

a {
    color: inherit;
    text-decoration: none;
}

img {
    display: block;
    max-width: 100%;
}

.page-form,
.page-success,
.page-admin,
.page-detail,
.page-login {
    min-height: 100vh;
}

.form-shell,
.success-shell,
.admin-shell,
.detail-shell {
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
    padding: 28px 0 44px;
}

.form-shell {
    width: min(760px, calc(100% - 28px));
}

.form-hero,
.admin-hero,
.success-card,
.detail-card,
.table-panel,
.form-panel {
    background: var(--panel);
    backdrop-filter: blur(14px);
    border: 1px solid rgba(255, 255, 255, 0.72);
    box-shadow: var(--shadow);
}

.form-hero {
    border-radius: var(--radius-xl);
    padding: 28px 24px 24px;
    background: linear-gradient(135deg, rgba(29, 78, 216, 0.94), rgba(11, 87, 208, 0.76));
    color: #fff;
    position: relative;
    overflow: hidden;
}

.form-hero::after,
.admin-hero::after {
    content: "";
    position: absolute;
    width: 220px;
    height: 220px;
    right: -60px;
    top: -70px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.14);
    font-size: 13px;
    letter-spacing: 0.04em;
}

.form-hero h1,
.admin-hero h1,
.success-card h1,
.detail-card h1 {
    margin: 14px 0 10px;
    font-size: clamp(1.8rem, 4vw, 2.8rem);
    line-height: 1.12;
}

.form-hero p,
.admin-hero p,
.success-card p,
.panel-head p,
.signature-header p {
    margin: 0;
}

.form-panel,
.success-card,
.detail-card,
.table-panel {
    border-radius: var(--radius-xl);
    padding: 22px;
    margin-top: 18px;
}

.visitor-form {
    display: grid;
    gap: 18px;
}

.section-title,
.panel-head,
.signature-header,
.detail-head,
.qr-card-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
}

.section-title h2,
.panel-head h2,
.signature-header h3,
.qr-card h2,
.media-card h2 {
    margin: 0;
    font-size: 1.1rem;
}

.section-title span,
.panel-head p,
.signature-header p,
.url-stack label,
.detail-item span,
.stat-card span,
.upload-card small,
.upload-card .upload-title {
    color: var(--muted);
    font-size: 0.95rem;
}

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

.field span {
    font-weight: 600;
    color: var(--ink);
}

.field input,
.field textarea,
.field select,
.toolbar input {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: rgba(248, 250, 252, 0.95);
    padding: 14px 16px;
    font: inherit;
    color: var(--ink);
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.field textarea {
    resize: vertical;
    min-height: 104px;
}

.field input:focus,
.field textarea:focus,
.field select:focus,
.toolbar input:focus {
    border-color: rgba(29, 78, 216, 0.5);
    box-shadow: 0 0 0 4px rgba(29, 78, 216, 0.12);
    transform: translateY(-1px);
}

.upload-grid,
.media-grid {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.upload-card {
    position: relative;
    display: grid;
    gap: 6px;
    padding: 20px;
    border-radius: var(--radius-lg);
    border: 1px dashed rgba(29, 78, 216, 0.28);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(238, 244, 255, 0.96));
    min-height: 148px;
    align-content: center;
    overflow: hidden;
}

.upload-card input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.upload-card strong {
    font-size: 1.15rem;
}

.notice-card,
.signature-card,
.qr-card,
.stat-card,
.media-card,
.detail-item {
    background: var(--panel-strong);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(187, 199, 222, 0.32);
}

.notice-card,
.signature-card {
    padding: 18px;
}

.agreement {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    font-size: 0.96rem;
}

.agreement input {
    margin-top: 3px;
}

.signature-header {
    align-items: center;
    margin-bottom: 12px;
}

.signature-canvas {
    width: 100%;
    min-height: 220px;
    border-radius: var(--radius-md);
    border: 1px dashed rgba(29, 78, 216, 0.32);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(243, 247, 255, 0.92)),
        repeating-linear-gradient(
            180deg,
            transparent,
            transparent 31px,
            rgba(29, 78, 216, 0.06) 31px,
            rgba(29, 78, 216, 0.06) 32px
        );
    touch-action: none;
}

.primary-button,
.secondary-button,
.danger-button,
.ghost-button,
.text-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    font-weight: 600;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.primary-button,
.secondary-button,
.danger-button,
.ghost-button {
    border: 0;
    cursor: pointer;
    padding: 12px 18px;
    font: inherit;
}

.primary-button {
    background: linear-gradient(135deg, var(--primary), #3b82f6);
    color: #fff;
    box-shadow: 0 10px 24px rgba(29, 78, 216, 0.24);
}

.secondary-button {
    background: rgba(255, 255, 255, 0.92);
    color: var(--primary-strong);
    border: 1px solid rgba(29, 78, 216, 0.18);
}

.danger-button {
    background: linear-gradient(135deg, #d92d20, #ef4444);
    color: #fff;
    box-shadow: 0 10px 24px rgba(217, 45, 32, 0.22);
}

.ghost-button {
    background: rgba(29, 78, 216, 0.08);
    color: var(--primary-strong);
}

.small {
    padding: 10px 14px;
    font-size: 0.95rem;
}

.primary-button:hover,
.secondary-button:hover,
.danger-button:hover,
.ghost-button:hover,
.text-link:hover {
    transform: translateY(-1px);
}

.submit-button {
    width: 100%;
    min-height: 52px;
    font-size: 1.05rem;
}

.error-text {
    color: #cf3442;
    font-size: 0.88rem;
}

.success-shell {
    display: grid;
    place-items: center;
    width: min(560px, calc(100% - 28px));
}

.login-shell {
    width: min(460px, calc(100% - 28px));
}

.success-card {
    margin-top: 80px;
    text-align: center;
    padding: 34px 28px;
}

.login-card {
    text-align: left;
}

.login-form {
    display: grid;
    gap: 14px;
    margin-top: 20px;
}

.success-mark {
    display: inline-flex;
    padding: 8px 14px;
    border-radius: 999px;
    background: rgba(29, 78, 216, 0.1);
    color: var(--primary);
    font-weight: 700;
}

.success-id {
    color: var(--ink) !important;
    margin: 12px 0 20px !important;
    font-weight: 600;
}

.admin-hero {
    border-radius: 32px;
    padding: 28px;
    display: grid;
    gap: 24px;
    grid-template-columns: minmax(0, 1.45fr) minmax(280px, 360px);
    background: linear-gradient(135deg, #082f7a 0%, #1d4ed8 50%, #0f65c8 100%);
    color: #fff;
    position: relative;
    overflow: hidden;
}

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

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 22px;
}

.hero-actions form {
    margin: 0;
}

.qr-card {
    position: relative;
    z-index: 1;
    padding: 18px;
    color: var(--ink);
}

.qr-image {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: contain;
    background: #fff;
    padding: 12px;
    border-radius: 22px;
    border: 1px solid rgba(29, 78, 216, 0.12);
}

.url-stack {
    display: grid;
    gap: 6px;
    margin-top: 12px;
}

.url-stack code {
    display: block;
    padding: 12px 14px;
    background: rgba(238, 244, 255, 0.9);
    border-radius: 14px;
    color: #163266;
    word-break: break-all;
}

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

.stat-card {
    padding: 18px 20px;
}

.stat-card strong {
    display: block;
    margin-top: 8px;
    font-size: clamp(1.6rem, 2vw, 2.2rem);
}

.stat-card.wide strong {
    font-size: clamp(1.2rem, 1.8vw, 1.6rem);
}

.table-panel {
    padding: 22px;
}

.sync-panel {
    margin-bottom: 20px;
}

.flash-stack {
    display: grid;
    gap: 12px;
    margin-top: 18px;
}

.flash-card {
    border-radius: var(--radius-lg);
    padding: 14px 18px;
    border: 1px solid transparent;
    box-shadow: var(--shadow);
}

.flash-card.success {
    background: #ecfdf3;
    border-color: rgba(16, 185, 129, 0.24);
    color: #0f766e;
}

.flash-card.error {
    background: #fef2f2;
    border-color: rgba(239, 68, 68, 0.24);
    color: #b42318;
}

.sync-grid {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 18px;
}

.sync-badge {
    display: inline-flex;
    align-items: center;
    padding: 8px 14px;
    border-radius: 999px;
    font-size: 0.92rem;
    font-weight: 700;
}

.sync-badge.online {
    background: rgba(16, 185, 129, 0.12);
    color: #0f766e;
}

.sync-badge.offline {
    background: rgba(148, 163, 184, 0.16);
    color: #475569;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.table-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin: 18px 0 14px;
}

.table-select {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    font-weight: 600;
}

.checkbox-cell {
    width: 62px;
    text-align: center !important;
}

.checkbox-cell input {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

.toolbar input {
    min-width: 180px;
    height: 44px;
}

.table-wrap {
    overflow: auto;
    border-radius: 18px;
    border: 1px solid rgba(187, 199, 222, 0.32);
}

.records-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 880px;
    background: #fff;
}

.records-table th,
.records-table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid rgba(187, 199, 222, 0.28);
    vertical-align: top;
}

.records-table thead th {
    background: rgba(238, 244, 255, 0.92);
    color: #163266;
    font-size: 0.94rem;
}

.empty-cell {
    text-align: center !important;
    color: var(--muted);
    padding: 32px 16px !important;
}

.text-link {
    color: var(--primary);
    padding: 0;
}

.danger-text {
    border: 0;
    background: transparent;
    color: #d92d20;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
}

.action-cell {
    display: grid;
    gap: 8px;
}

.detail-grid {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 20px;
}

.detail-item {
    padding: 16px 18px;
}

.detail-item strong {
    display: block;
    margin-top: 8px;
    font-size: 1.02rem;
    word-break: break-word;
}

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

.media-grid {
    margin-top: 20px;
}

.media-card {
    padding: 18px;
}

.media-card img {
    margin-top: 12px;
    border-radius: 18px;
    border: 1px solid rgba(187, 199, 222, 0.32);
    background: #fff;
}

@media (max-width: 960px) {
    .admin-hero,
    .stats-grid,
    .detail-grid,
    .sync-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 720px) {
    .form-shell,
    .success-shell,
    .admin-shell,
    .detail-shell {
        width: min(100% - 20px, 100%);
        padding-top: 18px;
        padding-bottom: 28px;
    }

    .form-hero,
    .form-panel,
    .admin-hero,
    .table-panel,
    .detail-card,
    .success-card {
        border-radius: 22px;
        padding: 18px;
    }

    .section-title,
    .panel-head,
    .signature-header,
    .detail-head,
    .qr-card-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .hero-actions,
    .toolbar,
    .table-actions {
        width: 100%;
    }

    .hero-actions .primary-button,
    .hero-actions .secondary-button,
    .hero-actions .danger-button,
    .toolbar input,
    .toolbar .secondary-button,
    .table-actions .danger-button {
        width: 100%;
    }

    .table-actions {
        align-items: stretch;
        flex-direction: column;
    }
}
