/* Explicitly restore native dialog centering after the global margin reset. */
body.workspace-theme dialog[open] {
 position:fixed; inset:0; margin:auto; height:fit-content;
 max-width:calc(100vw - 32px); max-height:calc(100dvh - 32px);
 overflow:auto; overscroll-behavior:contain; box-sizing:border-box;
 border-color:var(--theme-accent); box-shadow:0 24px 90px #0009;
}
body.workspace-theme dialog::backdrop { background:#080d16b8; backdrop-filter:blur(3px); }
body.workspace-theme:has(dialog[open]) { overflow-y:hidden; }
html:has(body.workspace-theme dialog[open]) { overflow-y:hidden; }

/* All ordinary controls use the same palette; semantic danger rules stay red. */
body.workspace-theme :is(.btn-action,.btn-outline-white,.btn-details,.btn-expediente,.btn-edit-date,.btn-close,.close-modal,.workspace-menu-toggle,.header-tool) {
 border-color:var(--theme-border) !important; color:var(--theme-accent) !important;
 background:var(--theme-soft) !important;
}
body.workspace-theme :is(.btn-action,.btn-outline-white,.btn-details,.btn-expediente,.btn-edit-date,.btn-close,.close-modal,.workspace-menu-toggle,.header-tool):hover:not(:disabled) {
 border-color:var(--theme-accent) !important; background:var(--theme-hover) !important; color:var(--theme-accent) !important;
}
body.workspace-theme :is(.btn-action.cyan,.btn-action.gold,.btn-liquid-launch),
body.workspace-theme :is(.btn-action.cyan,.btn-action.gold,.btn-liquid-launch):hover:not(:disabled) {
 background:var(--theme-accent) !important; color:#10151b !important; border-color:var(--theme-accent) !important;
}
body.workspace-theme :is(.btn-action.red,.btn-action.outline-red,.btn-hero-red,.btn-history-del,.account-delete),
body.workspace-theme :is(.btn-action.red,.btn-action.outline-red,.btn-hero-red,.btn-history-del,.account-delete):hover:not(:disabled) {
 background:#37201c !important; border-color:#b96d61 !important; color:#ffb2a6 !important;
}
body.workspace-theme :is(.user-avatar,.header-popover-panel,.profile-menu-content,.workspace-drawer>.modal-content,.release-preview,.modder-card,.modder-dialog) { border-color:var(--theme-border) !important; }
body.workspace-theme .player-initials { border-color:var(--theme-border); background:var(--theme-soft); color:var(--theme-accent); }
body.workspace-theme :is(.personal-greeting,.text-action,.audit-change strong,.audit-technical summary) { color:var(--theme-accent) !important; }
body.workspace-theme :is(.presence-indicator,.notification-count) { background:var(--theme-accent); }
body.workspace-theme .presence-indicator.away { background:transparent; border-color:var(--theme-border); }
body.workspace-theme .staff-avatar { background:var(--theme-soft); color:var(--theme-accent); }
body.workspace-theme .header-tool[aria-expanded=true],body.workspace-theme .dossier-tab[aria-selected=true] { background:var(--theme-soft); border-color:var(--theme-border); color:var(--theme-accent); }
body.workspace-theme .notice-item.is-unread { background:var(--theme-tint); border-left-color:var(--theme-accent); }
body.workspace-theme :is(.cosmic-data-table-staff,.gamer-table) th { border-bottom-color:var(--theme-border); }
body.workspace-theme #usersTableBody .staff-category td { background:var(--theme-soft); color:var(--theme-accent); }
body.workspace-theme .palette-shortcut { border-color:var(--theme-accent) !important; }
body.workspace-theme #devTimerContainer { background:var(--theme-soft) !important; border-color:var(--theme-border) !important; color:var(--theme-accent) !important; }

/* Filter the banner image independently so the text keeps its own contrast. */
body.workspace-theme .mission-intro { position:relative; isolation:isolate; overflow:hidden; background:var(--theme-soft) !important; border-color:var(--theme-border); }
body.workspace-theme .mission-intro::before {
 content:''; position:absolute; inset:0; z-index:-2; pointer-events:none;
 background-image:var(--personal-wallpaper,var(--default-wallpaper));
 background-size:cover; background-position:center; opacity:.55;
 filter:var(--theme-scene-filter,none);
}
body.workspace-theme.has-personal-wallpaper .mission-intro::before { filter:none; }
/* A dedicated composition fills the entire strip, with the car in the crop-safe band. */
body.workspace-theme:not(.has-personal-wallpaper):not(.has-site-wallpaper) .mission-intro::before {
 background-image:url('../assets/mission-banner-panorama.png');
 background-size:cover; background-position:right 67%; background-repeat:no-repeat; opacity:.85;
}
body.workspace-theme .mission-intro::after {
 content:''; position:absolute; inset:0; z-index:-1; pointer-events:none;
 background:linear-gradient(90deg,rgb(8 13 20 / .78),rgb(8 13 20 / .36) 55%,rgb(8 13 20 / .12)); opacity:1;
}
@media(max-width:600px){body.workspace-theme dialog[open]{max-width:calc(100vw - 20px);max-height:calc(100dvh - 24px);padding:18px;}}

/* Keep the player status filter beside search instead of stacking above it. */
body.workspace-theme .card-header-gamer .player-directory-filters {
 display:flex; flex-flow:row nowrap !important; align-items:center;
 flex:0 1 auto; width:420px; max-width:100%; min-width:0;
}
body.workspace-theme .card-header-gamer .player-directory-filters #filterStateInput {
 flex:0 0 120px; width:120px !important; min-width:0; height:40px; margin:0;
}
body.workspace-theme .card-header-gamer .player-directory-filters #searchPlayerInput {
 flex:1 1 0; width:0 !important; min-width:0; height:40px; margin:0;
}

/* Desktop history uses the available width and height to expose every action. */
@media(min-width:1024px) {
 body.workspace-theme #historyModal.workspace-drawer > .modal-content {
  width:min(1440px,96vw) !important; max-width:1440px !important;
  display:flex; flex-direction:column; box-sizing:border-box;
 }
 body.workspace-theme #historyModal .modal-header,
 body.workspace-theme #historyModal #searchHistoryInput,
 body.workspace-theme #historyModal #btnVaciarHistorial { flex:0 0 auto; }
 body.workspace-theme #historyModal > .modal-content > .table-wrapper-internal {
  flex:1 1 auto; min-height:220px; max-height:none !important;
 }
 body.workspace-theme #historyModal table { width:100%; min-width:0; table-layout:fixed; }
 body.workspace-theme #historyModal :is(th,td) { white-space:normal !important; overflow-wrap:anywhere; }
 body.workspace-theme #historyModal th:nth-child(1) { width:12%; }
 body.workspace-theme #historyModal th:nth-child(2) { width:19%; }
 body.workspace-theme #historyModal th:nth-child(3) { width:17%; }
 body.workspace-theme #historyModal th:nth-child(4) { width:17%; }
 body.workspace-theme #historyModal th:nth-child(5) { width:19%; }
 body.workspace-theme #historyModal th:nth-child(6) { width:16%; }
 body.workspace-theme #historyModal td:last-child > div { flex-wrap:wrap; }
 body.workspace-theme #historyModal td span[style*="border: 1px solid"] { white-space:normal !important; max-width:100%; box-sizing:border-box; }
}

/* Desktop has a stable labeled sidebar; Menu hides it instead of enlarging it. */
body.workspace-theme .workspace-menu-toggle { transform:none !important; transition:background-color .15s,border-color .15s,color .15s; }
@media(min-width:769px) and (max-width:1000px) {
 body.workspace-theme .dashboard-root { padding-left:0; }
 body.workspace-theme .side-nav.glass-panel { transform:translate(-120%,-50%); }
 body.workspace-theme .navigation-open .side-nav.glass-panel { transform:translate(0,-50%); }
}
@media(min-width:1001px) {
 body.workspace-theme .side-nav.glass-panel,
 body.workspace-theme .navigation-open .side-nav.glass-panel { width:220px !important; transition:none; }
 body.workspace-theme .dashboard-root.navigation-hidden { padding-left:0; }
 body.workspace-theme .navigation-hidden .side-nav.glass-panel { visibility:hidden; transform:translate(-130%,-50%); }
 body.workspace-theme #syncModal.workspace-drawer > .modal-content { width:min(1180px,96vw) !important; max-width:1180px !important; }
}
body.workspace-theme #syncModal .sync-plan { display:block; }
.sync-summary { display:flex; flex-wrap:wrap; gap:8px; margin:18px 0; }
.sync-summary span { background:var(--theme-soft); border:1px solid var(--theme-border); border-radius:8px; padding:10px 12px; }
.sync-groups { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:12px; margin-top:16px; }
.sync-groups .sub-panel { min-width:0; padding:16px; }
.sync-groups p,.sync-review p { font-size:13px; line-height:1.6; }
.sync-detected { padding:14px; border:1px solid var(--theme-border); border-radius:10px; }
.sync-detected summary { cursor:pointer; }
.sync-detected p { max-height:200px; overflow:auto; overflow-wrap:anywhere; }
.sync-review { padding:16px; border:1px solid var(--theme-border); border-radius:12px; }
.sync-review-row { display:grid; grid-template-columns:minmax(0,1fr) auto auto; gap:10px; padding:14px 0; border-bottom:1px solid var(--line); }
.sync-review-row p { grid-column:1/-1; margin:0; }
.sync-review-row input { min-width:0; }
@media(max-width:700px) {
 .sync-groups { grid-template-columns:1fr; }
 .sync-review-row { grid-template-columns:1fr 1fr; }
 .sync-review-row input { grid-column:1/-1; }
 .sync-review-row button { white-space:normal; }
}
