/* =====================================================
   Customer Hub — Custom styles (TailPanel-inspired)
   Bootstrap 4.6 base + Bootstrap Icons
   Rule: KHÔNG override Bootstrap class trực tiếp.
         Scope vào wrapper (.page-content, .topbar, v.v.)
         hoặc tạo class riêng.
   ===================================================== */

:root {
    --primary: #1e4c91;
    --primary-hover: #163b73;
    --primary-light: #e0eaf7;
    --sidebar-width: 252px;
    --topbar-height: 60px;
    --body-bg: #f1f5f9;
    --shadow-sm: 0 2px 8px rgba(0,0,0,.08), 0 1px 3px rgba(0,0,0,.06);
    --shadow: 0 4px 16px rgba(0,0,0,.10), 0 2px 6px rgba(0,0,0,.06);
    --card-radius: 0.75rem;
}

* { box-sizing: border-box; }

body {
    background: var(--body-bg);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    font-size: 14px;
    color: #1e293b;
}

/* ─── Sidebar ─── */
.sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-width);
    background: #fff;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    overflow-y: auto;
    transition: width .25s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    height: var(--topbar-height);
    padding: 0 18px;
    border-bottom: 1px solid #f1f5f9;
    text-decoration: none !important;
    flex-shrink: 0;
}

.sidebar-brand-icon {
    width: 36px; height: 36px;
    background: var(--primary);
    border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    font-weight: 800;
    font-size: 16px;
    flex-shrink: 0;
}

.sidebar-brand-name {
    font-size: 15px;
    font-weight: 700;
    color: #1e293b;
    white-space: nowrap;
}

/* ─── Brand row (Coursera-style master + module) ─── */
.sidebar-brand-row {
    display: flex;
    align-items: center;
    height: var(--topbar-height);
    border-bottom: 1px solid #f1f5f9;
    flex-shrink: 0;
    padding: 0 6px;
}

.brand-master {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 6px 10px;
    border-radius: 8px;
    text-decoration: none !important;
    cursor: pointer;
    transition: background .15s ease;
    min-width: 0;
}

.brand-master:hover { background: #f8fafc; }

.brand-master-icon {
    width: 30px; height: 30px;
    background: var(--primary);
    border-radius: 7px;
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    font-weight: 800;
    font-size: 14px;
    flex-shrink: 0;
}

.brand-master-name {
    font-size: 14px;
    font-weight: 700;
    color: #1e293b;
    white-space: nowrap;
}

.brand-divider {
    width: 1px;
    height: 22px;
    background: #e2e8f0;
    margin: 0 2px;
    flex-shrink: 0;
}

.brand-module {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 8px;
    text-decoration: none !important;
    cursor: pointer;
    transition: background .15s ease;
    font-size: 14px;
    font-weight: 600;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.brand-module:hover { background: #f8fafc; }

body.sidebar-collapsed .brand-master-name,
body.sidebar-collapsed .brand-divider,
body.sidebar-collapsed .brand-module { display: none; }
body.sidebar-collapsed .sidebar-brand-row { padding: 0; justify-content: center; }

.sidebar-nav {
    flex: 1;
    padding: 10px;
}

.sidebar-nav .nav-item { margin-bottom: 2px; }

/* Scoped: chỉ áp dụng cho nav-link trong sidebar */
.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #64748b;
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    transition: background .15s, color .15s;
}

.sidebar-nav .nav-link i {
    font-size: 17px;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-nav .nav-link:hover {
    color: var(--primary);
    background: var(--primary-light);
    text-decoration: none;
}

.sidebar-nav .nav-link.active {
    color: var(--primary);
    background: var(--primary-light);
    font-weight: 600;
}

/* ─── Sidebar collapse → icon-only ─── */
body.sidebar-collapsed .sidebar {
    width: 64px;
    overflow: hidden;
}

body.sidebar-collapsed .sidebar-brand-name,
body.sidebar-collapsed .sidebar-nav .nav-link span {
    display: none;
}

body.sidebar-collapsed .sidebar-brand {
    justify-content: center;
    padding: 16px 0;
}

body.sidebar-collapsed .sidebar-nav .nav-link {
    justify-content: center;
    padding: 10px 0;
}

body.sidebar-collapsed .sidebar-nav .nav-link i {
    width: auto;
    font-size: 19px;
}

/* ─── Main wrapper ─── */
.main-wrapper {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left .25s ease;
}

body.sidebar-collapsed .main-wrapper {
    margin-left: 64px;
}

/* ─── Topbar ─── */
.topbar {
    height: var(--topbar-height);
    background: #fff;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 900;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-title {
    font-size: 15px;
    font-weight: 600;
    color: #1e293b;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-toggle {
    color: #64748b;
    border: none;
    background: transparent;
    font-size: 18px;
    padding: 4px 8px;
    line-height: 1;
    border-radius: 7px;
}

.sidebar-toggle:hover {
    background: #f1f5f9;
    color: var(--primary);
}

/* ─── Topbar user dropdown trigger ─── */
.topbar-user-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    border: none;
    padding: 4px 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: background .15s;
}

.topbar-user-btn:hover,
.topbar-user-btn:focus {
    background: #f1f5f9;
    outline: none;
    box-shadow: none;
}

.topbar-user-btn::after {
    color: #94a3b8;
    margin-left: 2px;
}

.topbar-avatar {
    width: 34px; height: 34px;
    background: var(--primary);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 12px;
}

.topbar-user-name {
    font-size: 13px;
    font-weight: 500;
    color: #1e293b;
}

/* Scoped: dropdown chỉ trong topbar */
.topbar .dropdown-menu {
    border: none;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,.12);
    padding: 6px;
    min-width: 210px;
}

.topbar .dropdown-header {
    padding: 8px 12px;
    line-height: 1.4;
}

.topbar .dropdown-item {
    border-radius: 7px;
    font-size: 13px;
    padding: 8px 12px;
    color: #374151;
}

.topbar .dropdown-item:hover {
    background: #f1f5f9;
    color: #1e293b;
}

.topbar .dropdown-item.text-danger:hover {
    background: #fef2f2;
}

.topbar .dropdown-divider {
    margin: 4px 0;
    border-color: #f1f5f9;
}

/* ─── Globe language button ─── */
.topbar-lang-btn {
    background: transparent;
    border: 0;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    font-size: 18px;
    transition: background .15s ease, color .15s ease;
}

.topbar-lang-btn:hover {
    background: #f1f5f9;
    color: #1e293b;
}

/* ─── Page content ─── */
.page-content {
    flex: 1;
    padding: 15px;
}

/* The padding is published as --eh-content-pad: a page that bleeds a band to
   the box's edge writes `margin: 0 calc(-1 * var(--eh-content-pad, 24px))`,
   never a literal 24px — the phone shell (§ Responsive kit) narrows it.
   Exception: the HrStaff shell pads the box directly (hr-staff.css,
   `body.hrm-shell .content-box { padding: 16px }`), so the variable does not
   describe it there. */
.content-box {
    --eh-content-pad: 24px;
    background: #fff;
    border-radius: var(--card-radius);
    box-shadow: var(--shadow-sm);
    padding: var(--eh-content-pad);
    min-height: calc(100vh - var(--topbar-height) - 30px);
}

/* ─── Cards — scoped vào page-content ─── */
.page-content .card {
    border: none;
    border-radius: var(--card-radius);
    box-shadow: var(--shadow-sm);
}

.page-content .card-header {
    background: #fff;
    border-bottom: 1px solid #f1f5f9;
    border-radius: var(--card-radius) var(--card-radius) 0 0;
    padding: 14px 20px;
    font-weight: 600;
}

.page-content .card-body {
    padding: 20px;
}

/* ─── Card-body chứa bảng: padding nhỏ hơn ─── */
.page-content .card-body.table-pad {
    padding: 8px 12px;
}

/* ─── Table trong card: bỏ margin-bottom ─── */
.page-content .card .table-responsive .table,
.page-content .card > .table {
    margin-bottom: 0;
}

/* ─── Tables — scoped vào page-content ─── */
.page-content .table thead th,
.page-content .table thead.thead-light th {
    background: #fff;
    font-weight: 600;
    font-size: 12px;
    border-top: none;
    border-bottom: 2px solid #f1f5f9;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 10px 12px;
}

.page-content .table td {
    font-size: 13px;
    color: #374151;
    border-top: 1px solid #f1f5f9;
    padding: 10px 12px;
}

.page-content .table th {
    padding: 10px 12px;
}

.page-content .table td,
.page-content .table th {
    vertical-align: middle;
}

.page-content .table-hover tbody tr:hover td {
    background-color: #f8fafc;
}

.page-content .table-bordered {
    border: 1px solid #e2e8f0;
}

.page-content .table-bordered td,
.page-content .table-bordered th {
    border-color: #e2e8f0;
}

/* ─── Buttons — scoped vào page-content ─── */
.page-content .btn {
    border-radius: 7px;
    font-size: 13px;
}

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

.page-content .btn-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}

/* ─── Alerts — scoped vào page-content ─── */
.page-content .alert {
    border-radius: 8px;
    font-size: 13px;
}

.page-content .alert-success {
    background: #f0fdf4;
    color: #166534;
    border-color: #bbf7d0;
}

.page-content .alert-danger {
    background: #fef2f2;
    color: #991b1b;
    border-color: #fecaca;
}

/* ─── Form controls — scoped vào page-content ─── */
.page-content .form-control {
    border-color: #e2e8f0;
    border-radius: 7px;
    font-size: 14px;
}

.page-content .form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(30,76,145,.12);
}

/* ─── Modals ─── */
.modal .modal-content {
    border: none;
    border-radius: var(--card-radius);
    box-shadow: 0 20px 60px rgba(0,0,0,.15);
}

.modal .modal-header {
    border-bottom: 1px solid #f1f5f9;
    padding: 16px 20px;
}

.modal .modal-footer {
    border-top: 1px solid #f1f5f9;
    padding: 12px 20px;
}

.modal .btn {
    border-radius: 7px;
    font-size: 13px;
}

.modal .form-control {
    border-color: #e2e8f0;
    border-radius: 7px;
    font-size: 14px;
}

.modal .form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(30,76,145,.12);
}

/* ─── Badge soft variants (class riêng, không đè Bootstrap) ─── */
.badge-soft-success {
    background: #dcfce7;
    color: #16a34a;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    padding: 4px 10px;
}

.badge-soft-warning {
    background: #fef9c3;
    color: #a16207;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    padding: 4px 10px;
}

.badge-soft-danger {
    background: #fee2e2;
    color: #dc2626;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    padding: 4px 10px;
}

.badge-soft-info {
    background: #dbeafe;
    color: #1d4ed8;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    padding: 4px 10px;
}

.badge-soft-secondary {
    background: #f1f5f9;
    color: #64748b;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    padding: 4px 10px;
}

.badge-soft-primary {
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    padding: 4px 10px;
}

/* ─── Stat cards (dashboard) ─── */
.stat-card {
    background: #fff;
    border-radius: var(--card-radius);
    box-shadow: var(--shadow-sm);
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.stat-card .stat-label {
    font-size: 13px;
    color: #64748b;
    font-weight: 500;
    margin-bottom: 6px;
}

.stat-card .stat-value {
    font-size: 24px;
    font-weight: 700;
    color: #1e293b;
    line-height: 1;
    margin-bottom: 0;
}

.stat-icon {
    width: 52px; height: 52px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.stat-icon.green  { background: #f0fdf4; color: #16a34a; }
.stat-icon.blue   { background: #eff6ff; color: #2563eb; }
.stat-icon.purple { background: #faf5ff; color: #7c3aed; }
.stat-icon.orange { background: #fff7ed; color: #ea580c; }

/* ─── Sidebar backdrop (mobile) ─── */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 999;
}

body.sidebar-open .sidebar-backdrop { display: block; }

/* ─── Responsive ─── */
/* Phone = max-width 767.98px everywhere — the shell, the kit below and every
   module's phone rules switch at Bootstrap's `md` boundary together, so no
   width (an iPad held upright is exactly 768px) gets the phone shell with the
   desktop page rules (owner, 2026-10-14). */
@media (max-width: 767.98px) {
    /* Sidebar ẩn mặc định trên mobile */
    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width) !important;
        transition: transform .25s ease;
    }

    /* Khi mở sidebar trên mobile */
    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    /* Sidebar-collapsed trên mobile không ảnh hưởng (chỉ desktop) */
    body.sidebar-collapsed .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width) !important;
    }

    body.sidebar-collapsed.sidebar-open .sidebar {
        transform: translateX(0);
    }

    .main-wrapper { margin-left: 0 !important; }

    /* Stat cards stack */
    .stat-card { margin-bottom: 12px; }

    /* Form inline stack */
    .form-inline .form-control { margin-bottom: 8px; width: 100%; }
}

/* Below Bootstrap's `lg`: beside the 252px rail the top bar's right side (bell,
   branch switcher, account button) does not fit with the account NAME as well — at
   768px it pushed the page 35px sideways. The name is hidden the way
   `.visually-hidden` hides — out of sight, still the button's accessible name
   for a screen reader; the avatar stays, the menu it opens names the account,
   and the name returns at Bootstrap's `lg`. Phones included. */
@media (max-width: 991.98px) {
    /* …and the page title keeps to one line, ending in "…", instead of wrapping
       out of the bar (TD-547: at 800px "Tiến trình WF-2026-00002" stood on four
       lines). */
    .topbar-left { min-width: 0; flex: 1 1 auto; }
    .topbar-title {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .topbar-user-name {
        position: absolute !important;
        width: 1px !important;
        height: 1px !important;
        padding: 0 !important;
        margin: -1px !important;
        overflow: hidden !important;
        clip: rect(0, 0, 0, 0) !important;
        white-space: nowrap !important;
        border: 0 !important;
    }
}

/* The shared menu button (Core's sidebar-toggle component) is phone-only
   unless the layout passes `collapsible`: above the off-canvas width there is
   no drawer to open, and a layout not styled for the folded rail must not
   offer to fold it. Written as the exact negation of the phone block above
   (not `min-width: 768px`): a fractional width such as 767.99px (browser zoom,
   a scaled display) matches one of the two, never neither. */
@media not all and (max-width: 767.98px) {
    .sidebar-toggle[data-sidebar-phone-only] { display: none; }
}

/* ─── Responsive kit (AGENTS.md working agreement 28) ───
   Shared building blocks so every module meets the 375px baseline the same
   way; when to reach for each: .claude/skills/eduhub-design/README.md
   § Responsive layout. Each helper is opt-in by class or by Core component
   (filter-sheet, filter-sheet-button, more-actions, mirror-search; behaviour
   in app/Modules/Core/resources/js/responsive-kit.js), and every rule that
   changes a layout sits inside a phone-width query, so desktop renders as
   before. Four rules apply to every page without opt-in, all phone-only:
   modal-lg / modal-xl dialogs fill the screen below 576px; the shell is
   tighter below 768px (top bar, page padding, and the content box's
   --eh-content-pad 24px -> 14px); pagination wraps; and form fields in the
   page and in dialogs use 16px text below 768px (the last block here).

   Phone = max-width 767.98px, Bootstrap's `md` boundary, so a page's grid,
   `offcanvas-md` and these helpers switch together — and so does the shell's
   off-canvas width (§ Responsive above) since 2026-10-14; it used to be 768px
   inclusive, one pixel wider, which gave an upright iPad the phone shell over
   desktop page rules. */

/* Page header: title on the left, actions on the right; wraps instead of
   pushing the actions off-screen. */
.eh-page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px 12px;
    margin-bottom: 16px;
}
.eh-page-head > :first-child { min-width: 0; }
.eh-page-head h1,
.eh-page-head .eh-page-title { margin: 0; overflow-wrap: anywhere; }

/* A row of buttons (.eh-actions) or of filter controls (.eh-toolbar) that
   wraps; on a phone a toolbar's fields take a whole row each. */
.eh-actions,
.eh-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}
.eh-toolbar > * { min-width: 0; max-width: 100%; }

@media (max-width: 767.98px) {
    .eh-toolbar > :is(.form-control, .form-select, .input-group) { flex: 1 1 100%; }

    /* Tap targets of at least 44px inside the kit's containers. */
    :is(.eh-page-head, .eh-actions, .eh-toolbar) .btn,
    .eh-filter-sheet-btn,
    .eh-more-actions-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        min-height: 44px;
        min-width: 44px;
    }
    .eh-toolbar :is(.form-control, .form-select),
    .eh-mirror-search { min-height: 44px; }
}

/* Show on one side of the phone boundary only, keeping the element's own
   display (Bootstrap's d-* utilities force one). The second query is the
   exact negation of the first, so at any width — a fractional one included —
   exactly one of the pair shows. */
@media (max-width: 767.98px) {
    .eh-desktop-only { display: none !important; }
}
@media not all and (max-width: 767.98px) {
    .eh-phone-only { display: none !important; }
}

/* Filter sheet (<x-core::filter-sheet>): the page's filters inline on
   desktop, a bottom sheet on a phone. Bootstrap's `offcanvas-md` does the
   switching; these rules restore the desktop flow (from md up Bootstrap turns
   the sheet's body into a flex row) and shape the phone sheet. The compound
   `.eh-filter-sheet.offcanvas-md` outranks `.page-content .card*` and a
   page's grid classes without !important. */
@media (min-width: 768px) {
    .eh-filter-sheet.offcanvas-md { outline: 0; }
    .eh-filter-sheet.offcanvas-md > .offcanvas-body { display: block; }
}
@media (max-width: 767.98px) {
    .eh-filter-sheet.offcanvas-md.offcanvas-bottom {
        height: auto;
        max-height: 88vh;
        max-height: 88dvh;
        border-top: 0;
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -8px 24px rgba(15, 23, 42, .12);
    }
    .eh-filter-sheet.offcanvas-md .offcanvas-header {
        border-bottom: 1px solid #e2e8f0;
        padding: 12px 16px;
    }
    .eh-filter-sheet.offcanvas-md .offcanvas-title {
        font-size: 16px;
        font-weight: 600;
        color: #1e293b;
    }
    /* The bottom padding clears the AI help bubble (Ai's help-launcher.css:
       52px at bottom 22px, z-index 1080 above the sheet's 1045, hidden only
       while a modal is open), so the sheet's last row — usually its submit
       button — is never under it: 22 + 52 + 12px air. In the person portal
       the bubble rides above the tab bar (--eh-tabbar-h, which already holds
       the safe area), so the larger of the two lifts is added. */
    .eh-filter-sheet.offcanvas-md .offcanvas-body {
        padding: 16px 16px calc(86px + max(var(--eh-tabbar-h, 0px), env(safe-area-inset-bottom, 0px)));
    }
    /* A filter card loses its chrome inside the sheet, and its grid turns
       into one control per row. */
    .eh-filter-sheet.offcanvas-md :is(.card, .card-body) {
        border: 0;
        box-shadow: none;
        padding: 0;
        margin: 0;
        background: transparent;
    }
    .eh-filter-sheet.offcanvas-md .row > * {
        flex: 0 0 auto;
        width: 100%;
    }
    .eh-filter-sheet.offcanvas-md :is(.form-control, .form-select, .input-group) { max-width: 100%; }
}

/* Stacked table (`.eh-stack` on a <table>): below md each row becomes a card
   built from the same markup, so rows a page re-renders over AJAX keep
   working. Each <td> carries `data-label` (shown on the left, its value on
   the right); `.eh-stack-title` is the card's heading (moved to the top),
   `.eh-stack-check` pins a row checkbox to the top-right corner,
   `.eh-stack-actions` lays the row's buttons out along the bottom, and
   `.eh-stack-hide` drops a cell on a phone. The doubled class lifts these
   rules over `.page-content .table td` and Bootstrap's
   `.table > :not(caption) > * > *` without !important; the cell's
   background and column-width hints are !important because state colours
   and inline widths reach the cell that way. A row's state class
   (`tr.table-warning`, `.table-danger`, …) colours the whole card through
   Bootstrap's --bs-table-bg; a state class on a single CELL is not carried. */
@media (max-width: 767.98px) {
    .table-responsive:has(> table.eh-stack),
    [class*="table-responsive-"]:has(> table.eh-stack) { overflow-x: visible; }

    table.eh-stack.eh-stack,
    table.eh-stack.eh-stack > tbody { display: block; width: 100%; }
    table.eh-stack.eh-stack { border: 0; background: transparent; }
    table.eh-stack.eh-stack > thead { display: none; }

    table.eh-stack.eh-stack > tbody > tr {
        display: flex;
        flex-direction: column;
        gap: 6px;
        position: relative;
        background: var(--bs-table-bg, #fff);
        border: 1px solid #e2e8f0;
        border-radius: var(--card-radius);
        padding: 12px 14px;
        margin-bottom: 10px;
    }
    table.eh-stack.eh-stack > tbody > tr:last-child { margin-bottom: 0; }

    /* A cell is a block, not a flex row: a value made of several inline
       pieces (a name and its code, two badges) must stay one run of text. */
    table.eh-stack.eh-stack > tbody > tr > :is(td, th) {
        display: flow-root;
        width: auto !important;
        min-width: 0 !important;
        padding: 0;
        border: 0;
        box-shadow: none;
        background: transparent !important;
        text-align: right;
        white-space: normal;
        overflow-wrap: anywhere;
    }
    /* The heading, the checkbox and the actions carry no label even when the
       markup gives them one. */
    table.eh-stack.eh-stack > tbody > tr > :is(td, th)[data-label]:not(.eh-stack-title, .eh-stack-check, .eh-stack-actions)::before {
        content: attr(data-label);
        float: left;
        max-width: 50%;
        margin-right: 12px;
        color: #64748b;
        font-size: 12px;
        font-weight: 500;
        text-align: left;
    }

    table.eh-stack.eh-stack > tbody > tr > .eh-stack-title {
        order: -1;
        text-align: left;
        font-size: 15px;
        font-weight: 600;
        color: #1e293b;
    }
    table.eh-stack.eh-stack > tbody > tr:has(> .eh-stack-check) > .eh-stack-title { padding-right: 36px; }

    table.eh-stack.eh-stack > tbody > tr > .eh-stack-check {
        position: absolute;
        top: 10px;
        right: 10px;
    }
    table.eh-stack.eh-stack > tbody > tr > .eh-stack-check input[type="checkbox"] {
        width: 22px;
        height: 22px;
    }

    table.eh-stack.eh-stack > tbody > tr > .eh-stack-actions {
        order: 99;
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 8px;
        text-align: left;
        margin-top: 4px;
        padding-top: 10px;
        border-top: 1px solid #f1f5f9;
    }
    table.eh-stack.eh-stack > tbody > tr > .eh-stack-actions .btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-height: 44px;
        min-width: 44px;
    }

    /* An empty-state row (one cell spanning the table) stays plain text. */
    table.eh-stack.eh-stack > tbody > tr > td[colspan] { text-align: center; }
    table.eh-stack.eh-stack > tbody > tr:has(> td[colspan]:only-child) {
        border: 0;
        background: transparent;
        padding: 16px 0;
    }

    table.eh-stack.eh-stack > tbody > tr > .eh-stack-hide,
    table.eh-stack.eh-stack > tbody > tr > :is(td, th):empty { display: none; }
}

/* Large dialogs fill the screen on a phone — Bootstrap's
   `modal-fullscreen-sm-down`, applied to every modal-lg / modal-xl so no
   module has to opt in. The body scrolls between a fixed header and footer
   in all three markup shapes the app uses: `.modal-content` straight inside
   the dialog (the <form> may itself be the `.modal-content`), a <form>
   inside `.modal-content` wrapping header, body and footer, and a <form>
   between the dialog and `.modal-content` — that last one is a column too,
   or a tall form inside `modal-dialog-centered` overflows UPWARD and its
   header leaves the screen.
   The dialog's size and margin are !important on purpose, phone-only: a
   module's own dialog rule of equal weight loaded after this file (a
   `margin-top` that pushes the footer off-screen) and an inline
   `style="max-width:70%"` would otherwise win. */
@media (max-width: 575.98px) {
    .modal-dialog:is(.modal-lg, .modal-xl) {
        width: 100vw !important;
        max-width: none !important;
        height: 100% !important;
        margin: 0 !important;
    }
    .modal-dialog:is(.modal-lg, .modal-xl) > form {
        display: flex;
        flex-direction: column;
        width: 100%;
        height: 100%;
        min-height: 0;
    }
    .modal-dialog:is(.modal-lg, .modal-xl) > .modal-content,
    .modal-dialog:is(.modal-lg, .modal-xl) > form > .modal-content {
        height: 100%;
        max-height: none;
        border: 0;
        border-radius: 0;
    }
    .modal-dialog:is(.modal-lg, .modal-xl) > form > .modal-content {
        flex: 1 1 auto;
        min-height: 0;
    }
    .modal-dialog:is(.modal-lg, .modal-xl) > .modal-content > form {
        display: flex;
        flex-direction: column;
        flex: 1 1 auto;
        min-height: 0;
    }
    .modal-dialog:is(.modal-lg, .modal-xl) :is(.modal-header, .modal-footer) { border-radius: 0; }
    .modal-dialog:is(.modal-lg, .modal-xl) .modal-body { overflow-y: auto; }
}

/* Phone shell: a tighter top bar and content box so 375px has room. */
@media (max-width: 767.98px) {
    .topbar { padding: 0 8px 0 4px; gap: 6px; }
    .topbar-left { gap: 4px; }
    .topbar-right { gap: 4px; flex-shrink: 0; }
    /* The bell's wrapper spaces itself with Bootstrap's !important margin. */
    .topbar-right > .me-3 { margin-right: 0 !important; }
    .page-content { padding: 12px; }
    /* Through the variable, so a page's edge-to-edge band follows. */
    .content-box { --eh-content-pad: 14px; }
    .pagination { flex-wrap: wrap; }
}

/* iOS Safari zooms the page in when a field under 16px takes focus, and the
   app's 14px fields (.page-content .form-control above) trigger it on every
   form. Phone only — desktop keeps 14px. */
@media (max-width: 767.98px) {
    .page-content .form-control,
    .page-content .form-select,
    .modal .form-control,
    .modal .form-select { font-size: 16px; }
}

/* ─── Guest / Login layout ─── */
.guest-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-wrapper {
    width: 100%;
    max-width: 420px;
    padding: 20px;
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
    margin-bottom: 28px;
}

.login-brand-icon {
    width: 42px; height: 42px;
    background: var(--primary);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    font-weight: 800;
    font-size: 18px;
}

.login-brand-name {
    font-size: 20px;
    font-weight: 700;
    color: #1e293b;
}

.login-card {
    border-radius: 14px !important;
    box-shadow: 0 4px 24px rgba(0,0,0,.08) !important;
}

.login-card .card-body { padding: 32px; }

.login-card .card-title {
    font-size: 17px;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 4px;
}

.login-card .card-subtitle {
    font-size: 13px;
    color: #64748b;
    margin-bottom: 24px;
    display: block;
}

.login-card .form-control {
    border-color: #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    padding: 10px 14px;
    height: auto;
}

.login-card .form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(30,76,145,.12);
}

.login-card .btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    border-radius: 8px;
    font-weight: 600;
    padding: 10px;
    font-size: 14px;
}

.login-card .btn-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}

.login-footer {
    text-align: center;
    font-size: 12px;
    color: #94a3b8;
    margin-top: 20px;
}

/* ─── Smooth collapse animation ─── */
.collapsing {
    transition: height .35s ease;
}

.collapse-chevron {
    display: inline-block;
    transition: transform .3s ease;
}

[data-toggle="collapse"][aria-expanded="true"] .collapse-chevron,
[data-toggle="collapse"]:not(.collapsed) .collapse-chevron {
    transform: rotate(180deg);
}

/* ─── Sidebar section headers (module grouping) ─── */
.nav-section {
    padding: 14px 18px 4px;
    list-style: none;
}
.nav-section-label {
    font-size: 10px;
    font-weight: 700;
    color: #94a3b8;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
