:root { --brand: #13306b; --brand-2: #1f4ea3; --sidebar-w: 238px; }
body { background: #f3f5f9; font-size: .92rem; }
.bg-brand { background: linear-gradient(90deg, var(--brand), var(--brand-2)); }
.sidebar { width: var(--sidebar-w); flex: 0 0 var(--sidebar-w); min-height: calc(100vh - 44px); position: sticky; top: 44px; align-self: flex-start; max-height: calc(100vh - 44px); overflow-y: auto; }
@media (max-width: 991.98px) { .sidebar { position: fixed; max-height: none; } }
.sidebar .nav-link { color: #33415c; padding: .32rem 1rem; border-left: 3px solid transparent; font-size: .87rem; }
.sidebar .nav-link i { width: 1.3rem; display: inline-block; }
.sidebar .nav-link:hover { background: #eef2fa; }
.sidebar .nav-link.active { background: #e3eafa; color: var(--brand); border-left-color: var(--brand); font-weight: 600; }
.sidebar .nav-header { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: #8a94a6; padding: .8rem 1rem .2rem; }
.main-content { min-width: 0; }
.page-title { font-size: 1.25rem; font-weight: 600; color: var(--brand); margin: 0; }
.card { border: 1px solid #e1e6ef; box-shadow: 0 1px 2px rgba(16,24,40,.04); }
.card-header { background: #f8fafd; font-weight: 600; font-size: .88rem; }
.table-sm td, .table-sm th { vertical-align: middle; }
.table thead th { background: #f1f4f9; font-size: .8rem; text-transform: uppercase; letter-spacing: .02em; color: #4a5568; white-space: nowrap; }
.kpi { border-radius: .5rem; padding: .8rem 1rem; background: #fff; border: 1px solid #e1e6ef; height: 100%; }
.kpi .n { font-size: 1.55rem; font-weight: 700; color: var(--brand); line-height: 1.1; }
.kpi .l { font-size: .78rem; color: #6b7280; text-transform: uppercase; letter-spacing: .03em; }
.kpi.warn .n { color: #b45309; } .kpi.bad .n { color: #b91c1c; } .kpi.ok .n { color: #047857; }
.stage-flow { display: flex; flex-wrap: wrap; gap: .25rem; }
.stage-flow .st { font-size: .72rem; padding: .2rem .5rem; border-radius: 1rem; background: #e5e7eb; color: #6b7280; }
.stage-flow .st.done { background: #d1fae5; color: #065f46; }
.stage-flow .st.now { background: #1f4ea3; color: #fff; }
.l1 { background: #d1fae5 !important; font-weight: 700; }
.sel { outline: 2px solid #1f4ea3; outline-offset: -2px; }
.age-red { color: #b91c1c !important; font-weight: 600; } .age-amber { color: #b45309 !important; font-weight: 600; }
.item-grid input, .item-grid select, .item-grid textarea { font-size: .82rem; padding: .2rem .35rem; }
.item-grid td { padding: .2rem; }
.w-num { width: 95px; } .w-sm { width: 70px; }
.dl-compact dt { font-weight: 500; color: #6b7280; font-size: .8rem; }
.dl-compact dd { margin-bottom: .35rem; }
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #13306b, #2f6fd6); }
.perm-table td, .perm-table th { text-align: center; }
.perm-table td:first-child, .perm-table th:first-child { text-align: left; }
.text-pre { white-space: pre-line; }

/* scanned documents */
.min-w-0 { min-width: 0; }
.doc-list .doc-row { display: flex; align-items: center; gap: .5rem; padding: .3rem 0; border-bottom: 1px solid #eef1f6; }
.doc-thumb { width: 42px; height: 42px; flex: 0 0 42px; display: flex; align-items: center; justify-content: center; border: 1px solid #e1e6ef; border-radius: .35rem; background: #f8fafd; overflow: hidden; font-size: 1.35rem; }
.doc-thumb img { width: 100%; height: 100%; object-fit: cover; }
.stage-docs { display: flex; flex-wrap: wrap; gap: .4rem; }
.stage-doc { display: flex; flex-direction: column; padding: .45rem .75rem; border-radius: .5rem; border: 1px solid #e1e6ef; background: #fff; text-decoration: none; min-width: 150px; }
.stage-doc .nm { font-weight: 600; font-size: .82rem; color: #13306b; } .stage-doc .ct { font-size: .75rem; color: #6b7280; }
.stage-doc.has { border-color: #1f4ea3; background: #eef3fd; } .stage-doc.notyet { opacity: .55; }
.rec-block { padding: .5rem .25rem; border-bottom: 1px dashed #e1e6ef; }
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: .5rem; }
.doc-tile { display: block; border: 1px solid #e1e6ef; border-radius: .5rem; padding: .35rem; text-decoration: none; color: inherit; background: #fff; }
.doc-tile:hover { border-color: #1f4ea3; box-shadow: 0 1px 4px rgba(31,78,163,.15); }
.tile-img { height: 90px; display: flex; align-items: center; justify-content: center; background: #f3f5f9; border-radius: .35rem; overflow: hidden; font-size: 2.4rem; }
.tile-img img { width: 100%; height: 100%; object-fit: cover; }
.tile-t { font-size: .78rem; font-weight: 600; margin-top: .25rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-s { font-size: .7rem; color: #6b7280; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chk-chip { display: inline-block; font-size: .72rem; padding: .1rem .5rem; margin: 0 .25rem .25rem 0; border-radius: 1rem; background: #f1f3f7; color: #6b7280; }
.chk-chip.ok { background: #d1fae5; color: #065f46; }
.upload-band { margin-top: .5rem; padding: .5rem; background: #f8fafd; border: 1px dashed #c9d3e6; border-radius: .5rem; }
.doc-nav { position: sticky; top: 56px; max-height: calc(100vh - 72px); overflow-y: auto; }
.doc-stage { background: #525659; border-radius: .375rem; }
.doc-frame { width: 100%; height: calc(100vh - 210px); min-height: 520px; border: 0; display: block; border-radius: .375rem; }
.img-tools { position: sticky; top: 0; z-index: 2; display: flex; gap: .25rem; padding: .4rem; background: rgba(0,0,0,.25); }
.img-wrap { height: calc(100vh - 250px); min-height: 480px; overflow: auto; display: flex; align-items: flex-start; justify-content: center; padding: 1rem; }
.img-wrap img { max-width: 100%; transform-origin: center top; transition: transform .15s; background: #fff; }
.doc-nav .list-group-item.active i { color: #fff !important; }

/* Collapsible side panel (desktop): icon-only rail, remembered per browser */
.sidebar { transition: width .18s ease, flex-basis .18s ease; }
@media (min-width: 992px) {
  html.sb-collapsed .sidebar { width: 56px; flex-basis: 56px; overflow-x: hidden; scrollbar-width: none; }
  html.sb-collapsed .sidebar::-webkit-scrollbar { display: none; }
  html.sb-collapsed .sidebar .sb-label { display: none; }
  html.sb-collapsed .sidebar .nav-link { padding: .45rem 0; text-align: center; white-space: nowrap; }
  html.sb-collapsed .sidebar .nav-link i { width: auto; font-size: 1.1rem; }
  html.sb-collapsed .sidebar .nav-header { padding: .5rem 0 .2rem; height: 0; margin: .45rem .6rem; border-top: 1px solid #e3e7ef; }
}
@media print { .sidebar, .navbar { display: none !important; } }

/* Required field marker */
label.req::after, th.req::after { content: " *"; color: #dc3545; font-weight: 700; }
.form-control.is-invalid, .form-select.is-invalid { border-color: #dc3545 !important; background-color: #fff5f5 !important; }
