/* ============================================================
   Revoloox Engine — runtime SPA styles (light DOM only).
   Tokens come from @revoloox/wc/theme.css (horizon-crm.html).
   ============================================================ */

html, body { height: 100%; }
body { overflow: hidden; }
/* 100dvh: on iOS Safari 100vh includes the area under the browser toolbars (bottom of the page cut) */
#app { height: 100vh; height: 100dvh; }
#app > rx-app-shell { height: 100%; }

.x-boot { height: 100vh; height: 100dvh; display: grid; place-items: center; background: var(--rx-canvas); }
.x-boot-card { display: flex; flex-direction: column; align-items: center; gap: 14px; color: var(--rx-ink-2); }
.x-boot-mark { width: 44px; height: 44px; border-radius: 11px; background: var(--rx-blue); color: #fff; display: grid; place-items: center; font-family: var(--rx-ff-display); font-weight: 700; font-size: 20px; letter-spacing: -.03em; box-shadow: var(--rx-sh-2); }
.x-boot-error { max-width: 560px; padding: 0 16px; }

/* ---------- app bar ---------- */
.x-launcher-btn { display: flex; align-items: center; gap: 8px; padding: 6px 11px 6px 9px; border-radius: var(--rx-r-md); background: rgba(255,255,255,.09); color: #fff; font: inherit; font-size: 12.5px; font-weight: 500; border: none; cursor: pointer; flex: none; transition: background .14s; }
.x-launcher-btn:hover { background: rgba(255,255,255,.17); }
.x-launcher-btn.is-active { background: var(--rx-blue); }.x-launcher-btn.is-open { background: rgba(255,255,255,.22); }
/* app switcher: popup of the "App" button, apps grouped by module */
.x-switcher { position: fixed; z-index: 900; width: min(560px, calc(100vw - 16px)); max-height: min(560px, calc(100dvh - 80px)); display: flex; flex-direction: column; background: var(--rx-surface); color: var(--rx-ink); border: 1px solid var(--rx-line); border-radius: 10px; box-shadow: var(--rx-sh-3, 0 24px 60px rgba(12,13,15,.22)); animation: x-switcher-in .14s ease both; overflow: hidden; }
@keyframes x-switcher-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.x-switcher-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px 8px; }
.x-switcher-title { font-family: var(--rx-ff-display); font-weight: 600; font-size: 15px; letter-spacing: -.02em; flex: 1; }
.x-switcher-all { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 500; color: var(--rx-blue); text-decoration: none; padding: 3px 6px; border-radius: 5px; }
.x-switcher-all:hover { background: var(--rx-blue-wash, #EEF2FF); }
.x-switcher-search { margin: 0 14px 8px; padding: 7px 10px; border: 1px solid var(--rx-line-2); border-radius: var(--rx-r-md); font: inherit; font-size: 13px; background: var(--rx-surface); color: inherit; outline: none; }
.x-switcher-search:focus { border-color: var(--rx-blue); box-shadow: 0 0 0 3px rgba(20,71,255,.1); }
.x-switcher-body { overflow-y: auto; padding: 0 8px 10px; }
.x-switcher-group + .x-switcher-group { margin-top: 6px; }
.x-switcher-group-head { display: flex; align-items: center; gap: 6px; padding: 6px 6px 4px; font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--rx-ink-3); }
.x-switcher-group-head .x-module-ico { width: 18px; height: 18px; border-radius: 5px; }
.x-switcher-count { margin-left: auto; font-family: var(--rx-ff-mono); font-weight: 500; }
.x-switcher-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px; }
@media (max-width: 520px) { .x-switcher-grid { grid-template-columns: 1fr; } }
.x-switcher-app { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 7px; color: inherit; text-decoration: none; min-width: 0; }
.x-switcher-app:hover, .x-switcher-app.is-cur, .x-switcher-app:focus-visible { background: var(--rx-surface-2); }
.x-switcher-ico { width: 32px; height: 32px; border-radius: 8px; flex: none; display: grid; place-items: center; color: #fff; background: var(--x-tile-color, var(--rx-blue)); }
.x-switcher-text { display: flex; flex-direction: column; min-width: 0; }
.x-switcher-name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.x-switcher-desc { font-size: 11.5px; color: var(--rx-ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.x-switcher-note { padding: 10px 8px; font-size: 12.5px; color: var(--rx-ink-3); }
.x-switcher-note.err { color: var(--rx-red); }
.x-launcher-btn svg { display: block; }
.x-bar-sep { width: 1px; height: 22px; background: #2A2D33; margin: 0 6px; flex: none; }
.x-bar-title { color: var(--rx-bar-txt); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.x-bar-title b { color: #fff; font-weight: 500; }
.x-bar-btn { width: 30px; height: 30px; border-radius: var(--rx-r-md); color: var(--rx-bar-txt); display: grid; place-items: center; background: none; border: none; cursor: pointer; transition: background .14s, color .14s; }
.x-bar-btn:hover { background: var(--rx-bar-2); color: #fff; }
.x-bar-avatar { width: 28px; height: 28px; border-radius: 50%; background: #fff; color: var(--rx-ink); display: grid; place-items: center; font-size: 10.5px; font-weight: 600; margin-left: 3px; text-transform: uppercase; }
.x-side-version { font-family: var(--rx-ff-mono); font-size: 10.5px; color: var(--rx-ink-3); display: flex; justify-content: space-between; gap: 8px; }

/* ---------- page head ---------- */
.x-view { display: flex; flex-direction: column; gap: 16px; min-width: 0; animation: x-fade-in .18s ease; }
/* opacity only: a transform animation would make the view the containing
   block of position:fixed descendants (rx-modal overlays inside x-flow) */
@keyframes x-fade-in { from { opacity: 0; } to { opacity: 1; } }
.x-page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.x-page-head .x-titles { flex: 1; min-width: 0; }
.x-page-title { font-size: 25px; line-height: 1.1; letter-spacing: -.03em; margin: 4px 0 0; }
.x-page-sub { font-size: 12.5px; color: var(--rx-ink-2); margin-top: 5px; max-width: 70ch; }
.x-page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------- launcher ---------- */
.x-launcher { display: flex; flex-direction: column; gap: 6px; }
.x-launcher-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.x-launcher-toolbar rx-search { min-width: 260px; flex: 0 1 360px; }
.x-app-group { background: var(--rx-surface); border: 1px solid var(--rx-line); border-radius: var(--rx-r-lg); padding: 12px 14px 14px; margin-top: 10px; }
.x-app-group-head { display: flex; align-items: baseline; gap: 8px; padding: 0 4px 8px; }
.x-app-group-head .rx-eyebrow { flex: none; }
.x-app-group-count { font-family: var(--rx-ff-mono); font-size: 10px; color: var(--rx-ink-3); }
.x-app-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 4px; }
.x-tile { position: relative; padding: 12px 6px 11px; border-radius: 9px; display: flex; flex-direction: column; align-items: center; gap: 8px; background: none; border: none; cursor: pointer; font: inherit; color: inherit; text-decoration: none; transition: background .13s; min-width: 0; }
.x-tile:hover, .x-tile:focus-visible { background: var(--rx-surface-2); }
.x-tile-ico { width: 44px; height: 44px; border-radius: 11px; display: grid; place-items: center; color: #fff; box-shadow: 0 1px 2px rgba(12,13,15,.16); transition: transform .14s; }
.x-tile:hover .x-tile-ico { transform: translateY(-1px); }
.x-tile-name { font-size: 11.5px; font-weight: 500; text-align: center; line-height: 1.25; color: var(--rx-ink-2); max-width: 100%; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.x-tile-meta { font-family: var(--rx-ff-mono); font-size: 9.5px; color: var(--rx-ink-3); letter-spacing: .04em; text-transform: uppercase; }
.x-launcher-empty { padding: 8px 4px; color: var(--rx-ink-3); font-size: 12.5px; }

/* ---------- record page (auto layout) ---------- */
.x-rec-head { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; }
.x-rec-logo { width: 52px; height: 52px; border-radius: var(--rx-r-md); flex: none; display: grid; place-items: center; color: #fff; font-family: var(--rx-ff-display); font-weight: 600; font-size: 18px; }
.x-rec-titles { flex: 1; min-width: 0; }
.x-rec-title { font-size: 22px; line-height: 1.15; letter-spacing: -.03em; margin: 3px 0 0; overflow-wrap: anywhere; }
.x-rec-sub { font-size: 12.5px; color: var(--rx-ink-2); margin-top: 3px; }
.x-rec-sub .rx-mono { font-size: 11.5px; }
.x-record { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(280px, 1fr); gap: 14px; align-items: start; }
.x-record-main, .x-record-side { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
@media (max-width: 1100px) { .x-record { grid-template-columns: minmax(0, 1fr); } }

/* ---------- object list ---------- */
.x-list-card { background: var(--rx-surface); border: 1px solid var(--rx-line); border-radius: var(--rx-r-lg); overflow: hidden; }
.x-list-card rx-table { display: block; }

/* ---------- modals ---------- */
.x-modal-body { min-width: 0; }
.x-modal-body > rx-spinner { display: flex; justify-content: center; padding: 24px; }

/* ---------- page renderer ---------- */
[data-node-id][hidden] { display: none !important; }

/* ---------- apps ---------- */
.x-app-chip { display: inline-flex; align-items: center; gap: 7px; min-width: 0; flex: none; color: #fff; text-decoration: none; font-size: 12.5px; font-weight: 600; padding: 4px 8px 4px 4px; border-radius: var(--rx-r-md); transition: background .14s; }
.x-app-chip:hover { background: rgba(255,255,255,.09); }
.x-app-chip[hidden] { display: none; }
.x-app-chip-ico { width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; color: #fff; flex: none; background: var(--x-app-color, var(--rx-blue)); }
.x-app-chip-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 22ch; }
.x-app-chip:not([hidden]) + .x-bar-title::before { content: "/"; color: #4A4F57; margin: 0 8px 0 2px; }
.x-side-footer { display: flex; flex-direction: column; gap: 8px; }
.x-all-apps { display: flex; align-items: center; gap: 8px; padding: 7px 9px; border-radius: var(--rx-r-md); color: var(--rx-ink-2); text-decoration: none; font-size: 12.5px; font-weight: 500; border: 1px solid var(--rx-line); background: var(--rx-surface); transition: background .13s, color .13s, border-color .13s; }
.x-all-apps:hover { background: var(--rx-surface-2); color: var(--rx-ink); border-color: var(--rx-line-2); }
.x-all-apps[hidden] { display: none; }
.x-apps-grid { grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 8px; }
.x-app-tile { flex-direction: row; align-items: center; gap: 12px; padding: 12px; text-align: left; border: 1px solid var(--rx-line); background: var(--rx-surface); }
.x-app-tile:hover, .x-app-tile:focus-visible { border-color: var(--rx-line-2); background: var(--rx-surface-2); }
.x-app-tile .x-tile-ico { flex: none; background: var(--x-tile-color, var(--rx-blue)); }
.x-app-tile-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.x-app-tile .x-tile-name { text-align: left; font-size: 13px; font-weight: 600; color: var(--rx-ink); -webkit-line-clamp: 1; }
.x-tile-desc { font-size: 11.5px; line-height: 1.35; color: var(--rx-ink-3); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.x-module-groups { display: flex; flex-direction: column; gap: 12px; }
.x-module-group[hidden] { display: none; }
.x-module-head { display: flex; align-items: center; gap: 7px; padding: 0 2px 6px; }
.x-module-ico { width: 20px; height: 20px; border-radius: 6px; display: grid; place-items: center; color: #fff; flex: none; background: var(--x-module-color, var(--rx-ink-3)); }
.x-module-name { font-size: 12px; font-weight: 600; color: var(--rx-ink-2); }

/* ---------- SSO login ---------- */
.x-login-card { width: min(380px, calc(100vw - 32px)); background: var(--rx-surface); border: 1px solid var(--rx-line); border-radius: var(--rx-r-lg); box-shadow: var(--rx-sh-2); padding: 22px 22px 20px; display: flex; flex-direction: column; gap: 14px; animation: x-fade-in .18s ease; }
.x-login-head { display: flex; align-items: center; gap: 12px; }
.x-login-titles { min-width: 0; }
.x-login-title { font-size: 22px; line-height: 1.1; letter-spacing: -.03em; margin: 3px 0 0; }
.x-login-sub { display: flex; align-items: center; gap: 7px; margin: 0; font-size: 12.5px; color: var(--rx-ink-2); }
.x-login-form { display: flex; flex-direction: column; gap: 12px; }
.x-login-alert[hidden] { display: none; }

/* ---------- user (app bar) ---------- */
.x-bar-user { display: flex; align-items: center; gap: 7px; min-width: 0; padding-left: 4px; }
.x-bar-user-name { color: #fff; font-size: 12.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 18ch; }
.x-bar-logout { display: flex; align-items: center; gap: 6px; padding: 5px 9px; border-radius: var(--rx-r-md); background: rgba(255,255,255,.09); color: #fff; font: inherit; font-size: 12px; font-weight: 500; border: none; cursor: pointer; transition: background .14s; }
.x-bar-logout:hover { background: rgba(255,255,255,.17); }
