/* ELARA X12 — device safe-area + strict live theme parity. No structural layout changes. */
:root{
  --elara-safe-top:env(safe-area-inset-top,0px);
  --elara-safe-right:env(safe-area-inset-right,0px);
  --elara-safe-bottom:env(safe-area-inset-bottom,0px);
  --elara-safe-left:env(safe-area-inset-left,0px);
}
html,body,#root,.admin-shell,.admin-main{min-height:100%;min-height:100dvh}

/* Strict shell palette: expanded drawers must never inherit the opposite theme. */
html[data-theme="dark"] .sidebar{background:#0c1b2d!important;color:#edf6ff!important;border-color:#29435f!important}
html[data-theme="dark"] .sidebar-head{background:#0c1b2d!important;color:#edf6ff!important;border-color:#29435f!important}
html[data-theme="dark"] .sidebar-user{background:#0d2235!important;color:#edf6ff!important;border-color:#29435f!important}
html[data-theme="dark"] .sidebar .menu-group.collapsible{background:transparent!important;border-color:transparent!important;color:#edf6ff!important}
html[data-theme="dark"] .sidebar .menu-group.collapsible.expanded,
html[data-theme="dark"] .sidebar .menu-group.collapsible.has-active{background:#0d2235!important;border:1px solid #29435f!important}
html[data-theme="dark"] .sidebar .menu-group-title{background:transparent!important;color:#edf6ff!important}
html[data-theme="dark"] .sidebar .menu-group-title span,
html[data-theme="dark"] .sidebar .menu-group-title strong{color:#edf6ff!important}
html[data-theme="dark"] .sidebar .menu-group-title b{background:#173653!important;color:#9fb5c9!important}
html[data-theme="dark"] .sidebar .menu-group-items{background:transparent!important}
html[data-theme="dark"] .sidebar .menu-group-items a{background:transparent!important;color:#a9bfd2!important;border-right-color:#29435f!important}
html[data-theme="dark"] .sidebar .menu-group-items a:hover{background:#132c46!important;color:#fff!important}
html[data-theme="dark"] .sidebar .menu-group-items a.active,
html[data-theme="dark"] .sidebar .menu-group-items a.is-current-route{background:#173653!important;color:#fff!important;border-right-color:#e6a848!important}

html[data-theme="light"] .sidebar{background:#fff!important;color:#172638!important;border-color:#d7e0e9!important}
html[data-theme="light"] .sidebar-head{background:#fff!important;color:#172638!important;border-color:#d7e0e9!important}
html[data-theme="light"] .sidebar-user{background:#f7f9fc!important;color:#172638!important;border-color:#d7e0e9!important}
html[data-theme="light"] .sidebar .menu-group.collapsible{background:transparent!important;border-color:transparent!important;color:#172638!important}
html[data-theme="light"] .sidebar .menu-group.collapsible.expanded,
html[data-theme="light"] .sidebar .menu-group.collapsible.has-active{background:#f7f9fc!important;border:1px solid #d7e0e9!important}
html[data-theme="light"] .sidebar .menu-group-title{background:transparent!important;color:#21364a!important}
html[data-theme="light"] .sidebar .menu-group-title span,
html[data-theme="light"] .sidebar .menu-group-title strong{color:#21364a!important}
html[data-theme="light"] .sidebar .menu-group-title b{background:#e1eaf3!important;color:#526d84!important}
html[data-theme="light"] .sidebar .menu-group-items{background:transparent!important}
html[data-theme="light"] .sidebar .menu-group-items a{background:transparent!important;color:#526b82!important;border-right-color:#d7e0e9!important}
html[data-theme="light"] .sidebar .menu-group-items a:hover{background:#eef4fa!important;color:#173b62!important}
html[data-theme="light"] .sidebar .menu-group-items a.active,
html[data-theme="light"] .sidebar .menu-group-items a.is-current-route{background:#e8f0f8!important;color:#173b62!important;border-right-color:#c8871d!important}

/* Explicit top/bottom shell surfaces for both themes. */
html[data-theme="dark"] .admin-header,
html[data-theme="dark"] .mobile-bottom-nav{background:rgba(12,27,45,.97)!important;color:#edf6ff!important;border-color:#29435f!important}
html[data-theme="light"] .admin-header,
html[data-theme="light"] .mobile-bottom-nav{background:rgba(255,255,255,.97)!important;color:#172638!important;border-color:#d7e0e9!important}
html[data-theme="dark"] .admin-header .header-actions button{background:#11243a!important;color:#edf6ff!important;border-color:#29435f!important}
html[data-theme="light"] .admin-header .header-actions button{background:#f5f8fb!important;color:#172638!important;border-color:#d7e0e9!important}

/* Core cards/lists/tables that older screens may have hard-coded. */
html[data-theme="dark"] .admin-content :where(.panel,.card,.content-card,.section-card,.info-card,.detail-card,.profile-card,.finance-card,.accounting-card,.form-card,.settings-card,.empty-state,.modal,dialog,.module-host-panel,[class*="-card"]){background:#0c1b2d!important;color:#edf6ff!important;border-color:#29435f!important}
html[data-theme="dark"] .admin-content :where(.list-row,.entity-row,.conversation-row,.notification-page-list>article,.list-wrap,.table-wrap,.filter-bar,.filters,.toolbar,.tabs,.tab-list,.profile-nav,.basic-settings-nav){background:#11243a!important;color:#edf6ff!important;border-color:#29435f!important}
html[data-theme="dark"] .admin-content :where(table,thead,tbody,tr){border-color:#29435f!important}
html[data-theme="dark"] .admin-content th{background:#11243a!important;color:#9fb5c9!important;border-color:#29435f!important}
html[data-theme="dark"] .admin-content td{background:#0c1b2d!important;color:#edf6ff!important;border-color:#29435f!important}
html[data-theme="light"] .admin-content :where(.panel,.card,.content-card,.section-card,.info-card,.detail-card,.profile-card,.finance-card,.accounting-card,.form-card,.settings-card,.empty-state,.modal,dialog,.module-host-panel,[class*="-card"]){background:#fff!important;color:#172638!important;border-color:#d7e0e9!important}
html[data-theme="light"] .admin-content :where(.list-row,.entity-row,.conversation-row,.notification-page-list>article,.list-wrap,.table-wrap,.filter-bar,.filters,.toolbar,.tabs,.tab-list,.profile-nav,.basic-settings-nav){background:#f5f8fb!important;color:#172638!important;border-color:#d7e0e9!important}
html[data-theme="light"] .admin-content :where(table,thead,tbody,tr){border-color:#d7e0e9!important}
html[data-theme="light"] .admin-content th{background:#f5f8fb!important;color:#65798d!important;border-color:#d7e0e9!important}
html[data-theme="light"] .admin-content td{background:#fff!important;color:#172638!important;border-color:#d7e0e9!important}

/* Legal/editor paper remains paper-white in either theme. */
html[data-theme] :where(.contract-paper,.contract-body,.contract-frame-preview,.contract-a4-frame,.word-canvas,.word-editor,.rich-editor .editor,.signature-pad,.document-preview,.print-preview,.a4-page,[data-paper="1"]){color-scheme:light!important}

/* iOS/Android cutouts: consume system-provided safe-area only where the app shell touches screen edges. */
@media(max-width:800px){
  body{padding-top:0!important;padding-right:0!important;padding-left:0!important;min-height:100dvh!important}
  .admin-shell,.admin-main{min-height:100dvh!important}
  .admin-header{
    box-sizing:border-box!important;
    top:0!important;
    height:calc(58px + var(--elara-safe-top))!important;
    min-height:calc(58px + var(--elara-safe-top))!important;
    padding-top:var(--elara-safe-top)!important;
    padding-right:calc(10px + var(--elara-safe-right))!important;
    padding-left:calc(10px + var(--elara-safe-left))!important;
  }
  .sidebar{
    top:0!important;
    bottom:0!important;
    height:100dvh!important;
    min-height:100dvh!important;
    padding-top:0!important;
    padding-right:var(--elara-safe-right)!important;
    padding-left:var(--elara-safe-left)!important;
  }
  .sidebar-head{
    box-sizing:border-box!important;
    height:calc(62px + var(--elara-safe-top))!important;
    min-height:calc(62px + var(--elara-safe-top))!important;
    padding-top:var(--elara-safe-top)!important;
  }
  .sidebar nav{padding-bottom:calc(112px + var(--elara-safe-bottom))!important}
  .sidebar-user{margin-bottom:calc(15px + var(--elara-safe-bottom))!important}
  .admin-content{padding-bottom:calc(86px + var(--elara-safe-bottom))!important}
  .mobile-bottom-nav{
    box-sizing:border-box!important;
    min-height:calc(64px + var(--elara-safe-bottom))!important;
    padding-right:calc(6px + var(--elara-safe-right))!important;
    padding-left:calc(6px + var(--elara-safe-left))!important;
    padding-bottom:calc(5px + var(--elara-safe-bottom))!important;
  }
  .notification-popover{top:calc(64px + var(--elara-safe-top))!important}
  .modal-wrap{padding-top:var(--elara-safe-top)!important;padding-right:var(--elara-safe-right)!important;padding-left:var(--elara-safe-left)!important}
  .modal{max-height:calc(100dvh - var(--elara-safe-top))!important;padding-bottom:calc(14px + var(--elara-safe-bottom))!important}
}

/* Standalone admin pages opened inside the installed PWA. */
@media(max-width:800px){
  .topbar{
    box-sizing:border-box!important;
    top:0!important;
    height:calc(72px + var(--elara-safe-top))!important;
    min-height:calc(72px + var(--elara-safe-top))!important;
    padding-top:var(--elara-safe-top)!important;
    padding-right:calc(12px + var(--elara-safe-right))!important;
    padding-left:calc(12px + var(--elara-safe-left))!important;
  }
}

html[data-theme="dark"] .admin-content :where(h1,h2,h3,h4,h5,h6,.page-title,.page-title h1,.page-title h2,.section-title,.card-title,.list-title){color:#edf6ff!important}
html[data-theme="dark"] .admin-content :where(p,small,.page-title p,.subtitle,.muted){color:#9fb5c9!important}
html[data-theme="light"] .admin-content :where(h1,h2,h3,h4,h5,h6,.page-title,.page-title h1,.page-title h2,.section-title,.card-title,.list-title){color:#172638!important}
html[data-theme="light"] .admin-content :where(p,small,.page-title p,.subtitle,.muted){color:#65798d!important}

/* ELARA X13 — PWA install is modal-only. Legacy persistent install controls stay hidden. */
.install-app-button,
.pwa-install-settings {
  display: none !important;
}
