* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: #f5f7fa;
    color: #1f2937;
}

body.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: #eef2f7;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: #ffffff;
    border-radius: 14px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    padding: 28px;
}

.login-title {
    margin: 0 0 8px;
    font-size: 28px;
}

.login-subtitle {
    margin: 0 0 20px;
    color: #6b7280;
}

.alert {
    padding: 12px 14px;
    border-radius: 10px;
    margin-bottom: 16px;
    font-size: 14px;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
}

.alert-success {
    background: #dcfce7;
    color: #166534;
}

.form {
    display: grid;
    gap: 10px;
}

.form-label {
    font-size: 14px;
    font-weight: 600;
}

.form-input,
.form-select {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    background: #fff;
    font-size: 15px;
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: #2563eb;
}

.button {
    display: inline-block;
    text-decoration: none;
    border: none;
    border-radius: 10px;
    padding: 11px 16px;
    background: #2563eb;
    color: #fff;
    font-weight: 600;
    cursor: pointer;
}

.button:hover {
    background: #1d4ed8;
}

.button-secondary {
    background: #374151;
}

.button-secondary:hover {
    background: #1f2937;
}

.button-danger {
    background: #b91c1c;
}

.button-danger:hover {
    background: #991b1b;
}

.button-small {
    padding: 8px 12px;
    font-size: 13px;
}

.site-shell {
    min-height: 100vh;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 20px 24px;
    background: #ffffff;
    border-bottom: 1px solid #e5e7eb;
}

.page-title {
    margin: 0 0 6px;
    font-size: 28px;
}

.muted {
    color: #6b7280;
    font-size: 14px;
}

.content-wrap {
    max-width: 1280px;
    margin: 0 auto;
    padding: 24px;
}

.card {
    background: #ffffff;
    border-radius: 14px;
    padding: 20px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.05);
}

.doc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 18px;
}

.doc-card {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.doc-title {
    margin: 0;
    font-size: 20px;
}

.doc-meta {
    display: grid;
    gap: 8px;
    font-size: 14px;
    color: #374151;
}

.doc-actions {
    margin-top: auto;
}

.table-wrap {
    overflow-x: auto;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.admin-table th,
.admin-table td {
    padding: 10px 8px;
    border-bottom: 1px solid #e5e7eb;
    vertical-align: top;
}

.inline-form {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.inline-form .form-input,
.inline-form .form-select {
    width: auto;
    min-width: 140px;
}

.section-stack {
    display: grid;
    gap: 24px;
}

body.viewer-page {
    background: #1f2937;
    color: #fff;
}

.viewer-topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 18px;
    background: rgba(17, 24, 39, 0.95);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(4px);
}

.viewer-title {
    font-size: 18px;
    font-weight: 700;
}

.viewer-subtitle {
    margin-top: 4px;
    font-size: 13px;
    color: #d1d5db;
}

.viewer-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.viewer-wrap {
    position: relative;
    z-index: 10;
    max-width: 1100px;
    margin: 24px auto;
    padding: 0 16px 40px;
}

.viewer-page-image {
    display: block;
    width: 100%;
    height: auto;
    margin: 0 auto 24px;
    border-radius: 8px;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
    user-select: none;
    -webkit-user-drag: none;
    pointer-events: auto;
}

.viewer-watermark-grid {
    position: fixed;
    inset: 0;
    z-index: 20;
    pointer-events: none;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 90px 40px;
    padding: 40px;
    align-content: space-around;
    justify-items: center;
    overflow: hidden;
}

.viewer-watermark-grid span {
    display: block;
    font-size: clamp(18px, 2vw, 28px);
    font-weight: 700;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.12);
    transform: rotate(-28deg);
    text-transform: uppercase;
    white-space: nowrap;
}

.print-only {
    display: none;
}

@media print {
    body {
        background: #ffffff !important;
        color: #000000 !important;
    }

    .no-print,
    .printable-hidden,
    .viewer-watermark-grid {
        display: none !important;
    }

    .print-only {
        display: flex !important;
        min-height: 100vh;
        align-items: center;
        justify-content: center;
        text-align: center;
        font-size: 28px;
        font-weight: 700;
        padding: 40px;
    }
}

@media (max-width: 700px) {
    .topbar,
    .viewer-topbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .viewer-actions {
        width: 100%;
    }
}
.topbar-brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.portal-logo {
    display: block;
    height: auto;
    max-width: 100%;
}

.portal-logo-top-left {
    width: 54px;
    flex: 0 0 auto;
}

.login-logo-wrap {
    display: flex;
    justify-content: center;
    margin-bottom: 18px;
}

.portal-logo-login {
    width: 120px;
}

.viewer-corner-logos {
    position: fixed;
    inset: 0;
    z-index: 18;
    pointer-events: none;
}

.viewer-corner-logo {
    position: fixed;
    width: 90px;
    opacity: 0.14;
    filter: grayscale(100%);
}

.viewer-corner-logo.top-left {
    top: 18px;
    left: 18px;
}

.viewer-corner-logo.top-right {
    top: 18px;
    right: 18px;
}

.viewer-corner-logo.bottom-left {
    bottom: 18px;
    left: 18px;
}

.viewer-corner-logo.bottom-right {
    bottom: 18px;
    right: 18px;
}

.portal-footer {
    border-top: 1px solid #e5e7eb;
    background: #ffffff;
}

.portal-footer-text {
    margin: 0;
    padding: 20px 0 28px;
    font-size: 13px;
    line-height: 1.6;
    color: #6b7280;
}