:root {
    color-scheme: light;
}

.page-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.page-grid {
    display: grid;
    gap: 20px;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.ag-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    margin-top: 20px;
}

.ag-pagination .pagination {
    display: flex;
    gap: 4px;
}

.ag-pagination a {
    min-width: 34px;
    padding: 7px 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    text-align: center;
    text-decoration: none;
    color: inherit;
}

.ag-pagination a.active {
    background: var(--primary, #111827);
    color: #fff;
    border-color: transparent;
}

.ag-pagination-summary {
    color: var(--text-muted);
    font-size: .875rem;
}

.dt-page-btn[aria-disabled="true"] {
    opacity: .35;
    pointer-events: none;
}

.dt-page-ellipsis {
    display: inline-flex;
    align-items: center;
    padding: 0 5px;
    color: var(--text-muted);
}

.ag-list-header {
    gap: 12px;
    flex-wrap: nowrap;
    align-items: center;
}

.ag-table-header-main {
    flex: 0 1 auto;
    min-width: 0;
}

.ag-table-header-tools {
    flex: 1 1 auto;
    min-width: 0;
    margin-left: auto;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: nowrap;
}

.ag-table-filter-form {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: nowrap;
}

.ag-table-search {
    position: relative;
    min-width: 190px;
}

.ag-table-search>span {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.ag-table-search .form-control {
    padding-left: 28px;
}

.ag-table-filter-form>.form-control {
    flex: 0 0 120px;
    width: 120px;
    min-width: 0;
}

.ag-table-filter-form>.ag-table-search {
    flex: 1 1 220px;
    min-width: 160px;
    max-width: 260px;
}

.ag-table-filter-form>button {
    flex: 0 0 auto;
}

.ag-table-actions {
    flex: 0 0 auto;
    display: flex;
    gap: 6px;
    white-space: nowrap;
}

/* Generic overflow-actions dropdown — a <details> whose <summary> carries its own
   .btn classes (so it looks like any other button) and whose panel floats below it.
   Reused wherever a toolbar/row has more actions than should sit flat on the page. */
.ag-action-menu {
    position: relative;
    display: inline-block;
}

.ag-action-menu>summary {
    list-style: none;
}

.ag-action-menu>summary::-webkit-details-marker {
    display: none;
}

.ag-action-menu-list {
    position: absolute;
    right: 0;
    top: 100%;
    z-index: 40;
    display: grid;
    min-width: 13rem;
    margin-top: .4rem;
    padding: .45rem;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--surface, #fff);
    box-shadow: 0 14px 32px rgba(15, 23, 42, .16);
}

/* cms.js upgrades this to position:fixed with JS-computed coordinates on open — a container
   with overflow-x:auto (e.g. .ag-table-actions on a crowded toolbar) forces overflow-y to
   'auto' too per the CSS Overflow spec, silently clipping a plain position:absolute panel. */
.ag-action-menu-list a,
.ag-action-menu-list button {
    display: block;
    width: 100%;
    padding: .55rem .7rem;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: inherit;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    font: inherit;
    font-size: .85rem;
}

.ag-action-menu-list a:hover,
.ag-action-menu-list button:hover {
    background: var(--background, #f3f4f6);
}

[data-theme="dark"] {
    color-scheme: dark;
}

[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
    background: var(--bg-surface-alt);
    color: var(--text-main);
    border-color: var(--border-color);
}

[data-theme="dark"] .card,
[data-theme="dark"] .ag-drawer-panel {
    background: var(--bg-surface);
}

[data-theme="dark"] .table thead th,
[data-theme="dark"] .table-header {
    background: var(--bg-surface-alt);
}

[data-theme="dark"] .status-pill:not(.status-active):not(.status-warning):not(.status-inactive) {
    background: var(--bg-surface-alt);
    color: var(--text-main);
}

.ag-list-footer .ag-pagination {
    margin-top: 0;
}

.ag-list-footer:has(.ag-per-page) {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.ag-list-footer:has(.ag-per-page) .ag-pagination {
    flex: 1;
}

.ag-per-page {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 13px;
    white-space: nowrap;
}

.ag-per-page .form-control {
    width: auto;
    min-width: 72px;
}

.ag-empty-state {
    padding: 40px !important;
    text-align: center;
    color: var(--text-muted);
}

.channel-page {
    display: grid;
    gap: 20px;
}

.channel-page-header {
    margin-bottom: 0;
    gap: 16px;
}

.channel-page-actions,
.channel-publications {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.channel-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    background: var(--bg-surface, #fff);
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 16px;
    overflow: hidden;
}

.channel-summary>div {
    padding: 20px 24px;
    display: grid;
    gap: 4px;
    border-right: 1px solid var(--border-color, #e5e7eb);
}

.channel-summary>div:last-child {
    border-right: 0;
}

.channel-summary strong {
    font-size: 28px;
    line-height: 1;
}

.channel-summary span {
    color: var(--text-muted);
    font-size: 13px;
}

.channel-tree-card {
    background: var(--bg-surface, #fff);
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 16px;
    overflow: hidden;
}

.channel-tree-card>header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
}

.channel-tree-card h2,
.channel-tree-card p {
    margin: 0;
}

.channel-tree-card p {
    margin-top: 4px;
    color: var(--text-muted);
}

.channel-tree-item {
    border-bottom: 1px solid var(--border-color, #e5e7eb);
}

.channel-tree-item:last-child {
    border-bottom: 0;
}

.channel-tree-item>summary {
    list-style: none;
    min-height: 68px;
    padding: 12px 20px;
    display: grid;
    grid-template-columns: 4px minmax(180px, 1fr) auto auto;
    gap: 14px;
    align-items: center;
    cursor: pointer;
}

.channel-tree-item>summary::-webkit-details-marker {
    display: none;
}

.channel-tree-item>summary:hover {
    background: var(--bg-surface-alt, #f8fafc);
}

.channel-tree-item.depth-1>summary {
    padding-left: 44px;
}

.channel-tree-item.depth-2>summary {
    padding-left: 68px;
}

.channel-tree-guide {
    align-self: stretch;
    border-radius: 99px;
    background: #111827;
    opacity: .15;
}

.channel-tree-item.depth-1 .channel-tree-guide {
    background: #6b7280;
    opacity: .3;
}

.channel-tree-item.depth-2 .channel-tree-guide {
    background: #9ca3af;
    opacity: .5;
}

.channel-tree-label {
    min-width: 0;
    display: grid;
    gap: 3px;
}

.channel-tree-label small {
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.channel-badges {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
}

.channel-edit-label {
    color: var(--text-muted);
    font-size: 13px;
}

.channel-tree-item[open] .channel-edit-label {
    color: var(--text-main, #111827);
}

.channel-edit-panel {
    padding: 20px 24px 24px;
    background: var(--bg-surface-alt, #f8fafc);
    border-top: 1px solid var(--border-color, #e5e7eb);
}

.channel-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.channel-form-wide {
    grid-column: 1 / -1;
}

.channel-checks {
    display: flex;
    gap: 18px;
    align-items: center;
}

.channel-edit-panel>form+form {
    margin-top: 12px;
}

@media (max-width: 720px) {
    .channel-page-header {
        align-items: flex-start;
    }

    .channel-page-actions {
        width: 100%;
    }

    .channel-page-actions .btn {
        flex: 1;
    }

    .channel-summary>div {
        padding: 16px;
    }

    .channel-tree-item>summary {
        grid-template-columns: 4px minmax(0, 1fr) auto;
        padding-left: 14px !important;
    }

    .channel-badges {
        display: none;
    }

    .channel-edit-label {
        grid-column: 3;
    }

    .channel-edit-panel {
        padding: 16px;
    }

    .channel-form-grid {
        grid-template-columns: 1fr;
    }

    .channel-form-wide {
        grid-column: auto;
    }
}

.status-pill {
    white-space: nowrap;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.cms-form {
    max-width: 820px;
}

.cms-form .form-group {
    margin-bottom: 16px;
}

.cms-form label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
}

.cms-form textarea {
    min-height: 180px;
}

.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}

.media-card img {
    display: block;
    width: 100%;
    aspect-ratio: 4/3;
    object-fit: cover;
    border-radius: 8px 8px 0 0;
}

.media-card-body {
    padding: 12px;
}

.alert ul {
    margin: 0;
}

/* Employee details contain several independent forms; sticky action bars overlap them. */
.ag-drawer[id^="employee-"] .ag-drawer-body .form-actions {
    position: static;
    margin: 12px 0 0;
    padding: 0;
    border: 0;
}

.employee-placement-summary {
    display: block;
    margin: .2rem 0 .45rem;
}

.employee-placement-summary small {
    display: block;
    color: var(--text-muted);
}

.employee-placement-card {
    margin-bottom: .75rem;
}

.employee-placement-card form + form {
    border-top: 1px solid var(--border-color);
    margin-top: 18px;
    padding-top: 18px;
}

.report-scope-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: .55rem 1rem;
    padding: .7rem 0 1rem;
}

.report-scope-bar form {
    min-width: min(100%, 20rem);
}

.report-scope-bar label {
    display: block;
    margin-bottom: .3rem;
    font-size: .8rem;
    font-weight: 700;
}

.report-scope-bar p {
    flex: 1 1 20rem;
    margin: 0 0 .35rem;
    color: var(--text-muted);
    font-size: .84rem;
}

.report-scope-bar > a {
    margin-bottom: .35rem;
    font-size: .84rem;
}

.drawer-section-title {
    margin: 0 0 10px;
    font-size: .9375rem;
}

.drawer-list {
    display: grid;
    gap: 8px;
}

.drawer-list-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
}

.drawer-list-row small {
    color: var(--text-muted);
}

body.ag-drawer-visible {
    overflow: hidden;
}

.recovery-code-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 8px;
    margin-top: 12px;
}

.recovery-code-grid code,
.mfa-secret {
    display: inline-block;
    padding: 8px 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--background, #f3f4f6);
    letter-spacing: .08em;
}

.text-break {
    overflow-wrap: anywhere;
}

.dashboard-overview {
    padding: 2rem 0;
}

.dashboard-overview h1 {
    margin: 0;
    font-size: 2.75rem;
    line-height: 1.1;
    letter-spacing: -.035em;
}

.dashboard-overview>p {
    margin: 1.5rem 0 3.25rem;
    font-size: 1.25rem;
    color: var(--text-muted);
}

.page-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.page-heading h1 {
    margin: 0 0 .25rem;
}

.page-heading p {
    margin: 0;
    color: var(--text-muted);
}

.user-edit-grid {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(19rem, 1fr);
    gap: 1.25rem;
    align-items: start;
}

.user-edit-grid.single {
    grid-template-columns: 1fr;
}

.stack-lg,
.stack-md {
    display: flex;
    flex-direction: column;
}

.stack-lg {
    gap: 1.25rem;
}

.stack-md {
    gap: .8rem;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.form-grid-full {
    grid-column: 1 / -1;
}

.workspace-assignment {
    display: grid;
    grid-template-columns: minmax(12rem, 1fr) minmax(12rem, 1fr) auto;
    gap: .75rem;
    align-items: center;
    padding: .8rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.check-row {
    display: flex;
    align-items: center;
    gap: .5rem;
}

.check-row span {
    color: var(--text-muted);
    font-size: .85rem;
}

.security-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.security-options .form-hint {
    grid-column: 1 / -1;
}

.permission-panel {
    position: sticky;
    top: 1rem;
    max-height: calc(100vh - 2rem);
    overflow: hidden;
}

.permission-list {
    overflow: auto;
    max-height: calc(100vh - 9rem);
    padding: 0;
}

.permission-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 7rem;
    gap: .75rem;
    align-items: center;
    padding: .8rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

.access-role-list {
    display: grid;
    gap: .6rem;
}

.access-role-item {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

.access-role-item summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .9rem 1rem;
    cursor: pointer;
}

.access-role-item summary small {
    color: var(--text-muted);
}

.access-role-item> :not(summary) {
    margin-left: 1rem;
    margin-right: 1rem;
}

.access-role-item>.access-permission-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
    gap: .55rem 1rem;
    padding-bottom: 1rem;
}

.access-permission-form>button {
    justify-self: start;
    grid-column: 1 / -1;
}

.access-role-assignment {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: .5rem;
}

.access-role-assignment .form-control {
    min-width: 12rem;
}

.sticky-actions {
    position: sticky;
    bottom: 0;
    background: var(--surface, #fff);
    border-top: 1px solid var(--border-color);
    padding: 1rem;
    margin-top: 1.25rem;
    z-index: 5;
}

.navigation-manager {
    overflow: visible;
}

.navigation-manager .form-hint {
    display: block;
    margin-top: .2rem;
}

.navigation-tree-list {
    list-style: none;
    margin: 0;
    padding: 0;
    min-height: 8px;
}

.navigation-tree-children {
    margin-left: 2.1rem;
    border-left: 1px solid var(--border-color);
    padding-left: .75rem;
}

.navigation-tree-row {
    display: flex;
    align-items: center;
    gap: .75rem;
    min-height: 58px;
    padding: .65rem 1rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--surface, #fff);
}

.navigation-tree-item.is-dragging {
    opacity: .45;
}

.navigation-tree-item.navigation-drop-target>.navigation-tree-row,
.navigation-tree-list.navigation-drop-target {
    box-shadow: inset 0 2px 0 var(--primary, #111827);
}

.navigation-drag-handle {
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: grab;
    user-select: none;
}

.navigation-tree-copy {
    min-width: 0;
    flex: 1;
    display: grid;
    gap: 2px;
}

.navigation-tree-copy small {
    overflow: hidden;
    color: var(--text-muted);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.account-menu-link {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    padding: .5rem .55rem;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.account-menu-link:hover {
    background: var(--background, #f3f4f6);
}

.account-menu-divider {
    height: 1px;
    margin: .3rem 0;
    background: var(--border-color);
}

.account-menu-signout {
    color: #b42318;
}

.topbar-notifications {
    position: relative;
}

.topbar-notifications summary {
    position: relative;
    display: grid;
    width: 2.5rem;
    height: 2.5rem;
    place-items: center;
    list-style: none;
    cursor: pointer;
    border-radius: 8px;
    font-size: 1.1rem;
}

.ui-icon {
    width: 1.2rem;
    height: 1.2rem;
    color: #111;
}

[data-theme="dark"] .ui-icon {
    color: #f5f5f5;
}

.mfa-enroll-wrap {
    max-width: 48rem;
}

.mfa-enroll-grid {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 2rem;
    align-items: start;
    margin-top: 1.5rem;
}

.mfa-qr {
    display: grid;
    place-items: center;
    padding: .75rem;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 12px;
}

.mfa-qr img {
    display: block;
    max-width: 100%;
    height: auto;
}

@media (max-width:640px) {
    .mfa-enroll-grid {
        grid-template-columns: 1fr;
    }

    .mfa-qr {
        width: max-content;
    }
}

.topbar-notifications summary::-webkit-details-marker {
    display: none;
}

.topbar-notifications summary:hover {
    background: var(--background, #f3f4f6);
}

.notification-badge {
    position: absolute;
    top: .1rem;
    right: .05rem;
    min-width: 1.05rem;
    padding: 0 .2rem;
    border-radius: 99px;
    background: #b42318;
    color: #fff;
    font-size: .65rem;
    font-weight: 700;
    text-align: center;
}

.notification-dropdown {
    position: absolute;
    top: calc(100% + .6rem);
    right: 0;
    z-index: 45;
    width: min(23rem, calc(100vw - 2rem));
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--surface, #fff);
    box-shadow: 0 14px 32px rgba(15, 23, 42, .16);
    overflow: hidden;
}

.notification-dropdown-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .75rem .9rem;
    border-bottom: 1px solid var(--border-color);
}

.notification-dropdown-header button {
    border: 0;
    background: transparent;
    color: var(--primary, #111827);
    font: inherit;
    font-size: .8rem;
    cursor: pointer;
}

.notification-dropdown-item {
    display: grid;
    width: 100%;
    gap: .2rem;
    padding: .7rem .9rem;
    border: 0;
    border-bottom: 1px solid var(--border-color);
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.notification-dropdown-item:hover,
.notification-dropdown-item.is-unread {
    background: var(--background, #f3f4f6);
}

.notification-dropdown-item span,
.notification-dropdown-item small,
.notification-empty {
    color: var(--text-muted);
    font-size: .8rem;
}

.notification-empty {
    padding: .9rem;
    margin: 0;
}

.notification-view-all {
    display: block;
    padding: .7rem .9rem;
    color: inherit;
    font-size: .85rem;
    text-align: center;
    text-decoration: none;
}

.notification-list-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.notification-list-row p {
    margin: .3rem 0;
}

.notification-list-row small {
    color: var(--text-muted);
}

.notification-list-row.is-unread {
    background: var(--background, #f3f4f6);
}

.audit-detail-grid {
    display: grid;
    gap: 0;
    margin-bottom: 1.5rem;
}

.audit-detail-row {
    display: grid;
    grid-template-columns: 9rem minmax(0, 1fr);
    gap: 1rem;
    padding: .8rem 0;
    border-bottom: 1px solid var(--border-color);
}

.audit-detail-row>span {
    color: var(--text-muted);
    font-weight: 600;
}

.audit-detail-row code {
    overflow-wrap: anywhere;
}

.audit-change-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.audit-change-grid h4 {
    margin: .2rem 0 .5rem;
    color: var(--text-muted);
    font-size: .9rem;
}

.audit-json {
    max-height: 24rem;
    overflow: auto;
    margin: 0;
    padding: 1rem;
    border-radius: 8px;
    background: var(--background, #f3f4f6);
    color: var(--text-main);
    font: 500 .78rem/1.55 ui-monospace, SFMono-Regular, Menlo, monospace;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

@media (max-width:640px) {
    .audit-detail-row {
        grid-template-columns: 1fr;
        gap: .25rem;
    }

    .audit-change-grid {
        grid-template-columns: 1fr;
    }
}

.announcement-banner {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
    padding: 1rem 1.1rem;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-surface-alt);
}

.announcement-banner p {
    margin: .35rem 0 0;
}

.announcement-actions {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
}

.announcement-modal {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: grid;
    place-items: center;
    padding: 1rem;
    background: rgba(15, 23, 42, .5);
}

.announcement-modal-panel {
    width: min(34rem, 100%);
    padding: 1.5rem;
    border-radius: 14px;
    background: var(--surface, #fff);
    box-shadow: 0 20px 45px rgba(15, 23, 42, .28);
}

.announcement-modal-panel h2 {
    margin: 0 0 .8rem;
}

.announcement-modal-panel p {
    white-space: pre-wrap;
}

.announcement-modal-panel .announcement-actions {
    justify-content: flex-end;
    margin-top: 1.5rem;
}

@media(max-width:640px) {
    .announcement-banner {
        display: block
    }

    .announcement-banner .announcement-actions {
        margin-top: 1rem
    }
}

.auth-recovery-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .65rem;
}

.error-page {
    display: grid;
    min-height: 100vh;
    place-items: center;
    margin: 0;
    padding: 1.5rem;
    background: var(--bg-page, #f8fafc);
    color: var(--text-primary, #111827);
}

.error-card {
    width: min(32rem, 100%);
    padding: 2rem;
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 16px;
    background: var(--surface, #fff);
    box-shadow: 0 16px 40px rgba(15, 23, 42, .12);
    text-align: center;
}

.error-code {
    display: inline-block;
    padding: .32rem .65rem;
    border-radius: 999px;
    background: #fef2f2;
    color: #b42318;
    font-size: .78rem;
    font-weight: 800;
    letter-spacing: .08em;
}

.error-card h1 {
    margin: .9rem 0 .55rem;
    font-size: 1.65rem;
}

.error-card p {
    margin: 0;
    color: var(--text-muted, #667085);
    line-height: 1.6;
}

.error-actions {
    display: flex;
    justify-content: center;
    gap: .7rem;
    margin-top: 1.5rem;
}

@media (max-width: 960px) {
    .user-edit-grid {
        grid-template-columns: 1fr;
    }

    .permission-panel {
        position: static;
        max-height: none;
    }

    .permission-list {
        max-height: 32rem;
    }
}

@media (max-width: 1180px) {
    .ag-list-header {
        flex-wrap: wrap;
    }

    .ag-table-header-tools {
        width: 100%;
        margin-left: 0;
    }
}

@media (max-width: 640px) {

    .page-heading,
    .workspace-assignment {
        display: flex;
        flex-direction: column;
    }

    .form-grid,
    .security-options {
        grid-template-columns: 1fr;
    }

    .form-grid-full,
    .security-options .form-hint {
        grid-column: auto;
    }

    .navigation-tree-row {
        gap: .45rem;
        padding: .55rem .65rem;
    }

    .navigation-tree-row .status-pill,
    .navigation-tree-row .table-actions .btn-danger {
        display: none;
    }

    .navigation-tree-children {
        margin-left: 1.1rem;
        padding-left: .45rem;
    }
}

@media (max-width: 640px) {
    .dashboard-overview {
        padding: 1rem 0;
    }
}

@media (max-width: 760px) {

    .ag-table-header-tools,
    .ag-table-filter-form {
        width: 100%;
        margin-left: 0;
        justify-content: stretch;
    }

    .ag-table-search,
    .ag-table-filter-form>.ag-table-search {
        flex: 1 1 100%;
    }
}

@media (max-width: 1180px) {
    .ag-table-filter-form {
        flex-wrap: wrap;
        justify-content: flex-start;
    }

    .ag-table-actions {
        flex-wrap: wrap;
    }
}

@media (max-width: 760px) {
    .news-list-page {
        min-width: 0;
        overflow-x: clip;
    }

    .news-list-page .dt-stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .news-list-page .dt-stat-item {
        min-width: 0;
        margin: 0;
        padding: 14px;
        border-bottom: 1px solid var(--border-color);
    }

    .news-list-page .dt-stat-item:nth-child(even) {
        border-right: 0;
    }

    .news-list-page .dt-stat-item:last-child {
        grid-column: 1 / -1;
        border-bottom: 0;
    }

    .news-list-table .ag-list-header {
        display: grid;
        grid-template-columns: 1fr;
        align-items: stretch;
    }

    .news-list-table .ag-table-header-main,
    .news-list-table .ag-table-header-tools {
        width: 100%;
        min-width: 0;
    }

    .news-list-table .tabs {
        width: 100%;
        overflow-x: auto;
        overscroll-behavior-inline: contain;
        scrollbar-width: thin;
    }

    .news-list-table .tab-item {
        flex: 0 0 auto;
        padding-inline: 14px;
    }

    .news-list-table .ag-table-header-tools {
        display: grid;
        gap: 10px;
    }

    .news-list-table .ag-table-filter-form {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .news-list-table .ag-table-filter-form>.ag-table-search {
        grid-column: 1 / -1;
        width: 100%;
        min-width: 0;
        max-width: none;
    }

    .news-list-table .ag-table-filter-form>.form-control {
        width: 100%;
        min-width: 0;
    }

    .news-list-table .ag-table-filter-form>button {
        width: 100%;
        min-height: 40px;
    }

    .news-list-table .ag-table-actions {
        width: 100%;
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 2px;
        overscroll-behavior-inline: contain;
        scrollbar-width: thin;
    }

    .news-list-table .ag-table-actions>* {
        flex: 0 0 auto;
    }

    .news-list-table .table-responsive {
        overflow: visible;
    }

    .news-list-table #newsTable,
    .news-list-table #newsTable tbody {
        display: block;
        width: 100% !important;
    }

    .news-list-table #newsTable thead {
        display: none;
    }

    .news-list-table #newsTable tbody {
        padding: 10px;
        background: var(--bg-surface-alt);
    }

    .news-list-table #newsTable tr {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        gap: 12px 16px;
        margin-bottom: 10px;
        padding: 14px;
        border: 1px solid var(--border-color);
        border-radius: 12px;
        background: var(--bg-surface);
    }

    .news-list-table #newsTable tr:last-child {
        margin-bottom: 0;
    }

    .news-list-table #newsTable td {
        display: grid;
        min-width: 0;
        gap: 4px;
        padding: 0;
        border: 0;
        overflow-wrap: anywhere;
    }

    .news-list-table #newsTable td::before {
        content: attr(data-label);
        color: var(--text-muted);
        font-size: 10px;
        font-weight: 750;
        letter-spacing: .06em;
        text-transform: uppercase;
    }

    .news-list-table #newsTable td:first-child,
    .news-list-table #newsTable td:last-child {
        grid-column: 1 / -1;
    }

    .news-list-table #newsTable td.ag-empty-state {
        grid-column: 1 / -1;
        padding: 20px;
    }

    .news-list-table #newsTable td.ag-empty-state::before {
        content: none;
    }

    .news-list-table #newsTable .table-actions {
        justify-content: flex-start;
    }

    .news-list-table .ag-list-footer {
        padding: 12px 14px;
    }
}

@media (max-width: 420px) {

    .news-list-page .dt-stat-sub {
        display: none;
    }

    .news-list-table .ag-table-filter-form {
        grid-template-columns: 1fr;
    }

    .news-list-table .ag-table-filter-form>.ag-table-search {
        grid-column: auto;
    }

    .news-list-table #newsTable tr {
        grid-template-columns: 1fr;
    }

    .news-list-table #newsTable td:first-child,
    .news-list-table #newsTable td:last-child {
        grid-column: auto;
    }
}

/* Navigation adapts by device: full labels on desktop, icon rail on tablet, bottom bar on phone. */

/* The navigation rail is fixed; application pages use the rest of the viewport. */

/* Desktop rail follows the cashier pattern: compact labels under each icon. */

@media (max-width:768px) {

    html,
    body {
        max-width: 100%;
        overflow-x: hidden;
    }

    .page-header,
    .pos-page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .form-row,
    .pos-split-layout {
        grid-template-columns: 1fr !important;
        flex-direction: column;
        min-width: 0;
    }

    .ag-table-header-tools{
        flex-wrap: wrap;
        min-width: 0;
    }

    .ag-table-header-tools>*{
        max-width: 100%;
    }

}

/* Shared list toolbar: only keyword/date are primary; publication actions stay separate. */
.ag-data-table-card .ag-list-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
}

.ag-data-table-card .ag-table-header-main,
.ag-data-table-card .ag-table-header-tools {
    width: 100%;
    min-width: 0;
    margin: 0;
}

.ag-data-table-card .ag-table-header-tools {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-start;
}

.ag-data-table-card .tabs {
    width: 100%;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: thin;
}

.ag-data-table-card .tab-item {
    flex: 0 0 auto;
}

.ag-data-table-card .ag-table-filter-form {
    display: flex;
    flex: 1 1 480px;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: flex-start;
    min-width: 0;
}

.ag-data-table-card .ag-table-filter-form>.ag-table-search {
    flex: 1 1 210px;
    width: auto;
    max-width: 360px;
    min-width: 170px;
}

.ag-data-table-card .ag-date-range {
    flex: 0 1 220px;
    min-width: 170px;
}

.ag-data-table-card .ag-date-range .form-control {
    width: 100%;
    min-height: 36px;
    cursor: pointer;
}

.ag-data-table-card .ag-filter-submit {
    flex: 0 0 auto;
}

.ag-data-table-card .ag-advanced-filters {
    flex: 0 0 auto;
    position: relative;
}

.ag-data-table-card .ag-advanced-filters>summary {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    cursor: pointer;
    list-style: none;
}

.ag-data-table-card .ag-advanced-filters>summary::-webkit-details-marker {
    display: none;
}

.ag-data-table-card .ag-advanced-filters[open]>summary {
    border-color: var(--primary);
    color: var(--primary);
}

.ag-data-table-card .ag-advanced-filter-fields {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(2, minmax(140px, 1fr));
    gap: 8px;
    width: min(420px, calc(100vw - 32px));
    padding: 14px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--bg-surface);
    box-shadow: 0 12px 32px rgba(15, 23, 42, .14);
}

.ag-data-table-card .ag-advanced-filter-fields>.form-control {
    width: 100%;
    min-width: 0;
}

.ag-data-table-card .ag-advanced-filter-fields>button {
    grid-column: 1 / -1;
}

.ag-data-table-card .ag-table-actions {
    max-width: 100%;
    overflow-x: auto;
    scrollbar-width: thin;
}

.ag-date-preset-list {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
    padding: 10px;
    border-top: 1px solid var(--border-color);
}

.ag-date-preset-list button {
    padding: 7px 8px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--text-main);
    font: inherit;
    font-size: 12px;
    cursor: pointer;
    text-align: left;
}

.ag-date-preset-list button:hover {
    background: var(--bg-surface-alt);
}

.flatpickr-calendar.ag-range-calendar {
    box-shadow: 0 12px 32px rgba(15, 23, 42, .18);
}

.ag-date-preset-list button.is-active {
    background: var(--primary, #111827);
    color: #fff;
}

/* daterangepicker-style layout: preset ranges in a left column beside the two months. */
@media (min-width:761px) {
    .flatpickr-calendar.ag-range-calendar.open {
        display: grid;
        grid-template-columns: 9.5rem auto;
        width: auto !important;
    }

    .ag-range-calendar > :not(.ag-date-preset-list) {
        grid-column: 2;
    }

    .ag-range-calendar .flatpickr-months {
        position: relative;
    }

    .ag-range-calendar .ag-date-preset-list {
        grid-row: 1 / span 2;
        grid-template-columns: 1fr;
        align-content: start;
        border-top: 0;
        border-right: 1px solid var(--border-color);
    }
}

@media (max-width:760px) {
    .ag-data-table-card .ag-table-filter-form {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        width: 100%;
        flex-basis: 100%;
    }

    .ag-data-table-card .ag-table-filter-form>.ag-table-search {
        grid-column: 1 / -1;
        width: 100%;
        max-width: none;
    }

    .ag-data-table-card .ag-date-range {
        grid-column: 1 / -1;
        width: 100%;
    }

    .ag-data-table-card .ag-filter-submit {
        grid-column: 1;
    }

    .ag-data-table-card .ag-advanced-filters {
        grid-column: 2;
    }

    .ag-data-table-card .ag-advanced-filter-fields {
        left: auto;
        right: 0;
    }

    .ag-data-table-card .ag-table-actions {
        width: 100%;
    }
}

@media (max-width:420px) {
    .ag-data-table-card .ag-advanced-filter-fields {
        grid-template-columns: 1fr;
    }

    .ag-date-preset-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* Organisasi: one tree; PT -> cabang -> outlet, with staff under each node. */
.org-tree, .org-children, .org-staff { list-style:none; margin:0; padding:0; }
.org-children { margin:.15rem 0 .4rem 1.1rem; padding-left:.8rem; border-left:2px solid var(--border-color, #e7e5e1); }
.org-node { margin:.45rem 0; }
.org-box { border:1px solid var(--border-color, #e7e5e1); border-radius:.8rem; background:var(--bg-surface, #fff); }
.org-company > .org-box { background:var(--bg-surface-alt, #faf9f7); }
.org-outlet > .org-box, .org-branch > .org-box { background:var(--bg-surface, #fff); }
.org-row { display:flex; align-items:center; gap:.65rem; padding:.7rem .85rem; cursor:pointer; list-style:none; }
.org-row::-webkit-details-marker { display:none; }
.org-row::after { content:"⌄"; margin-left:auto; color:var(--text-muted, #6b7280); transition:transform .15s; }
.org-box[open] > .org-row::after { transform:rotate(180deg); }
.org-company > .org-box > .org-row { font-weight:600; }
.org-name { flex:0 1 auto; min-width:0; display:flex; flex-direction:column; overflow-wrap:anywhere; }
.org-name small { color:var(--text-muted, #6b7280); font-weight:400; }
.org-kind { flex:0 0 auto; padding:.1rem .5rem; border-radius:999px; background:#eef6f2; color:#0b5e42; font-size:.68rem; font-weight:700; text-transform:uppercase; }
.org-branch > .org-box > .org-row .org-kind { background:#fff4ec; color:#a24a1c; }
.org-outlet > .org-box > .org-row .org-kind { background:#eef2fb; color:#334a8a; }
.org-count { margin-left:auto; color:var(--text-muted, #6b7280); font-size:.8rem; white-space:nowrap; }
.org-count + * { margin-left:0; }
.org-body { padding:0 .85rem .75rem; }
.org-actions { display:flex; flex-wrap:wrap; gap:.4rem; align-items:center; }
.org-sub, .org-empty { margin:.5rem 0 0; color:var(--text-muted, #6b7280); font-size:.82rem; }
.org-staff li { display:flex; align-items:center; justify-content:space-between; gap:.75rem; padding:.45rem 0; border-bottom:1px solid var(--border-color, #eceae5); }
.org-staff li > span { display:flex; flex-direction:column; min-width:0; overflow-wrap:anywhere; }
.org-staff small { color:var(--text-muted, #6b7280); }
.org-body > .org-staff { margin-bottom:.6rem; }
.org-staff form { margin:0; }
.org-x { width:2rem; height:2rem; border:0; border-radius:50%; background:transparent; color:#b42318; font-size:1.2rem; cursor:pointer; }
.org-x:hover { background:#fdf1ee; }
@media (max-width:640px) {
    .org-row { flex-wrap:wrap; row-gap:.3rem; }
    .org-children { margin-left:.35rem; padding-left:.5rem; }
    .org-actions .btn { flex:1 1 auto; min-height:40px; }
}

/* Phones: the sidebar already says where you are, so the page title and its blurb are dropped (header actions stay). */
@media (max-width: 640px) {
    .page-header > div:first-child:has(> h1),
    .pos-page-header > div:first-child:has(> h1),
    .page-heading > div:first-child:has(> h1) {
        display: none;
    }

    .page-header:not(:has(> :nth-child(2))),
    .pos-page-header:not(:has(> :nth-child(2))),
    .page-heading:not(:has(> :nth-child(2))) {
        display: none;
    }
}
.org-staff li > a.btn { margin-left:auto; margin-right:.4rem; flex:0 0 auto; }
.org-sub { margin:0 0 .75rem; font-size:.95rem; }
.org-sep { margin:1.25rem 0; border:0; border-top:1px solid var(--border-color, #e7e5e1); }
