:root {
    --ciesto-magenta: #d120b1;
    --ciesto-purple: #8a2be2;
    --ciesto-bg: #0b0b0f;
    --ciesto-surface: #14141c;
    --ciesto-surface-2: #1c1c28;
    --ciesto-border: #2a2a3a;
    --ciesto-text: #f3eef8;
    --ciesto-muted: #a39bb3;
}

body[data-layout-mode="dark"] {
    background-color: var(--ciesto-bg) !important;
    color: var(--ciesto-text);
}

body[data-layout-mode="dark"] #page-topbar {
    background: #0a0a0e !important;
    border-bottom: 1px solid var(--ciesto-border);
}

body[data-layout-mode="dark"] .navbar-brand-box {
    background: transparent !important;
}

body[data-layout-mode="dark"] .vertical-menu {
    background: #0a0a0e !important;
    border-right: 1px solid var(--ciesto-border);
}

body[data-layout-mode="dark"] .main-content {
    background: var(--ciesto-bg);
}

body[data-layout-mode="dark"] .page-content {
    background: var(--ciesto-bg);
}

body[data-layout-mode="dark"] .card {
    background: var(--ciesto-surface);
    border-color: var(--ciesto-border);
}

body[data-layout-mode="dark"] .card-title,
body[data-layout-mode="dark"] .page-title-box h4,
body[data-layout-mode="dark"] .breadcrumb-item.active {
    color: var(--ciesto-text) !important;
}

body[data-layout-mode="dark"] .table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--ciesto-text);
    --bs-table-border-color: var(--ciesto-border);
    color: var(--ciesto-text);
}

body[data-layout-mode="dark"] .table-light,
body[data-layout-mode="dark"] .table > thead {
    --bs-table-bg: var(--ciesto-surface-2);
    --bs-table-color: var(--ciesto-text);
    background-color: var(--ciesto-surface-2) !important;
    color: var(--ciesto-text) !important;
}

body[data-layout-mode="dark"] .table-hover > tbody > tr:hover > * {
    --bs-table-accent-bg: rgba(209, 32, 177, 0.08);
    color: var(--ciesto-text);
}

/* Light mode table hover — soft brand tint instead of white flash */
.table-hover > tbody > tr:hover > * {
    --bs-table-accent-bg: rgba(209, 32, 177, 0.08) !important;
    --bs-table-hover-bg: rgba(209, 32, 177, 0.08) !important;
    background-color: rgba(209, 32, 177, 0.08) !important;
    color: inherit !important;
}

body[data-layout-mode="light"] .table-hover > tbody > tr:hover > * {
    color: #495057 !important;
}

.bg-soft-primary {
    background-color: rgba(209, 32, 177, 0.12) !important;
}

body[data-layout-mode="dark"] .form-control,
body[data-layout-mode="dark"] .form-select {
    background-color: var(--ciesto-surface-2);
    border-color: var(--ciesto-border);
    color: var(--ciesto-text);
}

body[data-layout-mode="dark"] .form-control:focus,
body[data-layout-mode="dark"] .form-select:focus {
    background-color: var(--ciesto-surface-2);
    border-color: var(--ciesto-magenta);
    color: var(--ciesto-text);
    box-shadow: 0 0 0 0.15rem rgba(209, 32, 177, 0.25);
}

body[data-layout-mode="dark"] .form-control::placeholder {
    color: var(--ciesto-muted);
}

body[data-layout-mode="dark"] .text-muted {
    color: var(--ciesto-muted) !important;
}

body[data-layout-mode="dark"] .dropdown-menu {
    background: var(--ciesto-surface);
    border-color: var(--ciesto-border);
}

body[data-layout-mode="dark"] .dropdown-item {
    color: var(--ciesto-text);
}

body[data-layout-mode="dark"] .dropdown-item:hover,
body[data-layout-mode="dark"] .dropdown-item:focus {
    background: rgba(209, 32, 177, 0.12);
    color: #fff;
}

body[data-layout-mode="dark"] .modal-content {
    background: var(--ciesto-surface);
    border-color: var(--ciesto-border);
    color: var(--ciesto-text);
}

body[data-layout-mode="dark"] .modal-header,
body[data-layout-mode="dark"] .modal-footer {
    border-color: var(--ciesto-border);
}

body[data-layout-mode="dark"] .page-link {
    background: var(--ciesto-surface);
    border-color: var(--ciesto-border);
    color: var(--ciesto-text);
}

body[data-layout-mode="dark"] .page-item.active .page-link {
    background: var(--ciesto-magenta);
    border-color: var(--ciesto-magenta);
}

/* Brand accents */
.text-primary,
a.text-primary {
    color: var(--ciesto-magenta) !important;
}

.bg-primary {
    background-color: var(--ciesto-magenta) !important;
}

.btn-primary {
    background: linear-gradient(135deg, var(--ciesto-purple), var(--ciesto-magenta));
    border-color: transparent;
}

.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active {
    background: linear-gradient(135deg, #9b3cf0, #e03ac0);
    border-color: transparent;
}

.btn-success {
    background-color: #2ecc71;
    border-color: #2ecc71;
}

#sidebar-menu ul li a:hover,
#sidebar-menu ul li a:focus,
#sidebar-menu ul li a mm-active,
#sidebar-menu ul li.mm-active > a {
    color: var(--ciesto-magenta) !important;
}

#sidebar-menu ul li a.mm-active,
#sidebar-menu ul li.mm-active > a {
    color: var(--ciesto-magenta) !important;
}

.navbar-brand-box .logo img {
    max-width: 160px;
    object-fit: contain;
}

/* Header logo — original size (no animation) */
body[data-layout="horizontal"] .navbar-brand-box .logo-lg img {
    height: 36px !important;
    width: auto !important;
    max-height: 36px !important;
    max-width: 160px !important;
}
body[data-layout="horizontal"] .navbar-brand-box .logo-sm img {
    height: 22px !important;
    width: auto !important;
}

/* Prevent avatar FOUC (large flash before CSS) */
.header-profile-user,
img.header-profile-user {
    width: 36px !important;
    height: 36px !important;
    max-width: 36px !important;
    max-height: 36px !important;
    object-fit: cover !important;
    border-radius: 50% !important;
}

/* Keep only one logo visible (theme swaps dark/light) */
body[data-layout="horizontal"][data-topbar="dark"] .logo.logo-dark {
    display: none !important;
}
body[data-layout="horizontal"][data-topbar="dark"] .logo.logo-light {
    display: block !important;
}
body[data-layout="horizontal"]:not([data-topbar="dark"]) .logo.logo-light {
    display: none !important;
}
body[data-layout="horizontal"]:not([data-topbar="dark"]) .logo.logo-dark {
    display: block !important;
}

/* Login / auth */
body.auth-body-bg,
.auth-full-bg {
    background: radial-gradient(ellipse at 20% 20%, rgba(138, 43, 226, 0.35), transparent 45%),
                radial-gradient(ellipse at 80% 80%, rgba(209, 32, 177, 0.28), transparent 50%),
                #050508 !important;
}

.auth-full-bg .bg-overlay {
    background: transparent !important;
}

.auth-full-page-content {
    background: #0d0d14;
}

.auth-logo img {
    max-height: 52px;
    width: auto;
}

/* ===== Centered web login (desktop browser) ===== */
body.ciesto-login-web,
body.ciesto-login-app {
    min-height: 100vh;
}
.ciesto-login {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 28px 16px 40px;
}
.ciesto-login__shell {
    width: 100%;
    max-width: 460px;
}
.ciesto-login.is-web .ciesto-login__shell {
    max-width: 520px;
}
.ciesto-login__card {
    background: rgba(20, 20, 28, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    padding: 28px 26px 20px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}
.ciesto-login__brand {
    text-align: center;
    margin-bottom: 18px;
}
.ciesto-login__logo {
    display: inline-block;
    line-height: 0;
}
.ciesto-login__logo img {
    display: block;
    height: 48px;
    width: auto;
    max-width: 240px;
    margin: 0 auto;
}
.ciesto-login__intro {
    text-align: center;
    margin-bottom: 18px;
}
.ciesto-login__intro h1 {
    font-family: "Poppins", system-ui, sans-serif;
    font-size: 1.35rem;
    font-weight: 650;
    margin: 0 0 4px;
    color: #f3eef8;
}
.ciesto-login__intro p {
    margin: 0;
    color: #a39bb3;
    font-size: 0.92rem;
}
.ciesto-login__forgot {
    font-size: 0.82rem;
    color: #c9a6ff;
    text-decoration: none;
}
.ciesto-login__forgot:hover {
    color: #f0a8e4;
}
.ciesto-biometric-btn {
    position: relative;
    z-index: 5;
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(209, 32, 177, 0.25);
    pointer-events: auto !important;
    min-height: 44px;
}
.ciesto-biometric-btn.is-busy {
    opacity: 0.75;
}
.ciesto-login__copy {
    text-align: center;
    margin: 18px 0 0;
    color: #7a7388;
    font-size: 0.8rem;
}
.ciesto-daypad-webmsg {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    border: 1px solid rgba(209, 32, 177, 0.28);
    border-radius: 14px;
    background:
        linear-gradient(145deg, rgba(209, 32, 177, 0.12), transparent 55%),
        rgba(255, 255, 255, 0.03);
    padding: 14px 14px 12px;
}
.ciesto-daypad-webmsg__icon {
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: rgba(209, 32, 177, 0.18);
    color: #ff7ad9;
    font-size: 1.35rem;
}
.ciesto-daypad-webmsg__title {
    font-family: "Poppins", system-ui, sans-serif;
    font-weight: 650;
    font-size: 0.95rem;
    color: #f3eef8;
    margin-bottom: 4px;
}
.ciesto-daypad-webmsg__text {
    margin: 0;
    font-size: 0.84rem;
    line-height: 1.45;
    color: #b7aec6;
}
.ciesto-daypad-webmsg__text strong {
    color: #f0d0ea;
}

body[data-layout-mode="dark"] .email-filter-row th,
body[data-layout-mode="dark"] .email-filter-row {
    background: var(--ciesto-surface-2) !important;
}

body[data-layout-mode="dark"] .alert-success,
body[data-layout-mode="dark"] .alert-danger {
    background: var(--ciesto-surface-2) !important;
    color: var(--ciesto-text);
}

/* Admin list tables: filters + dual horizontal scroll */
.dataTables_processing, .dataTables_filter, .dataTables_length { display: none !important; }

.admin-filter-row th,
.domain-filter-row th,
.customer-filter-row th,
.hosting-filter-row th,
.employee-filter-row th,
.template-filter-row th,
.email-filter-row th,
.roles-filter-row th,
.plans-filter-row th {
    padding: 0.4rem 0.5rem !important;
    vertical-align: middle;
    background: var(--ciesto-surface-2) !important;
}

.admin-filter-row .form-control,
.admin-filter-row .form-select,
.domain-filter-row .form-control,
.domain-filter-row .form-select,
.customer-filter-row .form-control,
.customer-filter-row .form-select,
.hosting-filter-row .form-control,
.hosting-filter-row .form-select,
.employee-filter-row .form-control,
.employee-filter-row .form-select,
.template-filter-row .form-control,
.template-filter-row .form-select,
.email-filter-row .form-control,
.email-filter-row .form-select,
.roles-filter-row .form-control,
.roles-filter-row .form-select,
.plans-filter-row .form-control,
.plans-filter-row .form-select {
    min-width: 110px;
    font-size: 12px;
    height: 32px;
    padding: 0.25rem 0.5rem;
}

.admin-table-scroll-top {
    overflow-x: auto;
    overflow-y: hidden;
    height: 14px;
    margin-bottom: 4px;
}
.admin-table-scroll-top-inner {
    height: 1px;
    width: 100%;
}
.admin-table-scroll-bottom {
    overflow-x: auto;
}

/* ========== Global motion / delight (all pages) ========== */
@media (prefers-reduced-motion: no-preference) {
    html {
        scroll-behavior: smooth;
    }

    .main-content .page-content {
        animation: ciestoPageIn 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
    }

    @keyframes ciestoPageIn {
        from { opacity: 0; }
        to { opacity: 1; }
    }

    .card,
    .alert,
    .dash-kpi,
    .dash-panel,
    .dash-hero,
    .module-card,
    .mini-stats-wid {
        transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease, background-color 0.25s ease;
    }

    /* Never transform modal ancestors / modal itself — breaks Bootstrap fixed positioning */
    .modal,
    .modal-dialog,
    .modal-content,
    .modal-backdrop {
        transform: none !important;
        transition: opacity 0.2s ease !important;
    }

    .card:hover,
    .dash-kpi:hover,
    .dash-panel:hover,
    .mini-stats-wid:hover,
    .module-card:hover {
        transform: translateY(-3px);
        box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
        border-color: rgba(209, 32, 177, 0.35) !important;
    }

    /* Don't lift cards while a modal is open */
    body.modal-open .card:hover,
    body.modal-open .dash-kpi:hover,
    body.modal-open .dash-panel:hover,
    body.modal-open .mini-stats-wid:hover,
    body.modal-open .module-card:hover {
        transform: none;
        box-shadow: none;
    }

    .btn {
        transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease, background-position 0.35s ease;
        background-size: 160% 160%;
    }
    .btn:hover {
        transform: translateY(-1px);
        filter: brightness(1.06);
    }
    .btn:active {
        transform: translateY(0) scale(0.98);
    }
    .btn-primary {
        background-image: linear-gradient(135deg, #d120b1 0%, #8a2be2 55%, #d120b1 100%);
        border: none;
    }
    .btn-primary:hover {
        background-position: 100% 0;
        box-shadow: 0 8px 22px rgba(209, 32, 177, 0.28);
    }

    #sidebar-menu ul li a {
        transition: color 0.2s ease, background-color 0.2s ease, padding-left 0.2s ease, transform 0.2s ease;
        border-radius: 8px;
        margin: 2px 8px;
    }
    #sidebar-menu ul li a:hover {
        padding-left: 1.35rem !important;
        background: rgba(209, 32, 177, 0.08);
    }
    #sidebar-menu ul li a i {
        transition: transform 0.25s ease, color 0.2s ease;
    }
    #sidebar-menu ul li a:hover i {
        transform: scale(1.12);
        color: var(--ciesto-magenta);
    }

    .table > tbody > tr {
        transition: background-color 0.2s ease, transform 0.2s ease;
    }
    .table-hover > tbody > tr:hover {
        background-color: rgba(209, 32, 177, 0.08) !important;
    }

    .form-control, .form-select, .select2-container .select2-selection {
        transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
    }
    .form-control:focus, .form-select:focus {
        border-color: rgba(209, 32, 177, 0.65) !important;
        box-shadow: 0 0 0 0.2rem rgba(209, 32, 177, 0.18) !important;
    }

    .badge, .badge-soft-primary, .badge-soft-success, .badge-soft-danger, .badge-soft-warning {
        transition: transform 0.2s ease, filter 0.2s ease;
    }
    .badge:hover {
        transform: scale(1.05);
    }

    .page-title-box {
        animation: ciestoFadeUp 0.4s ease both;
    }

    /* Scroll reveal */
    .ciesto-reveal {
        opacity: 0;
        transform: translateY(18px) scale(0.985);
        transition: opacity 0.55s cubic-bezier(0.22, 1, 0.36, 1), transform 0.55s cubic-bezier(0.22, 1, 0.36, 1);
        will-change: opacity, transform;
    }
    .ciesto-reveal.is-visible {
        opacity: 1;
        transform: none;
    }
    .ciesto-reveal.delay-1 { transition-delay: 0.06s; }
    .ciesto-reveal.delay-2 { transition-delay: 0.12s; }
    .ciesto-reveal.delay-3 { transition-delay: 0.18s; }
    .ciesto-reveal.delay-4 { transition-delay: 0.24s; }

    @keyframes ciestoFadeUp {
        from { opacity: 0; transform: translateY(8px); }
        to { opacity: 1; transform: none; }
    }

    /* Soft floating ambient on hero / welcome cards */
    .dash-hero,
    .card.overflow-hidden .bg-primary-subtle {
        animation: ciestoAmbient 8s ease-in-out infinite alternate;
    }
    @keyframes ciestoAmbient {
        from { filter: saturate(1); }
        to { filter: saturate(1.08); }
    }

    /* Alert entrance */
    .alert {
        animation: ciestoFadeUp 0.35s ease both;
    }

    /* Loader polish */
    .spinner-border.text-primary {
        animation: spinner-border 0.75s linear infinite, ciestoGlow 1.6s ease-in-out infinite alternate;
    }
    @keyframes ciestoGlow {
        from { filter: drop-shadow(0 0 0 rgba(209,32,177,0)); }
        to { filter: drop-shadow(0 0 8px rgba(209,32,177,0.55)); }
    }

    /* Topbar subtle underline on hover */
    .navbar-header .dropdown-toggle,
    .navbar-header .header-item {
        transition: color 0.2s ease, transform 0.2s ease;
    }
    .navbar-header .header-item:hover {
        transform: translateY(-1px);
    }

    /* Ripple click effect helper */
    .ciesto-ripple {
        position: relative;
        overflow: hidden;
    }
    .ciesto-ripple-wave {
        position: absolute;
        border-radius: 50%;
        transform: scale(0);
        animation: ciestoRipple 0.55s linear;
        background: rgba(255, 255, 255, 0.28);
        pointer-events: none;
    }
    @keyframes ciestoRipple {
        to { transform: scale(2.6); opacity: 0; }
    }
}

@media (prefers-reduced-motion: reduce) {
    .main-content .page-content,
    .ciesto-reveal,
    .page-title-box,
    .alert,
    .dash-hero {
        animation: none !important;
        transition: none !important;
        opacity: 1 !important;
        transform: none !important;
    }
}

/* ========== Horizontal chrome (header + nav) — rebuilt compact ========== */
/*
 * Stacking: header MUST sit above the nav bar so profile/alerts dropdowns
 * are never clipped behind the menu strip.
 */
body[data-layout="horizontal"] #page-topbar {
    background: linear-gradient(90deg, #0a0a0e 0%, #12121a 55%, #160b18 100%) !important;
    border-bottom: 1px solid rgba(209, 32, 177, 0.18);
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
    position: relative;
    z-index: 1300 !important;
}

body[data-layout="horizontal"] #page-topbar .navbar-header {
    min-height: 56px !important;
    height: 56px !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}

body[data-layout="horizontal"] #page-topbar .dropdown-menu {
    z-index: 1310 !important;
    position: absolute !important;
}

body[data-layout="horizontal"] .navbar-brand-box {
    width: auto !important;
    padding-left: 0.5rem !important;
    padding-right: 0.75rem !important;
    background: transparent !important;
}

body[data-layout="horizontal"] #page-topbar,
body[data-layout="horizontal"] #page-topbar .navbar-header,
body[data-layout="horizontal"] .topnav,
body[data-layout="horizontal"] .topnav.ciesto-topnav,
body[data-layout="horizontal"] .topnav .container-fluid,
body[data-layout="horizontal"] .topnav #topnav-menu-content,
body[data-layout="horizontal"] .topnav .navbar-collapse {
    max-height: none !important;
    overflow: visible !important;
    overflow-x: visible !important;
    overflow-y: visible !important;
}

body[data-layout="horizontal"] .topnav.ciesto-topnav {
    background: #0c0c12 !important;
    border-bottom: 1px solid var(--ciesto-border);
    position: relative;
    z-index: 1100 !important;
    padding: 0 !important;
    margin-top: 0 !important;
}

body[data-layout="horizontal"] .topnav.ciesto-topnav .container-fluid {
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}

body[data-layout="horizontal"] .topnav.ciesto-topnav .navbar {
    padding: 0 !important;
    min-height: 0 !important;
}

body[data-layout="horizontal"] .topnav.ciesto-topnav .navbar-nav {
    gap: 0.1rem;
    padding: 0.3rem 0 !important;
    margin: 0 !important;
    flex-wrap: wrap !important;
    width: 100%;
    max-width: 100%;
    align-items: center;
}

body[data-layout="horizontal"] .main-content,
body[data-layout="horizontal"] .page-content {
    position: relative;
    z-index: 1;
}

body[data-layout="horizontal"] .topnav.ciesto-topnav .nav-item.dropdown {
    position: relative;
}

body[data-layout="horizontal"] .topnav.ciesto-topnav .nav-link {
    color: var(--ciesto-muted) !important;
    font-weight: 500;
    font-size: 0.84rem;
    letter-spacing: 0.01em;
    padding: 0.5rem 0.75rem !important;
    min-height: 42px !important;
    line-height: 1.25 !important;
    border-radius: 8px;
    transition: color 0.15s ease, background 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

body[data-layout="horizontal"] .topnav.ciesto-topnav .nav-link i {
    font-size: 0.95rem;
    opacity: 0.9;
    margin-right: 0 !important;
}

body[data-layout="horizontal"] .topnav.ciesto-topnav .nav-link:hover,
body[data-layout="horizontal"] .topnav.ciesto-topnav .nav-link:focus {
    color: #fff !important;
    background: rgba(209, 32, 177, 0.12);
}

body[data-layout="horizontal"] .topnav.ciesto-topnav .nav-link.active {
    color: #fff !important;
    background: linear-gradient(135deg, rgba(209, 32, 177, 0.35), rgba(138, 43, 226, 0.28));
    box-shadow: 0 0 0 1px rgba(209, 32, 177, 0.28);
}

body[data-layout="horizontal"] .topnav.ciesto-topnav .dropdown-menu {
    background: #15151f !important;
    border: 1px solid var(--ciesto-border) !important;
    border-radius: 10px !important;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45) !important;
    padding: 0.35rem !important;
    margin-top: 0.2rem !important;
    min-width: 200px;
}

/*
 * Click-only topnav submenus (ciesto-topnav.js owns open state).
 */
body[data-layout="horizontal"] .topnav.ciesto-topnav .nav-item.dropdown > .dropdown-menu {
    display: none !important;
    position: absolute !important;
    top: 100% !important;
    left: 0 !important;
    float: none !important;
    z-index: 1200 !important;
}
body[data-layout="horizontal"] .topnav.ciesto-topnav .dropdown:hover > .dropdown-menu,
.topnav.ciesto-topnav .dropdown:hover > .dropdown-menu,
.topnav .dropdown:hover > .dropdown-menu {
    display: none !important;
}
body[data-layout="horizontal"] .topnav.ciesto-topnav .nav-item.dropdown.show > .dropdown-menu,
body[data-layout="horizontal"] .topnav.ciesto-topnav .nav-item.dropdown.show > .dropdown-menu.show {
    display: block !important;
    position: absolute !important;
    z-index: 1200 !important;
}

body[data-layout="horizontal"] .topnav.ciesto-topnav .dropdown-item {
    color: var(--ciesto-muted) !important;
    border-radius: 7px;
    padding: 0.4rem 0.7rem;
    font-size: 0.84rem;
    transition: background 0.15s ease, color 0.15s ease;
}

body[data-layout="horizontal"] .topnav.ciesto-topnav .dropdown-item:hover,
body[data-layout="horizontal"] .topnav.ciesto-topnav .dropdown-item:focus,
body[data-layout="horizontal"] .topnav.ciesto-topnav .dropdown-item.active {
    background: linear-gradient(135deg, rgba(209, 32, 177, 0.22), rgba(138, 43, 226, 0.16)) !important;
    color: #fff !important;
}

body[data-layout="horizontal"] .topnav.ciesto-topnav .nav-link.dropdown-toggle::after {
    display: none !important;
    content: none !important;
}

body[data-layout="horizontal"] .topnav.ciesto-topnav .nav-link .menu-arrow {
    display: inline-block !important;
    font-size: 0.9rem;
    margin-left: 0.15rem;
    line-height: 1;
    opacity: 0.85;
    transition: transform 0.2s ease;
}

body[data-layout="horizontal"] .topnav.ciesto-topnav .nav-item.dropdown.show > .nav-link .menu-arrow {
    transform: rotate(180deg);
}

body[data-layout="horizontal"] .topnav.ciesto-topnav .nav-link .arrow-down {
    display: none !important;
}

body[data-layout="horizontal"] .topnav.ciesto-topnav .dropdown-divider {
    border-top-color: var(--ciesto-border);
    margin: 0.25rem 0;
}

body[data-layout="horizontal"] .main-content {
    margin-left: 0 !important;
}

@media (min-width: 992px) {
    body[data-layout="horizontal"] .main-content {
        margin-top: 0;
    }
    body[data-layout="horizontal"] .page-content {
        padding-top: 1.25rem !important;
    }
}

@media (max-width: 991.98px) {
    body[data-layout="horizontal"] .topnav,
    body[data-layout="horizontal"] .topnav.ciesto-topnav,
    body[data-layout="horizontal"] .topnav #topnav-menu-content,
    body[data-layout="horizontal"] .topnav .navbar-collapse,
    body[data-layout="horizontal"] .topnav .container-fluid {
        max-height: none !important;
        height: auto !important;
        overflow: visible !important;
    }

    body[data-layout="horizontal"] .topnav.ciesto-topnav .navbar-nav {
        padding: 0.4rem 0.4rem 0.6rem !important;
        gap: 0.15rem;
        flex-wrap: wrap !important;
        display: block !important;
        width: 100%;
    }

    body[data-layout="horizontal"] .topnav.ciesto-topnav .nav-item {
        display: block !important;
        width: 100% !important;
        position: relative !important;
        float: none !important;
        clear: both !important;
    }

    body[data-layout="horizontal"] .topnav.ciesto-topnav .nav-item.dropdown {
        position: static !important;
    }

    body[data-layout="horizontal"] .topnav.ciesto-topnav .nav-link {
        width: 100%;
        border-radius: 8px;
        justify-content: flex-start;
        padding: 0.45rem 0.65rem !important;
    }

    body[data-layout="horizontal"] .topnav.ciesto-topnav .nav-item.dropdown > .dropdown-menu,
    body[data-layout="horizontal"] .topnav.ciesto-topnav .nav-item.dropdown.show > .dropdown-menu,
    body[data-layout="horizontal"] .topnav.ciesto-topnav .nav-item.dropdown.show > .dropdown-menu.show,
    body[data-layout="horizontal"] .topnav.ciesto-topnav .dropdown-menu {
        position: static !important;
        top: auto !important;
        left: auto !important;
        right: auto !important;
        float: none !important;
        transform: none !important;
        inset: auto !important;
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
        margin: 0 !important;
        box-shadow: none !important;
        border: none !important;
        background: rgba(209, 32, 177, 0.06) !important;
        border-radius: 8px !important;
        padding: 0.2rem 0.3rem 0.3rem 0.55rem !important;
        z-index: auto !important;
    }

    body[data-layout="horizontal"] .topnav.ciesto-topnav .nav-item.dropdown > .dropdown-menu {
        display: none !important;
    }

    body[data-layout="horizontal"] .topnav.ciesto-topnav .nav-item.dropdown.show > .dropdown-menu,
    body[data-layout="horizontal"] .topnav.ciesto-topnav .nav-item.dropdown.show > .dropdown-menu.show {
        display: block !important;
    }

    body[data-layout="horizontal"] .topnav.ciesto-topnav .dropdown-item {
        white-space: normal !important;
    }
}

body[data-layout="horizontal"] .topnav.ciesto-topnav .nav-item.dropdown.show > .nav-link .menu-arrow {
    transform: rotate(180deg);
}

/* ===== Modals above chrome / backdrop (fixes Settings/View overlay lock) ===== */
.modal {
    z-index: 2000 !important;
}
.modal-backdrop {
    z-index: 1990 !important;
}
body.modal-open .modal {
    pointer-events: auto !important;
}
body.modal-open .modal .modal-dialog {
    pointer-events: auto !important;
}

/* ===== DataTables: sort icons sit next to heading text (not floating mid-column) ===== */
table.dataTable thead > tr:first-child > th.sorting,
table.dataTable thead > tr:first-child > th.sorting_asc,
table.dataTable thead > tr:first-child > th.sorting_desc,
table.dataTable thead > tr:first-child > th.sorting_asc_disabled,
table.dataTable thead > tr:first-child > th.sorting_desc_disabled {
    background-image: none !important;
    white-space: nowrap !important;
    vertical-align: middle !important;
    position: relative;
    padding-right: 1.1rem !important;
}
table.dataTable thead > tr:first-child > th.sorting:before,
table.dataTable thead > tr:first-child > th.sorting_asc:before,
table.dataTable thead > tr:first-child > th.sorting_desc:before,
table.dataTable thead > tr:first-child > th.sorting_asc_disabled:before,
table.dataTable thead > tr:first-child > th.sorting_desc_disabled:before,
table.dataTable thead > tr:first-child > th.sorting:after,
table.dataTable thead > tr:first-child > th.sorting_asc:after,
table.dataTable thead > tr:first-child > th.sorting_desc:after,
table.dataTable thead > tr:first-child > th.sorting_asc_disabled:after,
table.dataTable thead > tr:first-child > th.sorting_desc_disabled:after {
    display: none !important;
    content: none !important;
    background: none !important;
}
table.dataTable thead > tr:first-child > th.sorting > .ciesto-sort,
table.dataTable thead > tr:first-child > th.sorting_asc > .ciesto-sort,
table.dataTable thead > tr:first-child > th.sorting_desc > .ciesto-sort {
    display: inline-block;
    margin-left: 0.35rem;
    font-size: 11px;
    line-height: 1;
    opacity: 0.55;
    vertical-align: middle;
    font-weight: 700;
}
table.dataTable thead > tr:first-child > th.sorting_asc > .ciesto-sort,
table.dataTable thead > tr:first-child > th.sorting_desc > .ciesto-sort {
    opacity: 0.95;
    color: var(--ciesto-magenta, #d120b1);
}
/* Filter rows never show sort affordances */
table.dataTable thead tr.employee-filter-row > th,
table.dataTable thead tr.admin-filter-row > th,
table.dataTable thead tr.domain-filter-row > th,
table.dataTable thead tr.hosting-filter-row > th,
table.dataTable thead tr.template-filter-row > th,
table.dataTable thead tr[class*="filter-row"] > th {
    background-image: none !important;
    cursor: default !important;
    padding-right: 0.5rem !important;
}
table.dataTable thead tr[class*="filter-row"] > th:before,
table.dataTable thead tr[class*="filter-row"] > th:after,
table.dataTable thead tr[class*="filter-row"] > th > .ciesto-sort {
    display: none !important;
    content: none !important;
}
/* Keep header/filter inputs aligned in columns */
table.dataTable thead th,
table.dataTable thead td {
    vertical-align: middle !important;
}
table.dataTable thead tr[class*="filter-row"] .form-control,
table.dataTable thead tr[class*="filter-row"] .form-select {
    min-width: 0;
    width: 100%;
    max-width: 100%;
}

/* ===== Admin tables: scroll + optional sticky Action (opt-in) =====
   Sticky Action used to apply to EVERY table last-column and overlapped
   neighbours (Hosting Plans Accounts, etc). Default = no sticky.
   Add class "sticky-actions" on .admin-table-scroll only for wide tables. */
.admin-table-scroll {
    width: 100%;
}
.admin-table-scroll-bottom {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
}
.admin-table-scroll-bottom table.yajra-datatable,
.admin-table-scroll-bottom table.dataTable,
.admin-table-scroll-bottom table.table {
    min-width: 100%;
    width: 100% !important;
    border-collapse: separate;
    border-spacing: 0;
}

/* Default Action column: normal flow, never covers other columns */
.admin-table-scroll-bottom table thead tr:first-child th:last-child,
.admin-table-scroll-bottom table thead tr[class*="filter-row"] th:last-child,
.admin-table-scroll-bottom table tbody td:last-child {
    position: static;
    right: auto;
    z-index: auto;
    box-shadow: none;
    min-width: 0;
    width: auto;
    max-width: none;
    overflow: visible;
    white-space: nowrap;
    vertical-align: middle;
}

/* Opt-in sticky Action — solid opaque plate so content never bleeds through */
.admin-table-scroll.sticky-actions .admin-table-scroll-bottom table.yajra-datatable,
.admin-table-scroll.sticky-actions .admin-table-scroll-bottom table.dataTable,
.admin-table-scroll.sticky-actions .admin-table-scroll-bottom table.table {
    min-width: 1280px;
}
.admin-table-scroll.sticky-actions table thead tr:first-child > th:last-child,
.admin-table-scroll.sticky-actions table thead tr[class*="filter-row"] > th:last-child,
.admin-table-scroll.sticky-actions table tbody > tr > td:last-child {
    position: sticky !important;
    right: 0 !important;
    z-index: 6;
    min-width: 230px !important;
    width: 230px !important;
    max-width: 260px !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    white-space: nowrap !important;
    padding-left: 0.85rem !important;
    padding-right: 0.85rem !important;
    /* Opaque fill (not transparent Bootstrap table vars) */
    background: #ffffff !important;
    background-image: none !important;
    background-clip: padding-box !important;
    box-shadow: -10px 0 16px rgba(15, 23, 42, 0.12);
    isolation: isolate;
}
body[data-layout-mode="dark"] .admin-table-scroll.sticky-actions table thead tr:first-child > th:last-child,
body[data-layout-mode="dark"] .admin-table-scroll.sticky-actions table thead tr[class*="filter-row"] > th:last-child,
body[data-layout-mode="dark"] .admin-table-scroll.sticky-actions table tbody > tr > td:last-child,
body[data-bs-theme="dark"] .admin-table-scroll.sticky-actions table thead tr:first-child > th:last-child,
body[data-bs-theme="dark"] .admin-table-scroll.sticky-actions table thead tr[class*="filter-row"] > th:last-child,
body[data-bs-theme="dark"] .admin-table-scroll.sticky-actions table tbody > tr > td:last-child {
    background: #1c1c28 !important;
    background-image: none !important;
    box-shadow: -10px 0 16px rgba(0, 0, 0, 0.45);
}
/* Keep sticky opaque on row hover / striped rows */
.admin-table-scroll.sticky-actions table.table-hover > tbody > tr:hover > td:last-child,
.admin-table-scroll.sticky-actions table.table-striped > tbody > tr > td:last-child,
.admin-table-scroll.sticky-actions table.dataTable.display tbody tr:hover > td:last-child,
.admin-table-scroll.sticky-actions table.dataTable.hover tbody tr:hover > td:last-child {
    background: #ffffff !important;
    background-image: none !important;
    --bs-table-accent-bg: transparent !important;
    --bs-table-bg-state: transparent !important;
}
body[data-layout-mode="dark"] .admin-table-scroll.sticky-actions table.table-hover > tbody > tr:hover > td:last-child,
body[data-layout-mode="dark"] .admin-table-scroll.sticky-actions table.table-striped > tbody > tr > td:last-child,
body[data-bs-theme="dark"] .admin-table-scroll.sticky-actions table.table-hover > tbody > tr:hover > td:last-child,
body[data-bs-theme="dark"] .admin-table-scroll.sticky-actions table.table-striped > tbody > tr > td:last-child {
    background: #1c1c28 !important;
    background-image: none !important;
}
.admin-table-scroll.sticky-actions table thead tr:first-child > th:last-child {
    z-index: 8;
}
.admin-table-scroll-bottom .col-action-btns {
    flex-wrap: nowrap !important;
    white-space: nowrap;
    max-width: 100%;
}

/* Page loader overlay */
#loader:not(.d-none) {
    position: fixed;
    inset: 0;
    z-index: 1800;
    background: rgba(11, 11, 15, 0.45);
    pointer-events: all;
}
#loader.d-none {
    pointer-events: none !important;
}

/* Sound controls in header */
.ciesto-sound-controls {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-right: 0.5rem;
}
.ciesto-sound-controls .btn {
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}
.ciesto-sound-controls .btn.active {
    background: rgba(209, 32, 177, 0.25);
    color: #fff;
}



/* Fallback: keep dark surfaces if only html theme attr is set */
html[data-bs-theme="dark"] body,
html[data-layout-mode="dark"] body {
    background-color: var(--ciesto-bg, #0b0b10) !important;
    color: #f3eef8;
}

/* ===== Ciesto Day Pad (login quick attendance) ===== */
.ciesto-daypad {
    --pad-bg: rgba(20, 20, 28, 0.92);
    --pad-line: rgba(255, 255, 255, 0.08);
    --pad-text: #f3eef8;
    --pad-muted: #9a92a8;
    border: 1px solid var(--pad-line);
    border-radius: 18px;
    background:
        linear-gradient(160deg, rgba(209, 32, 177, 0.12), transparent 42%),
        linear-gradient(320deg, rgba(138, 43, 226, 0.1), transparent 40%),
        var(--pad-bg);
    padding: 14px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}
.ciesto-daypad__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}
.ciesto-daypad__title {
    font-family: "Poppins", system-ui, sans-serif;
    font-weight: 650;
    font-size: 1rem;
    letter-spacing: 0.02em;
    color: var(--pad-text);
    line-height: 1.2;
}
.ciesto-daypad__sub {
    font-size: 0.72rem;
    color: var(--pad-muted);
    margin-top: 2px;
}
.ciesto-daypad__pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 5px 9px;
    border-radius: 999px;
    border: 1px solid var(--pad-line);
    white-space: nowrap;
}
.ciesto-daypad__pill.is-ok {
    color: #7dffa8;
    background: rgba(40, 167, 69, 0.15);
    border-color: rgba(40, 167, 69, 0.35);
}
.ciesto-daypad__pill.is-warn {
    color: #ffd27a;
    background: rgba(255, 193, 7, 0.12);
    border-color: rgba(255, 193, 7, 0.3);
}
.ciesto-daypad__pill.is-muted {
    color: var(--pad-muted);
    background: rgba(255, 255, 255, 0.04);
}
.ciesto-daypad__grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.ciesto-daypad__tile {
    appearance: none;
    border: 1px solid var(--pad-line);
    border-radius: 14px;
    min-height: 92px;
    padding: 12px 10px;
    text-align: left;
    color: var(--pad-text);
    background: rgba(255, 255, 255, 0.03);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 6px;
    transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}
.ciesto-daypad__tile::after {
    content: "";
    position: absolute;
    inset: auto -20% -40% auto;
    width: 90px;
    height: 90px;
    border-radius: 50%;
    opacity: 0.22;
    pointer-events: none;
}
.ciesto-daypad__tile.is-start::after { background: #d120b1; }
.ciesto-daypad__tile.is-lunch-out::after { background: #e0a800; }
.ciesto-daypad__tile.is-lunch-in::after { background: #2aa8ff; }
.ciesto-daypad__tile.is-end::after { background: #8a2be2; }
.ciesto-daypad__tile:hover:not(:disabled) {
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.055);
}
.ciesto-daypad__tile:active:not(:disabled) {
    transform: scale(0.98);
}
.ciesto-daypad__tile:disabled {
    opacity: 0.42;
    cursor: not-allowed;
    filter: grayscale(0.35);
}
.ciesto-daypad__tile.is-busy {
    border-color: rgba(209, 32, 177, 0.55);
    box-shadow: 0 0 0 1px rgba(209, 32, 177, 0.25);
}
.ciesto-daypad__tile.is-done {
    border-color: rgba(125, 255, 168, 0.55);
    box-shadow: 0 0 0 1px rgba(125, 255, 168, 0.2);
}
.ciesto-daypad__icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    background: rgba(0, 0, 0, 0.28);
}
.ciesto-daypad__tile.is-start .ciesto-daypad__icon { color: #ff7ad9; }
.ciesto-daypad__tile.is-lunch-out .ciesto-daypad__icon { color: #ffd27a; }
.ciesto-daypad__tile.is-lunch-in .ciesto-daypad__icon { color: #7ad4ff; }
.ciesto-daypad__tile.is-end .ciesto-daypad__icon { color: #c9a6ff; }
.ciesto-daypad__label {
    font-family: "Poppins", system-ui, sans-serif;
    font-weight: 650;
    font-size: 0.95rem;
    line-height: 1.1;
}
.ciesto-daypad__hint {
    font-size: 0.68rem;
    color: var(--pad-muted);
}
.ciesto-daypad__foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 12px;
    min-height: 1.25rem;
}
.ciesto-daypad__msg {
    font-size: 0.75rem;
    color: var(--pad-muted);
    flex: 1;
    min-width: 0;
}
.ciesto-daypad__msg.is-wait { color: #ffb8ec; }
.ciesto-daypad__msg.is-ok { color: #7dffa8; }
.ciesto-daypad__msg.is-err { color: #ff8f9f; }
.ciesto-daypad__ip {
    font-size: 0.65rem;
    color: rgba(163, 155, 179, 0.7);
    font-variant-numeric: tabular-nums;
}
.ciesto-daypad.is-working .ciesto-daypad__grid {
    opacity: 0.86;
}
.ciesto-auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 0 1rem;
    color: #8e869c;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
.ciesto-auth-divider::before,
.ciesto-auth-divider::after {
    content: "";
    height: 1px;
    flex: 1;
    background: rgba(255, 255, 255, 0.08);
}

/* Auth logo: center on mobile */
@media (max-width: 1199.98px) {
    .auth-full-page-content .auth-logo {
        text-align: center !important;
        display: block !important;
        width: 100%;
    }
    .auth-full-page-content .auth-logo img {
        margin-left: auto !important;
        margin-right: auto !important;
        display: block !important;
    }
    .auth-full-page-content > .w-100 > .d-flex.flex-column > .mb-4,
    .auth-full-page-content > .w-100 > .d-flex.flex-column > .mb-md-5 {
        text-align: center;
        width: 100%;
    }
}

/* Auth page: never show both logo variants */
.auth-logo .auth-logo-light { display: none !important; }
.auth-logo .auth-logo-dark { display: inline-block !important; }
.auth-logo-wrap { text-align: center; }
.auth-logo-wrap .auth-logo img { display: inline-block; margin: 0 auto; }
