/* ==========================================================================
   Admin + Agent panels
   ========================================================================== */
/* Panel palette, derived from the brand primary (#0b5c7a) and accent (#14a39a). */
:root {
  --sidebar-w: 240px; --topbar-h: 64px;
  --sb-bg: #0d2a3c; --sb-bg-2: #0a1f2d;          /* deep teal-navy, a darkened primary */
  --sb-text: #a7bccb; --sb-muted: #5f8095; --sb-icon: #7d9bb0;
  --sb-hover: rgba(255,255,255,.06); --sb-active: rgba(20,163,154,.17); --sb-accent: #3fc7bc;
  --sb-line: rgba(255,255,255,.07);
  --page-bg: #f2f6f8;                             /* cool, faintly teal-tinted canvas */
  --card-border: #e2e9ee;
  --card-shadow: 0 1px 2px rgba(13,42,60,.04), 0 2px 6px rgba(13,42,60,.03);
  --sb-gutter: 1.5rem;                           /* one left edge for brand, labels, icons and footer */
}
body.panel { background: var(--page-bg); min-height: 100vh; }
body.panel .card { border-color: var(--card-border); box-shadow: var(--card-shadow); }

/* ---------- sidebar ---------- */
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); background: linear-gradient(180deg, var(--sb-bg) 0%, var(--sb-bg-2) 100%); color: var(--sb-text); display: flex; flex-direction: column; z-index: 1040; transition: transform .25s ease; }
.sidebar .brand { color: #fff; padding: 0 var(--sb-gutter); height: var(--topbar-h); flex-shrink: 0; gap: .6rem; border-bottom: 1px solid var(--sb-line); }
.sidebar .brand .brand-mark { width: 46px; height: 34px; border-radius: 10px; box-shadow: 0 4px 12px rgba(20,163,154,.3); }
.sidebar .brand-text { font-size: .9rem; line-height: 1.15; }
.sidebar .brand-text small { color: var(--sb-muted); font-size: .62rem; margin-top: .15rem; }
/* Nav padding + link padding = --sb-gutter, so icons line up with the brand mark and section labels. */
.sidebar-nav { padding: .75rem .75rem 1rem; overflow-y: auto; flex: 1; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.16) transparent; }
.sidebar-label { font-size: .64rem; text-transform: uppercase; letter-spacing: .14em; color: var(--sb-muted); padding: 1rem .75rem .4rem; font-weight: 700; }
.sidebar-label:first-child { padding-top: .5rem; }
.sidebar-nav a { display: flex; align-items: center; gap: .7rem; color: var(--sb-text); padding: .55rem .75rem; border-radius: 8px; font-size: .875rem; font-weight: 500; margin-bottom: 2px; transition: background .15s ease, color .15s ease; }
.sidebar-nav a i { font-size: 1rem; width: 18px; text-align: center; flex-shrink: 0; color: var(--sb-icon); transition: color .15s ease; }
.sidebar-nav a span:not(.count) { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.sidebar-nav a:hover { background: var(--sb-hover); color: #fff; }
.sidebar-nav a:hover i { color: #fff; }
.sidebar-nav a.active { background: var(--sb-active); color: #fff; box-shadow: inset 3px 0 0 var(--sb-accent); }
.sidebar-nav a.active i { color: var(--sb-accent); }
.sidebar-nav .count { margin-left: auto; min-width: 20px; text-align: center; background: rgba(63,199,188,.18); color: var(--sb-accent); font-size: .68rem; font-weight: 700; padding: .1rem .45rem; border-radius: 999px; }
.sidebar-nav a.active .count { background: var(--sb-accent); color: var(--sb-bg); }
/* Short laptop screens (768px tall and below): tighten the menu so most or all of it fits without scrolling. */
@media (min-width: 992px) and (max-height: 820px) {
  .sidebar-nav { padding: .5rem .75rem; }
  .sidebar-label { padding: .65rem .75rem .25rem; }
  .sidebar-nav a { padding: .44rem .75rem; }
}
.sidebar-foot { padding: .85rem var(--sb-gutter); border-top: 1px solid var(--sb-line); font-size: .8rem; }
.sidebar-foot a { color: var(--sb-text); }
.sidebar-foot a:hover { color: var(--sb-accent); }
.role-pill { display: inline-block; font-size: .62rem; font-weight: 700; text-transform: uppercase; letter-spacing: .12em; padding: .2rem .6rem; border-radius: 999px; background: rgba(63,199,188,.14); color: var(--sb-accent); }

/* ---------- topbar ---------- */
.panel-main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.topbar-panel { height: var(--topbar-h); background: rgba(255,255,255,.92); backdrop-filter: saturate(1.4) blur(8px); border-bottom: 1px solid var(--card-border); display: flex; align-items: center; gap: 1rem; padding: 0 1.75rem; position: sticky; top: 0; z-index: 1020; }
.topbar-panel .search { max-width: 380px; flex: 1; }
.topbar-panel .search .form-control { background: var(--page-bg); border-color: transparent; border-radius: 999px; padding-left: 2.4rem; height: 40px; font-size: .88rem; }
.topbar-panel .search .form-control:focus { background: #fff; border-color: var(--primary); }
.topbar-panel .search i { position: absolute; left: .95rem; top: 50%; transform: translateY(-50%); color: var(--muted); }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), var(--accent)); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem; flex-shrink: 0; }
.user-menu .dropdown-toggle::after { display: none; }
.user-menu .dropdown-menu { border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); padding: .5rem; min-width: 220px; }
.user-menu .dropdown-item { border-radius: 8px; padding: .5rem .75rem; font-size: .9rem; }
.sidebar-toggle { display: none; }

/* ---------- content ---------- */
.panel-content { padding: 1.75rem 1.75rem 2.5rem; flex: 1; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.page-head h1 { font-size: 1.6rem; margin: 0; }
.page-head h1 .badge-soft { vertical-align: middle; position: relative; top: -2px; }
.page-head .breadcrumb { font-size: .8rem; margin-bottom: .35rem; }
.panel-footer { padding: 1rem 1.75rem; font-size: .8rem; color: var(--muted); border-top: 1px solid var(--card-border); background: var(--surface); }

/* ---------- stat cards ---------- */
.stat-card { position: relative; overflow: hidden; background: var(--surface); border: 1px solid var(--card-border); box-shadow: var(--card-shadow); border-radius: var(--radius); padding: 1.15rem 1.1rem; display: flex; align-items: center; gap: .85rem; height: 100%; transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease; color: inherit; }
/* Thin colour rail on the left picks up the icon's tone. */
.stat-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--rail, transparent); }
.stat-card:has(.tone-primary) { --rail: var(--primary); }
.stat-card:has(.tone-accent) { --rail: var(--accent); }
.stat-card:has(.tone-gold) { --rail: var(--gold); }
.stat-card:has(.tone-rose) { --rail: #d1435b; }
a.stat-card:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(13,42,60,.08); border-color: #cfdbe3; color: inherit; }
.stat-card .icon { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.35rem; flex-shrink: 0; }
.stat-card .value { font-size: 1.65rem; font-weight: 700; color: var(--ink); line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-card .label { font-size: .82rem; color: var(--muted); }
.tone-primary { background: #e4f0f5; color: var(--primary); }
.tone-accent { background: #e1f5f3; color: #0f8b83; }
.tone-gold { background: #fdf3e1; color: #b36d06; }
.tone-rose { background: #fceaed; color: #b42330; }
.tone-violet { background: #efecfc; color: #5a48c5; }

.stat-card .hint { font-size: .74rem; color: var(--muted); margin-top: .3rem; display: inline-flex; align-items: center; white-space: nowrap; }
.stat-card .hint i { font-size: 1rem; margin: 0 -.05rem 0 -.25rem; }
.stat-card .hint-up { color: #137a45; font-weight: 600; }
.stat-card .hint-warn { color: #a96404; font-weight: 600; }
.min-w-0 { min-width: 0; }

/* ---------- dashboard ---------- */
.panel-content .card-header { display: flex; align-items: center; justify-content: space-between; gap: .75rem; min-height: 56px; color: var(--ink); border-bottom-color: var(--card-border); }
.panel-content .card-header a.small { font-weight: 600; }
.card-header-note { font-size: .78rem; font-weight: 500; color: var(--muted); background: var(--page-bg); padding: .2rem .65rem; border-radius: 999px; }
.dash-date { font-size: .78rem; font-weight: 600; color: var(--accent); text-transform: uppercase; letter-spacing: .08em; margin-bottom: .35rem; }
.chart-fill { position: relative; flex: 1 1 auto; min-height: 300px; }
.chart-fill canvas { position: absolute; inset: 0; }
.donut-wrap { position: relative; height: 180px; margin-bottom: 1rem; }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; }
.donut-value { font-size: 1.9rem; font-weight: 700; color: var(--ink); line-height: 1; }
.donut-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-top: .25rem; }
.legend-list { list-style: none; margin: 0; padding: 0; }
.legend-list li { display: flex; align-items: center; justify-content: space-between; padding: .45rem 0; font-size: .87rem; border-top: 1px dashed var(--border); }
.legend-list li:first-child { border-top: 0; }
.legend-list a { display: inline-flex; align-items: center; gap: .55rem; }
.legend-list a:hover { color: var(--primary) !important; }
.swatch { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.legend-num { font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.legend-pct { display: inline-block; min-width: 3.1rem; text-align: right; font-weight: 500; color: var(--muted); font-size: .8rem; }
.avatar-sm { width: 34px; height: 34px; font-size: .74rem; }
.avatar-xs { width: 26px; height: 26px; font-size: .64rem; }
.dash-table td { padding-top: .8rem; padding-bottom: .8rem; }
.dash-table { table-layout: fixed; }
.dash-table .title-cell { white-space: normal; }
@media (max-width: 575.98px) { .dash-table { table-layout: auto; } .dash-table colgroup { display: none; } }
.dash-table .title-cell .sub { margin-top: .15rem; }
.dash-table .ref { font-weight: 600; color: var(--primary); }
.attention-title { font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin: 1.1rem 0 .4rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.attention-item { display: flex; align-items: center; gap: .75rem; padding: .55rem .6rem; margin: 0 -.6rem; border-radius: var(--radius-sm); color: var(--text); font-size: .88rem; transition: background .15s ease; }
.attention-item:hover { background: var(--page-bg); color: var(--ink); }
.attention-icon { width: 32px; height: 32px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.attention-count { min-width: 28px; text-align: center; font-weight: 700; font-size: .8rem; padding: .1rem .5rem; border-radius: 999px; background: var(--page-bg); color: var(--muted); font-variant-numeric: tabular-nums; }
.attention-count.is-due { background: #fff4e0; color: #a96404; }
.workload-list, .activity-list { list-style: none; margin: 0; padding: 0; }
.workload-list li { display: flex; align-items: center; gap: .8rem; padding: .7rem 0; border-top: 1px solid var(--border); }
.workload-list li:first-child { border-top: 0; padding-top: 0; }
.workload-counts { display: inline-flex; gap: .7rem; font-size: .82rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.workload-counts a { display: inline-flex; align-items: center; gap: .3rem; color: var(--ink-2); }
.workload-counts a:hover { color: var(--primary); }
.workload-counts i { color: var(--muted); }
.load-bar { height: 6px; border-radius: 999px; background: var(--page-bg); margin-top: .45rem; overflow: hidden; }
.load-bar span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primary), var(--accent)); min-width: 6px; }
.activity-list li { display: flex; align-items: center; gap: .8rem; padding: .7rem 0; border-top: 1px solid var(--card-border); }
.activity-list li:first-child { border-top: 0; }
.activity-time { font-size: .76rem; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.activity-body { font-size: .85rem; color: var(--text); margin-top: .15rem; }

/* ---------- edit forms (articles) ---------- */
.page-sub { color: var(--muted); font-size: .9rem; margin: .35rem 0 0; }
.section-head { display: flex; align-items: center; gap: .75rem; }
.section-icon { width: 34px; height: 34px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; font-size: 1rem; flex-shrink: 0; }
.section-title { font-weight: 600; color: var(--ink); line-height: 1.2; }
.section-hint { font-size: .78rem; font-weight: 400; color: var(--muted); margin-top: .1rem; }
.article-form .card-header { padding-top: .85rem; padding-bottom: .85rem; }
.article-form .card-body { padding: 1.5rem; }
.article-form .form-control, .article-form .form-select { min-height: 44px; }
.article-form textarea.form-control { min-height: 0; }
.form-control-title { font-size: 1.05rem; font-weight: 600; color: var(--ink); }
.form-control-title::placeholder { font-weight: 400; color: #9aa9b5; }
.article-form .form-control::placeholder { color: #9aa9b5; }
.form-control-abstract { line-height: 1.65; resize: vertical; min-height: 240px !important; }
.article-form .input-group-text { font-size: .82rem; font-family: var(--font-body); }
.article-form .input-group > .form-control { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.article-form .input-group > .input-group-text { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.status-help { list-style: none; padding: .75rem .9rem; margin: .75rem 0 1.25rem; background: var(--page-bg); border-radius: var(--radius-sm); font-size: .78rem; color: var(--muted); }
.status-help li { display: flex; gap: .4rem; padding: .12rem 0; }
.status-help strong { min-width: 70px; color: var(--ink-2); font-weight: 600; }
@media (min-width: 1200px) { .form-aside { position: sticky; top: calc(var(--topbar-h) + 1.25rem); } }

/* ---------- list tables ---------- */
@media (min-width: 576px) { .table-fixed { table-layout: fixed; } }
.table .cell-main { color: var(--ink); font-weight: 500; }
.table .sub i { font-size: .75rem; opacity: .7; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.4; }
.ref-link { font-weight: 600; color: var(--primary); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ref-link:hover { color: var(--primary-600); text-decoration: underline; text-underline-offset: 3px; }
.agent-chip { display: inline-flex; align-items: center; gap: .5rem; max-width: 100%; color: var(--ink); font-weight: 500; }
.unassigned-pill { display: inline-flex; align-items: center; padding: .2rem .65rem; border: 1px dashed #c3ced8; border-radius: 999px; font-size: .76rem; font-weight: 600; color: var(--muted); white-space: nowrap; }
.sub-table tbody tr { transition: background .12s ease; }
.sub-table tbody tr:hover .ref-link { text-decoration: underline; text-underline-offset: 3px; }
.sub-table td { padding-top: 1rem; padding-bottom: 1rem; }
/* Tighter gutters between columns; outer cells keep 1.25rem so text lines up with the card header. */
@media (min-width: 576px) {
  .sub-table th, .sub-table td { padding-left: .75rem; padding-right: .75rem; }
  .sub-table th:first-child, .sub-table td:first-child { padding-left: 1.25rem; }
  .sub-table th:last-child, .sub-table td:last-child { padding-right: 1.25rem; }
}

/* ---------- pagination ---------- */
body.panel .card-footer { padding: .9rem 1.25rem; background: #fbfcfd; border-top-color: var(--card-border); border-radius: 0 0 var(--radius) var(--radius); }
body.panel .pagination { gap: .3rem; }
body.panel .page-link { min-width: 34px; height: 34px; padding: 0 .6rem; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px !important; border: 1px solid var(--card-border); background: #fff; color: var(--ink-2); font-size: .84rem; font-weight: 600; font-variant-numeric: tabular-nums; transition: background .15s ease, color .15s ease, border-color .15s ease; }
body.panel .page-link:hover { background: var(--primary-50); border-color: #c9dde6; color: var(--primary); }
body.panel .page-link:focus { box-shadow: 0 0 0 .2rem rgba(11,92,122,.15); }
body.panel .page-item.active .page-link { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 3px 8px rgba(11,92,122,.25); }
body.panel .page-item.disabled .page-link { background: transparent; color: #b4c0ca; border-color: var(--card-border); }
body.panel .page-step .page-link { padding: 0 .75rem; }
body.panel .page-step i { font-size: .75rem; }
@media (max-width: 575.98px) { body.panel .page-step span { display: none; } }

/* ---------- tables ---------- */
.table-card .card-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; }
.table { --bs-table-hover-bg: #f5f9fa; margin: 0; font-size: .9rem; }
.table thead th { background: #f6f9fb; color: #6a7f8e; font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; font-weight: 600; border-bottom: 1px solid var(--card-border); padding: .8rem 1.25rem; white-space: nowrap; }
.table td { padding: .85rem 1.25rem; vertical-align: middle; border-color: var(--card-border); }
.table .title-cell { font-weight: 600; color: var(--ink); }
.table td > .fw-600, .table td > a.fw-600 { white-space: nowrap; }
.table .sub { font-size: .8rem; color: var(--muted); font-weight: 400; }
.sort-link { color: inherit; }
.sort-link:hover, .sort-link.active { color: var(--primary); }
.actions { display: flex; gap: .35rem; justify-content: flex-end; flex-wrap: nowrap; }
.actions form { margin: 0; }
/* One row on laptops: search grows, selects size to their text, buttons match control height. */
.filter-bar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.filter-bar .form-control, .filter-bar .form-select { font-size: .87rem; height: 38px; }
.filter-bar .form-control { flex: 1 1 240px; width: auto; min-width: 200px; padding: .45rem .75rem; }
.filter-bar .form-select { flex: 0 1 auto; min-width: 140px; max-width: 260px; padding: .45rem 2.25rem .45rem .75rem; }
.filter-bar .cs { flex: 0 1 auto; min-width: 140px; max-width: 260px; }
.filter-bar .cs-btn.form-select { max-width: none; padding-right: .75rem; }
.filter-bar .btn { height: 38px; display: inline-flex; align-items: center; padding: 0 1rem; font-size: .85rem; white-space: nowrap; }
.card-footer { background: transparent; border-top: 1px solid var(--border); padding: .85rem 1.25rem; }

/* ---------- detail views ---------- */
.detail-list { margin-bottom: 0; } /* keep .row's negative side margins so columns line up with card text */
.detail-list dt { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; margin-bottom: .2rem; }
.detail-list dd { margin-bottom: 1rem; color: var(--ink); }
.timeline { list-style: none; padding: 0; margin: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 15px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.timeline li { position: relative; padding-left: 44px; padding-bottom: 1.15rem; }
.timeline li:last-child { padding-bottom: 0; }
.timeline .dot { position: absolute; left: 6px; top: 2px; width: 20px; height: 20px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); display: flex; align-items: center; justify-content: center; font-size: .6rem; color: var(--accent); }
.timeline .meta { font-size: .78rem; color: var(--muted); }
.timeline .body { font-size: .9rem; white-space: pre-line; }

/* ---------- auth pages ---------- */
body.auth { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; background: var(--surface); }
.auth-side { background: radial-gradient(800px 400px at 100% 0, rgba(20,163,154,.35), transparent 60%), linear-gradient(150deg, var(--ink), #12345a 60%, var(--primary)); color: #fff; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-side::before { content: ""; position: absolute; inset: 0; background-image: linear-gradient(rgba(255,255,255,.05) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.05) 1px, transparent 1px); background-size: 44px 44px; }
.auth-side > * { position: relative; }
.auth-side .brand { color: #fff; }
.auth-side .brand-text small { color: #9fb2cc; }
.auth-side h2 { color: #fff; font-size: 2.2rem; max-width: 460px; }
.auth-side p { color: #c9d6e8; max-width: 440px; }
.auth-art { display: block; width: min(400px, 100%); height: auto; margin-top: 2.25rem; pointer-events: none; filter: drop-shadow(0 22px 40px rgba(4, 16, 34, .35)); }
.auth-form-wrap { display: flex; align-items: center; justify-content: center; padding: 2.5rem 1.5rem; }
.auth-form { width: 100%; max-width: 410px; }
.auth-form h1 { font-size: 1.9rem; }

/* ---------- responsive ---------- */
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  body.sidebar-open .sidebar { transform: none; }
  body.sidebar-open .sidebar-backdrop { display: block; }
  .sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(15,30,54,.45); z-index: 1035; }
  .panel-main { margin-left: 0; }
  .sidebar-toggle { display: inline-flex; }
  .panel-content { padding: 1.25rem 1rem 2rem; }
  .topbar-panel { padding: 0 1rem; }
  body.auth { grid-template-columns: 1fr; }
  .auth-side { display: none; }
}
@media (max-width: 575.98px) {
  .topbar-panel .search { display: none; }
  .page-head h1 { font-size: 1.35rem; }
  .filter-bar > * { flex: 1 1 100%; }
  .filter-bar .form-control, .filter-bar .form-select, .filter-bar .cs { flex: 1 1 100%; min-width: 0; max-width: none; }
  .table-stack .cell-stack { min-width: 0; text-align: right; }
  /* Stack table rows as cards on phones */
  .table-stack thead { display: none; }
  .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
  .table-stack tr { border-bottom: 1px solid var(--border); padding: .6rem 0; }
  .table-stack td { border: 0; padding: .3rem 1rem; display: flex; justify-content: space-between; gap: 1rem; text-align: right; }
  .table-stack td::before { content: attr(data-label); font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; text-align: left; }
  .table-stack td.title-cell { display: block; text-align: left; }
  .table-stack td.title-cell::before { display: none; }
  .table-stack td.article-cell { min-width: 0; max-width: none; }
  .table-stack .actions { justify-content: flex-end; }
}

/* article form: journal page stage */
.inpress-toggle { padding: .75rem .9rem; border-radius: var(--radius-sm); border: 1px dashed var(--border); background: var(--page-bg, #f4f6f9); }

/* article form: full-text toolbar and figures */
.md-toolbar { display: flex; flex-wrap: wrap; gap: .35rem; padding: .5rem; margin-bottom: -1px; border: 1px solid var(--border); border-bottom: 0; border-radius: var(--radius-sm) var(--radius-sm) 0 0; background: var(--page-bg, #f4f6f9); }
.md-toolbar .btn { display: inline-flex; align-items: center; gap: .3rem; }
.md-toolbar + label + .body-editor { border-top-left-radius: 0; border-top-right-radius: 0; }
.body-editor { font-size: .85rem; line-height: 1.6; min-height: 340px; }
.fig-list, .fig-new { display: grid; gap: .75rem; }
.fig-list { margin-bottom: .75rem; }
.fig-row { padding: .75rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface, #fff); }
.fig-row-new { border-style: dashed; }
.fig-thumb { flex: 0 0 96px; width: 96px; height: 96px; border-radius: 8px; overflow: hidden; background: var(--page-bg, #f4f6f9); display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 1.6rem; }
.fig-thumb img { width: 100%; height: 100%; object-fit: cover; }
.fig-fields { flex: 1; min-width: 0; }
.fig-num { font-size: .85rem; }
.fig-order { width: 70px; }
@media (max-width: 575.98px) { .fig-row-main { flex-direction: column; } .fig-thumb { width: 100%; flex-basis: auto; height: 160px; } }

/* articles list: title (two lines max), authors (one line), type + volume/issue */
.article-cell { min-width: 300px; max-width: 460px; white-space: normal; }
.article-title { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.35; font-weight: 600; color: var(--ink); text-decoration: none; }
a.article-title:hover { color: var(--primary); }
.article-cell .sub { margin-top: .3rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.article-cell .sub .bi { margin-right: .35rem; opacity: .7; }
.article-cell .meta { display: flex; flex-wrap: wrap; gap: .25rem .4rem; margin-top: .4rem; }
.article-cell .meta span { font-size: .7rem; font-weight: 600; color: #5d7385; background: #f1f5f8; border-radius: 6px; padding: .12rem .45rem; line-height: 1.4; }

/* articles list: stage badge with its one-step move button */
.stage-cell { display: flex; align-items: center; gap: .5rem; flex-wrap: nowrap; }
.stage-cell form { margin: 0; }
.btn-stage { display: inline-flex; align-items: center; gap: .3rem; height: 26px; padding: 0 .7rem; border-radius: 999px; font-size: .74rem; font-weight: 600; white-space: nowrap; color: var(--primary); background: transparent; border: 1px solid var(--card-border); }
.btn-stage:hover, .btn-stage:focus-visible { color: #fff; background: var(--primary); border-color: var(--primary); }
.btn-stage .bi { font-size: .8rem; transition: transform .2s ease; }
.btn-stage:hover .bi { transform: translateX(2px); }

/* small pill tabs inside a card header (journal menu pages) */
.nav-pills-sm { gap: .25rem; }
.nav-pills-sm .nav-link { padding: .3rem .75rem; font-size: .8rem; font-weight: 500; border-radius: 999px; color: var(--muted); }
.nav-pills-sm .nav-link:hover { color: var(--primary); background: var(--primary-50); }
.nav-pills-sm .nav-link.active { color: #fff; background: var(--primary); }
.table-stack .btn-sm.btn-icon { width: 30px; height: 30px; }

/* ---------- article form: sections in PDF order ---------- */
.pdf-steps { position: sticky; top: calc(var(--topbar-h, 64px) + .5rem); z-index: 5; display: flex; gap: .25rem; margin-bottom: 1.25rem; padding: .35rem; overflow-x: auto; scrollbar-width: none; background: rgba(255, 255, 255, .92); backdrop-filter: blur(8px); border: 1px solid var(--card-border, var(--border)); border-radius: 14px; box-shadow: 0 4px 16px rgba(15, 30, 54, .06); }
.pdf-steps::-webkit-scrollbar { display: none; }
.pdf-steps a { flex: 1 0 auto; display: inline-flex; align-items: center; justify-content: center; gap: .45rem; padding: .5rem .7rem; border-radius: 10px; color: var(--muted); font-size: .84rem; font-weight: 600; white-space: nowrap; transition: background .2s, color .2s; }
.pdf-steps a .n { width: 22px; height: 22px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: .72rem; background: var(--page-bg, #f1f4f7); color: var(--muted); transition: background .2s, color .2s; }
.pdf-steps a .bi { display: none; }
.pdf-steps a:hover { background: var(--page-bg, #f1f4f7); color: var(--ink); }
.pdf-steps a.current { background: var(--primary-50, #e8f2f6); color: var(--primary); }
.pdf-steps a.done .n { background: var(--accent, #14a39a); color: #fff; font-size: 0; }
.pdf-steps a.done .n::before { content: "\F26E"; font-family: bootstrap-icons; font-size: .8rem; }
@media (max-width: 767.98px) { .pdf-steps a .t { display: none; } .pdf-steps a .bi { display: inline; } }
.pdf-sec { scroll-margin-top: calc(var(--topbar-h, 64px) + 5rem); }
.sec-n { font-weight: 700; font-size: .95rem; }

.chip-preview { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .55rem; }
.chip-preview:empty { display: none; }
.chip-preview span { padding: .15rem .55rem; border-radius: 6px; background: var(--primary-50, #e8f2f6); color: var(--primary); font-size: .78rem; font-weight: 500; }

/* "as printed in the PDF" box */
.pdf-mini { margin-top: 1.25rem; padding: 1rem 1.15rem; border-radius: 10px; background: #fff; border: 1px solid var(--border); box-shadow: inset 4px 0 0 var(--accent, #14a39a); font-family: "Source Serif 4", Georgia, serif; }
.pdf-mini-label { display: inline-flex; align-items: center; gap: .35rem; margin-bottom: .5rem; font-family: var(--font-body); font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.pdf-mini-label .bi { color: #d92d20; }
.pdf-mini-authors { margin: 0 0 .4rem; font-weight: 700; font-size: .98rem; text-align: center; color: var(--ink); }
.pdf-mini-authors sup, .pdf-mini-affil sup { font-size: .65em; }
.pdf-mini-affil { list-style: none; padding: 0; margin: 0; font-style: italic; font-size: .86rem; line-height: 1.45; color: var(--ink-2, #33415c); }
.pdf-mini-affil sup { font-style: normal; margin-right: 2px; }

/* full text: Write / Preview */
.seg-tabs { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--page-bg, #f1f4f7); }
.seg-tabs button { display: inline-flex; align-items: center; gap: .35rem; padding: .35rem .8rem; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: .82rem; font-weight: 600; }
.seg-tabs button.active { background: #fff; color: var(--primary); box-shadow: 0 1px 3px rgba(15, 30, 54, .12); }
.md-sep { width: 1px; align-self: stretch; margin: .2rem .15rem; background: var(--border); }
.body-preview { min-height: 340px; max-height: 640px; overflow-y: auto; padding: 1.5rem 1.75rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; font-family: "Source Serif 4", Georgia, serif; font-size: .98rem; line-height: 1.6; color: #1b1f24; text-align: justify; }
.body-preview h2 { font-family: inherit; font-size: 1.25rem; font-weight: 700; margin: 1.3rem 0 .6rem; text-align: left; }
.body-preview h3 { font-family: inherit; font-size: 1.05rem; font-weight: 700; margin: 1rem 0 .5rem; text-align: left; }
.body-preview > h2:first-child { margin-top: 0; }
.body-preview p { margin-bottom: .7rem; text-indent: 1.5em; }
.body-preview ul { margin-bottom: .7rem; }
.body-preview .paper-figure { margin: 1rem 0 1.25rem; }
.body-preview .paper-figure img { display: block; max-width: 100%; max-height: 360px; margin: 0 auto; }
.body-preview .paper-figure figcaption { font-size: .82rem; margin-top: .45rem; text-align: left; }

/* figures and references */
.fig-code { font-size: .74rem; padding: .1rem .4rem; border-radius: 5px; background: var(--page-bg, #f1f4f7); color: var(--primary); }
.fig-drop { cursor: pointer; margin: 0; transition: border-color .2s, background .2s; }
.fig-drop:hover { border-color: var(--accent, #14a39a); background: #fbfefd; }
.fig-drop { position: relative; } .fig-drop:focus-within { outline: 2px solid var(--accent, #14a39a); outline-offset: 2px; }
.refs-editor { font-size: .82rem; line-height: 1.6; }

/* PDF preview card in the form sidebar */
.pdf-preview-card { overflow: hidden; }
.pdf-thumb { position: relative; height: 128px; background: linear-gradient(180deg, #525659, #3c4043); display: flex; flex-direction: column; align-items: center; padding-top: 16px; }
.pdf-thumb::before { content: ""; position: absolute; top: 16px; width: 120px; height: 140px; background: #fff; border-radius: 2px; box-shadow: 0 4px 14px rgba(0, 0, 0, .35); }
.pdf-thumb > span { position: relative; display: block; width: 96px; margin-top: 6px; }
.pt-bar { height: 3px !important; background: var(--accent, #14a39a); margin-top: 12px !important; }
.pt-title { height: 7px; border-radius: 2px; background: #1b1f24; width: 80px !important; }
.pt-line { height: 4px; border-radius: 2px; background: #c3cad3; }
.pt-line.w80 { width: 76px !important; } .pt-line.w60 { width: 58px !important; }
.pt-cols { display: flex !important; gap: 6px; }
.pt-cols span { flex: 1; height: 30px; background: repeating-linear-gradient(180deg, #d5dbe2 0 3px, transparent 3px 7px); }
.pdf-thumb .bi { position: absolute; right: 14px; bottom: 10px; font-size: 1.6rem; color: #f28b82; }

/* article form: embedded PDF preview */
.pdf-embed-card { overflow: hidden; }
.pdf-embed-frame { background: #525659; height: 920px; max-height: 85vh; }
.pdf-embed-frame iframe { display: block; width: 100%; height: 100%; border: 0; }
.pdf-embed-empty { display: flex; flex-direction: column; align-items: center; gap: .5rem; padding: 2.5rem 1rem; border: 1px dashed var(--border); border-radius: var(--radius-sm); color: var(--muted); }
.pdf-embed-empty .bi { font-size: 2rem; color: #d92d20; }

/* figure: PDF layout controls and mini page sketch */
.fig-row-main { display: flex; gap: .9rem; align-items: flex-start; }
.fig-layout { margin-top: .75rem; padding: .75rem .85rem .85rem; border-radius: 10px; background: var(--page-bg, #f4f6f9); }
.fig-layout-head { display: flex; align-items: center; gap: .4rem; margin-bottom: .6rem; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.fig-layout-head .bi { color: #d92d20; font-size: .85rem; }
.fig-layout-grid { display: grid; grid-template-columns: minmax(0, 1fr) 118px; gap: 1rem; align-items: start; }
.fig-layout-fields { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: .55rem .75rem; align-items: center; }
.fig-l-label { margin: 0; font-size: .78rem; font-weight: 600; color: var(--ink-2, #33415c); }
.fig-presets { grid-column: 2; display: flex; flex-wrap: wrap; gap: .3rem; margin-top: -.25rem; }
.fig-presets .btn { padding: .12rem .55rem; font-size: .74rem; }
.fig-presets .btn.active { background: var(--primary-50, #e8f2f6); color: var(--primary); border-color: currentColor; }
.fig-size { display: flex; align-items: center; gap: .6rem; }
.fig-size .form-range { flex: 1; }
.fig-size-out { min-width: 3rem; padding: .1rem .4rem; border-radius: 6px; background: #fff; border: 1px solid var(--border); font-size: .78rem; font-weight: 700; text-align: center; color: var(--primary); }
.fig-seg { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; border-radius: 9px; background: #fff; border: 1px solid var(--border); justify-self: start; }
.fig-seg label { position: relative; margin: 0; cursor: pointer; }
.fig-seg input { position: absolute; opacity: 0; pointer-events: none; }
.fig-seg span { display: inline-flex; align-items: center; gap: .3rem; padding: .25rem .6rem; border-radius: 7px; font-size: .78rem; font-weight: 600; color: var(--muted); transition: background .15s, color .15s; }
.fig-seg label:hover span { color: var(--ink); }
.fig-seg input:checked + span { background: var(--primary); color: #fff; }
.fig-seg input:focus-visible + span { outline: 2px solid var(--accent, #14a39a); outline-offset: 1px; }
/* sketch of an A4 page: two text columns with the figure box placed as chosen */
.fig-mini-page { --fig-w: 100%; display: flex; flex-direction: column; gap: 6px; width: 118px; height: 160px; padding: 12px 10px; background: #fff; border-radius: 3px; box-shadow: 0 2px 8px rgba(15, 30, 54, .14); overflow: hidden; }
.fm-lines { flex: 1; min-height: 14px; background: repeating-linear-gradient(180deg, #d5dbe2 0 2px, transparent 2px 6px) left / 46% 100% no-repeat, repeating-linear-gradient(180deg, #d5dbe2 0 2px, transparent 2px 6px) right / 46% 100% no-repeat; }
.fm-row { display: flex; flex: none; }
.fig-span-column .fm-row { display: grid; grid-template-columns: 46% 1fr; gap: 8%; }
.fig-span-column .fm-row::after { content: ""; background: repeating-linear-gradient(180deg, #d5dbe2 0 2px, transparent 2px 6px); }
.fm-box { width: var(--fig-w); height: 52px; display: flex; align-items: center; justify-content: center; overflow: hidden; border-radius: 2px; background: var(--primary-50, #e8f2f6); outline: 1.5px solid var(--primary); color: var(--primary); font-size: .9rem; transition: width .15s, margin .15s; }
.fig-span-column .fm-box { height: 40px; }
.fm-box img { width: 100%; height: 100%; object-fit: cover; }
.fig-mini-page.fig-center .fm-box { margin: 0 auto; }
.fig-mini-page.fig-right .fm-box { margin-left: auto; }
@media (max-width: 767.98px) { .fig-layout-grid { grid-template-columns: 1fr; } .fig-mini-page { justify-self: center; } }
@media (max-width: 575.98px) { .fig-layout-fields { grid-template-columns: 1fr; } .fig-presets { grid-column: 1; margin-top: 0; } }

/* full-text preview follows the same figure layout */
.body-preview .paper-figure:is(.fig-left, .fig-center, .fig-right) { width: var(--fig-w, 100%); max-width: 100%; }
.body-preview .paper-figure.fig-center { margin-left: auto; margin-right: auto; }
.body-preview .paper-figure.fig-left { margin-left: 0; margin-right: auto; }
.body-preview .paper-figure.fig-right { margin-left: auto; margin-right: 0; }

/* ---------- my profile ---------- */
.profile-card { overflow: hidden; position: sticky; top: calc(var(--topbar-h, 64px) + 1.5rem); }
.profile-cover { height: 96px; background: radial-gradient(circle at 85% -20%, rgba(255, 255, 255, .22) 0 60px, transparent 61px), radial-gradient(circle at 8% 130%, rgba(255, 255, 255, .14) 0 70px, transparent 71px), linear-gradient(120deg, var(--primary), var(--accent)); }
.profile-id { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 0 1.5rem 1.25rem; margin-top: -46px; }
.profile-avatar { width: 92px; height: 92px; font-size: 1.85rem; letter-spacing: .02em; border: 4px solid #fff; box-shadow: 0 6px 18px rgba(15, 30, 54, .18); margin-bottom: .85rem; }
.profile-name { font-size: 1.3rem; margin: 0 0 .2rem; }
.profile-email { margin: 0 0 .75rem; color: var(--muted); font-size: .9rem; word-break: break-all; }
.profile-badges { display: flex; flex-wrap: wrap; justify-content: center; gap: .35rem; }
.profile-stats { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--card-border, var(--border)); }
.profile-stats > div { display: flex; flex-direction: column; align-items: center; gap: .1rem; padding: .9rem .5rem; text-align: center; }
.profile-stats > div + div { border-left: 1px solid var(--card-border, var(--border)); }
.profile-stats strong { font-size: 1.35rem; line-height: 1.1; color: var(--primary); }
.profile-stats span { font-size: .72rem; color: var(--muted); line-height: 1.25; }
.profile-facts { list-style: none; margin: 0; padding: .5rem 1.5rem; border-top: 1px solid var(--card-border, var(--border)); }
.profile-facts li { display: flex; align-items: center; gap: .85rem; padding: .7rem 0; }
.profile-facts li + li { border-top: 1px dashed var(--card-border, var(--border)); }
.profile-facts li > div { display: flex; flex-direction: column; min-width: 0; }
.profile-facts span:not(.section-icon) { font-size: .74rem; color: var(--muted); }
.profile-facts strong { font-size: .9rem; font-weight: 600; color: var(--ink); overflow-wrap: anywhere; }
.profile-links { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--card-border, var(--border)); }
.profile-links a { display: flex; align-items: center; justify-content: center; gap: .45rem; padding: .85rem .5rem; font-size: .84rem; font-weight: 600; color: var(--primary); transition: background .2s; }
.profile-links a + a { border-left: 1px solid var(--card-border, var(--border)); }
.profile-links a:hover { background: var(--primary-50, #e8f2f6); }
.profile-form { scroll-margin-top: calc(var(--topbar-h, 64px) + 1.5rem); }
.profile-form .card-body { padding: 1.5rem; }
.profile-form .input-group-text { background: var(--page-bg, #f4f6f9); color: var(--muted); min-width: 44px; justify-content: center; }
.profile-form .form-control:disabled { background: var(--page-bg, #f4f6f9); color: var(--ink-2, #33415c); }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; padding: .9rem 1.5rem; background: var(--page-bg, #f8fafb); border-top-color: var(--card-border, var(--border)); }
.form-actions-note { display: inline-flex; align-items: center; gap: .4rem; font-size: .8rem; color: var(--muted); }
.form-actions .btn { margin-left: auto; min-width: 170px; }
@media (max-width: 575.98px) { .form-actions .btn { width: 100%; } }
@media (max-width: 991.98px) { .profile-card { position: static; } }
/* password strength */
.pw-meter { padding: .9rem 1rem; border-radius: 10px; background: var(--page-bg, #f4f6f9); --pw: #c3cad3; }
.pw-meter[data-level="1"] { --pw: #d92d20; }
.pw-meter[data-level="2"] { --pw: #f79009; }
.pw-meter[data-level="3"] { --pw: #14a39a; }
.pw-meter[data-level="4"] { --pw: #079455; }
.pw-meter-bar { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.pw-meter-bar span { height: 6px; border-radius: 3px; background: #dde3ea; transition: background .2s; }
.pw-meter[data-level="1"] .pw-meter-bar span:nth-child(-n+1), .pw-meter[data-level="2"] .pw-meter-bar span:nth-child(-n+2),
.pw-meter[data-level="3"] .pw-meter-bar span:nth-child(-n+3), .pw-meter[data-level="4"] .pw-meter-bar span { background: var(--pw); }
.pw-meter-label { margin: .45rem 0 .55rem; font-size: .8rem; font-weight: 600; color: var(--pw); }
.pw-meter[data-level="0"] .pw-meter-label { color: var(--muted); }
.pw-rules { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .3rem 1rem; list-style: none; margin: 0; padding: 0; font-size: .8rem; color: var(--muted); }
.pw-rules li { display: flex; align-items: center; gap: .4rem; }
.pw-rules .bi { color: #c3cad3; transition: color .2s; }
.pw-rules li.ok { color: var(--ink); }
.pw-rules li.ok .bi { color: #079455; }

/* ---------- analytics ---------- */
.range-tabs { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--surface, #fff); border: 1px solid var(--card-border, var(--border)); }
.range-tabs a { padding: .4rem .8rem; border-radius: 8px; font-size: .82rem; font-weight: 600; color: var(--muted); white-space: nowrap; }
.range-tabs a:hover { color: var(--ink); }
.range-tabs a.active { background: var(--primary); color: #fff; }
.an-kpis .stat-card { padding: 1rem .95rem; gap: .7rem; }
.an-kpis .stat-card .icon { width: 42px; height: 42px; font-size: 1.15rem; }
.an-kpis .stat-card .value { font-size: 1.5rem; }
.an-kpis .stat-card .hint { white-space: normal; }
.an-chart { height: 280px; }
.an-table td, .an-table th { vertical-align: middle; }
.an-table .num, .an-list .num { font-variant-numeric: tabular-nums; }
.an-page { display: block; font-weight: 600; color: var(--ink); }
a.an-page:hover { color: var(--primary); }
.an-path { display: block; font-size: .74rem; color: var(--muted); font-family: var(--bs-font-monospace); overflow-wrap: anywhere; }
.an-bar { display: block; height: 4px; margin-top: .4rem; border-radius: 2px; background: var(--page-bg, #f1f4f7); overflow: hidden; }
.an-bar > span { display: block; height: 100%; border-radius: 2px; background: var(--accent, #14a39a); }
.an-list { list-style: none; margin: 0; padding: 0; }
.an-list li { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: .2rem .75rem; padding: .55rem 0; }
.an-list li + li { border-top: 1px dashed var(--card-border, var(--border)); }
.an-list .an-bar { grid-column: 1 / -1; margin-top: 0; }
.an-list-name { display: inline-flex; align-items: center; gap: .5rem; min-width: 0; font-size: .9rem; font-weight: 500; overflow-wrap: anywhere; }
.an-list-name .bi { color: var(--muted); }
.an-list .num { font-weight: 700; color: var(--ink); }
@media (max-width: 575.98px) { .range-tabs { width: 100%; } .range-tabs a { flex: 1; text-align: center; padding: .4rem .3rem; } }
/* analytics: visitors */
.an-country { display: inline-flex; align-items: center; gap: .65rem; min-width: 0; }
.an-flag { flex: 0 0 auto; width: 28px !important; height: 20px; border-radius: 3px; background-size: cover; box-shadow: 0 0 0 1px rgba(15, 30, 54, .12); }
.an-flag-none { display: inline-flex; align-items: center; justify-content: center; background: var(--page-bg, #f1f4f7); color: var(--muted); font-size: .8rem; }
.an-loyalty { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.an-loyalty > div { display: grid; grid-template-columns: auto 1fr; align-items: center; column-gap: .5rem; }
.an-loyalty strong { font-size: 1.5rem; line-height: 1.1; color: var(--ink); font-variant-numeric: tabular-nums; }
.an-loyalty > div > span:last-child { grid-column: 2; font-size: .8rem; color: var(--muted); }
.an-loyalty small { font-size: .72rem; }
.an-dot { width: 10px; height: 10px; border-radius: 50%; }
.an-dot-new, .an-split > span:first-child { background: var(--primary); }
.an-dot-ret, .an-split > span:last-child { background: var(--accent, #14a39a); }
.an-split { display: flex; gap: 2px; height: 10px; margin-top: .9rem; border-radius: 5px; overflow: hidden; background: var(--page-bg, #f1f4f7); }
.an-split > span { display: block; min-width: 2px; }
.an-tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; gap: .25rem; }
.an-tabs .nav-link { white-space: nowrap; }
.an-sub { display: block; font-size: .76rem; color: var(--muted); }
.an-sub .bi { margin-right: .1rem; }
.an-ref { display: inline-flex; align-items: center; gap: .35rem; white-space: nowrap; }
.an-ref .bi { color: var(--muted); }

/* ---------- live chat inbox ---------- */
.chat-app { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 1.25rem; height: calc(100vh - var(--topbar-h, 64px) - 210px); min-height: 520px; }
.chat-list-card, .chat-thread-card { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.chat-list-head { padding: .85rem; border-bottom: 1px solid var(--card-border, var(--border)); display: grid; gap: .6rem; }
.chat-list-head .range-tabs a { flex: 1; text-align: center; }
.chat-count { display: inline-block; min-width: 1.4em; padding: 0 .35em; margin-left: .2rem; border-radius: 999px; background: rgba(15, 30, 54, .08); font-size: .7rem; }
.range-tabs a.active .chat-count { background: rgba(255, 255, 255, .25); }
.chat-search { position: relative; }
.chat-search .bi { position: absolute; left: .7rem; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: .85rem; }
.chat-search .form-control { padding-left: 2rem; }
.chat-list { flex: 1; overflow-y: auto; }
.chat-item { position: relative; display: flex; align-items: center; gap: .7rem; padding: .8rem .9rem; border-bottom: 1px solid var(--card-border, var(--border)); color: inherit; transition: background .15s; }
.chat-item:hover { background: var(--page-bg, #f4f6f9); }
.chat-item.active { background: var(--primary-50, #e8f2f6); box-shadow: inset 3px 0 0 var(--primary); }
.chat-item-main { flex: 1; min-width: 0; }
.chat-item-top { display: flex; justify-content: space-between; gap: .5rem; }
.chat-item-top strong { font-size: .88rem; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item-top time { font-size: .72rem; color: var(--muted); flex-shrink: 0; }
.chat-item-preview { display: block; font-size: .8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item.unread strong, .chat-item.unread .chat-item-preview { color: var(--ink); font-weight: 700; }
.chat-unread { flex-shrink: 0; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: #d92d20; color: #fff; font-size: .7rem; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.chat-closed-dot { color: var(--muted); font-size: .9rem; }
.chat-empty { margin: auto; text-align: center; padding: 2rem; max-width: 320px; }
.chat-empty .section-icon { width: 52px; height: 52px; font-size: 1.4rem; border-radius: 14px; margin-bottom: .9rem; }
.chat-thread-head { display: flex; align-items: center; gap: .8rem; padding: .85rem 1.1rem; border-bottom: 1px solid var(--card-border, var(--border)); }
.chat-thread-name { display: flex; align-items: center; gap: .5rem; font-weight: 700; color: var(--ink); }
.chat-thread-sub { display: flex; flex-wrap: wrap; gap: .1rem .4rem; font-size: .78rem; color: var(--muted); }
.chat-thread-sub a { color: var(--primary); }
.chat-messages { flex: 1; overflow-y: auto; padding: 1.25rem; background: var(--page-bg, #f6f8fb); display: flex; flex-direction: column; gap: .75rem; }
.cm { display: flex; flex-direction: column; max-width: 72%; align-self: flex-start; }
.cm-bubble { padding: .65rem .9rem; border-radius: 14px; font-size: .9rem; line-height: 1.5; overflow-wrap: anywhere; background: #fff; border: 1px solid var(--card-border, var(--border)); border-bottom-left-radius: 4px; }
.cm-meta { font-size: .7rem; color: var(--muted); margin-top: .2rem; }
.cm-staff { align-self: flex-end; align-items: flex-end; }
.cm-staff .cm-bubble { background: var(--primary); color: #fff; border-color: var(--primary); border-radius: 14px 14px 4px 14px; }
.cm-system .cm-bubble { background: var(--accent-50, #e6f6f4); border-color: transparent; color: var(--ink-2, #33415c); font-size: .84rem; }
.chat-reply { display: flex; gap: .6rem; align-items: flex-end; padding: .8rem 1rem; border-top: 1px solid var(--card-border, var(--border)); }
.chat-reply textarea { resize: none; }
.chat-reply .btn { flex-shrink: 0; height: 42px; }
.chat-reply-error:empty { display: none; }
@media (max-width: 991.98px) {
  .chat-app { grid-template-columns: 1fr; height: auto; min-height: 0; }
  .chat-app .chat-list-card { max-height: 70vh; }
  .chat-app.has-active .chat-list-card { display: none; }
  .chat-app:not(.has-active) .chat-thread-card { display: none; }
  .chat-app.has-active .chat-thread-card { height: calc(100vh - var(--topbar-h, 64px) - 180px); min-height: 460px; }
  .cm { max-width: 88%; }
}
