/* ==========================================================
   YPWK Digital Live Ready UI/UX V14
   Final responsive overrides for portal, login, and public site.
   Loaded after portal.css / ypwk.css to neutralize older cascade conflicts.
   ========================================================== */

:root {
    --lr-navy: #0b213b;
    --lr-navy-2: #12365f;
    --lr-gold: #f3aa17;
    --lr-gold-soft: #fff5d9;
    --lr-bg: #f6f8fb;
    --lr-card: #ffffff;
    --lr-line: #e6edf5;
    --lr-text: #152235;
    --lr-muted: #66758a;
    --lr-radius: 22px;
    --lr-shadow: 0 18px 48px rgba(10, 31, 54, .10);
    --lr-shadow-soft: 0 10px 28px rgba(10, 31, 54, .08);
}

html {
    width: 100%;
    -webkit-text-size-adjust: 100%;
}

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

img,
svg,
video,
canvas {
    max-width: 100%;
}

button,
a,
input,
select,
textarea {
    -webkit-tap-highlight-color: transparent;
}

/* ---------- Shared utility hardening ---------- */
.panel,
.kpi-card,
.role-card,
.cms-guide-card,
.module-overview-card,
.focus-card,
.summary-card,
.login-card,
.table-wrap,
.form-grid,
.module-layout,
.dashboard-grid,
.finance-report-grid,
.cms-layout,
.cms-content-stack,
.clean-dashboard-grid,
.clean-reminder-grid,
.page-assistant,
.portal-flow {
    min-width: 0 !important;
}

.table-wrap {
    max-width: 100% !important;
    overflow-x: auto !important;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.table-wrap table {
    width: 100%;
    border-collapse: collapse;
}

.input,
select.input,
textarea.input,
.readonly-field {
    max-width: 100%;
}

.btn {
    line-height: 1.15;
    text-align: center;
}

/* ==========================================================
   PORTAL INTERNAL
   ========================================================== */
body.portal-body {
    background:
        radial-gradient(circle at 8% -2%, rgba(243, 170, 23, .10), transparent 30rem),
        radial-gradient(circle at 95% 8%, rgba(18, 54, 95, .07), transparent 26rem),
        var(--lr-bg) !important;
}

body.portal-body .app-shell {
    display: grid !important;
    grid-template-columns: 286px minmax(0, 1fr) !important;
    min-height: 100dvh;
}

body.portal-body .sidebar {
    width: auto;
    min-width: 0;
    margin: 0 !important;
    border-radius: 0 !important;
}

body.portal-body .main {
    width: 100% !important;
    max-width: 1500px;
    min-width: 0;
    margin: 0 auto !important;
    padding: clamp(18px, 2.4vw, 30px) !important;
}

body.portal-body .topbar {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    position: sticky;
    top: 14px;
    z-index: 40;
    min-width: 0;
}

body.portal-body .topbar > div:first-child {
    min-width: 0;
}

body.portal-body .topbar h1 {
    overflow-wrap: anywhere;
}

body.portal-body .topbar-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 9px;
    min-width: min(100%, 360px);
}

body.portal-body .topbar-actions form {
    margin: 0;
}

body.portal-body .portal-flow {
    display: grid;
    grid-template-columns: minmax(0, .72fr) minmax(0, 1fr);
    gap: 16px;
}

body.portal-body .portal-flow ol {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin: 0;
    padding: 0;
}

body.portal-body .portal-flow li {
    min-width: 0;
}

body.portal-body .page-assistant {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 16px;
    align-items: center;
}

body.portal-body .assistant-actions {
    min-width: 0;
}

body.portal-body .module-layout,
body.portal-body .cms-layout {
    display: grid;
    grid-template-columns: minmax(300px, 390px) minmax(0, 1fr) !important;
    align-items: start;
    gap: 16px;
}

body.portal-body .dashboard-grid,
body.portal-body .clean-dashboard-grid,
body.portal-body .clean-reminder-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.28fr) minmax(320px, .72fr) !important;
    gap: 16px;
}

body.portal-body .kpi-grid,
body.portal-body .role-grid,
body.portal-body .cms-guide-grid,
body.portal-body .cms-guide-grid.expanded {
    display: grid;
    gap: 16px;
}

body.portal-body .kpi-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
}

body.portal-body .role-grid,
body.portal-body .cms-guide-grid,
body.portal-body .cms-guide-grid.expanded {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
}

body.portal-body .finance-report-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) repeat(3, minmax(0, .8fr)) !important;
    gap: 14px;
}

body.portal-body .form-grid,
body.portal-body .form-grid-compact {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 14px;
}

body.portal-body .form-grid > .field-full,
body.portal-body .form-grid > .form-actions-line,
body.portal-body .form-grid > .action-row,
body.portal-body .form-grid > button,
body.portal-body .form-grid > .full {
    grid-column: 1 / -1;
}

body.portal-body .field,
body.portal-body .field label {
    min-width: 0;
}

body.portal-body .inline-form {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

body.portal-body .stack-actions {
    min-width: 0 !important;
}

body.portal-body .mobile-shellbar,
body.portal-body .mobile-bottom-nav {
    display: none !important;
}

/* Drawer layout for tablet and mobile */
@media (max-width: 1180px) {
    body.portal-body .app-shell {
        display: block !important;
        grid-template-columns: 1fr !important;
        min-height: auto;
    }

    body.portal-body .mobile-shellbar {
        position: sticky !important;
        top: 0;
        z-index: 190;
        display: flex !important;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        min-height: 62px;
        padding: calc(8px + env(safe-area-inset-top)) 14px 8px;
        border-bottom: 1px solid rgba(230, 237, 245, .9);
        background: rgba(255, 255, 255, .96);
        backdrop-filter: blur(18px);
        box-shadow: 0 12px 34px rgba(10, 31, 54, .10);
    }

    body.portal-body .mobile-brand {
        min-width: 0;
        display: inline-flex;
        align-items: center;
        justify-content: flex-end;
        gap: 8px;
        color: var(--lr-navy);
        font-weight: 950;
    }

    body.portal-body .mobile-brand strong {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    body.portal-body .mobile-menu-toggle {
        min-width: 98px;
        min-height: 42px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 5px;
        border: 1px solid var(--lr-line);
        border-radius: 14px;
        background: #fff;
        color: var(--lr-navy);
        font-weight: 950;
    }

    body.portal-body .mobile-menu-toggle span {
        width: 14px;
        height: 2px;
        border-radius: 999px;
        background: currentColor;
    }

    body.portal-body .mobile-menu-toggle b {
        margin-left: 4px;
        font-size: 12px;
    }

    body.portal-body .sidebar {
        position: fixed !important;
        inset: 0 auto 0 0 !important;
        z-index: 210 !important;
        width: min(326px, 88vw) !important;
        height: 100dvh !important;
        max-height: 100dvh;
        padding: calc(14px + env(safe-area-inset-top)) 14px calc(18px + env(safe-area-inset-bottom)) !important;
        overflow-y: auto !important;
        border-radius: 0 24px 24px 0 !important;
        transform: translateX(-112%) !important;
        transition: transform .24s ease;
        box-shadow: 24px 0 72px rgba(2, 6, 23, .34) !important;
    }

    body.portal-body .sidebar.open {
        transform: translateX(0) !important;
    }

    body.portal-body .sidebar-brand {
        min-height: auto;
        margin-bottom: 14px;
        padding: 12px !important;
    }

    body.portal-body .sidebar-menu {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 6px !important;
        margin-top: 0 !important;
        padding: 0 0 18px !important;
        overflow: visible !important;
        scroll-snap-type: none !important;
    }

    body.portal-body .menu-section-title {
        width: 100%;
        margin: 16px 9px 6px !important;
    }

    body.portal-body .side-link {
        width: 100%;
        min-width: 0 !important;
        flex: none !important;
        scroll-snap-align: none !important;
    }

    body.portal-body.sidebar-is-open {
        overflow: hidden !important;
    }

    body.portal-body.sidebar-is-open::after {
        content: "";
        position: fixed;
        inset: 0;
        z-index: 200;
        background: rgba(4, 15, 28, .48);
        backdrop-filter: blur(2px);
    }

    body.portal-body .main {
        max-width: none;
        padding: 16px !important;
    }

    body.portal-body .topbar {
        position: relative !important;
        top: auto !important;
        z-index: 1;
        display: grid !important;
        grid-template-columns: 1fr !important;
        align-items: start;
    }

    body.portal-body .topbar-actions {
        justify-content: flex-start;
        width: 100%;
        min-width: 0;
    }

    body.portal-body .portal-flow,
    body.portal-body .page-assistant,
    body.portal-body .module-layout,
    body.portal-body .cms-layout,
    body.portal-body .dashboard-grid,
    body.portal-body .clean-dashboard-grid,
    body.portal-body .clean-reminder-grid,
    body.portal-body .finance-report-grid {
        grid-template-columns: 1fr !important;
    }

    body.portal-body .kpi-grid,
    body.portal-body .role-grid,
    body.portal-body .cms-guide-grid,
    body.portal-body .cms-guide-grid.expanded {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

    body.portal-body .form-grid,
    body.portal-body .form-grid-compact {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
}

@media (max-width: 920px) {
    body.portal-body {
        padding-bottom: calc(88px + env(safe-area-inset-bottom));
    }

    body.portal-body .main {
        padding: 14px 12px 18px !important;
    }

    body.portal-body .topbar {
        gap: 14px;
        padding: 16px !important;
        border-radius: 22px !important;
    }

    body.portal-body .topbar-actions {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    body.portal-body .topbar-actions > *,
    body.portal-body .topbar-actions form,
    body.portal-body .topbar-actions .btn,
    body.portal-body .topbar-meta {
        width: 100%;
        min-width: 0;
    }

    body.portal-body .topbar-meta {
        justify-content: center;
        border-radius: 14px;
    }

    body.portal-body .portal-flow {
        padding: 14px !important;
    }

    body.portal-body .portal-flow ol {
        grid-template-columns: 1fr !important;
    }

    body.portal-body .page-assistant {
        padding: 14px !important;
    }

    body.portal-body .assistant-actions {
        display: flex !important;
        align-items: stretch;
        justify-content: flex-start;
        gap: 8px;
        max-width: 100%;
        overflow-x: auto;
        padding-bottom: 2px;
        flex-wrap: nowrap !important;
        -webkit-overflow-scrolling: touch;
    }

    body.portal-body .assistant-chip {
        flex: 0 0 auto;
        white-space: nowrap;
    }

    body.portal-body .panel-head {
        display: grid !important;
        grid-template-columns: 1fr !important;
        align-items: start;
        gap: 12px;
        padding: 16px !important;
    }

    body.portal-body .panel-head .action-row,
    body.portal-body .panel-head .panel-actions {
        justify-content: flex-start;
    }

    body.portal-body .table-wrap {
        border-radius: 18px !important;
    }

    body.portal-body .table-wrap table,
    body.portal-body table {
        min-width: 760px !important;
        font-size: 12.5px !important;
    }

    body.portal-body .mobile-bottom-nav {
        position: fixed;
        left: max(10px, env(safe-area-inset-left));
        right: max(10px, env(safe-area-inset-right));
        bottom: max(10px, env(safe-area-inset-bottom));
        z-index: 180;
        display: grid !important;
        grid-template-columns: repeat(5, minmax(0, 1fr));
        gap: 6px;
        padding: 8px;
        border-radius: 24px;
        border: 1px solid rgba(230, 237, 245, .94);
        background: rgba(255, 255, 255, .94);
        backdrop-filter: blur(18px);
        box-shadow: 0 20px 58px rgba(10, 31, 54, .20);
    }

    body.portal-body .mobile-bottom-nav a,
    body.portal-body .mobile-bottom-nav button {
        min-width: 0;
        min-height: 50px;
        display: grid;
        place-items: center;
        gap: 3px;
        border: 0;
        border-radius: 17px;
        background: transparent;
        color: var(--lr-muted);
        font: inherit;
        font-size: 10px;
        font-weight: 950;
        cursor: pointer;
    }

    body.portal-body .mobile-bottom-nav span {
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    body.portal-body .mobile-bottom-nav i {
        width: 28px;
        height: 28px;
        display: grid;
        place-items: center;
        border-radius: 12px;
        background: #f2f6fb;
        color: var(--lr-navy-2);
        font-style: normal;
        font-size: 11px;
    }

    body.portal-body .mobile-bottom-nav .active,
    body.portal-body .mobile-bottom-nav a.active,
    body.portal-body .mobile-bottom-nav button:focus-visible {
        background: var(--lr-gold-soft);
        color: #6d4600;
    }

    body.portal-body .mobile-bottom-nav .active i,
    body.portal-body .mobile-bottom-nav a.active i {
        background: var(--lr-gold);
        color: #1f1707;
    }

    body.portal-body .back-to-top {
        bottom: calc(92px + env(safe-area-inset-bottom)) !important;
    }
}

@media (max-width: 680px) {
    body.portal-body .mobile-shellbar {
        min-height: 58px;
        padding-left: 10px;
        padding-right: 10px;
    }

    body.portal-body .mobile-menu-toggle {
        min-width: 88px;
    }

    body.portal-body .mobile-brand .brand-mark {
        width: 38px;
        height: 38px;
        flex-basis: 38px;
    }

    body.portal-body .main {
        padding: 12px 10px 18px !important;
    }

    body.portal-body .topbar h1 {
        font-size: clamp(25px, 8vw, 31px) !important;
        line-height: 1.08;
    }

    body.portal-body .topbar p,
    body.portal-body .page-assistant p,
    body.portal-body .portal-flow strong {
        font-size: 13.5px;
    }

    body.portal-body .topbar-actions {
        grid-template-columns: 1fr !important;
    }

    body.portal-body .topbar-command kbd {
        display: none !important;
    }

    body.portal-body .kpi-grid,
    body.portal-body .role-grid,
    body.portal-body .cms-guide-grid,
    body.portal-body .cms-guide-grid.expanded,
    body.portal-body .media-upload-form,
    body.portal-body .media-library-grid,
    body.portal-body .workflow-steps,
    body.portal-body .content-workflow-cards,
    body.portal-body .import-result-grid {
        grid-template-columns: 1fr !important;
    }

    body.portal-body .form-grid,
    body.portal-body .form-grid-compact,
    body.portal-body .cms-page-row,
    body.portal-body .cms-edit-context,
    body.portal-body .media-picker,
    body.portal-body .attached-media-item,
    body.portal-body .qr-label {
        grid-template-columns: 1fr !important;
    }

    body.portal-body .form-grid,
    body.portal-body .stack-list {
        padding: 14px !important;
    }

    body.portal-body .action-row,
    body.portal-body .inline-form,
    body.portal-body .stack-actions,
    body.portal-body .cms-row-actions,
    body.portal-body .quick-create-row,
    body.portal-body .filter-row,
    body.portal-body .panel-actions {
        display: grid !important;
        grid-template-columns: 1fr !important;
        width: 100%;
        gap: 8px;
    }

    body.portal-body .action-row .btn,
    body.portal-body .inline-form .btn,
    body.portal-body .inline-form .input,
    body.portal-body .stack-actions .btn,
    body.portal-body .panel-actions .btn,
    body.portal-body .cms-row-actions .btn,
    body.portal-body .quick-create-row .btn,
    body.portal-body .quick-create-row .input,
    body.portal-body .filter-row .btn,
    body.portal-body .filter-row .input,
    body.portal-body .input-small {
        width: 100% !important;
        min-width: 0 !important;
    }

    body.portal-body .table-ux-toolbar {
        display: grid !important;
        grid-template-columns: 1fr !important;
        align-items: stretch;
    }

    body.portal-body .table-ux-toolbar label,
    body.portal-body .table-ux-toolbar small {
        width: 100% !important;
        white-space: normal !important;
    }

    body.portal-body .table-wrap table,
    body.portal-body table {
        min-width: 680px !important;
    }

    body.portal-body th,
    body.portal-body td {
        padding: 10px 11px !important;
    }

    body.portal-body .mobile-bottom-nav {
        grid-template-columns: repeat(5, minmax(0, 1fr));
        left: 8px;
        right: 8px;
        bottom: 8px;
        padding: 7px;
        border-radius: 22px;
    }

    body.portal-body .mobile-bottom-nav a,
    body.portal-body .mobile-bottom-nav button {
        min-height: 48px;
        font-size: 9.5px;
    }
}

@media (max-width: 390px) {
    body.portal-body .mobile-bottom-nav span {
        display: none;
    }

    body.portal-body .mobile-bottom-nav a,
    body.portal-body .mobile-bottom-nav button {
        min-height: 44px;
    }

    body.portal-body .mobile-bottom-nav i {
        width: 30px;
        height: 30px;
    }
}

/* ==========================================================
   LOGIN + 2FA
   ========================================================== */
body.login-page {
    min-height: 100dvh !important;
    display: grid !important;
    place-items: center !important;
    padding: max(24px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)) !important;
    background:
        radial-gradient(circle at 12% 12%, rgba(243, 170, 23, .28), transparent 26rem),
        radial-gradient(circle at 92% 82%, rgba(39, 187, 157, .18), transparent 28rem),
        linear-gradient(135deg, #071629 0%, #102a56 52%, #06111f 100%) !important;
}

body.login-page .login-shell {
    width: min(1100px, 100%) !important;
    min-height: auto !important;
    margin: 0 auto !important;
    padding: 0 !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) minmax(380px, 450px) !important;
    align-items: center;
    gap: clamp(28px, 6vw, 72px) !important;
}

body.login-page .login-copy {
    min-width: 0;
    color: #fff;
}

body.login-page .brand-inline {
    width: fit-content;
    max-width: 100%;
    margin-bottom: 28px !important;
    padding: 10px 12px;
    border-radius: 20px;
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.12);
}

body.login-page .brand-inline small,
body.login-page .brand-inline span small {
    color: rgba(255,255,255,.68) !important;
}

body.login-page .login-copy h1 {
    max-width: 720px;
    font-size: clamp(34px, 5vw, 58px) !important;
    line-height: .98 !important;
    letter-spacing: -.045em;
}

body.login-page .login-copy p {
    max-width: 620px;
    margin-top: 18px !important;
    color: rgba(255,255,255,.74) !important;
    font-size: clamp(15px, 2vw, 18px) !important;
}

body.login-page .login-card {
    width: 100% !important;
    max-width: 450px;
    padding: clamp(22px, 3vw, 34px) !important;
    border-radius: 30px !important;
    background: rgba(255,255,255,.96) !important;
    border: 1px solid rgba(255,255,255,.78) !important;
    box-shadow: 0 30px 80px rgba(0,0,0,.28) !important;
    backdrop-filter: blur(18px);
}

body.login-page .login-card h2 {
    font-size: clamp(24px, 3vw, 31px) !important;
    line-height: 1.08;
    letter-spacing: -.025em;
}

body.login-page .login-card p {
    color: var(--lr-muted) !important;
}

body.login-page .login-card .alert {
    margin-top: 16px;
    margin-bottom: 0;
}

body.login-page .login-card .form-grid {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 15px !important;
    padding: 20px 0 0 !important;
}

body.login-page .login-card .field,
body.login-page .login-card .check-row,
body.login-page .login-card .btn,
body.login-page .login-card form {
    width: 100%;
}

body.login-page .password-field {
    position: relative;
}

body.login-page .password-field .input {
    min-height: 50px;
    padding-right: 96px !important;
}

body.login-page .password-field button {
    min-width: 74px;
    min-height: 36px;
    right: 7px;
    border-radius: 13px;
}

body.login-page .login-helper-grid {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 8px;
    margin-top: 16px;
}

body.login-page .login-helper-grid span {
    display: grid;
    place-items: center;
    min-height: 48px;
}

body.login-page .otp-input {
    width: 100%;
    min-height: 56px;
    text-align: center;
    letter-spacing: .24em;
    font-size: 23px;
    font-weight: 950;
}

@media (max-width: 880px) {
    body.login-page {
        place-items: start center !important;
        padding: 18px 14px !important;
    }

    body.login-page .login-shell {
        grid-template-columns: 1fr !important;
        gap: 22px !important;
        width: min(560px, 100%) !important;
    }

    body.login-page .login-copy {
        text-align: center;
    }

    body.login-page .brand-inline {
        margin-left: auto;
        margin-right: auto;
        margin-bottom: 18px !important;
    }

    body.login-page .login-copy h1 {
        margin: 0 auto;
        font-size: clamp(28px, 8vw, 42px) !important;
    }

    body.login-page .login-copy p {
        margin-left: auto !important;
        margin-right: auto !important;
    }

    body.login-page .login-card {
        max-width: none;
        border-radius: 26px !important;
    }
}

@media (max-width: 560px) {
    body.login-page {
        padding: 12px !important;
    }

    body.login-page .login-shell {
        gap: 14px !important;
    }

    body.login-page .brand-inline {
        width: 100%;
        justify-content: flex-start;
        margin-bottom: 14px !important;
    }

    body.login-page .brand-inline strong {
        font-size: 13px;
        line-height: 1.15;
    }

    body.login-page .login-copy h1 {
        font-size: 27px !important;
        line-height: 1.06 !important;
    }

    body.login-page .login-copy p {
        margin-top: 10px !important;
        font-size: 14px !important;
    }

    body.login-page .login-card {
        padding: 20px !important;
        border-radius: 22px !important;
    }

    body.login-page .login-helper-grid {
        grid-template-columns: 1fr !important;
    }
}

/* ==========================================================
   PUBLIC WEBSITE MOBILE FINAL POLISH
   ========================================================== */
body.public-site .site-header {
    z-index: 100;
}

body.public-site .header-inner,
body.public-site .container,
body.public-site .hero-inner,
body.public-site .page-hero-inner {
    max-width: 100%;
}

body.public-site .brand,
body.public-site .brand > div,
body.public-site .section-title,
body.public-site .hero-panel,
body.public-site .page-hero-media {
    min-width: 0;
}

body.public-site .brand strong,
body.public-site .hero h1,
body.public-site .page-hero h1,
body.public-site .section-title h2 {
    overflow-wrap: anywhere;
}

@media (max-width: 980px) {
    body.public-site .header-inner {
        position: relative;
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) auto !important;
        gap: 10px;
    }

    body.public-site .public-menu-toggle {
        display: inline-flex !important;
        justify-content: center;
        min-width: 94px;
    }

    body.public-site .header-action {
        display: none !important;
    }

    body.public-site .nav {
        grid-column: 1 / -1;
        display: none !important;
        width: 100% !important;
        margin: 0 0 10px !important;
        padding: 10px !important;
        border: 1px solid var(--lr-line) !important;
        border-radius: 20px !important;
        background: rgba(255,255,255,.98) !important;
        box-shadow: var(--lr-shadow) !important;
    }

    body.public-site .nav.open {
        display: grid !important;
        gap: 4px;
    }

    body.public-site .nav a {
        display: flex !important;
        align-items: center;
        justify-content: space-between;
        min-height: 44px;
        padding: 11px 13px !important;
        border-radius: 14px !important;
    }

    body.public-site .mobile-nav-cta {
        display: flex !important;
        justify-content: center !important;
        background: var(--lr-gold) !important;
        color: #201400 !important;
        font-weight: 950;
    }

    body.public-site .hero-inner,
    body.public-site .page-hero-inner,
    body.public-site .profile-layout,
    body.public-site .profile-condensed,
    body.public-site .profile-dense,
    body.public-site .detail-layout,
    body.public-site .contact-layout,
    body.public-site .section-title {
        grid-template-columns: 1fr !important;
    }

    body.public-site .feature-grid,
    body.public-site .unit-grid,
    body.public-site .news-grid,
    body.public-site .gallery-grid,
    body.public-site .page-card-grid,
    body.public-site .mini-stat-grid,
    body.public-site .detail-media-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

    body.public-site .news-card:first-child {
        grid-column: span 2;
    }
}

@media (max-width: 680px) {
    body.public-site .container,
    body.public-site .header-inner,
    body.public-site .hero-inner,
    body.public-site .page-hero-inner {
        width: min(100% - 24px, 1180px) !important;
    }

    body.public-site .site-header {
        border-radius: 0 0 20px 20px !important;
    }

    body.public-site .brand {
        max-width: 100% !important;
        gap: 9px;
    }

    body.public-site .brand .logo,
    body.public-site .logo {
        width: 40px !important;
        height: 40px !important;
        flex-basis: 40px !important;
        border-radius: 14px !important;
    }

    body.public-site .brand strong {
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        font-size: 13px !important;
        line-height: 1.16;
    }

    body.public-site .brand span {
        display: none !important;
    }

    body.public-site .public-menu-toggle {
        min-width: 82px;
    }

    body.public-site .public-menu-toggle b {
        font-size: 12px;
    }

    body.public-site .hero {
        min-height: auto !important;
        margin-top: 0 !important;
        padding-top: 0 !important;
    }

    body.public-site .hero-inner,
    body.public-site .page-hero-inner {
        gap: 20px !important;
        padding: 40px 0 54px !important;
    }

    body.public-site .hero h1,
    body.public-site .page-hero h1 {
        font-size: clamp(32px, 10vw, 42px) !important;
        line-height: 1.04 !important;
        letter-spacing: -.045em;
    }

    body.public-site .hero p,
    body.public-site .page-hero p {
        font-size: 15px !important;
    }

    body.public-site .hero-actions {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 10px;
    }

    body.public-site .hero-actions .btn {
        width: 100%;
    }

    body.public-site .feature-grid,
    body.public-site .unit-grid,
    body.public-site .news-grid,
    body.public-site .gallery-grid,
    body.public-site .page-card-grid,
    body.public-site .mini-stat-grid,
    body.public-site .detail-media-grid {
        grid-template-columns: 1fr !important;
    }

    body.public-site .news-card:first-child {
        grid-column: auto;
    }

    body.public-site .section {
        padding: 54px 0 !important;
    }
}

/* Final hamburger alignment: stack the three bars instead of showing dashes in one row. */
@media (max-width: 1180px) {
    body.portal-body .mobile-menu-toggle,
    body.public-site .public-menu-toggle {
        display: grid !important;
        grid-template-columns: 18px auto;
        grid-template-rows: repeat(3, 3px);
        align-content: center;
        align-items: center;
        column-gap: 8px;
        row-gap: 3px;
    }

    body.portal-body .mobile-menu-toggle span,
    body.public-site .public-menu-toggle span {
        grid-column: 1;
        width: 18px;
        height: 2px;
        margin: 0;
    }

    body.portal-body .mobile-menu-toggle span:nth-child(1),
    body.public-site .public-menu-toggle span:nth-child(1) { grid-row: 1; }

    body.portal-body .mobile-menu-toggle span:nth-child(2),
    body.public-site .public-menu-toggle span:nth-child(2) { grid-row: 2; }

    body.portal-body .mobile-menu-toggle span:nth-child(3),
    body.public-site .public-menu-toggle span:nth-child(3) { grid-row: 3; }

    body.portal-body .mobile-menu-toggle b,
    body.public-site .public-menu-toggle b {
        grid-column: 2;
        grid-row: 1 / 4;
        align-self: center;
        margin: 0;
        line-height: 1;
    }
}

/* ==========================================================
   YPWK Digital UI/UX Emergency Fix V15
   Root fix: prevent CRUD data tables from being squeezed into
   narrow two-column panels and make mobile tables readable.
   Loaded at the very end so it wins over older V13/V14 rules.
   ========================================================== */

:root {
    --v15-safe-gutter: clamp(14px, 2.2vw, 28px);
}

/* App shell: stable desktop, no accidental clipping. */
body.portal-body .app-shell {
    grid-template-columns: 282px minmax(0, 1fr) !important;
    width: 100% !important;
    max-width: 100% !important;
}

body.portal-body .main {
    max-width: 1480px !important;
    width: 100% !important;
    min-width: 0 !important;
    overflow-x: clip;
}

/* CRITICAL FIX: CRUD pages must be readable. Data panels first, full width.
   The previous V14 rule forced a 390px column, causing finance tables to be cut. */
body.portal-body .module-layout,
body.portal-body .cms-layout {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 18px !important;
    align-items: stretch !important;
    width: 100% !important;
    max-width: 100% !important;
}

body.portal-body .module-layout > .panel,
body.portal-body .cms-layout > .panel,
body.portal-body .cms-layout > .cms-content-stack,
body.portal-body .module-layout > .panel:not(.wide):first-child,
body.portal-body .cms-layout > .panel:not(.wide):first-child {
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
}

body.portal-body .module-layout > .panel.wide,
body.portal-body .cms-layout > .panel.wide,
body.portal-body .cms-layout > .cms-content-stack {
    order: -1 !important;
}

body.portal-body .module-layout + .module-layout,
body.portal-body .module-layout.space-top,
body.portal-body .panel.space-top,
body.portal-body .form-collapse.space-top {
    margin-top: 18px !important;
}

/* Panel headers should not crush buttons or titles. */
body.portal-body .panel-head {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 14px !important;
    min-width: 0 !important;
}

body.portal-body .panel-head > div {
    min-width: 0 !important;
}

body.portal-body .panel-head h2,
body.portal-body .panel-head p {
    overflow-wrap: anywhere;
}

body.portal-body .panel-head .btn,
body.portal-body .panel-head .panel-actions,
body.portal-body .panel-head .action-row {
    flex: 0 0 auto;
}

/* Tables: full-width desktop, readable scroll if needed. */
body.portal-body .table-ux-toolbar {
    margin: 14px 18px 10px !important;
}

body.portal-body .table-wrap {
    width: calc(100% - 36px) !important;
    max-width: calc(100% - 36px) !important;
    margin: 0 18px 18px !important;
    padding: 0 !important;
    overflow-x: auto !important;
    overflow-y: visible !important;
    overscroll-behavior-x: contain;
}

body.portal-body .table-wrap table {
    width: 100% !important;
    min-width: 920px !important;
    margin: 0 !important;
    table-layout: auto !important;
}

body.portal-body .table-wrap th,
body.portal-body .table-wrap td {
    white-space: normal !important;
    word-break: normal;
    overflow-wrap: anywhere;
}

body.portal-body .table-wrap td:last-child,
body.portal-body .table-wrap th:last-child {
    min-width: 128px;
}

body.portal-body .table-wrap td .action-row,
body.portal-body .table-wrap td .inline-form,
body.portal-body .table-wrap td .stack-actions {
    display: inline-flex !important;
    width: auto !important;
    min-width: max-content;
    align-items: center;
    flex-wrap: wrap;
}

body.portal-body nav[role="navigation"] {
    width: 100%;
    padding-left: 18px !important;
    padding-right: 18px !important;
}

/* Forms are secondary work areas; keep them clean and full-width when opened. */
body.portal-body .ux-form-panel.ux-collapsed {
    background: rgba(255, 255, 255, .82) !important;
}

body.portal-body .ux-form-panel:not(.ux-collapsed) .form-grid,
body.portal-body .form-collapse:not(.ux-collapsed) .form-grid {
    width: 100% !important;
    max-width: none !important;
}

/* Dashboard/list grids remain flexible without forcing data tables narrow. */
@media (min-width: 1121px) {
    body.portal-body .dashboard-grid,
    body.portal-body .clean-dashboard-grid,
    body.portal-body .clean-reminder-grid {
        grid-template-columns: minmax(0, 1.2fr) minmax(320px, .8fr) !important;
    }
}

/* Mobile/tablet shell: drawer sidebar + no hidden content. */
@media (max-width: 1120px) {
    body.portal-body .app-shell {
        display: block !important;
        grid-template-columns: 1fr !important;
        padding-top: calc(64px + env(safe-area-inset-top)) !important;
    }

    body.portal-body .main {
        max-width: none !important;
        overflow-x: visible !important;
    }

    body.portal-body .panel-head {
        display: grid !important;
        grid-template-columns: 1fr !important;
        align-items: start !important;
    }

    body.portal-body .panel-head .btn,
    body.portal-body .panel-head .panel-actions,
    body.portal-body .panel-head .action-row {
        width: 100% !important;
    }
}

@media (max-width: 920px) {
    body.portal-body .kpi-grid,
    body.portal-body .role-grid,
    body.portal-body .cms-guide-grid,
    body.portal-body .cms-guide-grid.expanded,
    body.portal-body .finance-report-grid,
    body.portal-body .dashboard-grid,
    body.portal-body .clean-dashboard-grid,
    body.portal-body .clean-reminder-grid {
        grid-template-columns: 1fr !important;
    }

    body.portal-body .table-ux-toolbar {
        width: calc(100% - 28px) !important;
        max-width: calc(100% - 28px) !important;
        margin: 12px 14px 10px !important;
        display: grid !important;
        grid-template-columns: 1fr !important;
        align-items: stretch !important;
    }

    body.portal-body .table-wrap {
        width: calc(100% - 28px) !important;
        max-width: calc(100% - 28px) !important;
        margin: 0 14px 16px !important;
    }
}

/* True mobile table cards: no more clipped tables on phones. */
@media (max-width: 680px) {
    body.portal-body .main {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }

    body.portal-body .topbar-actions {
        grid-template-columns: 1fr !important;
    }

    body.portal-body .form-grid,
    body.portal-body .form-grid-compact {
        grid-template-columns: 1fr !important;
    }

    body.portal-body .table-wrap {
        overflow-x: visible !important;
        border: 0 !important;
        background: transparent !important;
        box-shadow: none !important;
    }

    body.portal-body .table-wrap table,
    body.portal-body .table-wrap thead,
    body.portal-body .table-wrap tbody,
    body.portal-body .table-wrap tr,
    body.portal-body .table-wrap th,
    body.portal-body .table-wrap td {
        display: block !important;
        width: 100% !important;
        min-width: 0 !important;
    }

    body.portal-body .table-wrap table {
        border-collapse: separate !important;
        border-spacing: 0 !important;
        background: transparent !important;
    }

    body.portal-body .table-wrap thead {
        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;
    }

    body.portal-body .table-wrap tbody tr {
        margin: 0 0 12px !important;
        padding: 12px !important;
        border: 1px solid var(--lr-line) !important;
        border-radius: 18px !important;
        background: #fff !important;
        box-shadow: var(--lr-shadow-soft) !important;
    }

    body.portal-body .table-wrap tbody tr.ux-empty-row {
        padding: 0 !important;
        box-shadow: none !important;
    }

    body.portal-body .table-wrap tbody td {
        display: grid !important;
        grid-template-columns: minmax(94px, .38fr) minmax(0, 1fr) !important;
        gap: 10px !important;
        align-items: start !important;
        padding: 9px 0 !important;
        border-bottom: 1px solid #eef3f8 !important;
        white-space: normal !important;
    }

    body.portal-body .table-wrap tbody td:last-child {
        border-bottom: 0 !important;
    }

    body.portal-body .table-wrap tbody td::before {
        content: attr(data-label);
        color: var(--lr-muted);
        font-size: 11px;
        font-weight: 950;
        letter-spacing: .045em;
        text-transform: uppercase;
    }

    body.portal-body .table-wrap tbody td[colspan] {
        display: block !important;
    }

    body.portal-body .table-wrap tbody td[colspan]::before {
        content: "" !important;
        display: none !important;
    }

    body.portal-body .table-wrap td .action-row,
    body.portal-body .table-wrap td .inline-form,
    body.portal-body .table-wrap td .stack-actions {
        display: flex !important;
        width: 100% !important;
        min-width: 0 !important;
        gap: 7px !important;
    }

    body.portal-body .table-wrap td .btn-small,
    body.portal-body .table-wrap td .input-small {
        flex: 1 1 auto;
        min-width: 0 !important;
    }
}

/* Login/2FA: one stable client-facing layout on all devices. */
body.login-page {
    overflow-x: hidden !important;
}

body.login-page .login-shell {
    width: min(560px, 100%) !important;
    max-width: 560px !important;
    display: grid !important;
    grid-template-columns: 1fr !important;
    align-items: start !important;
    gap: 16px !important;
}

body.login-page .login-copy {
    text-align: center !important;
}

body.login-page .brand-inline {
    margin-left: auto !important;
    margin-right: auto !important;
    justify-content: center !important;
}

body.login-page .login-copy h1 {
    margin-left: auto !important;
    margin-right: auto !important;
    font-size: clamp(28px, 6vw, 42px) !important;
    line-height: 1.05 !important;
    letter-spacing: -.035em !important;
}

body.login-page .login-copy p {
    margin-left: auto !important;
    margin-right: auto !important;
    font-size: 15.5px !important;
}

body.login-page .login-card {
    width: 100% !important;
    max-width: 560px !important;
}

body.login-page .login-card .form-grid,
body.login-page .login-card form.form-grid {
    grid-template-columns: 1fr !important;
    width: 100% !important;
}

body.login-page .password-field {
    display: block !important;
    width: 100% !important;
}

body.login-page .password-field .input {
    width: 100% !important;
    padding-right: 104px !important;
}

body.login-page .password-field button {
    position: absolute !important;
    top: 50% !important;
    right: 8px !important;
    transform: translateY(-50%) !important;
    white-space: nowrap !important;
}

@media (max-width: 560px) {
    body.login-page {
        place-items: start center !important;
        padding: 10px !important;
    }

    body.login-page .login-card {
        padding: 18px !important;
    }

    body.login-page .brand-inline {
        width: 100% !important;
        justify-content: flex-start !important;
    }

    body.login-page .login-copy {
        text-align: left !important;
    }

    body.login-page .login-copy h1,
    body.login-page .login-copy p {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    body.login-page .login-helper-grid {
        grid-template-columns: 1fr !important;
    }
}
