:root {
    --bg: #0a0a0f;
    --card: #111727;
    --text: #f4f7ff;
    --muted: #8895b1;
    --accent: #6f9dff;
    --accent-strong: #5b7fe0;
    --danger: #ff6b6b;
    --success: #3dd598;
    --border: rgba(255, 255, 255, 0.08);
    font-family: "Space Grotesk", "Cairo", sans-serif;
}

:root[data-theme="light"] {
    --bg: #f6f7fb;
    --card: rgba(255, 255, 255, 0.9);
    --text: #111827;
    --muted: #6b7280;
    --accent: #7c3aed;
    --accent-strong: #6d28d9;
    --danger: #dc2626;
    --success: #16a34a;
    --border: rgba(17, 24, 39, 0.10);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    background: radial-gradient(circle at top, rgba(111, 157, 255, 0.15), transparent 55%), var(--bg);
    color: var(--text);
    font-family: "Space Grotesk", "Cairo", sans-serif;
    min-height: 100vh;
}

body.has-sidebar {
    background: radial-gradient(circle at top, rgba(165, 110, 255, 0.12), transparent 55%), var(--bg);
}

.auth-page {
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0;
}

.auth-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 3.5rem 1.25rem;
    background:
        radial-gradient(circle at 20% 10%, rgba(165, 110, 255, 0.22), transparent 55%),
        radial-gradient(circle at 90% 30%, rgba(111, 157, 255, 0.20), transparent 60%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(0, 0, 0, 0)),
        var(--bg);
}

.auth-card {
    width: min(440px, 100%);
    background: rgba(17, 23, 39, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 22px;
    padding: 2.25rem 2rem;
    box-shadow: 0 40px 120px rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(14px);
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    margin-bottom: 1.5rem;
}

.auth-logo {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    background:
        radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.25), transparent 55%),
        linear-gradient(135deg, rgba(165, 110, 255, 0.95), rgba(111, 157, 255, 0.95));
    box-shadow: 0 16px 40px rgba(111, 157, 255, 0.25);
}

.auth-title {
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: 0.2px;
}

.auth-subtitle {
    margin-top: 0.15rem;
    color: var(--muted);
    font-size: 0.95rem;
}

.auth-form {
    display: grid;
    gap: 1rem;
}

.field label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: rgba(244, 247, 255, 0.86);
}

.field input {
    width: 100%;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.10);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text);
    padding: 0.95rem 1rem;
    outline: none;
}

.field input:focus {
    border-color: rgba(111, 157, 255, 0.6);
    box-shadow: 0 0 0 4px rgba(111, 157, 255, 0.14);
}

.btn-primary {
    width: 100%;
    border: none;
    border-radius: 16px;
    padding: 0.95rem 1rem;
    font-weight: 800;
    background: linear-gradient(135deg, rgba(165, 110, 255, 0.95), rgba(111, 157, 255, 0.95));
    color: #0b0e18;
    cursor: pointer;
    box-shadow: 0 18px 60px rgba(111, 157, 255, 0.20);
}

.btn-primary:hover {
    filter: brightness(1.05);
}

.btn-ghost {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.65rem 0.9rem;
    border-radius: 14px;
    border: 1px solid rgba(111, 157, 255, 0.45);
    background: rgba(255, 255, 255, 0.92);
    color: #0b0e18;
    text-decoration: none;
    font-weight: 700;
    font-family: "Cairo", system-ui, -apple-system, Segoe UI, sans-serif;
}

.btn-ghost:hover {
    background: linear-gradient(135deg, rgba(165, 110, 255, 0.95), rgba(111, 157, 255, 0.95));
    color: #0b0e18;
}

.btn-danger {
    color: rgba(255, 107, 107, 1);
    border-color: rgba(255, 107, 107, 0.28);
    background: rgba(255, 107, 107, 0.06);
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.7rem 1.1rem;
    border-radius: 14px;
    border: 1px solid rgba(111, 157, 255, 0.45);
    background: rgba(255, 255, 255, 0.92);
    color: #0b0e18;
    font-weight: 800;
    font-family: "Cairo", system-ui, -apple-system, Segoe UI, sans-serif;
    text-decoration: none;
}

.btn-secondary:hover {
    background: linear-gradient(135deg, rgba(165, 110, 255, 0.95), rgba(111, 157, 255, 0.95));
    color: #0b0e18;
}

.card.viewer-card {
    padding: 0;
    overflow: hidden;
}

.viewer-card-native {
    width: 100%;
    max-width: 100%;
    margin: 0;
    border-radius: 0;
    min-height: 100vh;
}

main {
    width: min(1200px, 100%);
    margin: 0 auto;
    padding: 2rem 1.5rem 4rem;
}

body.has-sidebar main {
    width: calc(100% - 320px);
    max-width: 1200px;
    margin-right: 320px;
}

body.has-sidebar {
    padding-bottom: 70px;
}

@media (max-width: 860px) {
    body.has-sidebar main {
        width: 100%;
        margin-right: 0;
        padding-top: 5.25rem;
    }

    body.has-sidebar {
        padding-bottom: 88px;
    }
}

.site-footer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    padding: 0.85rem 1rem;
    text-align: center;
    border-top: 1px solid var(--border);
    background: rgba(10, 10, 15, 0.72);
    backdrop-filter: blur(12px);
}

:root[data-theme="light"] .site-footer {
    background: rgba(255, 255, 255, 0.72);
}

.site-footer-link {
    color: var(--muted);
    text-decoration: none;
    font-weight: 700;
}

.site-footer-link:hover {
    color: var(--accent);
}

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

.icon-btn,
.icon-link {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.03);
    color: rgba(244, 247, 255, 0.86);
    text-decoration: none;
    padding: 0;
    box-shadow: none;
    transform: none;
}

.icon-btn.sm,
.icon-link.sm {
    width: 32px;
    height: 32px;
    border-radius: 10px;
}

.icon-btn.sm svg,
.icon-link.sm svg {
    width: 16px;
    height: 16px;
}

.token-link {
    display: inline-block;
    max-width: 320px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0.35rem 0.6rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.03);
}

:root[data-theme="light"] .token-link {
    background: rgba(17, 24, 39, 0.03);
}

:root[data-theme="light"] .icon-btn,
:root[data-theme="light"] .icon-link {
    background: rgba(17, 24, 39, 0.03);
    color: rgba(17, 24, 39, 0.85);
}

.icon-btn:hover,
.icon-link:hover {
    background: rgba(255, 255, 255, 0.06);
    box-shadow: none;
    transform: none;
}

.icon-btn svg,
.icon-link svg {
    width: 18px;
    height: 18px;
}

.icon-btn-danger {
    color: rgba(255, 107, 107, 1);
    border-color: rgba(255, 107, 107, 0.25);
    background: rgba(255, 107, 107, 0.06);
}

.icon-btn-danger:hover {
    background: rgba(255, 107, 107, 0.10);
}

.pager {
    display: flex;
    gap: 0.6rem;
    align-items: center;
    justify-content: center;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.sidebar {
    position: fixed;
    right: 0;
    top: 0;
    height: 100vh;
    width: 300px;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: rgba(10, 10, 15, 0.72);
    border-left: 1px solid var(--border);
    backdrop-filter: blur(16px);
    z-index: 50;
}

:root[data-theme="light"] .sidebar {
    background: rgba(255, 255, 255, 0.72);
}

.sidebar-head {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.75rem;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
}

.sidebar-title {
    font-weight: 900;
    letter-spacing: 0.2px;
}

.sidebar-subtitle {
    color: var(--muted);
    font-size: 0.85rem;
    margin-top: 0.15rem;
    max-width: 210px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-links {
    display: grid;
    gap: 0.5rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 0.9rem;
    border-radius: 16px;
    border: 1px solid transparent;
    background: rgba(255, 255, 255, 0.03);
    color: rgba(244, 247, 255, 0.86);
    text-decoration: none;
    font-weight: 800;
}

:root[data-theme="light"] .sidebar-link {
    color: rgba(17, 24, 39, 0.85);
    background: rgba(17, 24, 39, 0.03);
}

.sidebar-link:hover {
    background: rgba(255, 255, 255, 0.06);
}

.sidebar-link.active {
    color: #0b0e18;
    background: linear-gradient(135deg, rgba(165, 110, 255, 0.95), rgba(111, 157, 255, 0.95));
    border-color: rgba(255, 255, 255, 0.18);
}

.sidebar-ico {
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.sidebar-ico svg {
    width: 22px;
    height: 22px;
}

.sidebar-foot {
    margin-top: auto;
    display: grid;
    gap: 0.6rem;
}

@media (max-width: 860px) {
    .sidebar {
        right: 0;
        left: 0;
        width: 100%;
        height: auto;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        padding: 0.75rem 0.75rem;
        border-left: 0;
        border-bottom: 1px solid var(--border);
    }

    .sidebar-links {
        display: flex;
        gap: 0.5rem;
        overflow-x: auto;
        padding: 0.25rem;
    }

    .sidebar-foot {
        margin-top: 0;
        display: flex;
        gap: 0.5rem;
    }

    .sidebar-subtitle {
        display: none;
    }
}

.main-fullscreen {
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0;
}

.auth-container,
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 2rem;
    margin: 3rem auto;
    box-shadow: 0 50px 80px rgba(0, 0, 0, 0.35);
}

.pdf-canvas-stack {
    padding: 1.5rem;
    max-height: 85vh;
    overflow-y: auto;
}

.no-select {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

.secure-canvas {
    display: block;
    margin: 0 auto 20px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: #ffffff;
    box-shadow: 0 12px 45px rgba(0, 0, 0, 0.35);
    touch-action: none;
}

@media (max-width: 640px) {
    main {
        padding: 0;
        width: 100%;
    }

    .auth-container,
    .card {
        margin: 0;
        border-radius: 0;
        border-left: 0;
        border-right: 0;
    }

    .viewer-header {
        padding: 1rem;
    }

    .pdf-canvas-stack {
        padding: 0.75rem;
        max-height: calc(100vh - 140px);
    }

    .secure-canvas {
        width: 100% !important;
        height: auto !important;
        margin: 0 auto 12px;
        border-radius: 8px;
    }

    .viewer-controls {
        gap: 0.4rem;
        padding: 0 0.75rem 1rem;
        flex-wrap: wrap;
    }

    .viewer-controls button {
        min-width: 100px;
    }
}

.privacy-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.96);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 2rem;
}

.privacy-overlay.active {
    display: flex;
}

.privacy-overlay-content {
    text-align: center;
    max-width: 520px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.5rem 1.75rem;
}

@media print {
    body {
        background: #000 !important;
        color: #000 !important;
    }

    body * {
        visibility: hidden !important;
    }

    #privacyOverlay,
    #privacyOverlay * {
        visibility: visible !important;
    }

    #privacyOverlay {
        display: flex !important;
        position: fixed !important;
        inset: 0 !important;
        background: #000 !important;
    }
}

.pdf-canvas-stack canvas {
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 12px 45px rgba(0, 0, 0, 0.35);
}

.viewer-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 0 0 1rem;
}

.viewer-controls button {
    width: auto;
    min-width: 120px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border);
}

.viewer-controls button:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.viewer-controls.hidden {
    display: none;
}

.viewer-controls {
    display: none;
}

.viewer-page-indicator {
    font-weight: 600;
}

.pdf-native-shell {
    width: 100%;
    height: calc(100vh - 80px);
    background: rgba(5, 7, 15, 0.85);
}

.pdf-native-shell iframe {
    width: 100%;
    height: 100%;
    border: none;
    background: #0b0e18;
}

.apryse-shell {
    position: relative;
    width: 100%;
}

.watermark-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0.32;
    z-index: 2147483647;
    mix-blend-mode: normal;
    background-size: 700px 480px;
    background-position: 0 0;
}

#viewerControls,
#nativePdfControls,
.viewer-controls {
    display: none !important;
}

.auth-container {
    max-width: 480px;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--muted);
}

input,
select,
textarea {
    width: 100%;
    padding: 0.8rem 1rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.02);
    color: var(--text);
    font-size: 1rem;
}

button {
    border: none;
    background: linear-gradient(120deg, var(--accent), var(--accent-strong));
    cursor: pointer;
    font-weight: 600;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    width: auto;
    min-width: 140px;
    padding: 0.7rem 1.1rem;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

form button {
    justify-self: center;
}

button.btn-block {
    width: 100%;
    min-width: 0;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(111, 157, 255, 0.25);
}

button.btn-secondary {
    border: 1px solid rgba(111, 157, 255, 0.45);
    background: rgba(255, 255, 255, 0.92);
    color: #0b0e18;
    font-weight: 800;
    font-family: "Cairo", system-ui, -apple-system, Segoe UI, sans-serif;
    box-shadow: none;
    transform: none;
}

button.btn-secondary:hover {
    background: linear-gradient(135deg, rgba(165, 110, 255, 0.95), rgba(111, 157, 255, 0.95));
    color: #0b0e18;
    box-shadow: 0 12px 24px rgba(111, 157, 255, 0.25);
    transform: translateY(-2px);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    filter: grayscale(0.5);
}

table {
    width: 100%;
    margin-top: 1rem;
    border-collapse: separate;
    border-spacing: 0 10px;
}

th,
td {
    padding: 0.75rem 0.6rem;
    text-align: left;
    border-bottom: none;
}

th {
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-size: 0.75rem;
    color: var(--muted);
}

thead th {
    padding-top: 0.85rem;
    padding-bottom: 0.85rem;
}

tbody tr {
    background: rgba(255, 255, 255, 0.03);
}

:root[data-theme="light"] tbody tr {
    background: rgba(17, 24, 39, 0.03);
}

tbody tr:hover {
    background: rgba(255, 255, 255, 0.06);
}

tbody td:first-child {
    border-top-right-radius: 16px;
    border-bottom-right-radius: 16px;
}

tbody td:last-child {
    border-top-left-radius: 16px;
    border-bottom-left-radius: 16px;
}

td {
    font-size: 0.9rem;
}

.nav {
    display: flex;
    gap: 1rem;
    padding: 1.25rem 2rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    background: rgba(10, 10, 15, 0.7);
    backdrop-filter: blur(16px);
    position: sticky;
    top: 0;
    z-index: 10;
}

.nav-modern {
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: rgba(10, 10, 15, 0.7);
    backdrop-filter: blur(14px);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-width: 160px;
}

.nav-mark {
    width: 34px;
    height: 34px;
    border-radius: 12px;
    background:
        radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.25), transparent 55%),
        linear-gradient(135deg, rgba(165, 110, 255, 0.95), rgba(111, 157, 255, 0.95));
}

.nav-brand-title {
    font-weight: 800;
    letter-spacing: 0.2px;
}

.nav-links {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.nav-link {
    padding: 0.65rem 0.9rem;
    border-radius: 14px;
    border: 1px solid transparent;
    background: rgba(255, 255, 255, 0.03);
    color: rgba(244, 247, 255, 0.80);
    text-decoration: none;
    font-weight: 700;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.06);
}

.nav-link.active {
    color: #0b0e18;
    background: linear-gradient(135deg, rgba(165, 110, 255, 0.95), rgba(111, 157, 255, 0.95));
    border-color: rgba(255, 255, 255, 0.18);
}

.nav-spacer {
    flex: 1;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.nav-user-chip {
    padding: 0.55rem 0.8rem;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.10);
    background: rgba(255, 255, 255, 0.03);
    color: rgba(244, 247, 255, 0.84);
    font-weight: 700;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav a {
    color: var(--muted);
    font-weight: 500;
}

.alert {
    margin: 1rem 0;
    padding: 1rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.03);
}

.alert-success {
    border-color: rgba(61, 213, 152, 0.3);
    background: rgba(61, 213, 152, 0.08);
}

.alert-danger {
    border-color: rgba(255, 107, 107, 0.3);
    background: rgba(255, 107, 107, 0.1);
}

.badge {
    display: inline-block;
    padding: 0.2rem 0.8rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-secure {
    background: rgba(111, 157, 255, 0.2);
    color: var(--accent);
}

.badge-native {
    background: rgba(61, 213, 152, 0.2);
    color: var(--success);
}

.grid {
    display: grid;
    gap: 1.5rem;
}

.grid-2 {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.stats {
    display: flex;
    gap: 1rem;
}

.stat-card {
    flex: 1;
    padding: 1.5rem;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.02);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
}

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

@media (max-width: 1100px) {
    .kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 560px) {
    .kpi-grid {
        grid-template-columns: 1fr;
    }
}

.kpi-card {
    border-radius: 20px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.03);
    padding: 1.25rem 1.25rem;
    box-shadow: 0 20px 70px rgba(0, 0, 0, 0.28);
}

.kpi-ico {
    width: 44px;
    height: 44px;
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.03);
    color: var(--accent);
}

.kpi-ico svg {
    width: 22px;
    height: 22px;
}

:root[data-theme="light"] .kpi-card {
    background: rgba(17, 24, 39, 0.03);
    box-shadow: 0 18px 55px rgba(17, 24, 39, 0.10);
}

.kpi-label {
    color: var(--muted);
    font-weight: 700;
    font-size: 0.92rem;
}

.kpi-value {
    margin-top: 0.35rem;
    font-size: 2.05rem;
    font-weight: 900;
    letter-spacing: 0.2px;
}

.segmented {
    display: inline-flex;
    gap: 0.35rem;
    padding: 0.25rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.03);
}

.segmented .seg-btn {
    width: auto;
    padding: 0.55rem 0.9rem;
    border-radius: 999px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--muted);
    font-weight: 800;
    box-shadow: none;
    transform: none;
}

.segmented .seg-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    box-shadow: none;
    transform: none;
}

.segmented .seg-btn.active {
    color: #0b0e18;
    background: linear-gradient(135deg, rgba(165, 110, 255, 0.95), rgba(111, 157, 255, 0.95));
    border-color: rgba(255, 255, 255, 0.18);
}

.chart-wrap {
    margin-top: 1rem;
    border-radius: 18px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.02);
    padding: 0.85rem;
    position: relative;
}

:root[data-theme="light"] .chart-wrap {
    background: rgba(17, 24, 39, 0.02);
}

.chart-controls {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 5;
}

.chart-wrap canvas {
    display: block;
    width: 100%;
    height: 220px;
    margin-top: 42px;
}

.muted {
    color: var(--muted);
    font-size: 0.9rem;
}
