:root {
  --app-primary: #4968f2;
  --app-primary-rgb: 73, 104, 242;
  --app-primary-strong: #3553df;
  --app-success: #23a26d;
  --app-warning: #e7a62a;
  --app-danger: #e24d5f;
  --app-info: #3187d7;
  --app-purple: #805ad5;
  --app-bg: #f5f7fb;
  --app-surface: #ffffff;
  --app-surface-soft: #f8faff;
  --app-surface-raised: #ffffff;
  --app-sidebar-bg: rgba(255, 255, 255, .96);
  --app-topbar-bg: rgba(245, 247, 251, .88);
  --app-text: #172033;
  --app-text-muted: #697386;
  --app-border: #e5eaf1;
  --app-border-strong: #d7deea;
  --app-shadow-sm: 0 1px 2px rgba(16, 24, 40, .03), 0 5px 18px rgba(16, 24, 40, .04);
  --app-shadow-md: 0 12px 30px rgba(16, 24, 40, .08);
  --app-shadow-lg: 0 24px 60px rgba(16, 24, 40, .14);
  --app-radius-sm: .65rem;
  --app-radius: .9rem;
  --app-radius-lg: 1.15rem;
  --app-sidebar-width: 270px;
  --app-sidebar-collapsed: 84px;
  --app-topbar-height: 70px;
  --app-control-height: 44px;
  --bs-primary: var(--app-primary);
  --bs-primary-rgb: var(--app-primary-rgb);
  --bs-success: var(--app-success);
  --bs-body-bg: var(--app-bg);
  --bs-body-color: var(--app-text);
  --bs-border-color: var(--app-border);
  --bs-secondary-color: var(--app-text-muted);
  --bs-link-color: var(--app-primary);
  --bs-link-hover-color: var(--app-primary-strong);
  --bs-font-sans-serif: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

[data-bs-theme="dark"] {
  color-scheme: dark;
  --app-primary: #6f87ff;
  --app-primary-rgb: 111, 135, 255;
  --app-primary-strong: #91a3ff;
  --app-success: #3fc38a;
  --app-warning: #efb84d;
  --app-danger: #f16d7d;
  --app-info: #5ca7ea;
  --app-purple: #9b7be8;
  --app-bg: #0c1421;
  --app-surface: #121d2c;
  --app-surface-soft: #162233;
  --app-surface-raised: #182536;
  --app-sidebar-bg: rgba(13, 22, 36, .97);
  --app-topbar-bg: rgba(12, 20, 33, .88);
  --app-text: #eef3fb;
  --app-text-muted: #9aa8ba;
  --app-border: #263447;
  --app-border-strong: #334359;
  --app-shadow-sm: 0 2px 16px rgba(0, 0, 0, .16);
  --app-shadow-md: 0 18px 42px rgba(0, 0, 0, .25);
  --app-shadow-lg: 0 28px 72px rgba(0, 0, 0, .38);
  --bs-body-bg: var(--app-bg);
  --bs-body-color: var(--app-text);
  --bs-border-color: var(--app-border);
  --bs-secondary-color: var(--app-text-muted);
  --bs-tertiary-bg: var(--app-surface-soft);
  --bs-secondary-bg: var(--app-surface-soft);
  --bs-emphasis-color: #fff;
}

* { box-sizing: border-box; }
html { min-height: 100%; scroll-behavior: smooth; }
body {
  min-height: 100vh;
  margin: 0;
  background: var(--app-bg);
  color: var(--app-text);
  font-size: .925rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, select, textarea { font: inherit; }
a { text-underline-offset: .15em; }
::selection { background: rgba(var(--app-primary-rgb), .22); }

/* Shell */
.app-shell { min-height: 100vh; }
.app-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 1045;
  width: var(--app-sidebar-width);
  display: flex;
  flex-direction: column;
  background: var(--app-sidebar-bg);
  border-right: 1px solid var(--app-border);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  transition: width .24s ease, transform .24s ease;
}
.app-main {
  min-height: 100vh;
  margin-left: var(--app-sidebar-width);
  transition: margin-left .24s ease;
}
.app-topbar {
  position: sticky;
  top: 0;
  z-index: 1025;
  height: var(--app-topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1.65rem;
  background: var(--app-topbar-bg);
  border-bottom: 1px solid rgba(128, 144, 165, .12);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
.app-topbar-left, .app-topbar-actions { display: flex; align-items: center; gap: .55rem; }
.app-content {
  width: 100%;
  max-width: 1680px;
  margin: 0 auto;
  padding: 1.65rem;
  padding-bottom: 3rem;
}

/* Brand and sidebar */
.app-sidebar-header {
  min-height: var(--app-topbar-height);
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .8rem .9rem .8rem 1rem;
  border-bottom: 1px solid var(--app-border);
}
.app-brand {
  min-width: 0;
  flex: 1;
  display: flex;
  align-items: center;
  gap: .75rem;
  color: var(--app-text);
  text-decoration: none;
}
.app-brand:hover { color: var(--app-text); }
.app-brand-mark {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 13px;
  color: #fff;
  font-size: 1.22rem;
  background: linear-gradient(145deg, #5c78ff, #3553df);
  box-shadow: 0 9px 20px rgba(73, 104, 242, .26);
}
.app-brand-mark-sm { width: 34px; height: 34px; border-radius: 10px; font-size: 1rem; }
.app-brand-copy { min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.app-brand-copy strong { font-size: .97rem; white-space: nowrap; }
.app-brand-copy small { margin-top: .2rem; color: var(--app-text-muted); font-size: .66rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-sidebar-collapse, .app-sidebar-close {
  width: 37px;
  height: 37px;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: var(--app-text-muted);
  border: 1px solid transparent;
  border-radius: 10px;
}
.app-sidebar-collapse:hover, .app-sidebar-close:hover { color: var(--app-text); background: var(--app-surface-soft); border-color: var(--app-border); }
.app-sidebar-scroll { flex: 1; overflow: auto; padding: .85rem .7rem 1.1rem; scrollbar-width: thin; }
.app-nav-section + .app-nav-section { margin-top: 1.15rem; }
.app-nav-heading {
  padding: .4rem .78rem .45rem;
  color: var(--app-text-muted);
  font-size: .65rem;
  font-weight: 750;
  letter-spacing: .095em;
  text-transform: uppercase;
  white-space: nowrap;
}
.app-nav-link {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 43px;
  gap: .75rem;
  margin: .12rem 0;
  padding: .56rem .72rem;
  color: var(--app-text-muted);
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: 12px;
  transition: color .16s ease, background-color .16s ease, border-color .16s ease, transform .16s ease;
}
.app-nav-link:hover { color: var(--app-text); background: var(--app-surface-soft); }
.app-nav-link.active {
  color: var(--app-primary);
  background: rgba(var(--app-primary-rgb), .11);
  border-color: rgba(var(--app-primary-rgb), .08);
  font-weight: 650;
}
.app-nav-link.active::before {
  content: "";
  position: absolute;
  left: -.72rem;
  width: 3px;
  height: 22px;
  border-radius: 0 4px 4px 0;
  background: var(--app-primary);
  box-shadow: 0 0 12px rgba(var(--app-primary-rgb), .42);
}
.app-nav-icon { width: 24px; flex: 0 0 24px; display: inline-flex; justify-content: center; font-size: 1.05rem; }
.app-nav-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-nav-badge {
  min-width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 .38rem;
  border-radius: 999px;
  color: #fff;
  background: var(--app-danger);
  font-size: .67rem;
  font-weight: 750;
}
.app-sidebar-user { padding: .75rem; border-top: 1px solid var(--app-border); }
.app-user-card, .app-topbar-user {
  width: 100%;
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .55rem;
  color: var(--app-text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 13px;
  text-align: left;
}
.app-user-card:hover, .app-topbar-user:hover { background: var(--app-surface-soft); border-color: var(--app-border); }
.app-user-avatar {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  border-radius: 50%;
  color: var(--app-primary);
  background: rgba(var(--app-primary-rgb), .13);
  border: 1px solid rgba(var(--app-primary-rgb), .18);
  font-weight: 750;
}
.app-user-avatar-sm { width: 35px; height: 35px; }
.app-user-copy { min-width: 0; flex: 1; display: flex; flex-direction: column; line-height: 1.25; }
.app-user-copy strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .86rem; }
.app-user-copy small, .app-topbar-user small { color: var(--app-text-muted); font-size: .7rem; }
.app-user-chevron { color: var(--app-text-muted); font-size: .78rem; }
.app-user-menu { width: 238px; }

/* Collapsed sidebar */
body.sidebar-collapsed .app-sidebar { width: var(--app-sidebar-collapsed); }
body.sidebar-collapsed .app-main { margin-left: var(--app-sidebar-collapsed); }
body.sidebar-collapsed .app-brand-copy,
body.sidebar-collapsed .app-nav-heading,
body.sidebar-collapsed .app-nav-label,
body.sidebar-collapsed .app-nav-badge,
body.sidebar-collapsed .app-user-copy,
body.sidebar-collapsed .app-user-chevron { display: none; }
body.sidebar-collapsed .app-sidebar-header { justify-content: center; padding-inline: .7rem; }
body.sidebar-collapsed .app-brand { flex: 0 0 auto; }
body.sidebar-collapsed .app-sidebar-collapse { position: absolute; top: 76px; right: -16px; background: var(--app-surface); border-color: var(--app-border); box-shadow: var(--app-shadow-sm); }
body.sidebar-collapsed .app-nav-link { justify-content: center; padding-inline: .5rem; }
body.sidebar-collapsed .app-nav-link.active::before { left: -.7rem; }
body.sidebar-collapsed .app-user-card { justify-content: center; padding-inline: 0; }

/* Topbar */
.app-icon-btn {
  width: 41px;
  height: 41px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: var(--app-text-muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 12px;
  font-size: 1.05rem;
}
.app-icon-btn:hover, .app-icon-btn:focus-visible { color: var(--app-text); background: var(--app-surface); border-color: var(--app-border); box-shadow: var(--app-shadow-sm); }
.app-topbar-user { width: auto; min-width: 188px; padding: .35rem .45rem; }
.app-topbar-user > span:nth-child(2) { min-width: 0; flex: 1; display: flex; flex-direction: column; line-height: 1.2; }
.app-topbar-user strong { max-width: 145px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .82rem; }
.app-notification-dot {
  position: absolute;
  top: 2px;
  right: 1px;
  min-width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 .22rem;
  color: #fff;
  background: var(--app-danger);
  border: 2px solid var(--app-topbar-bg);
  border-radius: 999px;
  font-size: .58rem;
  font-weight: 800;
}
.app-mobile-brand { display: flex; align-items: center; gap: .55rem; }
.app-theme-menu { min-width: 190px; }
.app-theme-option { border-radius: 9px; }
.app-theme-option.active { color: var(--app-primary); background: rgba(var(--app-primary-rgb), .12); font-weight: 650; }

/* Typography / page headers */
h1, h2, h3, h4, h5, h6 { color: var(--app-text); letter-spacing: -.018em; }
h1.h3, .page-title { font-size: clamp(1.45rem, 2vw, 1.8rem); font-weight: 730; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.page-header-copy { max-width: 780px; }
.page-header-copy h1 { margin-bottom: .25rem; }
.page-header-copy p { margin: 0; color: var(--app-text-muted); }
.page-actions { display: flex; flex-wrap: wrap; gap: .55rem; }
.text-muted { color: var(--app-text-muted) !important; }
[data-bs-theme="dark"] .text-dark { color: var(--app-text) !important; }
[data-bs-theme="dark"] .text-body { color: var(--app-text) !important; }
code { color: var(--app-primary); font-size: .84em; }
.masked { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .065em; }

/* Cards */
.card {
  --bs-card-bg: var(--app-surface);
  --bs-card-border-color: var(--app-border);
  color: var(--app-text);
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
  box-shadow: var(--app-shadow-sm);
  overflow: hidden;
}
.card-body { padding: 1.15rem; }
.card-header, .card-footer {
  padding: .9rem 1.1rem;
  color: var(--app-text);
  background: var(--app-surface);
  border-color: var(--app-border);
}
a.card { transition: transform .17s ease, border-color .17s ease, box-shadow .17s ease; }
a.card:hover { transform: translateY(-2px); border-color: rgba(var(--app-primary-rgb), .28); box-shadow: var(--app-shadow-md); }
.app-panel { border-radius: var(--app-radius-lg); }
.app-panel-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.15rem; border-bottom: 1px solid var(--app-border); }
.app-panel-title { margin: 0; font-size: .96rem; font-weight: 700; }

/* Stat cards */
.app-stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(155px, 1fr)); gap: .85rem; }
.app-stat-card {
  position: relative;
  min-height: 126px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: var(--app-text);
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
  box-shadow: var(--app-shadow-sm);
  text-decoration: none;
  overflow: hidden;
  transition: transform .17s ease, border-color .17s ease, box-shadow .17s ease;
}
.app-stat-card:hover { color: var(--app-text); transform: translateY(-2px); border-color: rgba(var(--app-primary-rgb), .25); box-shadow: var(--app-shadow-md); }
.app-stat-card.active { border-color: rgba(var(--app-primary-rgb), .55); box-shadow: 0 0 0 3px rgba(var(--app-primary-rgb), .09), var(--app-shadow-sm); }
.app-stat-card::after {
  content: "";
  position: absolute;
  width: 95px;
  height: 95px;
  right: -44px;
  bottom: -52px;
  border-radius: 50%;
  background: var(--stat-glow, rgba(var(--app-primary-rgb), .08));
}
.app-stat-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.app-stat-label { color: var(--app-text-muted); font-size: .74rem; font-weight: 650; }
.app-stat-icon {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  color: var(--stat-color, var(--app-primary));
  background: var(--stat-bg, rgba(var(--app-primary-rgb), .12));
}
.app-stat-value { margin-top: .6rem; font-size: 1.72rem; line-height: 1; font-weight: 760; letter-spacing: -.04em; }
.app-stat-note { margin-top: .35rem; color: var(--app-text-muted); font-size: .68rem; }
.stat-primary { --stat-color: var(--app-primary); --stat-bg: rgba(var(--app-primary-rgb), .12); --stat-glow: rgba(var(--app-primary-rgb), .1); }
.stat-warning { --stat-color: #d58912; --stat-bg: rgba(231, 166, 42, .14); --stat-glow: rgba(231, 166, 42, .1); }
.stat-purple { --stat-color: var(--app-purple); --stat-bg: rgba(128, 90, 213, .13); --stat-glow: rgba(128, 90, 213, .1); }
.stat-info { --stat-color: var(--app-info); --stat-bg: rgba(49, 135, 215, .13); --stat-glow: rgba(49, 135, 215, .1); }
.stat-success { --stat-color: var(--app-success); --stat-bg: rgba(35, 162, 109, .13); --stat-glow: rgba(35, 162, 109, .1); }
.stat-danger { --stat-color: var(--app-danger); --stat-bg: rgba(226, 77, 95, .13); --stat-glow: rgba(226, 77, 95, .1); }

/* Forms */
.form-label { margin-bottom: .42rem; color: var(--app-text); font-size: .78rem; font-weight: 650; }
.form-control, .form-select, .input-group-text {
  min-height: var(--app-control-height);
  color: var(--app-text);
  background-color: var(--app-surface);
  border-color: var(--app-border-strong);
  border-radius: 10px;
}
.form-control-sm, .form-select-sm { min-height: 35px; border-radius: 8px; }
.form-control:focus, .form-select:focus {
  color: var(--app-text);
  background-color: var(--app-surface);
  border-color: rgba(var(--app-primary-rgb), .62);
  box-shadow: 0 0 0 .22rem rgba(var(--app-primary-rgb), .11);
}
.form-control::placeholder { color: var(--app-text-muted); opacity: .72; }
.form-check-input { border-color: var(--app-border-strong); }
.form-check-input:checked { background-color: var(--app-primary); border-color: var(--app-primary); }
.input-group > .form-control:not(:first-child), .input-group > .form-select:not(:first-child) { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.input-group > .btn { min-height: var(--app-control-height); }
.filter-card { padding: 1rem; background: var(--app-surface); border: 1px solid var(--app-border); border-radius: var(--app-radius); box-shadow: var(--app-shadow-sm); }
.filter-card .form-label { color: var(--app-text-muted); }

/* Buttons */
.btn { min-height: 40px; padding: .52rem .86rem; border-radius: 10px; font-size: .82rem; font-weight: 650; transition: transform .12s ease, box-shadow .15s ease, color .15s ease, background-color .15s ease, border-color .15s ease; }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-sm { min-height: 33px; padding: .36rem .66rem; border-radius: 8px; font-size: .75rem; }
.btn-lg { min-height: 49px; padding: .72rem 1.1rem; border-radius: 12px; }
.btn-primary, .btn-success {
  --bs-btn-bg: var(--app-primary);
  --bs-btn-border-color: var(--app-primary);
  --bs-btn-hover-bg: var(--app-primary-strong);
  --bs-btn-hover-border-color: var(--app-primary-strong);
  --bs-btn-active-bg: var(--app-primary-strong);
  --bs-btn-active-border-color: var(--app-primary-strong);
  --bs-btn-disabled-bg: var(--app-primary);
  --bs-btn-disabled-border-color: var(--app-primary);
  box-shadow: 0 7px 16px rgba(var(--app-primary-rgb), .18);
}
.btn-outline-primary, .btn-outline-success {
  --bs-btn-color: var(--app-primary);
  --bs-btn-border-color: rgba(var(--app-primary-rgb), .38);
  --bs-btn-hover-bg: rgba(var(--app-primary-rgb), .10);
  --bs-btn-hover-border-color: rgba(var(--app-primary-rgb), .58);
  --bs-btn-hover-color: var(--app-primary);
  --bs-btn-active-bg: rgba(var(--app-primary-rgb), .16);
  --bs-btn-active-border-color: rgba(var(--app-primary-rgb), .62);
  --bs-btn-active-color: var(--app-primary);
}
.btn-outline-secondary { --bs-btn-color: var(--app-text-muted); --bs-btn-border-color: var(--app-border-strong); --bs-btn-hover-bg: var(--app-surface-soft); --bs-btn-hover-color: var(--app-text); --bs-btn-hover-border-color: var(--app-border-strong); }
.btn-light { --bs-btn-bg: var(--app-surface); --bs-btn-border-color: var(--app-border); --bs-btn-hover-bg: var(--app-surface-soft); --bs-btn-hover-border-color: var(--app-border-strong); --bs-btn-color: var(--app-text); }

/* Tables */
.table-responsive { scrollbar-width: thin; }
.table {
  --bs-table-color: var(--app-text);
  --bs-table-bg: transparent;
  --bs-table-border-color: var(--app-border);
  --bs-table-hover-bg: rgba(var(--app-primary-rgb), .035);
  margin-bottom: 0;
  font-size: .82rem;
}
.table > :not(caption) > * > * { padding: .82rem .9rem; vertical-align: middle; }
.table thead th {
  color: var(--app-text-muted);
  background: var(--app-surface-soft);
  border-bottom-width: 1px;
  font-size: .69rem;
  font-weight: 730;
  letter-spacing: .025em;
  text-transform: none;
  white-space: nowrap;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table-hover > tbody > tr:hover > * { color: var(--app-text); }
.table-sticky thead th { position: sticky; top: 0; z-index: 4; background: var(--app-surface-soft); }
.app-table-card .table-responsive { max-height: min(68vh, 720px); }
.app-table-empty { padding: 3.8rem 1rem !important; text-align: center; color: var(--app-text-muted); }
.app-table-empty i { display: block; margin-bottom: .6rem; font-size: 1.8rem; opacity: .55; }

/* Badges */
.badge { padding: .43em .66em; border-radius: 7px; font-weight: 680; letter-spacing: .005em; }
.text-bg-primary { background: rgba(var(--app-primary-rgb), .13) !important; color: var(--app-primary) !important; }
.text-bg-success { background: rgba(35, 162, 109, .13) !important; color: var(--app-success) !important; }
.text-bg-warning { background: rgba(231, 166, 42, .16) !important; color: #b47309 !important; }
.text-bg-danger { background: rgba(226, 77, 95, .14) !important; color: var(--app-danger) !important; }
.text-bg-info { background: rgba(49, 135, 215, .13) !important; color: var(--app-info) !important; }
.text-bg-dark { background: rgba(128, 90, 213, .14) !important; color: var(--app-purple) !important; }
.text-bg-secondary { background: rgba(105, 115, 134, .13) !important; color: var(--app-text-muted) !important; }
.text-bg-light { background: var(--app-surface-soft) !important; color: var(--app-text) !important; }
.source-badge { display: inline-flex; align-items: center; gap: .35rem; }

/* Alerts, dropdowns, modals */
.alert { border: 1px solid transparent; border-radius: var(--app-radius); }
.app-alert { box-shadow: var(--app-shadow-sm); }
.alert-success { color: var(--app-success); background: rgba(35, 162, 109, .09); border-color: rgba(35, 162, 109, .18); }
.alert-warning { color: #9a650c; background: rgba(231, 166, 42, .10); border-color: rgba(231, 166, 42, .22); }
.alert-danger { color: var(--app-danger); background: rgba(226, 77, 95, .09); border-color: rgba(226, 77, 95, .19); }
.alert-info { color: var(--app-info); background: rgba(49, 135, 215, .09); border-color: rgba(49, 135, 215, .19); }
.dropdown-menu {
  --bs-dropdown-bg: var(--app-surface-raised);
  --bs-dropdown-color: var(--app-text);
  --bs-dropdown-border-color: var(--app-border);
  --bs-dropdown-link-color: var(--app-text);
  --bs-dropdown-link-hover-color: var(--app-text);
  --bs-dropdown-link-hover-bg: var(--app-surface-soft);
  padding: .45rem;
  border-radius: 12px;
  box-shadow: var(--app-shadow-md);
}
.dropdown-item { padding: .55rem .65rem; border-radius: 8px; font-size: .82rem; }
.modal-content, .offcanvas { color: var(--app-text); background: var(--app-surface); border-color: var(--app-border); border-radius: var(--app-radius-lg); }
.modal-header, .modal-footer, .offcanvas-header { border-color: var(--app-border); }
.list-group-item { color: var(--app-text); background: var(--app-surface); border-color: var(--app-border); }
.list-group-item-action:hover { color: var(--app-text); background: var(--app-surface-soft); }
.progress { background: var(--app-surface-soft); border-radius: 999px; }

/* Verification workspace */
.kk-viewer, #documentViewport { background: #182231 !important; border-radius: 0 0 var(--app-radius) var(--app-radius); }
.kk-viewer { min-height: 600px; display: flex; align-items: center; justify-content: center; overflow: auto; }
.kk-viewer img { max-width: 100%; transform-origin: center; }
#documentTransform { transition: transform .16s ease; }
.field-valid { border-left: 4px solid var(--app-success) !important; }
.field-review { border-left: 4px solid var(--app-warning) !important; }
.field-error { border-left: 4px solid var(--app-danger) !important; }
.border-success { border-color: rgba(35, 162, 109, .62) !important; }
.border-warning { border-color: rgba(231, 166, 42, .68) !important; }
.border-danger { border-color: rgba(226, 77, 95, .68) !important; }
.is-invalid { border-color: var(--app-danger) !important; }
.verification-actions { position: sticky; bottom: .8rem; z-index: 18; padding: .75rem; background: rgba(255,255,255,.88); border: 1px solid var(--app-border); border-radius: var(--app-radius); box-shadow: var(--app-shadow-md); backdrop-filter: blur(14px); }
[data-bs-theme="dark"] .verification-actions { background: rgba(18,29,44,.9); }

/* Login */
.app-guest {
  background:
    radial-gradient(circle at 8% 5%, rgba(var(--app-primary-rgb), .12), transparent 33%),
    radial-gradient(circle at 92% 90%, rgba(35, 162, 109, .09), transparent 34%),
    var(--app-bg);
}
.guest-main { min-height: 100vh; display: grid; place-items: center; padding: 2rem 1rem; }
.guest-theme-control { position: fixed; z-index: 20; top: 1rem; right: 1rem; }
.guest-flash { position: fixed; z-index: 30; top: 1rem; left: 50%; width: min(520px, calc(100% - 2rem)); transform: translateX(-50%); }
.login-shell {
  width: min(1040px, 100%);
  min-height: 610px;
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(380px, .92fr);
  overflow: hidden;
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: 24px;
  box-shadow: var(--app-shadow-lg);
}
.login-visual {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 3rem;
  color: #fff;
  background:
    radial-gradient(circle at 20% 20%, rgba(255,255,255,.18), transparent 28%),
    radial-gradient(circle at 85% 75%, rgba(76, 220, 164, .20), transparent 35%),
    linear-gradient(145deg, #3653dc 0%, #253aa7 48%, #15266f 100%);
  overflow: hidden;
}
.login-visual::before, .login-visual::after { content: ""; position: absolute; border: 1px solid rgba(255,255,255,.1); border-radius: 50%; }
.login-visual::before { width: 420px; height: 420px; right: -210px; top: -150px; }
.login-visual::after { width: 260px; height: 260px; left: -130px; bottom: -100px; }
.login-brand { position: relative; z-index: 1; display: flex; align-items: center; gap: .8rem; }
.login-brand .app-brand-mark { color: #3653dc; background: #fff; box-shadow: 0 12px 24px rgba(0,0,0,.15); }
.login-brand-copy { display: flex; flex-direction: column; line-height: 1.2; }
.login-brand-copy strong { font-size: 1.05rem; }
.login-brand-copy small { color: rgba(255,255,255,.72); font-size: .72rem; }
.login-hero { position: relative; z-index: 1; max-width: 520px; }
.login-hero h1 { color: #fff; font-size: clamp(2rem, 4vw, 3.2rem); font-weight: 770; line-height: 1.08; }
.login-hero p { max-width: 460px; color: rgba(255,255,255,.76); font-size: 1rem; }
.login-feature-list { display: grid; gap: .8rem; margin-top: 1.6rem; }
.login-feature { display: flex; align-items: center; gap: .75rem; color: rgba(255,255,255,.86); }
.login-feature i { width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; border-radius: 9px; background: rgba(255,255,255,.12); }
.login-footer-note { position: relative; z-index: 1; color: rgba(255,255,255,.56); font-size: .72rem; }
.login-form-panel { display: flex; align-items: center; padding: 3rem; }
.login-form-wrap { width: 100%; max-width: 390px; margin: 0 auto; }
.login-form-wrap h2 { font-size: 1.65rem; font-weight: 750; }
.login-form-wrap .form-control { min-height: 48px; padding-inline: .9rem; }
.login-input-group { position: relative; }
.login-input-group > i { position: absolute; z-index: 4; top: 50%; left: .9rem; color: var(--app-text-muted); transform: translateY(-50%); }
.login-input-group .form-control { padding-left: 2.55rem; }
.login-password-toggle { position: absolute; z-index: 4; right: .35rem; top: 50%; width: 39px; height: 39px; display: inline-flex; align-items: center; justify-content: center; color: var(--app-text-muted); background: transparent; border: 0; border-radius: 9px; transform: translateY(-50%); }
.login-password-toggle:hover { color: var(--app-text); background: var(--app-surface-soft); }
.login-security-note { display: flex; align-items: flex-start; gap: .55rem; margin-top: 1.2rem; padding: .75rem; color: var(--app-text-muted); background: var(--app-surface-soft); border: 1px solid var(--app-border); border-radius: 10px; font-size: .72rem; }

/* Mobile sidebar and bottom navigation */
.app-sidebar-backdrop { display: none; }
.app-mobile-nav { display: none; }

@media (max-width: 1199.98px) {
  .app-sidebar { width: min(300px, 88vw); transform: translateX(-105%); box-shadow: var(--app-shadow-lg); }
  .app-main { margin-left: 0; }
  body.sidebar-open { overflow: hidden; }
  body.sidebar-open .app-sidebar { transform: translateX(0); }
  .app-sidebar-backdrop { position: fixed; inset: 0; z-index: 1040; display: block; visibility: hidden; opacity: 0; background: rgba(7, 13, 24, .48); backdrop-filter: blur(2px); transition: opacity .2s ease, visibility .2s ease; }
  body.sidebar-open .app-sidebar-backdrop { visibility: visible; opacity: 1; }
}

@media (max-width: 767.98px) {
  :root { --app-topbar-height: 61px; }
  body { font-size: .9rem; }
  .app-topbar { padding: 0 .8rem; }
  .app-content { padding: 1rem .8rem calc(6rem + env(safe-area-inset-bottom)); }
  .page-header { flex-direction: column; margin-bottom: 1rem; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1; }
  .app-stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; }
  .app-stat-card { min-height: 112px; padding: .85rem; }
  .app-stat-value { font-size: 1.45rem; }
  .card-body { padding: .9rem; }
  .table > :not(caption) > * > * { padding: .72rem .75rem; }
  .app-mobile-nav {
    position: fixed;
    left: .7rem;
    right: .7rem;
    bottom: max(.65rem, env(safe-area-inset-bottom));
    z-index: 1030;
    height: 67px;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    align-items: center;
    padding: .35rem;
    background: rgba(255,255,255,.92);
    border: 1px solid var(--app-border);
    border-radius: 19px;
    box-shadow: 0 15px 40px rgba(16, 24, 40, .18);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
  }
  [data-bs-theme="dark"] .app-mobile-nav { background: rgba(18,29,44,.92); box-shadow: 0 18px 44px rgba(0,0,0,.36); }
  .app-mobile-nav .app-nav-link { min-height: 52px; flex-direction: column; justify-content: center; gap: .12rem; margin: 0; padding: .25rem; border-radius: 13px; font-size: .62rem; }
  .app-mobile-nav .app-nav-link.active::before { display: none; }
  .app-mobile-nav .app-nav-icon { width: auto; flex: 0; font-size: 1.08rem; }
  .app-mobile-nav .app-nav-label { flex: 0; max-width: 100%; }
  .app-mobile-nav .app-nav-badge { position: absolute; top: 2px; right: 15%; min-width: 17px; height: 17px; font-size: .52rem; }
  .app-mobile-create {
    width: 48px;
    height: 48px;
    justify-self: center;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: linear-gradient(145deg, #607bff, #3c58e5);
    border-radius: 15px;
    box-shadow: 0 9px 20px rgba(var(--app-primary-rgb), .35);
    text-decoration: none;
    font-size: 1.25rem;
    transform: translateY(-9px);
  }
  .app-mobile-create:hover { color: #fff; }
  .login-shell { min-height: auto; grid-template-columns: 1fr; border-radius: 19px; }
  .login-visual { display: none; }
  .login-form-panel { padding: 2rem 1.25rem; }
  .guest-main { padding: 1rem; }
  .guest-theme-control { top: .65rem; right: .65rem; }
  #documentViewport { height: 62vh !important; }
  .verification-actions { bottom: 5.35rem; }
}

@media (max-width: 420px) {
  .app-stat-grid { grid-template-columns: 1fr 1fr; }
  .app-stat-label { font-size: .69rem; }
  .app-stat-value { font-size: 1.3rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

/* Pagination and utility Bootstrap components */
.pagination { gap: .28rem; margin-bottom: 0; }
.page-link {
  min-width: 36px;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .35rem .6rem;
  color: var(--app-text-muted);
  background: var(--app-surface);
  border-color: var(--app-border);
  border-radius: 9px !important;
  font-size: .78rem;
}
.page-link:hover { color: var(--app-primary); background: var(--app-surface-soft); border-color: rgba(var(--app-primary-rgb), .3); }
.active > .page-link, .page-link.active { color: #fff; background: var(--app-primary); border-color: var(--app-primary); }
.disabled > .page-link, .page-link.disabled { color: var(--app-text-muted); background: var(--app-surface-soft); border-color: var(--app-border); opacity: .55; }
.nav-tabs { border-color: var(--app-border); }
.nav-tabs .nav-link { color: var(--app-text-muted); border-radius: 9px 9px 0 0; }
.nav-tabs .nav-link:hover { color: var(--app-text); border-color: transparent; background: var(--app-surface-soft); }
.nav-tabs .nav-link.active { color: var(--app-primary); background: var(--app-surface); border-color: var(--app-border) var(--app-border) var(--app-surface); font-weight: 650; }
.accordion { --bs-accordion-bg: var(--app-surface); --bs-accordion-color: var(--app-text); --bs-accordion-border-color: var(--app-border); --bs-accordion-btn-bg: var(--app-surface); --bs-accordion-btn-color: var(--app-text); --bs-accordion-active-bg: var(--app-surface-soft); --bs-accordion-active-color: var(--app-primary); }
.btn-close { filter: none; }
[data-bs-theme="dark"] .btn-close { filter: invert(1) grayscale(100%) brightness(200%); }
