/* ===== Base / compact density ===== */
html { font-size: 13px; }
body { background: var(--dw-body-bg); font-family: "Inter","Segoe UI",system-ui,-apple-system,sans-serif; }
.btn-primary { --bs-btn-bg: var(--dw-primary); --bs-btn-border-color: var(--dw-primary); --bs-btn-hover-bg: #3a6fe6; --bs-btn-hover-border-color: #3a6fe6; }
.btn-outline-primary { --bs-btn-color: var(--dw-primary); --bs-btn-border-color: var(--dw-primary); --bs-btn-hover-bg: var(--dw-primary); --bs-btn-hover-border-color: var(--dw-primary); }
.text-primary { color: var(--dw-primary) !important; }
.bg-primary { background-color: var(--dw-primary) !important; }
.btn-icon { background: transparent; border: 0; color: inherit; padding: .25rem .5rem; font-size: 1.15rem; line-height: 1; }
.btn-icon:hover { opacity: .8; }
.btn-xs { padding: .1rem .4rem; font-size: .75rem; }
.card { background: var(--dw-card-bg); border: 1px solid var(--dw-card-border); border-radius: 6px; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.card-header { background: transparent; border-bottom: 1px solid var(--dw-card-border); padding: .6rem .85rem; font-weight: 600; }
.card-body { padding: .75rem .85rem; }
.form-label { font-size: .85rem; font-weight: 500; margin-bottom: .2rem; }
.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table > thead th { background: var(--dw-table-head); font-size: .74rem; text-transform: uppercase; letter-spacing: .03em; color: var(--dw-muted); font-weight: 600; white-space: nowrap; border-bottom-width: 1px; }
.table-sm > :not(caption) > * > * { padding: .35rem .5rem; }
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: var(--dw-row-hover); }
.text-muted-2 { color: var(--dw-muted) !important; }
code, pre { font-family: "Cascadia Code", Consolas, monospace; }

/* soft badges */
.badge { font-weight: 500; }
.badge-soft-primary, .badge-soft-info { background: rgba(62,201,214,.15); color: #1a9aa5; }
.badge-soft-success { background: rgba(44,168,127,.15); color: #2ca87f; }
.badge-soft-warning { background: rgba(244,194,43,.2); color: #b88a00; }
.badge-soft-danger { background: rgba(244,66,54,.15); color: #e53a2f; }
.badge-soft-secondary { background: rgba(137,150,164,.18); color: var(--dw-muted); }
[data-bs-theme="dark"] .badge-soft-warning { color: #f4c22b; }
.chip { display: inline-block; background: rgba(var(--dw-primary-rgb),.1); color: var(--dw-primary); border-radius: 10px; padding: .05rem .45rem; font-size: .72rem; margin: 0 .2rem .2rem 0; white-space: nowrap; }

/* ===== Sidebar ===== */
.sidebar { position: fixed; inset: 0 auto 0 0; width: 230px; background: var(--dw-sidebar-bg); border-right: 1px solid var(--dw-card-border); z-index: 1030; display: flex; flex-direction: column; transition: width .2s, transform .2s; overflow: hidden; }
.brand { height: 52px; display: flex; align-items: center; gap: .5rem; padding: 0 1.1rem; font-size: 1.3rem; color: #fff; background: var(--dw-topbar-bg); text-decoration: none; white-space: nowrap; flex-shrink: 0; }
.brand i { font-size: 1.4rem; }
.sb-nav { overflow-y: auto; padding: .5rem .6rem 1rem; flex: 1; }
.sb-label { color: var(--dw-sidebar-label); font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; padding: .9rem .5rem .35rem; white-space: nowrap; }
.sb-link { display: flex; align-items: center; gap: .65rem; padding: .45rem .65rem; border-radius: 5px; color: var(--dw-sidebar-text); text-decoration: none; white-space: nowrap; margin-bottom: 2px; font-size: .93rem; }
.sb-link i { font-size: 1.05rem; width: 1.2rem; text-align: center; }
.sb-link:hover { background: var(--dw-row-hover); color: var(--dw-primary); }
.sb-link.active { background: var(--dw-sidebar-active-bg); color: var(--dw-sidebar-active-text); box-shadow: 0 2px 6px rgba(70,128,255,.35); }
.main { margin-left: 230px; transition: margin .2s; min-height: 100vh; display: flex; flex-direction: column; }
.sb-collapsed .sidebar { width: 60px; }
.sb-collapsed .sidebar .sb-link span, .sb-collapsed .sidebar .brand span, .sb-collapsed .sidebar .sb-label { display: none; }
.sb-collapsed .sidebar .sb-link { justify-content: center; }
.sb-collapsed .main { margin-left: 60px; }
.sb-backdrop { display: none; }

/* ===== Topbar + band ===== */
.topbar { height: 52px; background: var(--dw-topbar-bg); color: var(--dw-topbar-text); display: flex; align-items: center; gap: .5rem; padding: 0 1rem; position: sticky; top: 0; z-index: 1020; }
.topbar .btn-icon { color: var(--dw-topbar-text); }
.credit-pill { color: var(--dw-topbar-text); text-decoration: none; background: rgba(255,255,255,.18); border-radius: 14px; padding: .15rem .65rem; font-size: .85rem; font-weight: 600; white-space: nowrap; }
.credit-pill:hover { background: rgba(255,255,255,.3); color: var(--dw-topbar-text); }
.credit-pill.empty { background: #f44236; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: rgba(255,255,255,.25); display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: .85rem; }
.page-band { background: var(--dw-band-bg); color: var(--dw-band-text); padding: .9rem 1.25rem 3.6rem; }
.page-title { font-size: 1.1rem; font-weight: 600; margin: 0 0 .2rem; }
.crumbs { font-size: .8rem; opacity: .9; display: flex; gap: .4rem; align-items: center; }
.crumbs a { color: inherit; }
.content { padding: 0 1.25rem 1.25rem; margin-top: -2.9rem; flex: 1; }
.content-full { padding: 0 .75rem .75rem; }

/* ===== Stat cards ===== */
.stat-card { border: 0; color: #fff; overflow: hidden; }
.stat-card .card-body { display: flex; justify-content: space-between; align-items: center; padding: .85rem 1rem; }
.stat-card .val { font-size: 1.55rem; font-weight: 600; line-height: 1.1; }
.stat-card .lbl { font-size: .8rem; opacity: .9; }
.stat-card i { font-size: 2rem; opacity: .55; }
.stat-card.bg-p { background: linear-gradient(135deg,#4680ff,#6b9bff); }
.stat-card.bg-s { background: linear-gradient(135deg,#2ca87f,#4cc39a); }
.stat-card.bg-w { background: linear-gradient(135deg,#f4a52b,#f4c22b); }
.stat-card.bg-d { background: linear-gradient(135deg,#f44236,#f8746b); }
.stat-card.bg-i { background: linear-gradient(135deg,#20a8b5,#3ec9d6); }
.stat-card.bg-g { background: linear-gradient(135deg,#5b6b79,#8996a4); }

/* ===== Auth / landing ===== */
.auth-body { min-height: 100vh; display: flex; flex-direction: column; background: linear-gradient(180deg, var(--dw-band-bg) 0, var(--dw-band-bg) 300px, var(--dw-body-bg) 300px); }
.auth-top { display: flex; justify-content: space-between; align-items: center; padding: .8rem 1.5rem; color: #fff; }
.brand-inline { color: #fff; text-decoration: none; font-size: 1.35rem; }
.auth-main { flex: 1; display: flex; justify-content: center; align-items: flex-start; padding: 1.5rem 1rem; }
.auth-card { width: 100%; max-width: 420px; }
.auth-card.wide { max-width: 560px; }
.auth-foot { text-align: center; padding: .8rem; }
.hero { color: #fff; text-align: center; max-width: 760px; margin: 0 auto 1.5rem; }
.hero h1 { font-size: 2rem; font-weight: 700; }
.feature i { font-size: 1.6rem; color: var(--dw-primary); }

/* ===== Upload ===== */
.dropzone { border: 2px dashed var(--dw-card-border); border-radius: 8px; padding: 2.2rem 1rem; text-align: center; cursor: pointer; transition: .15s; }
.dropzone:hover, .dropzone.drag { border-color: var(--dw-primary); background: rgba(var(--dw-primary-rgb),.05); }
.dropzone i { font-size: 2.6rem; color: var(--dw-primary); }

/* ===== Workspace split ===== */
.ws-header { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; }
.ws-meta { display: flex; flex-wrap: wrap; gap: .25rem 1rem; font-size: .82rem; color: var(--dw-muted); }
.ws-meta b { color: var(--bs-body-color); font-weight: 600; }
.split { display: flex; height: calc(100vh - 175px); min-height: 480px; gap: 0; }
.split > .pane { overflow: hidden; display: flex; flex-direction: column; min-width: 280px; }
.split > .pane-left { flex: 0 0 45%; }
.split > .pane-right { flex: 1 1 auto; }
.gutter { flex: 0 0 8px; cursor: col-resize; display: flex; align-items: center; justify-content: center; }
.gutter::after { content: ""; width: 3px; height: 40px; border-radius: 2px; background: var(--dw-card-border); }
.gutter:hover::after { background: var(--dw-primary); }
.pane .card { height: 100%; display: flex; flex-direction: column; }
.pane .card-body.scroll { overflow: auto; flex: 1; padding: 0; }
.idx-table tbody tr { cursor: pointer; }
.idx-table tbody tr.active > * { --bs-table-bg-state: var(--dw-row-active); }
.idx-table thead th { position: sticky; top: 0; z-index: 2; }
.idx-table td.name { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toolbar { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; padding: .45rem .6rem; border-bottom: 1px solid var(--dw-card-border); }
@media (max-width: 991.98px) {
    .split { flex-direction: column; height: auto; }
    .split > .pane-left { flex: none; height: 55vh; }
    .split > .pane-right { height: 75vh; }
    .gutter { display: none; }
}

/* ===== Data popup (workspace) ===== */
.data-modal { max-width: min(1600px, 96vw); width: 96vw; }
.data-modal .modal-content { height: 92vh; }
.data-modal .modal-body { overflow: hidden; }
.data-split { height: 100%; min-height: 0; }
.data-split > .pane-left { flex: 0 0 45%; }
@media (max-width: 991.98px) { .data-split > .pane-left, .data-split > .pane-right { height: 50%; } }

/* ===== PDF viewer ===== */
.pdfv { display: flex; flex-direction: column; height: 100%; }
.pdfv-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; padding: .35rem .5rem; border-bottom: 1px solid var(--dw-card-border); }
.pdfv-bar input.pg { width: 60px; text-align: center; }
.pdfv-scroll { flex: 1; overflow: auto; background: var(--dw-pdf-bg); padding: .75rem; position: relative; }
.pdf-page { margin: 0 auto .75rem; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.25); position: relative; }
.pdf-page canvas { display: block; width: 100%; height: 100%; }
.pdf-page.in-range { outline: 3px solid rgba(var(--dw-primary-rgb),.55); }
.pdf-page .pg-label { position: absolute; top: 4px; right: 6px; font-size: .7rem; background: rgba(0,0,0,.55); color: #fff; padding: 0 .35rem; border-radius: 3px; }
.pdfv-empty { color: var(--dw-muted); text-align: center; padding: 3rem 1rem; }

/* ===== JSON editor / viewer ===== */
.json-editor { display: flex; border: 1px solid var(--dw-card-border); border-radius: 5px; overflow: hidden; background: var(--dw-code-bg); }
.json-editor .ln { padding: .5rem .4rem; text-align: right; color: var(--dw-muted); user-select: none; font: 12px/1.5 "Cascadia Code", Consolas, monospace; min-width: 38px; border-right: 1px solid var(--dw-card-border); overflow: hidden; white-space: pre; }
.json-editor textarea { flex: 1; border: 0; outline: 0; resize: vertical; padding: .5rem; background: transparent; color: var(--bs-body-color); font: 12px/1.5 "Cascadia Code", Consolas, monospace; min-height: 420px; white-space: pre; overflow: auto; tab-size: 2; }
.json-editor.invalid { border-color: var(--dw-danger); }
.json-view { background: var(--dw-code-bg); padding: .75rem; font: 12px/1.5 "Cascadia Code", Consolas, monospace; white-space: pre; overflow: auto; margin: 0; height: 100%; }
.json-view .k { color: #7c4dff; } .json-view .s { color: #2ca87f; } .json-view .n { color: #e67e22; } .json-view .b { color: #4680ff; } .json-view .z { color: var(--dw-muted); }
[data-bs-theme="dark"] .json-view .k { color: #b39dff; }
.kv-table td:first-child { color: var(--dw-muted); font-family: "Cascadia Code", Consolas, monospace; font-size: .78rem; width: 45%; word-break: break-all; }
.kv-table td:last-child { word-break: break-word; }
.sub-title { font-size: .78rem; font-weight: 600; text-transform: uppercase; color: var(--dw-primary); margin: .6rem 0 .25rem; }

/* ===== Dual list ===== */
.dual { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.dual .list { border: 1px solid var(--dw-card-border); border-radius: 5px; height: 420px; overflow: auto; }
.dual .cat { position: sticky; top: 0; background: var(--dw-table-head); font-size: .74rem; font-weight: 600; padding: .3rem .5rem; display: flex; justify-content: space-between; z-index: 1; }
.dual .item { padding: .25rem .5rem; display: flex; gap: .4rem; align-items: center; cursor: pointer; font-size: .85rem; }
.dual .item:hover { background: var(--dw-row-hover); }
@media (max-width: 767.98px) { .dual { grid-template-columns: 1fr; } }

/* ===== Mobile sidebar ===== */
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); width: 230px !important; }
    .sb-open .sidebar { transform: none; }
    .sb-open .sb-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 1025; }
    .main, .sb-collapsed .main { margin-left: 0; }
    .sb-collapsed .sidebar .sb-link span, .sb-collapsed .sidebar .brand span, .sb-collapsed .sidebar .sb-label { display: initial; }
}
.progress { height: .6rem; }
.pagination { --bs-pagination-padding-y: .2rem; --bs-pagination-padding-x: .55rem; --bs-pagination-font-size: .8rem; margin: 0; }
