:root {
  --app-navy: #0b1739;
  --app-ink: #17223b;
  --app-muted: #667085;
  --app-primary: #3157d5;
  --app-primary-dark: #2447bd;
  --app-primary-soft: #eef2ff;
  --app-bg: #f5f7fb;
  --app-surface: #ffffff;
  --app-border: #e1e6ef;
  --app-success: #16875c;
  --app-danger: #c63f4b;
  --app-warning: #b7791f;
  --app-radius: .85rem;
  --app-shadow: 0 8px 28px rgba(24, 39, 75, .07);
}

html { position: relative; min-height: 100%; font-size: 14px; }
@media (min-width: 768px) { html { font-size: 16px; } }
body { min-height: 100vh; margin: 0; color: var(--app-ink); background: var(--app-bg); font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--app-primary); }
a:hover { color: var(--app-primary-dark); }

/* Application chrome */
.app-header { position: sticky; top: 0; z-index: 1030; }
.app-navbar { min-height: 68px; padding: .55rem 0; border-bottom: 1px solid rgba(218, 224, 235, .9); background: rgba(255, 255, 255, .96); box-shadow: 0 2px 14px rgba(24, 39, 75, .04); backdrop-filter: blur(14px); }
.app-brand { display: inline-flex; align-items: center; gap: .65rem; margin-right: 1.5rem; color: var(--app-navy) !important; font-size: 1.05rem; font-weight: 780; letter-spacing: -.025em; }
.app-brand-mark { display: grid; place-items: center; width: 2.1rem; height: 2.1rem; border-radius: .65rem; color: #fff; background: linear-gradient(145deg, #5678ef, #3157d5); box-shadow: 0 7px 18px rgba(49, 87, 213, .22); }
.app-navbar .navbar-toggler { padding: .45rem; border: 1px solid var(--app-border); border-radius: .65rem; box-shadow: none; }
.app-navbar .navbar-nav { align-items: center; gap: .12rem; }
.app-navbar .nav-link { padding: .55rem .68rem !important; border-radius: .55rem; color: #536078; font-size: .8rem; font-weight: 620; white-space: nowrap; transition: color .15s, background .15s; }
.app-navbar .nav-link:hover, .app-navbar .nav-link.show { color: var(--app-primary); background: var(--app-primary-soft); }
.app-navbar .dropdown-menu { min-width: 220px; max-height: min(72vh, 620px); margin-top: .55rem; padding: .5rem; overflow-y: auto; border: 1px solid var(--app-border); border-radius: .8rem; box-shadow: 0 16px 42px rgba(24, 39, 75, .14); }
.app-navbar .dropdown-item { padding: .55rem .7rem; border-radius: .48rem; color: #455168; font-size: .82rem; }
.app-navbar .dropdown-item:hover, .app-navbar .dropdown-item:focus { color: var(--app-primary); background: var(--app-primary-soft); }
.app-navbar .dropdown-header { padding: .55rem .7rem .3rem; color: #9099aa; font-size: .65rem; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.app-navbar .dropdown-divider { margin: .4rem .25rem; border-color: #edf0f5; }
.app-content { width: 100%; min-height: calc(100vh - 132px); padding-top: 1.75rem; padding-bottom: 2.5rem; }
.app-footer { padding: 1rem 0; border-top: 1px solid var(--app-border); color: #8a94a6; background: #fff; font-size: .72rem; }
.app-footer a { color: #667085; }

/* Page titles and inline guidance */
.app-content > h1:first-child, .app-content > h2:first-child,
.app-content > form:first-child + h1, .app-content > form:first-child + h2 { margin: 0 0 1.4rem; color: var(--app-ink); font-size: clamp(1.55rem, 2.4vw, 2.15rem); font-weight: 760; letter-spacing: -.04em; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1.2rem; margin-bottom: 1.5rem; }
.page-header h1, .page-header h2 { margin: 0; font-size: clamp(1.55rem, 2.4vw, 2.15rem); font-weight: 760; letter-spacing: -.04em; }
.page-header p, .page-subtitle { max-width: 720px; margin: .4rem 0 0; color: var(--app-muted); line-height: 1.55; }
.form-text, small.text-muted { color: #7b879b !important; line-height: 1.45; }

/* Cards become clear task containers */
.card { border: 1px solid var(--app-border); border-radius: var(--app-radius); background: var(--app-surface); box-shadow: 0 3px 14px rgba(24, 39, 75, .045); }
.card.shadow-sm { box-shadow: var(--app-shadow) !important; }
.card-header { padding: .9rem 1.1rem; border-bottom: 1px solid #e9edf3; border-radius: var(--app-radius) var(--app-radius) 0 0 !important; color: #344054; background: #fbfcfe; font-weight: 680; }
.card-body { padding: 1.15rem; }
.card-footer { padding: .85rem 1.1rem; border-top-color: #e9edf3; background: #fbfcfe; }

/* Forms with larger targets and consistent action hierarchy */
.form-label, .form-group > label:not(.form-check-label) { margin-bottom: .4rem; color: #344054; font-size: .82rem; font-weight: 650; }
.form-control, .form-select { min-height: 2.75rem; padding: .58rem .78rem; border-color: #d8dee9; border-radius: .62rem; color: var(--app-ink); background-color: #fff; box-shadow: 0 1px 2px rgba(16, 24, 40, .025); }
.form-control::placeholder { color: #a1a9b6; }
.form-control:focus, .form-select:focus { border-color: #7891e8; box-shadow: 0 0 0 4px rgba(49, 87, 213, .1); }
.form-check-input:checked { border-color: var(--app-primary); background-color: var(--app-primary); }
.form-check-input:focus { border-color: #7891e8; box-shadow: 0 0 0 4px rgba(49, 87, 213, .1); }
fieldset { margin-bottom: 1.4rem; }
legend { margin-bottom: 1rem; color: var(--app-ink); font-size: 1rem; font-weight: 720; }

.btn { min-height: 2.45rem; padding: .48rem .88rem; border-radius: .58rem; font-size: .83rem; font-weight: 650; transition: transform .12s, box-shadow .12s, background .12s, border-color .12s; }
.btn:hover { transform: translateY(-1px); }
.btn-primary { border-color: var(--app-primary); background: linear-gradient(135deg, #3e64dd, #294dca); box-shadow: 0 5px 13px rgba(49, 87, 213, .17); }
.btn-primary:hover, .btn-primary:focus { border-color: var(--app-primary-dark); background: var(--app-primary-dark); box-shadow: 0 7px 17px rgba(49, 87, 213, .23); }
.btn-outline-primary { border-color: #a6b5eb; color: var(--app-primary); }
.btn-outline-primary:hover { border-color: var(--app-primary); background: var(--app-primary); }
.btn-outline-secondary { border-color: #d4dae4; color: #536078; background: #fff; }
.btn-outline-secondary:hover { border-color: #bac2d0; color: var(--app-ink); background: #f7f8fa; }
.btn-danger { background: #c8424e; border-color: #c8424e; }
.btn-link { color: var(--app-primary); text-decoration: none; box-shadow: none; }
.btn-sm { min-height: 2.05rem; padding: .35rem .65rem; font-size: .76rem; }
.btn-group .btn { transform: none; }

/* Data views: readable, scannable, and actionable */
.table-responsive { border: 1px solid var(--app-border); border-radius: var(--app-radius); background: #fff; box-shadow: 0 3px 14px rgba(24, 39, 75, .04); }
.table { margin-bottom: 0; color: #344054; vertical-align: middle; }
.table > :not(caption) > * > * { padding: .78rem .72rem; border-bottom-color: #edf0f4; }
.table thead th { border-bottom-width: 1px; color: #68758b; background: #f8fafc; font-size: .7rem; font-weight: 780; letter-spacing: .045em; text-transform: uppercase; white-space: nowrap; }
.table tbody tr { transition: background .12s; }
.table-hover tbody tr:hover, .table tbody tr:hover { background: #f8faff; }
.table tbody tr:last-child td { border-bottom: 0; }
.table-wide-fit { width: 100% !important; font-size: .875rem; }
.table-wide-fit > :not(caption) > * > * { padding-left: .45rem; padding-right: .45rem; }
.dataTables_wrapper .dataTables_filter input, .dataTables_wrapper .dataTables_length select { border: 1px solid #d8dee9; border-radius: .55rem; }
.dataTables_wrapper .dataTables_length select,
.dt-container .dt-length select {
  width: auto;
  min-width: 4.75rem;
  min-height: 2.25rem;
  padding: .35rem 2.15rem .35rem .65rem;
  background-position: right .65rem center;
  background-size: 16px 12px;
}
.dataTables_wrapper .dataTables_info { color: var(--app-muted); font-size: .78rem; }
.pagination .page-link { margin: 0 .12rem; border-color: transparent; border-radius: .45rem; color: #536078; }
.pagination .active .page-link { border-color: var(--app-primary); background: var(--app-primary); }

/* Feedback should explain state without alarming the user */
.alert { padding: .85rem 1rem; border-width: 1px; border-radius: .7rem; font-size: .86rem; }
.alert-danger { border-color: #fecaca; color: #9f2832; background: #fff5f5; }
.alert-success { border-color: #bdebd7; color: #146b4c; background: #f0fbf6; }
.alert-warning { border-color: #f4d9a7; color: #855b17; background: #fffaf0; }
.alert-info { border-color: #cbd9fa; color: #31539c; background: #f3f7ff; }
.app-connection-banner { position: sticky; top: 0; z-index: 1030; border-radius: 0; }
.badge { padding: .4em .62em; border-radius: 999px; font-size: .68rem; font-weight: 700; }
.text-muted { color: var(--app-muted) !important; }
.modal-content { border: 0; border-radius: 1rem; box-shadow: 0 24px 70px rgba(24,39,75,.2); }
.modal-header, .modal-footer { border-color: var(--app-border); }
.nav-tabs { gap: .25rem; border-bottom-color: var(--app-border); }
.nav-tabs .nav-link { padding: .65rem .9rem; border: 0; border-bottom: 2px solid transparent; color: #667085; font-size: .82rem; font-weight: 650; }
.nav-tabs .nav-link.active { border-bottom-color: var(--app-primary); color: var(--app-primary); background: transparent; }
.breadcrumb { font-size: .78rem; }

/* Automatically applied progressive UX helpers */
.app-page-title { margin-bottom: .35rem !important; }
.app-page-lead { margin-top: 0; margin-bottom: 1.4rem; color: var(--app-muted); }
.app-empty-state { padding: 2.2rem 1.2rem !important; color: var(--app-muted); text-align: center; }
.app-empty-state::before { content: ""; display: block; width: 2.8rem; height: 2.8rem; margin: 0 auto .8rem; border-radius: 50%; background: radial-gradient(circle, #b5c3f3 0 18%, #edf1ff 20% 100%); }
.app-action-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .55rem; margin-bottom: 1rem; }

@media (min-width: 992px) { .app-content .table-responsive { overflow-x: auto; } }
@media (max-width: 1199.98px) {
  .app-navbar .navbar-collapse { margin-top: .7rem; padding: .8rem; border: 1px solid var(--app-border); border-radius: .8rem; background: #fff; box-shadow: var(--app-shadow); }
  .app-navbar .navbar-nav { align-items: stretch; }
  .app-navbar .dropdown-menu { max-height: none; margin: .2rem 0 .5rem; border: 0; box-shadow: none; }
}
@media (max-width: 767.98px) {
  .app-content { padding-top: 1.15rem; }
  .page-header { flex-direction: column; }
  .page-header .btn, .page-header .btn-group { width: 100%; }
  .card-body { padding: 1rem; }
  .table > :not(caption) > * > * { padding: .65rem .58rem; }
  .app-footer .container-fluid { justify-content: center !important; text-align: center; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; } }
