:root {
    --bg: #f6f7fb;
    --surface: #ffffff;
    --surface-2: #fbfbfd;
    --surface-3: #f7f8fa;

    --text: #111827;
    --muted: #6b7280;
    --text-soft: #374151;

    --border: #e5e7eb;
    --border-strong: #d1d5db;
    --border-soft: rgba(229, 231, 235, 0.85);
    --border-table: #eef0f3;

    --primary: #111827;
    --primary-hover: #000000;
    --primary-soft: #1e3a8a;

    --success: #16a34a;
    --warning: #f59e0b;
    --danger: #dc2626;
    --danger-soft: rgba(220, 38, 38, 0.08);
    --danger-border: rgba(220, 38, 38, 0.14);
    --danger-text: #b42318;
    --info: #06b6d4;

    --hover-soft: rgba(15, 23, 42, 0.06);
    --hover-row: rgba(14, 165, 233, 0.07);
    /* ZENTRA-014: opacity raised from 0.08/0.06 -- measured contrast against
       --surface was 1.1-1.6:1, well under the WCAG 1.4.11 3:1 floor for UI
       focus indicators. 0.5/0.55 measure at ~3.4:1+. */
    --focus-ring: 0 0 0 0.2rem rgba(17, 24, 39, 0.55);
    --focus-ring-soft: 0 0 0 0.2rem rgba(17, 24, 39, 0.5);

    --shadow-sm: 0 2px 10px rgba(15, 23, 42, 0.05);
    --shadow-md: 0 16px 36px rgba(15, 23, 42, 0.10);
    --shadow-lg: 0 22px 48px rgba(0, 0, 0, 0.14);
    --shadow-toast: 0 10px 24px rgba(0, 0, 0, 0.14);

    --radius: 20px;
    --radius-md: 16px;
    --radius-sm: 14px;
    --radius-xs: 12px;
    --radius-2xs: 10px;

    --transition-fast: 0.15s ease;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
    letter-spacing: -0.01em;
}

body {
    margin: 0;
    color: var(--text);
    background: var(--bg);
}

/* Layout */
main.container-fluid {
    max-width: 1600px;
    margin: 0 auto;
    padding: 28px;
}

/* Bootstrap overrides */
.bg-body-tertiary .card,
.bg-body-tertiary .modal-content,
.bg-body-tertiary .dropdown-menu {
    border-color: var(--border-soft);
}

.text-body-secondary,
.text-secondary {
    color: var(--muted) !important;
}

/* Header / Navbar */
.navbar {
    min-height: 68px;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.navbar-brand {
    color: var(--text) !important;
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.navbar-brand:hover {
    color: var(--text) !important;
}

.navbar .nav-link {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    padding: 0 7px;
    border-radius: var(--radius-2xs);
    color: var(--text-soft) !important;
    font-size: 15px;
    font-weight: 500;
    transition:
        background var(--transition-fast),
        color var(--transition-fast),
        box-shadow var(--transition-fast);
}

.navbar .nav-link:hover {
    background: #f9f9f9;
    color: var(--text) !important;
}

.navbar .nav-link.active {
    background: transparent;
    color: var(--text) !important;
    font-weight: 700 !important;
}

.navbar-toggler {
    border-radius: var(--radius-xs);
    border-color: var(--border);
}

.navbar-toggler:focus {
    box-shadow: var(--focus-ring);
}

.navbar-brand-divider {
    font-size: 1.5rem;
    line-height: 1;
}

.navbar-brand-label {
    font-size: 1.1rem;
}

/* Logos */
.logo-sm {
    height: 40px;
    width: auto;
}

.logo-md {
    height: 52px;
    width: auto;
}

.logo-lg {
    height: 100px;
    width: auto;
}

/* Avatars -- a photo or initials standing for a person. Four sizes cover
   every place one appears (navbar menu, user cards, dashboard, profile
   page); change the look here and it updates everywhere at once. */
.avatar-circle {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-weight: 600;
}

.avatar-circle img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-circle-sm {
    width: 38px;
    height: 38px;
}

.avatar-circle-md {
    width: 44px;
    height: 44px;
}

.avatar-circle-lg {
    width: 88px;
    height: 88px;
    font-size: 1.75rem;
}

.avatar-circle-xl {
    width: 120px;
    height: 120px;
    font-size: 2.5rem;
}

/* Decorative icon wrappers -- not a person, just an icon in a shape.
   Circle for empty states, tile (rounded square) for category/type
   markers. */
.icon-circle {
    width: 56px;
    height: 56px;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--surface-3);
}

.icon-tile {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    background: var(--surface-3);
}

.icon-tile-sm {
    width: 44px;
    height: 44px;
}

.icon-tile-lg {
    width: 72px;
    height: 72px;
}

/* Matches .icon-tile-lg's width, for a caption sitting under one */
.mw-72 {
    max-width: 72px;
}

/* Global cards */
.card {
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    background: var(--surface);
}

.card .card {
    border-radius: var(--radius-md);
}

.shadow-sm {
    box-shadow: var(--shadow-sm) !important;
}

.shadow {
    box-shadow: var(--shadow-md) !important;
}

/* Hero */
#heroTitle {
    margin: 0;
    font-size: 32px;
    line-height: 1.05;
    font-weight: 800 !important;
    letter-spacing: -0.02em;
}

/* KPI cards */
.kpi-filter {
    cursor: pointer;
    transition:
        transform var(--transition-fast),
        box-shadow var(--transition-fast),
        border-color var(--transition-fast),
        background var(--transition-fast),
        color var(--transition-fast);
}

button.kpi-filter.card {
    position: relative;
    overflow: hidden;
    padding: 0;
    text-align: left;
}

button.kpi-filter.card .card-body {
    position: relative;
    min-height: 118px;
    padding: 18px 18px 16px;
    z-index: 1;
}

button.kpi-filter.card::after {
    content: "";
    position: absolute;
    inset: auto -25px -25px auto;
    width: 92px;
    height: 92px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(17, 24, 39, 0.05), rgba(17, 24, 39, 0.01));
    z-index: 0;
}

button.kpi-filter.card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: rgba(17, 24, 39, 0.12);
}

button.kpi-filter.card.border-warning {
    border-color: rgba(245, 158, 11, 0.35) !important;
    box-shadow:
        0 0 0 4px rgba(245, 158, 11, 0.14),
        var(--shadow-md) !important;
}

button.kpi-filter.card.border-warning::after {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.14), rgba(245, 158, 11, 0.02));
}

button.kpi-filter.card .display-6 {
    margin: 2px 0 4px;
    font-size: 40px;
    line-height: 1;
    font-weight: 900 !important;
    letter-spacing: -0.03em;
    color: var(--text);
}

button.kpi-filter.card .text-uppercase {
    font-size: 12px !important;
    font-weight: 800 !important;
    letter-spacing: 0.08em;
}

button.kpi-filter.card .fs-4 {
    font-size: 24px !important;
    opacity: 0.9;
}

/* KPI pills */
.btn.rounded-pill.kpi-filter {
    cursor: pointer;
}

/* Filter bars -- a <select>/search box inside a flex-wrap row, wide enough
   that its own content doesn't force it to collapse too narrow. */
.filter-control {
    min-width: 200px;
}

.filter-control-wide {
    min-width: 260px;
}

/* Live search results dropdown (device/user lookups) */
.search-results-dropdown {
    z-index: 1056;
    max-height: 240px;
    overflow-y: auto;
}

/* A small counter badge pinned to the corner of an icon/avatar */
.corner-badge {
    width: 14px;
    height: 14px;
    right: -6px;
    bottom: 2px;
    z-index: 2;
    font-size: 10px;
    line-height: 1;
}

/* Charts */
.chart-wrap {
    position: relative;
    height: 280px;
}

.chart-wrap-sm {
    position: relative;
    min-height: 220px;
}

/* Site dashboard's 5-column layout (dashboards/index.php) */
.dashboard-grid-5 {
    grid-template-columns: repeat(5, minmax(0, 1fr));
}

.grid-span-1 {
    grid-column: span 1;
}

.grid-span-2 {
    grid-column: span 2;
}

.grid-span-3 {
    grid-column: span 3;
}

/* Buttons */
.btn {
    border-radius: var(--radius-xs);
    font-weight: 700;
}

.btn-dark {
    background: var(--primary);
    border-color: var(--primary);
}

.btn-dark:hover,
.btn-dark:focus,
.btn-dark:active {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}

.btn-light {
    border-color: var(--border);
    background: var(--surface);
}

.btn-outline-secondary {
    color: var(--text-soft);
    border-color: var(--border);
}

.btn-outline-secondary:hover {
    background: #f3f4f6;
    color: var(--text);
    border-color: var(--border-strong);
}

/* Alerts / loading */
#pageError.alert {
    border-radius: var(--radius);
    border: 1px solid var(--danger-border);
    background: var(--danger-soft);
    color: var(--danger-text);
    font-size: 13px;
    font-weight: 600;
}

#loadingBox .card-body {
    padding: 24px;
}

/* Table wrapper */
#tableWrap {
    overflow: hidden;
}

#tableWrap .card-body {
    padding: 18px;
    overflow: hidden;
}

#tableWrap h2,
#tableWrap .h5 {
    margin: 0;
    font-size: 17px;
    font-weight: 800;
}

/* Table */
.table-responsive {
    width: 100%;
    font-size: 12px;
    overflow-x: auto;
    overflow-y: hidden;
}

#devices,
table.dataTable {
    width: 100% !important;
    margin-bottom: 0 !important;
}

#devices td,
#devices th,
table.dataTable td,
table.dataTable th {
    vertical-align: middle !important;
}

#devices th {
    color: var(--muted);
    font-size: 11px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    white-space: nowrap;
}

.table > :not(caption) > * > * {
    border-bottom-color: var(--border-table);
}

/* DataTables stripes compatible with child rows */
#devices tbody > tr:not(.child) > td {
    transition:
        background-color var(--transition-fast),
        border-color var(--transition-fast);
}

#devices tbody > tr:nth-child(odd of :not(.child)) > td {
    background-color: rgba(0, 0, 0, 0.018);
}

#devices tbody > tr:nth-child(even of :not(.child)) > td {
    background-color: #ffffff;
}

#devices tbody > tr:not(.child):hover > td {
    background-color: var(--hover-row) !important;
}

#devices tbody td.editable-cell {
    cursor: pointer;
    transition: background var(--transition-fast);
}

#devices tbody td.editable-cell:focus-visible {
    outline: none;
    box-shadow: inset var(--focus-ring);
}

/* DataTables child rows */
#devices tbody > tr.child > td {
    padding: 0 !important;
    background: #ffffff !important;
    border-top: 0 !important;
    border-bottom: 1px solid var(--border-table) !important;
}

#devices tbody > tr.child:hover > td {
    background: #ffffff !important;
}

#devices tbody td.dt-control {
    cursor: pointer;
}

#devices tbody td.dt-control:hover {
    background-color: var(--hover-row) !important;
}

.device-link-remove-btn {
    color: var(--danger) !important;
}

.device-link-remove-btn:hover {
    color: var(--danger-text) !important;
}

/* DataTables */
.dataTables_wrapper {
    width: 100%;
}

#tableWrap .dataTables_wrapper .row {
    margin-left: 0;
    margin-right: 0;
}

#tableWrap .dataTables_wrapper .row > * {
    padding-left: 0;
    padding-right: 0;
}

.dataTables_wrapper .dataTables_scroll {
    width: 100%;
}

.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
    min-height: 38px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-2xs);
    background: var(--surface);
}

.dataTables_wrapper .dataTables_filter input {
    padding-left: 10px;
}

.dataTables_wrapper .dataTables_filter label,
.dataTables_wrapper .dataTables_length label {
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
}

.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_paginate {
    color: var(--muted);
    font-size: 12px;
}

.dataTables_wrapper .paginate_button,
.dataTables_wrapper .page-link {
    border-radius: var(--radius-2xs) !important;
}

.dataTables_wrapper .page-link {
    margin: 0 2px;
    border-color: var(--border);
    color: var(--text);
}

.dataTables_wrapper .page-item.active .page-link {
    border-color: var(--primary);
    background: var(--primary);
    color: #fff;
}

.dataTables_wrapper .page-link:focus {
    box-shadow: var(--focus-ring);
}

/* Device cells */
#devices tbody td:nth-child(2) .fw-semibold {
    color: var(--text);
    line-height: 1.2;
    font-weight: 700 !important;
}

.device-actions-btn,
#devices .device-actions-btn {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-xs) !important;
    border: 0;
    background: transparent;
    color: var(--muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition:
        background var(--transition-fast),
        color var(--transition-fast),
        transform var(--transition-fast);
}

.device-actions-btn:hover,
#devices .device-actions-btn:hover {
    background: var(--hover-soft);
    color: var(--text);
    transform: translateY(-1px);
}

/* Toasts */

.toast-zone {
    z-index: 2100 !important;
    pointer-events: none;
}

#zentra-toast-container {
    z-index: 1080;
}

.toast {
    min-width: 280px;
    max-width: 360px;
    border-radius: var(--radius-sm) !important;
    box-shadow: var(--shadow-toast) !important;
    font-size: 13px;
    font-weight: 600;
    pointer-events: auto;
}

/* Notification panel -- opens from the bell, lists recent notifications
   (read and unread) so history stays visible instead of disappearing the
   moment it's been seen once. */

.notification-panel {
    position: fixed;
    z-index: 2150;
    width: 360px;
    max-width: calc(100vw - 2rem);
    max-height: 420px;
    overflow-y: auto;
    background: var(--surface);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
}

.notification-panel-header {
    position: sticky;
    top: 0;
    padding: .75rem 1rem;
    font-weight: 600;
    font-size: .9rem;
    color: var(--text);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.notification-panel-empty {
    padding: 2.5rem 1rem;
    text-align: center;
    color: var(--muted);
    font-size: .85rem;
}

.notification-panel-item {
    display: flex;
    gap: .75rem;
    padding: .65rem 1rem;
    border-bottom: 1px solid var(--border-table);
}

.notification-panel-item:last-child {
    border-bottom: none;
}

.notification-panel-item.is-unread {
    background: var(--hover-soft);
}

.notification-panel-item.is-clickable {
    cursor: pointer;
}

.notification-panel-item.is-clickable:hover {
    background: var(--hover-soft);
}

.notification-panel-item-icon {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .8rem;
}

.notification-panel-item-body {
    min-width: 0;
    flex: 1 1 auto;
}

.notification-panel-item-title {
    font-size: .82rem;
    color: var(--text);
}

.notification-panel-item.is-unread .notification-panel-item-title {
    font-weight: 700;
}

.notification-panel-item-message {
    font-size: .78rem;
    color: var(--muted);
    margin-top: .1rem;
}

.notification-panel-item-time {
    font-size: .72rem;
    color: var(--muted);
    margin-top: .25rem;
}

/* Modals */
.modal-content {
    overflow: hidden;
    border: 0 !important;
    border-radius: 22px !important;
    box-shadow: var(--shadow-lg) !important;
    background: var(--surface) !important;
}

.modal-header {
    align-items: flex-start;
    padding: 16px 18px 12px;
    border-bottom: 1px solid var(--border-table);
    background: var(--surface);
}

.modal-title {
    margin-bottom: 2px;
    color: var(--text);
    font-size: 16px;
    font-weight: 800;
}

.modal-header .small {
    color: var(--muted);
    font-size: 11px;
}

.modal-body {
    padding: 14px 18px;
    background: var(--surface-3) !important;
}

.modal-footer {
    padding: 12px 18px 16px;
    border-top: 1px solid var(--border-table);
    background: var(--surface-3);
}

.form-label {
    margin-bottom: 0.45rem;
}

.form-control,
.form-select {
    min-height: 38px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-xs);
    background: var(--surface);
    color: var(--text);
    box-shadow: none !important;
}

.form-control-sm,
.form-select-sm {
    min-height: 34px;
    border-radius: var(--radius-2xs);
}

.form-control:focus,
.form-select:focus {
    border-color: rgba(17, 24, 39, 0.22);
    box-shadow: var(--focus-ring-soft) !important;
}

.form-check-input:focus {
    box-shadow: var(--focus-ring-soft);
    border-color: rgba(17, 24, 39, 0.22);
}

.form-check-input:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

.btn-close:focus {
    box-shadow: var(--focus-ring);
}

#macList .card,
#macLoading,
#macInlineError {
    margin-bottom: 0;
}

#macList .card-body {
    padding: 12px;
}

#macList .fw-semibold.small {
    font-size: 13px !important;
    line-height: 1.2;
}

#macList .text-body-secondary.small,
#macList .text-secondary.small {
    font-size: 11px !important;
}

#macList .btn {
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: var(--radius-2xs);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

#macList .btn i {
    font-size: 14px;
}

/* Reserves space for the connectivity options that appear once a
   connection type is picked, so the modal doesn't jump when they show. */
.connectivity-options-space {
    min-height: 65px;
}

/* Dropdown */
.dropdown-menu {
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    padding: 8px;
}

.dropdown-item {
    border-radius: var(--radius-2xs);
    font-weight: 500;
}

.dropdown-item:hover {
    background: #f3f4f6;
    color: var(--text);
}

/* Utility */
.d-none {
    display: none !important;
}

.cursor-pointer {
    cursor: pointer;
}

/* Flex children need min-width:0 for text-truncate to actually clip
   instead of overflowing their row -- Bootstrap doesn't ship this one. */
.min-w-0 {
    min-width: 0;
}

.line-clamp-2 {
    display: -webkit-box;
    min-height: 2.5rem;
    line-height: 1.25rem;
    overflow: hidden;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* Fine print -- named by role, not by pixel count, so the actual size can
   change here without hunting the class name down everywhere it's used. */
.text-2xs {
    font-size: 10px;
}

.text-xs {
    font-size: 11px;
}

.text-caption {
    font-size: 13px;
}

.text-caption-lg {
    font-size: 14px;
}

.fs-eyebrow {
    font-size: .65rem;
}

.lh-tight {
    line-height: 1.2;
}

/* Centered single-card pages (login, change password) */
.auth-card {
    width: 100%;
    max-width: 440px;
}

/* Narrower content column for text-heavy pages (profile) */
.content-narrow {
    max-width: 900px;
}

/* Responsive */
@media (max-width: 1199.98px) {
    main.container-fluid {
        padding-top: 92px;
    }
}

@media (max-width: 991.98px) {
    .navbar .navbar-collapse {
        margin-top: 10px;
        padding-top: 10px;
        border-top: 1px solid var(--border-table);
    }

    .navbar-nav .nav-link {
        min-height: 42px;
    }
}

@media (max-width: 767.98px) {
    main.container-fluid {
        padding-top: 86px;
        padding-left: 14px;
        padding-right: 14px;
        padding-bottom: 18px;
    }

    #heroTitle {
        font-size: 26px;
    }

    .toast {
        min-width: 0;
        max-width: none;
    }

    .modal-dialog {
        margin: 0.75rem;
    }
}

.tracking-col {
    width: 12px;
    max-width: 12px;
    padding: 2px 4px !important;
}

.tracking-col span {
    font-size: 8px;
    line-height: 2;
}

#devices tbody tr.device-links-open > td {
    border-bottom: 0 !important;
}