:root {
    --app-bg: #f3f6fa;
    --app-primary: #165dff;
    --app-text: #172033;
    --app-muted: #64748b;
    --app-border: #dfe5ee;
    --app-card-shadow: 0 .125rem .45rem rgba(15, 23, 42, .07);
}

body {
    background: var(--app-bg);
    color: var(--app-text);
    display: flex;
    flex-direction: column;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    min-height: 100vh;
}

.app-navbar {
    box-shadow: 0 .15rem .5rem rgba(15, 23, 42, .04);
}

.app-navbar .navbar-brand {
    color: var(--app-primary);
    font-weight: 800;
    max-width: 180px;
}

.app-navbar .nav-link {
    color: #516076;
    font-weight: 600;
    margin-right: 8px;
}

.app-navbar .nav-link:hover,
.app-navbar .nav-link:focus,
.app-navbar .nav-link.active {
    color: var(--app-primary);
}

.app-navbar .nav-link.active {
    font-weight: 800;
}

.app-main {
    flex: 1 0 auto;
    min-height: calc(100vh - 96px);
}

.app-main h1,
.app-main h2 {
    color: var(--app-text);
    font-weight: 800;
    letter-spacing: 0;
}

.btn,
.form-control,
.form-select,
.input-group-text {
    border-radius: 8px;
}

.btn-group > .btn:not(:first-child) {
    border-bottom-left-radius: 0;
    border-top-left-radius: 0;
}

.btn-group > .btn:not(:last-child) {
    border-bottom-right-radius: 0;
    border-top-right-radius: 0;
}

.input-group > :not(:first-child) {
    border-bottom-left-radius: 0;
    border-top-left-radius: 0;
}

.input-group > :not(:last-child) {
    border-bottom-right-radius: 0;
    border-top-right-radius: 0;
}

.btn-primary {
    background: var(--app-primary);
    border-color: var(--app-primary);
}

.btn-outline-primary {
    border-color: #b8c9ff;
    color: var(--app-primary);
}

.btn-outline-primary:hover,
.btn-outline-primary:focus {
    background: var(--app-primary);
    border-color: var(--app-primary);
    color: #fff;
}

.metric {
    background: #fff;
    border: 0;
    border-radius: 8px;
    box-shadow: var(--app-card-shadow);
    padding: 18px;
}

.metric .value {
    color: var(--app-text);
    font-size: 28px;
    font-weight: 700;
}

.table-card,
.form-card {
    background: #fff;
    border: 0;
    border-radius: 8px;
    box-shadow: var(--app-card-shadow);
}

.table-card .table-responsive {
    border-radius: 8px;
}

.table thead th {
    background: #f8fafc;
    color: #516076;
    font-size: .82rem;
    font-weight: 700;
    white-space: nowrap;
}

.table td,
.table th {
    padding: .85rem .8rem;
    vertical-align: middle;
}

.table-hover > tbody > tr:hover > * {
    background-color: #f6f8fc;
}

.doc-no-link {
    background: #eef4ff;
    border: 1px solid #cbdcff;
    border-radius: 8px;
    color: var(--app-primary);
    display: inline-block;
    font-size: .86rem;
    font-weight: 800;
    line-height: 1.2;
    padding: .32rem .55rem;
    text-decoration: none;
    white-space: nowrap;
}

.doc-no-link:hover,
.doc-no-link:focus {
    background: #dfe9ff;
    border-color: #a9c0ff;
    color: #0f46c9;
}

.attachment-row > td {
    background: #f8fafc;
    border-top: 0;
}

.attachment-row .border {
    border-color: var(--app-border) !important;
}

.table td.text-end > .btn:not(:last-child),
.table td.text-end > .btn-group:not(:last-child) {
    margin-right: .25rem;
}

.badge-status {
    text-transform: uppercase;
}

.tag-badge {
    background: #eef4ff;
    border: 1px solid #cbdcff;
    border-radius: 999px;
    color: #1749a5;
    display: inline-block;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.2;
    margin: 1px 3px 1px 0;
    padding: 3px 8px;
    text-decoration: none;
    white-space: nowrap;
}

.tag-badge:hover,
.tag-badge:focus {
    background: #dfe9ff;
    border-color: #a9c0ff;
    color: #0f46c9;
}

.app-footer {
    flex-shrink: 0;
    font-size: .9rem;
}

.environment-badge {
    background: #eef4ff;
    border: 1px solid #cbdcff;
    border-radius: 999px;
    color: #1749a5;
    display: inline-block;
    font-size: .75rem;
    font-weight: 700;
    padding: .25rem .65rem;
}

.pdf-frame {
    width: 100%;
    height: calc(100vh - 170px);
    min-height: 620px;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    background: #fff;
}

.pdf-sticky-header {
    background: var(--app-bg);
    border-bottom: 1px solid var(--app-border);
    margin: -1.5rem 0 12px;
    padding: 1.5rem 0 12px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.pdf-viewer-toolbar {
    align-items: center;
    background: #fff;
    border: 0;
    border-radius: 8px;
    box-shadow: var(--app-card-shadow);
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 0;
    padding: 10px;
}

.pdf-js-viewer {
    background: #e9ecef;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    min-height: 620px;
    overflow: auto;
    padding: 18px;
    text-align: center;
}

.pdf-page {
    position: relative;
    margin: 0 auto 18px;
}

.pdf-page canvas {
    background: #fff;
    box-shadow: 0 2px 10px rgba(15, 23, 42, .18);
    display: block;
    margin: 0 auto;
    max-width: 100%;
}

.pdf-floating-nav {
    bottom: 22px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: fixed;
    right: 22px;
    z-index: 30;
}

.pdf-floating-nav .btn {
    border: 1px solid var(--app-border);
    box-shadow: 0 .25rem .7rem rgba(15, 23, 42, .16);
    color: var(--app-text);
    font-weight: 700;
    min-width: 44px;
}

.attachment-image {
    max-height: calc(100vh - 180px);
    max-width: 100%;
    object-fit: contain;
}

.textLayer {
    inset: 0;
    line-height: 1;
    overflow: hidden;
    position: absolute;
    text-align: initial;
    transform-origin: 0 0;
}

.textLayer span,
.textLayer br {
    color: transparent;
    cursor: text;
    position: absolute;
    transform-origin: 0 0;
    white-space: pre;
}

.textLayer ::selection {
    background: rgba(13, 110, 253, .28);
}

@media (max-width: 767.98px) {
    .app-main {
        padding-left: .75rem;
        padding-right: .75rem;
    }

    .app-navbar .navbar-brand {
        max-width: 150px;
    }

    .metric,
    .table-card,
    .form-card {
        box-shadow: 0 .08rem .28rem rgba(15, 23, 42, .06);
    }

    .pdf-floating-nav {
        bottom: 14px;
        right: 14px;
    }
}
