/* =====================================================================
   CommunityHub - Fluent / Microsoft Store design system
   The app's own stylesheet. Only material_menu.css (menu engine),
   picker.css, DataTables and select2 ship as third-party styles.
   ===================================================================== */

:root {
    --accent:        #2A5D84;
    --accent-dark:   #1E4560;
    --accent-light:  #DCE7EF;
    --accent-lighter:#F0F4F8;
    --bg:            #EFEEE5;
    --card:          #FFFFFF;
    --stroke:        #E1DFDD;
    --text:          #201F1E;
    --text-2:        #605E5C;
    --text-3:        #A19F9D;
    --success:       #107C10;
    --success-bg:    #DFF6DD;
    --warning:       #986F0B;
    --warning-bg:    #FFF4CE;
    --danger:        #D13438;
    --danger-bg:     #FDE7E9;
    --purple:        #8764B8;
    --purple-bg:     #F0EBF9;
    /* HCFM brand (app owners: Rosario en Familia Chile / Holy Cross Family Ministries) */
    --hcfm-blue:     #0047BB;
    --hcfm-gold:     #FFB500;
    --hcfm-muted-gold: #89764B;
    --radius:        8px;
    --shadow:        0 2px 4px rgba(0,0,0,.08), 0 0.3px 0.9px rgba(0,0,0,.11);
    --shadow-lg:     0 8px 16px rgba(0,0,0,.14), 0 0.6px 1.8px rgba(0,0,0,.11);
    --rail-w:        72px;
    --menubar-h:     46px;
    /* HCFM brand (Rosario en Familia Chile / Holy Cross Family Ministries) */
    --hcfm-blue:     #0047BB;
    --hcfm-gold:     #FFB500;
    --hcfm-muted-gold: #89764B;
}

/* owner branding on login screens */
.owner-logo {
    display: block;
    max-width: 230px; width: 100%;
    margin: 0 auto 12px;
}
.brand-subtitle {
    font-size: 11.5px; color: var(--text-2); font-weight: 600;
    margin: -14px 0 16px; letter-spacing: .2px;
}

/* EN / ES language switcher (top-right of the login screen) */
.lang-switch {
    position: absolute; top: 18px; right: 22px; z-index: 5;
    display: flex; gap: 4px; background: #fff; border: 1px solid var(--stroke);
    border-radius: 16px; padding: 3px;
}
.lang-switch a {
    padding: 5px 10px; border-radius: 13px; font-size: 11px; font-weight: 700;
    color: var(--text-2); cursor: pointer;
}
.lang-switch a.active { background: var(--accent); color: #fff; }

/* staff / member login switcher */
.login-switch {
    display: flex; margin: 0 0 18px;
    background: var(--accent-lighter);
    border: 1px solid var(--stroke);
    border-radius: 20px; padding: 3px;
}
.login-switch a {
    flex: 1; text-align: center; padding: 8px 0;
    border-radius: 17px; font-size: 12.5px; font-weight: 600;
    color: var(--text-2); cursor: pointer; text-decoration: none;
}
.login-switch a i { margin-right: 6px; }
.login-switch a.active { background: var(--accent); color: #fff; }
.login-switch a:not(.active):hover { color: var(--accent-dark); }

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden; /* the shell never scrolls as a whole - each panel scrolls itself */
    overscroll-behavior: none; /* no rubber-band/pull-to-refresh bounce on mobile */
    font-family: "Segoe UI", "Segoe UI Variable", -apple-system, "Helvetica Neue", Arial, sans-serif;
    font-size: 13px;
    color: var(--text);
    /* flat, warm background (XAMPP style) - easy on the eyes over long hours */
    background: var(--bg);
}

a { color: var(--accent); text-decoration: none; }
.hidden { display: none !important; }
.disable { pointer-events: none; opacity: .55; }
h { display: none; }

/* ---------- loading spinner ---------- */
#loadingSpinner {
    position: fixed; inset: 0; z-index: 100000;
    display: flex; align-items: center; justify-content: center;
    background: rgba(255,255,255,.7); backdrop-filter: blur(6px);
}
#loadingSpinner i { font-size: 40px; color: var(--accent); animation: spin 1.1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.rotating { animation: spin .6s linear; display: inline-block; }

/* =====================================================================
   LOGIN
   ===================================================================== */
.loginer {
    position: fixed; inset: 0; z-index: 9000;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    overflow: hidden;
}
.loginer { background: var(--bg); }
.loginer .orange-blob { display: none; }

.login-form {
    position: relative; z-index: 2;
    width: 360px; padding: 30px 34px 26px;
    background: #fff;
    border: 1px solid var(--stroke);
    border-top: 3px solid var(--hcfm-gold); /* brand rule: thin border, brand colors */
    border-radius: var(--radius);
    text-align: center;
}
.login-logo-sm i { font-size: 40px; color: var(--accent); }
/* app owners' logo (HCFM / Rosario en Familia Chile) */
.owner-logo {
    display: block; width: 240px; max-width: 100%;
    margin: 4px auto 12px;
}
.login-form h3 {
    margin: 6px 0 20px; font-size: 15px; font-weight: 600;
    color: var(--text-2); letter-spacing: .4px; text-transform: uppercase;
}
.login-form .input-container { position: relative; margin-bottom: 14px; }
.login-form .input-icon {
    position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
    color: var(--accent); font-size: 14px;
}
.login-form input {
    width: 100%; padding: 10px 12px 10px 36px;
    font: inherit; color: var(--text);
    background: #fff;
    border: 1px solid var(--stroke);
    border-radius: 4px;
    outline: none;
}
.login-form input:focus { border-color: var(--accent); }
.login-form a[role="login-btn"],
.login-form a[role="code-btn"] {
    display: block; margin-top: 6px; padding: 10px 0;
    background: var(--accent); color: #fff;
    border-radius: 4px; font-weight: 600; cursor: pointer;
}
.login-form a[role="login-btn"]:hover,
.login-form a[role="code-btn"]:hover { background: var(--accent-dark); }
.login-footer { display: none; font-size: 12px; color: var(--text-2); }
.error_msg { display: block; min-height: 16px; font-size: 12px; color: var(--danger); }

.login-options { display: none; position: relative; z-index: 2; }
.login-options fieldset {
    width: 380px; border: 1px solid var(--stroke); border-radius: var(--radius);
    border-top: 3px solid var(--hcfm-gold);
    background: #fff;
    padding: 24px 26px;
}
.login-options h4 { margin: 0 0 4px; font-size: 16px; text-align: center; }
.pick-stage-label { text-align: center; color: var(--text-2); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(105px, 1fr)); gap: 10px; margin: 14px 0 6px; }
.pick-card {
    padding: 14px 8px; text-align: center; cursor: pointer;
    background: #fff; border: 1px solid var(--stroke); border-radius: var(--radius);
    transition: border-color .12s, transform .12s;
}
.pick-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.login-options a#reset { font-size: 12px; color: var(--text-2); }
.login-options a#reset:hover { color: var(--accent); }

.tiny-footnote {
    position: absolute; bottom: 16px; left: 0; right: 0;
    text-align: center; font-size: 11px; color: var(--text-3); z-index: 2;
}

/* =====================================================================
   APP SHELL
   ===================================================================== */
#menuObj {
    position: fixed; top: 0; left: 0; right: 0; z-index: 5000;
    height: var(--menubar-h);
    background: rgba(255,255,255,.75);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--stroke);
    display: flex; align-items: center; padding: 0 10px;
}

#mainWindow { display: block; }

/* mobile-only nav (hamburger topbar + slide-in sidebar) - hidden on desktop,
   shown instead of the dhtmlx tab bar inside the mobile media query below */
#mobile-topbar { display: none; }
#mobile-nav-overlay { display: none; }
#mobile-nav { display: none; }

/* left rail */
#aside {
    position: fixed; top: var(--menubar-h); left: 0; bottom: 0; z-index: 4000;
    width: var(--rail-w);
    display: flex; flex-direction: column; align-items: center;
    background: rgba(255,255,255,.66);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--stroke);
    padding: 8px 0;
    overflow-y: auto; overflow-x: hidden;
}
#aside .top-menu { flex: 1; width: 100%; }
#aside .bottom-menu { width: 100%; }
#aside .menu-item {
    position: relative;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; width: calc(100% - 12px); margin: 2px 6px;
    padding: 9px 0; border-radius: 6px; cursor: pointer;
    color: var(--text-2);
}
#aside .menu-item i { font-size: 17px; color: var(--text-2); }
#aside .menu-item span { font-size: 9.5px; line-height: 1; }
#aside .menu-item:hover, #aside .menu-item.active { background: var(--accent-light); }
#aside .menu-item:hover i, #aside .menu-item.active i,
#aside .menu-item:hover span, #aside .menu-item.active span { color: var(--accent-dark); }
#aside .menu-item:not(.plus).active::before {
    content: ""; position: absolute; left: -6px; top: 20%; bottom: 20%;
    width: 3px; border-radius: 2px; background: var(--accent);
}
#aside .menu-item.user img.user-img {
    width: 34px; height: 34px; border-radius: 50%; object-fit: cover;
    border: 2px solid var(--stroke);
}
#aside .menu-item.user:hover img.user-img { border-color: var(--accent); }
#sideAdd .menu-item.plus i { font-size: 26px; color: var(--accent); }
#aside .indicator {
    position: absolute; top: 4px; right: 10px;
    min-width: 15px; height: 15px; padding: 0 4px;
    display: none; align-items: center; justify-content: center;
    background: var(--danger); color: #fff;
    font-size: 9px; font-weight: 700; border-radius: 8px;
}
#aside .indicator.on { display: flex; }

/* main surface */
#main {
    margin-left: var(--rail-w);
    padding-top: var(--menubar-h);
    height: 100vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
#main .main-content { padding: 6px 16px 30px; }

/* command bar (page-breadcrumb keeps its name - hidePages() relies on it) */
.page-breadcrumb {
    display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
    margin: 12px 16px 4px; padding: 10px 16px;
    background: rgba(255,255,255,.74);
    backdrop-filter: blur(18px);
    border: 1px solid var(--stroke); border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.page-breadcrumb .page-id { display: flex; align-items: center; gap: 10px; margin-right: auto; }
.page-breadcrumb .page-id > i { font-size: 22px; color: var(--accent); }
#page_data_title { font-size: 14.5px; font-weight: 600; }
#page_data_subtitle { font-size: 11px; color: var(--text-2); }
.page-breadcrumb label { font-size: 12px; font-weight: 600; color: var(--text-2); }
.page-breadcrumb select, .page-breadcrumb input[role="date"] {
    padding: 6px 9px; font: inherit; font-size: 12.5px;
    border: 1px solid var(--stroke); border-radius: 4px; outline: none; background: #fff;
}
.page-breadcrumb input[role="date"] { width: 105px; }
.clock-chip {
    display: inline-flex; align-items: center; gap: 4px;
    background: var(--accent); color: #fff;
    padding: 5px 12px; border-radius: 4px;
    font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums;
}
#reload-icon i { color: var(--accent); font-size: 14px; }
a#date_save {
    padding: 6px 16px; border-radius: 4px; background: var(--accent);
    color: #fff; font-size: 12px; font-weight: 600;
}
a#date_save:hover { background: var(--accent-dark); }
a[role="new_form"] {
    padding: 6px 16px; border-radius: 4px;
    border: 1px solid var(--accent); color: var(--accent);
    font-size: 12px; font-weight: 600; background: transparent;
}
a[role="new_form"]:hover { background: var(--accent-lighter); }

/* =====================================================================
   MENU ENGINE (dhtmlx material) - Fluent overrides
   ===================================================================== */
#menuObj .dhtmlxMenu_material_Middle { background: transparent; }
#menuObj div[class*="TopLevel_Item"] {
    font-family: "Segoe UI", sans-serif !important;
    font-size: 13px; border-radius: 4px;
}
#menuObj .dhtmlxMenu_material_TopLevel_Item_Selected {
    background: var(--accent-light) !important;
    color: var(--accent-dark) !important;
}
div.dhtmlxMenu_material_SubLevelArea_Polygon {
    /* engine sets a low inline z-index - keep dropdowns above the rail (4000),
       menubar (5000) and flyouts so nothing covers them */
    z-index: 100010 !important;
    border-radius: var(--radius) !important;
    border: 1px solid var(--stroke) !important;
    box-shadow: var(--shadow-lg) !important;
    font-family: "Segoe UI", sans-serif !important;
}
div.dhtmlxMenu_material_SubLevelArea_Polygon tr.sub_item_selected td { background: var(--accent-lighter) !important; }
div.dhtmlxMenu_material_SubLevelArea_Polygon i { color: var(--accent); }

/* =====================================================================
   POPUP WINDOWS (create / edit / onin)
   ===================================================================== */
.popup {
    position: fixed; inset: 0; z-index: 9500;
    display: flex; align-items: center; justify-content: center;
    background: rgba(0,0,0,.30);
}
.window {
    background: #fff;
    border: 1px solid var(--stroke);
    border-radius: 12px;
    box-shadow: 0 20px 50px rgba(32, 31, 30, .16);
    overflow: hidden;
    max-height: 92vh; display: flex; flex-direction: column;
}
.window .title-bar {
    display: flex; align-items: center; justify-content: space-between;
    background: #fff; color: var(--text);
    padding: 18px 22px 14px; cursor: move; user-select: none;
    border-bottom: 1px solid var(--stroke);
}
.window .title-bar-text {
    font-weight: 600; font-size: 15px; color: var(--text);
    display: flex; align-items: center; gap: 10px;
}
.window .title-bar-text::before {
    content: ""; width: 4px; height: 18px; border-radius: 2px;
    background: var(--accent); display: inline-block;
}
.title-bar-controls .close-btn {
    width: 30px; height: 30px; border: none; border-radius: 6px;
    background: transparent; color: var(--text-2); cursor: pointer; font-size: 14px; line-height: 1;
    transition: background .12s, color .12s;
}
.title-bar-controls .close-btn::before { content: "\2715"; }
.title-bar-controls .close-btn:hover { background: var(--danger-bg); color: var(--danger); }
.window-body { padding: 18px 22px 8px; overflow-y: auto; }
.button-container {
    padding: 14px 22px 16px; display: flex; justify-content: space-between; align-items: center;
    background: #fff;
    border-top: 1px solid var(--stroke);
}
.error_error { font-size: 11.5px; }
.buttons button, button[role="save"], button[role="update"], button[role="onin"], button[role="close"] {
    font: inherit; font-size: 12.5px; font-weight: 600;
    padding: 8px 22px; margin-left: 8px;
    border-radius: 6px; cursor: pointer;
    background: var(--accent); color: #fff; border: 1px solid var(--accent);
    transition: background .12s;
}
.buttons button:hover { background: var(--accent-dark); }
button[role="close"] { background: #fff !important; color: var(--text) !important; border: 1px solid var(--stroke) !important; }
button[role="close"]:hover { background: var(--bg) !important; }
button:disabled { opacity: .45; cursor: not-allowed; }

/* =====================================================================
   FORMS (div.insert pattern)
   ===================================================================== */
.insert form { margin: 0; }
.flexholder { display: flex; gap: 14px; flex-wrap: wrap; }
.flexitem { flex: 1; min-width: 270px; }
.insert fieldset {
    border: 1px solid var(--stroke); border-radius: var(--radius);
    padding: 10px 14px 14px; margin: 0 0 10px;
    background: #fff;
}
.insert legend { padding: 0 6px; font-weight: 600; font-size: 12.5px; color: var(--accent-dark); }
.insert table { width: 100%; border-collapse: collapse; }
.insert table td { padding: 5px 4px; vertical-align: middle; }
.insert table td:first-child { width: 38%; }
.insert label { font-size: 12.5px; color: var(--text-2); }
.insert input, .insert select, .insert textarea {
    width: 100%; padding: 8px 10px; font: inherit; font-size: 12.5px;
    color: var(--text); background: #fff;
    border: 1px solid var(--stroke);
    border-radius: 4px; outline: none; resize: vertical;
}
.insert input:focus, .insert select:focus, .insert textarea:focus { border-color: var(--accent); }
.form-loader { opacity: .6; pointer-events: none; }

/* select2 sizing to match inputs */
.select2-container { width: 100% !important; font-size: 12.5px; }
.select2-container .select2-selection--single { height: 34px; border: 1px solid var(--stroke); border-radius: 4px; }
.select2-container--default .select2-selection--single .select2-selection__rendered { line-height: 32px; }
.select2-container--default .select2-selection--single .select2-selection__arrow { height: 32px; }
.select2-dropdown { border: 1px solid var(--stroke); border-radius: 6px; box-shadow: var(--shadow-lg); font-size: 12.5px; }
.select2-container--default .select2-results__option--highlighted[aria-selected] { background: var(--accent); }

/* =====================================================================
   DATA TABLES
   ===================================================================== */
#main_main { padding: 8px 2px; }
table.dataTable { font-size: 12.5px; }
table.dataTable thead th {
    background: var(--accent-lighter); color: var(--text);
    font-weight: 600; border-bottom: 1px solid var(--stroke);
}
table.dataTable tbody tr:hover { background: var(--accent-lighter); }
table.dataTable td { vertical-align: middle; }
.left-text { text-align: left !important; }
.dataTables_wrapper { background: var(--card); border: 1px solid var(--stroke); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px; }
.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--accent) !important; color: #fff !important;
    border-radius: 4px; border-color: var(--accent) !important;
}

/* =====================================================================
   REUSABLE FLUENT COMPONENTS (cards, pills, buttons, flyouts)
   ===================================================================== */
.ms-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin: 10px 0 16px; }
.ms-card {
    background: var(--card); border: 1px solid var(--stroke); border-radius: var(--radius);
    padding: 14px 16px;
    transition: transform .12s ease, border-color .12s ease;
}
.ms-card:hover { transform: translateY(-2px); border-color: var(--accent); }
.ms-card .ms-card-icon {
    width: 38px; height: 38px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 17px; margin-bottom: 10px;
    background: var(--accent-light); color: var(--accent-dark);
}
.ms-card .ms-card-value { font-size: 22px; font-weight: 700; }
.ms-card .ms-card-label { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.ms-card.green  .ms-card-icon { background: var(--success-bg); color: var(--success); }
.ms-card.orange .ms-card-icon { background: var(--warning-bg); color: var(--warning); }
.ms-card.red    .ms-card-icon { background: var(--danger-bg); color: var(--danger); }
.ms-card.purple .ms-card-icon { background: var(--purple-bg); color: var(--purple); }

.ms-panel {
    background: var(--card); border: 1px solid var(--stroke); border-radius: var(--radius);
    padding: 14px 16px; margin-bottom: 14px;
}
.ms-panel h4 { margin: 0 0 10px; font-size: 14px; font-weight: 600; }

.ms-pill { display: inline-block; padding: 2px 10px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.ms-pill.blue   { background: var(--accent-light); color: var(--accent-dark); }
.ms-pill.green  { background: var(--success-bg); color: var(--success); }
.ms-pill.orange { background: var(--warning-bg); color: var(--warning); }
.ms-pill.red    { background: var(--danger-bg); color: var(--danger); }
.ms-pill.grey   { background: #F3F2F1; color: var(--text-2); }

.ms-btn {
    display: inline-block; padding: 4px 10px; margin: 0 2px;
    border-radius: 4px; border: 1px solid var(--stroke);
    background: #fff; color: var(--text); font-size: 11.5px; font-weight: 600;
    cursor: pointer; white-space: nowrap;
}
.ms-btn:hover { border-color: var(--accent); color: var(--accent-dark); background: var(--accent-lighter); }
.ms-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.ms-btn.primary:hover { background: var(--accent-dark); }
.ms-btn.danger:hover { border-color: var(--danger); color: var(--danger); background: var(--danger-bg); }

/* row actions: desktop = single kebab button opening a context menu of the same
   actions; mobile (see media query below) reverts to a plain row of .ms-btn pills */
.row-actions { position: relative; display: inline-flex; }
.ms-kebab {
    width: 30px; height: 30px; border-radius: 50%; /* always a round icon button */
    border: 1px solid var(--stroke); background: #fff; color: var(--text-2);
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer; font-size: 13px; padding: 0;
}
.ms-kebab:hover { background: var(--accent-lighter); border-color: var(--accent); color: var(--accent-dark); }

/* desktop-only: the dropdown card + its list-style menu rows */
@media (min-width: 721px) {
    .row-actions-menu {
        display: none; position: absolute; right: 0; top: 36px; z-index: 500;
        min-width: 180px; background: #fff; border: 1px solid var(--stroke);
        border-radius: 10px; box-shadow: var(--shadow-lg);
        padding: 6px; flex-direction: column; gap: 2px;
    }
    .row-actions-menu.open { display: flex; }
    .row-actions-menu .ms-btn {
        display: flex; align-items: center; gap: 8px; justify-content: flex-start;
        width: 100%; margin: 0; padding: 8px 10px; border-radius: 6px;
        border: none; background: transparent; color: var(--text); font-size: 12.5px; font-weight: 500;
    }
    .row-actions-menu .ms-btn:hover { background: var(--accent-lighter); color: var(--text); }
    .row-actions-menu .ms-btn.primary { color: var(--accent-dark); font-weight: 600; }
    .row-actions-menu .ms-btn.danger:hover { background: var(--danger-bg); color: var(--danger); }
    /* labels auto-appended (in JS) to icon-only buttons like the bare trash icon,
       so a plain icon reads as a real menu item once it's a dropdown row */
    .ms-btn-menu-label { display: inline; }
}

.ms-flyout {
    position: fixed; top: 0; right: 0; height: 100vh; width: 360px;
    background: rgba(255,255,255,.93); backdrop-filter: blur(30px);
    border-left: 1px solid var(--stroke); box-shadow: -8px 0 24px rgba(0,0,0,.12);
    z-index: 10050; display: flex; flex-direction: column;
    animation: msSlideIn .18s ease;
}
@keyframes msSlideIn { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.ms-flyout-head {
    padding: 16px 18px; border-bottom: 1px solid var(--stroke);
    display: flex; align-items: center; justify-content: space-between;
    font-weight: 600; font-size: 15px;
}
.ms-flyout-head i.close { cursor: pointer; color: var(--text-2); }
.ms-flyout-body { flex: 1; overflow-y: auto; padding: 10px 14px; }
.ms-notif {
    border: 1px solid var(--stroke); border-radius: var(--radius);
    padding: 10px 12px; margin-bottom: 8px; background: #fff;
}
.ms-notif.unread { border-left: 3px solid var(--accent); background: var(--accent-lighter); }
.ms-notif .t { font-weight: 600; font-size: 12.5px; }
.ms-notif .m { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.ms-notif .d { font-size: 10.5px; color: var(--text-3); margin-top: 4px; }
#ms-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.25); z-index: 10040; }

/* =====================================================================
   QUICK-CREATE PANEL + CONTEXT MENU
   ===================================================================== */
#new_menu {
    display: none; position: fixed; top: calc(var(--menubar-h) + 10px); left: calc(var(--rail-w) + 10px);
    z-index: 9000; max-width: 720px;
    background: rgba(255,255,255,.95); backdrop-filter: blur(30px);
    border: 1px solid var(--stroke); border-radius: var(--radius);
    box-shadow: var(--shadow-lg); padding: 14px;
}
#new_menu ul { display: flex; flex-wrap: wrap; gap: 12px; list-style: none; margin: 0; padding: 0; }
#new_menu fieldset { border: 1px solid var(--stroke); border-radius: 6px; min-width: 170px; padding: 6px 10px 10px; }
#new_menu legend { font-size: 11.5px; font-weight: 700; color: var(--accent-dark); padding: 0 5px; }
#new_menu li { padding: 6px 8px; border-radius: 4px; cursor: pointer; }
#new_menu li:hover { background: var(--accent-lighter); }
#new_menu li a { color: var(--text); font-size: 12.5px; }

.context-menu { display: none; }

/* =====================================================================
   ONE UI THEME (mobile, whole system)
   ===================================================================== */
@media (max-width: 720px) {

    /* ---- logins: full-screen, white background ---- */
    .loginer { background: #fff; padding: 0 26px; }
    .login-form, .login-options fieldset {
        width: 100%; max-width: 420px;
        border: none; border-top: none; border-radius: 0;
        padding: 10px 0 0;
        background: #fff;
    }
    .owner-logo { max-width: 250px; margin-bottom: 26px; }
    .login-form h3 { font-size: 24px; font-weight: 700; letter-spacing: -0.3px; margin-bottom: 26px; }
    .login-form input {
        padding: 14px 14px 14px 42px;
        border-radius: 14px; background: #F5F4F0;
        border-color: transparent;
    }
    .login-form input:focus { border-color: var(--accent); background: #fff; }
    .login-form .input-container { margin-bottom: 12px; }
    .login-form a[role="login-btn"],
    .login-form a[role="code-btn"] { border-radius: 26px; padding: 14px 0; font-size: 14.5px; margin-top: 12px; }
    .login-switch { border-radius: 26px; background: #F5F4F0; border-color: transparent; }
    .login-switch a { padding: 11px 0; border-radius: 23px; font-size: 13px; }
    .pick-card { border-radius: 18px; padding: 18px 8px; }
    .tiny-footnote { background: #fff; padding: 10px 0 16px; }

    /* ---- staff shell: rail becomes One UI bottom nav ---- */
    /* the dhtmlx tab bar wraps into several rows on narrow screens - replace it
       with a slim topbar + hamburger that opens a full slide-in sidebar instead */
    #menuObj { display: none; }
    #mobile-topbar {
        display: flex; align-items: center; gap: 12px;
        position: fixed; top: 0; left: 0; right: 0; height: var(--menubar-h); z-index: 5000;
        background: rgba(255,255,255,.9); backdrop-filter: blur(20px);
        border-bottom: 1px solid var(--stroke); padding: 0 14px;
    }
    #mobile-menu-toggle {
        width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--stroke);
        background: #fff; color: var(--text); font-size: 15px;
        display: flex; align-items: center; justify-content: center; cursor: pointer;
    }
    #mobile-menu-toggle:active { background: var(--accent-lighter); border-color: var(--accent); color: var(--accent-dark); }
    .mobile-topbar-logo { height: 26px; }

    #mobile-nav-overlay {
        position: fixed; inset: 0; z-index: 9500; background: rgba(0,0,0,.4);
        opacity: 0; pointer-events: none; transition: opacity .2s ease;
    }
    #mobile-nav-overlay.show { display: block; opacity: 1; pointer-events: auto; }
    #mobile-nav {
        display: flex; flex-direction: column;
        position: fixed; top: 0; left: 0; bottom: 0; z-index: 9600;
        width: 84vw; max-width: 320px; background: #fff;
        box-shadow: 8px 0 28px rgba(0,0,0,.18);
        transform: translateX(-105%); transition: transform .25s ease;
    }
    #mobile-nav.open { transform: translateX(0); }
    .mobile-nav-head {
        display: flex; align-items: center; justify-content: space-between;
        padding: 16px 14px; border-bottom: 1px solid var(--stroke); flex-shrink: 0;
    }
    .mobile-nav-logo { height: 30px; }
    #mobile-nav-close {
        width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--stroke);
        background: #fff; color: var(--text-2); display: flex; align-items: center; justify-content: center;
        cursor: pointer;
    }
    .mobile-nav-body {
        flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
        padding: 8px 0 calc(16px + env(safe-area-inset-bottom));
    }
    .mn-group-head, .mn-item {
        display: flex; align-items: center; gap: 12px;
        padding: 13px 16px 13px calc(16px + (var(--mn-depth, 0) * 18px));
        cursor: pointer; font-size: 13.5px; color: var(--text);
        border-bottom: 1px solid #F6F5F1;
    }
    .mn-group-head { justify-content: space-between; font-weight: 600; }
    .mn-group-head .mn-label { display: flex; align-items: center; gap: 12px; }
    .mn-group-head i:not(.chevron), .mn-item > i { width: 18px; text-align: center; color: var(--accent); font-size: 14px; }
    .mn-group-head .chevron { font-size: 11px; color: var(--text-3); transition: transform .2s ease; }
    .mn-group.open > .mn-group-head .chevron { transform: rotate(90deg); }
    .mn-group-head:active, .mn-item:active { background: var(--accent-lighter); }
    .mn-group-items { display: none; background: #FAFAF7; }
    .mn-group.open > .mn-group-items { display: block; }
    #aside {
        top: auto; bottom: 0; left: 0; right: 0; width: 100%; height: 68px;
        flex-direction: row; align-items: center;
        border-right: none; border-top: 1px solid var(--stroke);
        background: rgba(255,255,255,.97); backdrop-filter: blur(20px);
        padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
        overflow-x: auto; overflow-y: hidden; z-index: 6000;
    }
    #aside .top-menu, #aside .bottom-menu, #sideAdd { display: flex; flex: none; width: auto; align-items: center; }
    #aside .top-menu { flex: 1; justify-content: space-around; }
    #aside .menu-item { width: 54px; min-width: 54px; margin: 0 1px; padding: 7px 0; border-radius: 16px; }
    #aside .menu-item span { font-size: 9px; white-space: nowrap; }
    #aside .menu-item:not(.plus).active::before { display: none; }
    #aside .indicator { top: 0; right: 6px; }
    #main { margin-left: 0; padding-top: calc(var(--menubar-h) + 4px); padding-bottom: 96px; }
    #main .main-content { padding: 4px 10px 30px; }

    /* ---- bottom nav overflow: "More" trigger + bottom sheet ---- */
    #aside .menu-item.more-trigger i { font-size: 17px; }
    #more-sheet-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 6900; }
    #more-sheet {
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 7000;
        background: #fff; border-radius: 26px 26px 0 0;
        box-shadow: 0 -8px 24px rgba(0,0,0,.14);
        padding: 8px 10px calc(14px + env(safe-area-inset-bottom));
        max-height: 60vh; overflow-y: auto;
    }
    #more-sheet .more-sheet-handle {
        width: 36px; height: 4px; border-radius: 2px; background: var(--stroke);
        margin: 8px auto 12px;
    }
    #more-sheet .more-sheet-grid {
        display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
    }
    /* items are moved OUT of #aside into this grid, so they need their own
       complete styling - the "#aside .menu-item" base rules no longer apply
       once a node is a descendant of #more-sheet instead */
    #more-sheet .menu-item {
        position: relative; display: flex; flex-direction: column;
        align-items: center; justify-content: center; gap: 6px;
        width: auto; margin: 0; padding: 14px 4px;
        border-radius: 16px; cursor: pointer; color: var(--text-2);
    }
    #more-sheet .menu-item i { font-size: 20px; color: var(--text-2); }
    #more-sheet .menu-item span { font-size: 10.5px; line-height: 1.2; white-space: normal; text-align: center; }
    #more-sheet .menu-item:hover,
    #more-sheet .menu-item:active { background: var(--accent-light); }
    #more-sheet .menu-item:hover i, #more-sheet .menu-item:active i,
    #more-sheet .menu-item:hover span, #more-sheet .menu-item:active span { color: var(--accent-dark); }
    #more-sheet .menu-item.user img.user-img {
        width: 34px; height: 34px; border-radius: 50%; object-fit: cover;
        border: 2px solid var(--stroke);
    }
    #more-sheet .indicator {
        position: absolute; top: 4px; right: 10px;
        min-width: 15px; height: 15px; padding: 0 4px;
        display: none; align-items: center; justify-content: center;
        background: var(--danger); color: #fff;
        font-size: 9px; font-weight: 700; border-radius: 8px;
    }
    #more-sheet .indicator.on { display: flex; }

    /* ---- command bar: One UI big-title header ---- */
    .page-breadcrumb {
        flex-direction: column; align-items: stretch; gap: 10px;
        margin: 10px 10px 4px; padding: 16px 16px 12px; border-radius: 22px;
    }
    .page-breadcrumb .page-id { margin-right: 0; }
    #page_data_title { font-size: 21px; font-weight: 700; letter-spacing: -0.3px; }
    .page-breadcrumb select, .page-breadcrumb input[role="date"] { border-radius: 16px; padding: 9px 12px; }
    a#date_save, a[role="new_form"] { border-radius: 20px; padding: 9px 18px; text-align: center; }

    /* ---- cards, panels, buttons: One UI radii ---- */
    .ms-card, .ms-panel, .dataTables_wrapper, .ms-notif { border-radius: 20px; }
    .ms-cards { grid-template-columns: 1fr 1fr; }
    .ms-btn { border-radius: 18px; padding: 7px 13px; }
    .ms-flyout { width: 100%; }

    /* dashboard grids stack */
    #main_main [style*="grid-template-columns"] { grid-template-columns: 1fr !important; }

    /* ---- popups become One UI bottom sheets ---- */
    .popup { align-items: flex-end; }
    .popup .window {
        width: 100% !important; max-width: 100% !important; min-width: 0 !important;
        max-height: 90vh;
        border: none; border-radius: 26px 26px 0 0;
        padding-bottom: env(safe-area-inset-bottom);
    }
    .window .title-bar { justify-content: center; padding-top: 20px; }
    .window .title-bar .title-bar-text { font-size: 16px; }
    .title-bar-controls { position: absolute; right: 14px; }
    .button-container { border-top: none; padding-bottom: 20px; }
    .button-container .buttons { display: flex; width: 100%; }
    .buttons button, button[role="save"], button[role="update"], button[role="onin"], button[role="close"] {
        flex: 1; padding: 13px 0 !important; border-radius: 24px !important; font-size: 14px;
    }
    .flexholder { flex-direction: column; }
    .insert fieldset { border-radius: 18px; }
    .insert input, .insert select, .insert textarea { padding: 11px 12px; border-radius: 12px; }

    /* confirm dialogs (returns/extends) as bottom sheets */
    #ms-confirm {
        top: auto !important; bottom: 0 !important; left: 0 !important;
        transform: none !important; width: 100% !important; max-width: 100% !important;
        border-radius: 26px 26px 0 0 !important;
        padding-bottom: env(safe-area-inset-bottom);
    }
    #ms-confirm button { border-radius: 24px !important; padding: 12px 24px !important; }

    /* quick-create panel as bottom sheet */
    #new_menu {
        top: auto; left: 0; right: 0; bottom: 0; max-width: 100%;
        border-radius: 26px 26px 0 0; border: none;
        max-height: 75vh; overflow-y: auto;
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
    }
    #new_menu fieldset { min-width: 100%; border-radius: 16px; }
    #new_menu li { padding: 11px 10px; border-radius: 12px; }

    /* datatable chrome */
    table.dataTable { font-size: 12px; }
    .dataTables_wrapper { padding: 12px 10px; }
    div.dataTables_wrapper div.dataTables_filter input { border-radius: 16px; }
    div.dataTables_wrapper div.dataTables_length select { border-radius: 12px; }

    /* ---- DataTables as One UI cards (no scrolling, no click-to-expand) ---- */
    table.dataTable.dtr-inline.collapsed { table-layout: auto; }
    table.dataTable thead { display: none; }
    table.dataTable, table.dataTable tbody { display: block; width: 100%; }
    table.dataTable tbody tr {
        display: block; width: 100%; margin-bottom: 10px;
        background: var(--card); border: 1px solid var(--stroke); border-radius: 18px;
        padding: 12px 14px;
    }
    table.dataTable tbody tr td {
        display: flex; justify-content: space-between; align-items: center; gap: 12px;
        border: none !important; padding: 5px 0 !important; text-align: right; white-space: normal;
    }
    table.dataTable tbody tr td::before {
        content: attr(data-label);
        font-weight: 600; color: var(--text-2); text-align: left; flex-shrink: 0; padding-right: 8px;
    }
    /* action buttons: no label, full width, wrap */
    table.dataTable tbody tr td:last-child {
        justify-content: flex-end; flex-wrap: wrap; padding-top: 10px !important;
        border-top: 1px solid #F3F2F1 !important; margin-top: 4px;
    }
    table.dataTable tbody tr td:last-child::before { content: none; }
    table.dataTable tbody tr td.dtr-control { display: none; }
    table.dataTable td.child { display: none; } /* not needed: all columns already shown */

    /* row actions on mobile: no kebab/dropdown, just the plain (rounded) button row
       as before - the desktop-only dropdown rules above simply don't apply here */
    .ms-kebab { display: none; }
    .row-actions { display: flex; width: 100%; justify-content: flex-end; }
    .row-actions-menu { display: flex; flex-direction: row; flex-wrap: wrap; justify-content: flex-end; gap: 4px; }
    .ms-btn-menu-label { display: none; } /* icon-only buttons stay icon-only pills on mobile */
}

/* misc */
.darkable { position: fixed; inset: 0; z-index: 8000; background: rgba(0,0,0,.35); }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #C8C6C4; border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: #A19F9D; }
