@import url("sysimple-surfaces.css?v=20260920");
/*
  Sysimple Studio Shell
  Couche finale de structure UX: header commun, menus, icônes, logos et boutons non arrondis.
  À charger après sysimple-ux-foundation.css.
*/

:root,
html[data-theme],
body[data-theme]{
  --studio-header-h:58px;
  --studio-logo-size:34px;
  --studio-radius:6px;
  --studio-gap:8px;
  --studio-control-h:32px;
  --studio-font:var(--adm-font, Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif);
}

body[data-theme]{
  background:var(--adm-bg, #f3f5f8) !important;
}

/* Reset agressif des boutons trop ronds: aucun bouton applicatif ne doit être en pilule. */
body[data-theme] button,
body[data-theme] .btn,
body[data-theme] .btn-mini,
body[data-theme] a.btn,
body[data-theme] a.btn-mini,
body[data-theme] .button,
body[data-theme] .chip,
body[data-theme] .pill,
body[data-theme] .badge,
body[data-theme] .dropdown-menu,
body[data-theme] .dropdown-item,
body[data-theme] .main-tab,
body[data-theme] .tool-tab,
body[data-theme] .file-tab,
body[data-theme] .right-tab,
body[data-theme] input:not([type="checkbox"]):not([type="radio"]),
body[data-theme] select,
body[data-theme] textarea{
  border-radius:var(--studio-radius) !important;
}

/* Exceptions limitées aux avatars / indicateurs d'état. */
body[data-theme] .avatar,
body[data-theme] .user-image,
body[data-theme] .direct-chat-img,
body[data-theme] .status-dot,
body[data-theme] .badge-dot,
body[data-theme] .dot,
body[data-theme] input[type="radio"]{
  border-radius:50% !important;
}

/* Header commun */
.sys-studio-header,
body[data-theme] .sys-studio-header,
body[data-theme] header.sys-studio-header.topbar,
body[data-theme] .topbar.sys-studio-header{
  min-height:var(--studio-header-h) !important;
  height:auto !important;
  width:100% !important;
  display:flex !important;
  align-items:center !important;
  justify-content:space-between !important;
  gap:12px !important;
  padding:10px 16px !important;
  background:var(--adm-header-bg, #fff) !important;
  color:var(--adm-header-text, #162235) !important;
  border-bottom:1px solid var(--adm-header-border, #d9e3ef) !important;
  box-shadow:none !important;
  position:relative !important;
  z-index:900 !important;
  box-sizing:border-box !important;
  font-family:var(--studio-font) !important;
  overflow:visible !important;
}

.sys-studio-header *{ box-sizing:border-box; }

.sys-studio-brand{
  display:flex;
  align-items:center;
  min-width:190px;
  gap:14px;
  color:var(--adm-header-text, #162235);
}

.sys-studio-logo,
.sys-studio-header .logo,
.sys-studio-header .brand-mark,
.sys-studio-header .topbar-logo,
.sys-studio-header .logo-img{
  width:var(--studio-logo-size) !important;
  height:var(--studio-logo-size) !important;
  min-width:var(--studio-logo-size) !important;
  min-height:var(--studio-logo-size) !important;
  max-width:var(--studio-logo-size) !important;
  max-height:var(--studio-logo-size) !important;
  object-fit:contain !important;
  display:block !important;
  border-radius:0 !important;
}

.sys-studio-title-wrap{
  display:flex;
  flex-direction:column;
  min-width:0;
  line-height:1.15;
}

.sys-studio-title,
.sys-studio-header .title,
.sys-studio-header h1,
.sys-studio-header .brand-title{
  margin:0 !important;
  padding:0 !important;
  font-size:16px !important;
  font-weight:700 !important;
  line-height:1.15 !important;
  color:var(--adm-header-text, #162235) !important;
  white-space:nowrap !important;
  overflow:hidden !important;
  text-overflow:ellipsis !important;
}

.sys-studio-subtitle{
  margin-top:2px;
  font-size:11px;
  font-weight:600;
  color:var(--adm-header-muted, #6f819b);
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.sys-studio-nav{
  display:flex;
  align-items:center;
  gap:6px;
  flex:1 1 auto;
  min-width:0;
  overflow-x:auto;
  scrollbar-width:thin;
}

.sys-studio-right{
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap:8px;
  flex:0 0 auto;
  min-width:0;
}

.sys-studio-primary-actions{
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap:7px;
  flex:0 1 auto;
  min-width:0;
}

.sys-studio-link,
.sys-studio-menu-button,
.sys-studio-action-button,
.sys-studio-header button,
.sys-studio-header .btn,
.sys-studio-header .btn-mini,
.sys-studio-header a.btn,
.sys-studio-header a.btn-mini{
  min-height:var(--studio-control-h) !important;
  height:var(--studio-control-h) !important;
  padding:0 10px !important;
  display:inline-flex !important;
  align-items:center !important;
  justify-content:center !important;
  gap:7px !important;
  border:1px solid var(--adm-header-border, #d9e3ef) !important;
  border-radius:var(--studio-radius) !important;
  background:var(--adm-header-bg, #fff) !important;
  color:var(--adm-header-text, #162235) !important;
  font-size:12px !important;
  font-weight:650 !important;
  line-height:1 !important;
  text-decoration:none !important;
  box-shadow:none !important;
  transform:none !important;
  cursor:pointer !important;
  white-space:nowrap !important;
}

.sys-studio-auth-menu{
  max-width:190px;
}

.sys-studio-auth-menu .sys-studio-menu-button{
  max-width:190px;
}

.sys-studio-auth-menu .sys-studio-menu-button span:first-of-type{
  min-width:0;
  max-width:110px;
  overflow:hidden;
  text-overflow:ellipsis;
}

.sys-studio-user-summary{
  display:flex;
  align-items:center;
  gap:8px;
  padding:9px 8px;
  border:1px solid var(--adm-border-soft, #e7edf3);
  border-radius:var(--studio-radius);
  background:var(--adm-panel-2, #f8fafc);
  color:var(--adm-text, #162235);
  font-size:12px;
  font-weight:700;
  line-height:1.25;
}

.sys-studio-user-summary span{
  min-width:0;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.sys-studio-session-identity {
  display:grid;
  gap:9px;
  padding:10px 8px;
  color:var(--adm-text, #263238);
  font-size:12px;
  line-height:1.4;
  white-space:normal;
  overflow-wrap:anywhere;
}
.sys-studio-session-identity small { color:var(--adm-muted, #657786); font-size:11px; }
.sys-studio-auth-menu .sys-studio-menu-panel { max-width:calc(100vw - 24px); }

.sys-studio-link:hover,
.sys-studio-menu-button:hover,
.sys-studio-action-button:hover,
.sys-studio-header button:hover,
.sys-studio-header .btn:hover,
.sys-studio-header .btn-mini:hover,
.sys-studio-header a.btn:hover,
.sys-studio-header a.btn-mini:hover{
  background:var(--adm-primary-soft, rgba(21,139,255,.12)) !important;
  color:var(--adm-primary, #158bff) !important;
  border-color:color-mix(in srgb, var(--adm-primary, #158bff) 35%, var(--adm-header-border, #d9e3ef)) !important;
  transform:none !important;
}

.sys-studio-link.is-active{
  background:var(--adm-primary, #158bff) !important;
  color:#fff !important;
  border-color:var(--adm-primary, #158bff) !important;
}

.sys-studio-header select,
.sys-studio-theme-select,
.sys-studio-header #themePicker,
.sys-studio-header #ocrThemePicker{
  min-height:var(--studio-control-h) !important;
  height:var(--studio-control-h) !important;
  padding:0 30px 0 10px !important;
  border:1px solid var(--adm-header-border, #d9e3ef) !important;
  border-radius:var(--studio-radius) !important;
  background:var(--adm-header-bg, #fff) !important;
  color:var(--adm-header-text, #162235) !important;
  font-size:12px !important;
  font-weight:650 !important;
  box-shadow:none !important;
  max-width:135px;
}

.sys-studio-menu{
  position:relative;
  flex:0 0 auto;
}

.sys-studio-menu-panel{
  position:absolute;
  right:0;
  top:calc(100% + 6px);
  min-width:230px;
  max-width:min(420px, 92vw);
  display:none;
  flex-direction:column;
  gap:6px;
  padding:8px;
  background:var(--adm-panel, #fff);
  color:var(--adm-text, #162235);
  border:1px solid var(--adm-border, #d9e0e8);
  border-radius:var(--studio-radius) !important;
  box-shadow:var(--adm-shadow-soft, 0 10px 24px rgba(15,23,42,.12));
  z-index:2000;
}

.sys-studio-menu.is-open > .sys-studio-menu-panel,
.sys-studio-menu:focus-within > .sys-studio-menu-panel{
  display:flex;
}

.sys-studio-menu-panel .btn,
.sys-studio-menu-panel .btn-mini,
.sys-studio-menu-panel button,
.sys-studio-menu-panel a,
.sys-studio-menu-panel select,
.sys-studio-menu-panel .button,
.sys-studio-menu-panel .pill,
.sys-studio-menu-panel .chip{
  width:100% !important;
  max-width:100% !important;
  justify-content:flex-start !important;
  text-align:left !important;
  margin:0 !important;
}

.sys-studio-menu-title{
  padding:5px 7px 2px;
  font-size:11px;
  font-weight:800;
  color:var(--adm-text-soft, #73849a);
  text-transform:uppercase;
  letter-spacing:.04em;
}

.sys-studio-menu-sep{
  height:1px;
  background:var(--adm-border-soft, #e7edf3);
  margin:4px 0;
}

.sys-studio-local-actions{
  display:flex;
  flex-direction:column;
  gap:6px;
}

.sys-studio-empty-actions{
  padding:7px;
  font-size:12px;
  color:var(--adm-text-soft, #73849a);
}

/* Les headers existants ne doivent plus afficher de gros logos accidentels. */
.topbar:not(.sys-studio-header) .logo,
.topbar:not(.sys-studio-header) .brand-mark,
.topbar:not(.sys-studio-header) .topbar-logo,
.topbar:not(.sys-studio-header) .logo-img,
.hero-shell .logo,
.hero-shell img.logo{
  width:var(--studio-logo-size) !important;
  height:var(--studio-logo-size) !important;
  max-width:var(--studio-logo-size) !important;
  max-height:var(--studio-logo-size) !important;
  object-fit:contain !important;
  border-radius:0 !important;
}

/* IA: mise en page propre, logo contrôlé, chat lisible */
#sysimpleAIBuilder{
  background:var(--adm-bg, #f3f5f8) !important;
}
#sysimpleAIBuilder .wrap{
  grid-template-columns:280px minmax(0, 1fr) 320px !important;
  gap:14px !important;
  padding:14px !important;
}
#sysimpleAIBuilder .pane,
#sysimpleAIBuilder #stageIA > .card,
#sysimpleAIBuilder .card{
  border-radius:var(--studio-radius) !important;
}
#sysimpleAIBuilder .card h3{
  font-size:17px !important;
  font-weight:700 !important;
  margin:0 0 8px 0 !important;
  color:var(--adm-text, #162235) !important;
}
#sysimpleAIBuilder .hint{
  color:var(--adm-text-soft, #73849a) !important;
  font-size:12px !important;
}
#sysimpleAIBuilder .ai-chat-area{
  background:var(--adm-panel-2, #f8fafc) !important;
  border:1px solid var(--adm-border-soft, #e7edf3) !important;
  border-radius:var(--studio-radius) !important;
}
#sysimpleAIBuilder .bubble,
#sysimpleAIBuilder .direct-chat-text{
  border-radius:var(--studio-radius) !important;
  background:var(--adm-panel, #fff) !important;
  color:var(--adm-text, #162235) !important;
  border:1px solid var(--adm-border, #d9e0e8) !important;
  box-shadow:none !important;
}
#sysimpleAIBuilder .ai-chat-footer{
  border-top:1px solid var(--adm-border-soft, #e7edf3) !important;
  margin-top:10px !important;
}
#sysimpleAIBuilder #send-btn{
  border-radius:var(--studio-radius) !important;
}
#sysimpleAIBuilder #aiOutput{
  background:var(--adm-panel-2, #f8fafc) !important;
  color:var(--adm-text, #162235) !important;
  border:1px solid var(--adm-border, #d9e0e8) !important;
  border-radius:var(--studio-radius) !important;
}

/* Uniformisation des panneaux des autres modules */
body[data-theme] .panel,
body[data-theme] .card,
body[data-theme] .pane,
body[data-theme] .hero-main,
body[data-theme] .hero-side-panel,
body[data-theme] .ocr-panel,
body[data-theme] .ocr-form-card,
body[data-theme] .editor-zone,
body[data-theme] .right-zone,
body[data-theme] #palette,
body[data-theme] #rightbar,
body[data-theme] .builder-left,
body[data-theme] .builder-right,
body[data-theme] .properties-panel{
  border-radius:var(--studio-radius) !important;
}

/* Liens rapides historiques: remplacés par le shell. */
.sysimple-quick-links.is-replaced,
.topbar.is-replaced,
header.topbar.is-replaced,
.app-topbar.is-replaced,
#header.is-replaced{
  display:none !important;
}

/* Workflow garde une barre interne historique dans le DOM. Une fois le shell commun en place,
   seul le switcher Workflows / Designer doit rester visible. */
body[data-sysimple-shell="true"] > header.topbar:not(.sys-studio-header){
  display:none !important;
}

@media (max-width:1100px){
  .sys-studio-header{
    flex-wrap:wrap !important;
    align-items:flex-start !important;
  }
  .sys-studio-brand{
    flex:1 1 260px;
  }
  .sys-studio-nav{
    order:3;
    width:100%;
    flex-basis:100%;
    padding-top:2px;
  }
  .sys-studio-right{
    flex:0 0 auto;
  }
  #sysimpleAIBuilder .wrap{
    grid-template-columns:250px minmax(0, 1fr) 290px !important;
  }
}

@media (max-width:820px){
  .sys-studio-title{ font-size:15px !important; }
  .sys-studio-subtitle{ display:none; }
  .sys-studio-link span:not(.sr-only),
  .sys-studio-menu-button span:not(.sr-only){ display:none; }
  .sys-studio-link,
  .sys-studio-menu-button{ width:36px; padding:0 !important; }
  .sys-studio-brand{ min-width:170px; }
  #sysimpleAIBuilder .wrap{
    grid-template-columns:1fr !important;
  }
}


/* V3 - Couleurs sémantiques et actions prioritaires */
:root,
html[data-theme],
body[data-theme]{
  --sys-success:#198754;
  --sys-success-soft:rgba(25,135,84,.12);
  --sys-danger:#dc3545;
  --sys-danger-soft:rgba(220,53,69,.12);
  --sys-warning:#f0ad00;
  --sys-warning-soft:rgba(240,173,0,.18);
  --sys-info:#2f9fe8;
  --sys-info-soft:rgba(47,159,232,.14);
}

.sys-studio-primary-actions{
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap:6px;
  flex:0 1 auto;
  min-width:0;
  max-width:45vw;
  overflow-x:auto;
  scrollbar-width:thin;
}

.sys-studio-primary-actions:empty{display:none;}

.sys-studio-primary-actions .btn,
.sys-studio-primary-actions .btn-mini,
.sys-studio-primary-actions button,
.sys-studio-primary-actions a,
.sys-studio-local-actions .btn,
.sys-studio-local-actions .btn-mini,
.sys-studio-local-actions button,
.sys-studio-local-actions a{
  width:auto !important;
  max-width:none !important;
  min-width:auto !important;
}

.sys-studio-menu-panel{
  z-index:2147483000 !important;
  overflow:auto !important;
}
.sys-studio-menu-panel.is-floating{
  z-index:2147483000 !important;
  max-height:calc(100vh - 90px) !important;
}

/* Couleurs de boutons. Les classes existantes Bootstrap/AdminLTE sont gardées, mais normalisées. */
body[data-theme] .btn-danger,
body[data-theme] .danger,
body[data-theme] .sys-btn-danger,
.sys-studio-header .sys-btn-danger{
  background:var(--sys-danger-soft) !important;
  border-color:color-mix(in srgb, var(--sys-danger) 42%, transparent) !important;
  color:var(--sys-danger) !important;
}
body[data-theme] .btn-danger:hover,
body[data-theme] .danger:hover,
body[data-theme] .sys-btn-danger:hover,
.sys-studio-header .sys-btn-danger:hover{
  background:var(--sys-danger) !important;
  border-color:var(--sys-danger) !important;
  color:#fff !important;
}

body[data-theme] .btn-warning,
body[data-theme] .warning,
body[data-theme] .sys-btn-warning,
.sys-studio-header .sys-btn-warning{
  background:var(--sys-warning-soft) !important;
  border-color:color-mix(in srgb, var(--sys-warning) 48%, transparent) !important;
  color:#7a5800 !important;
}
body[data-theme] .btn-warning:hover,
body[data-theme] .warning:hover,
body[data-theme] .sys-btn-warning:hover,
.sys-studio-header .sys-btn-warning:hover{
  background:var(--sys-warning) !important;
  border-color:var(--sys-warning) !important;
  color:#1f2937 !important;
}

body[data-theme] .btn-info,
body[data-theme] .info,
body[data-theme] .sys-btn-info,
.sys-studio-header .sys-btn-info{
  background:var(--sys-info-soft) !important;
  border-color:color-mix(in srgb, var(--sys-info) 38%, transparent) !important;
  color:var(--sys-info) !important;
}
body[data-theme] .btn-info:hover,
body[data-theme] .info:hover,
body[data-theme] .sys-btn-info:hover,
.sys-studio-header .sys-btn-info:hover{
  background:var(--sys-info) !important;
  border-color:var(--sys-info) !important;
  color:#fff !important;
}

body[data-theme] .btn-success,
body[data-theme] .success,
body[data-theme] .primary,
body[data-theme] .sys-btn-success,
.sys-studio-header .sys-btn-success{
  background:var(--sys-success-soft) !important;
  border-color:color-mix(in srgb, var(--sys-success) 42%, transparent) !important;
  color:var(--sys-success) !important;
}
body[data-theme] .btn-success:hover,
body[data-theme] .success:hover,
body[data-theme] .primary:hover,
body[data-theme] .sys-btn-success:hover,
.sys-studio-header .sys-btn-success:hover{
  background:var(--sys-success) !important;
  border-color:var(--sys-success) !important;
  color:#fff !important;
}

body[data-theme] .sys-btn-primary-soft,
.sys-studio-header .sys-btn-primary-soft{
  background:var(--adm-primary-soft, rgba(21,139,255,.12)) !important;
  border-color:color-mix(in srgb, var(--adm-primary, #158bff) 35%, transparent) !important;
  color:var(--adm-primary, #158bff) !important;
}
body[data-theme] .sys-btn-primary-soft:hover,
.sys-studio-header .sys-btn-primary-soft:hover{
  background:var(--adm-primary, #158bff) !important;
  border-color:var(--adm-primary, #158bff) !important;
  color:#fff !important;
}

/* Statuts dans les grilles */
.sys-status-badge{
  display:inline-flex !important;
  align-items:center !important;
  justify-content:center !important;
  min-height:22px !important;
  padding:3px 8px !important;
  border-radius:var(--studio-radius) !important;
  font-size:12px !important;
  font-weight:750 !important;
  line-height:1.1 !important;
  border:1px solid transparent !important;
  width:auto !important;
}
td.sys-status-badge{ display:table-cell !important; }
.sys-status-badge.is-success{ background:var(--sys-success-soft) !important; border-color:color-mix(in srgb, var(--sys-success) 35%, transparent) !important; color:var(--sys-success) !important; }
.sys-status-badge.is-info{ background:var(--sys-info-soft) !important; border-color:color-mix(in srgb, var(--sys-info) 32%, transparent) !important; color:var(--sys-info) !important; }
.sys-status-badge.is-warning{ background:var(--sys-warning-soft) !important; border-color:color-mix(in srgb, var(--sys-warning) 42%, transparent) !important; color:#7a5800 !important; }
.sys-status-badge.is-danger{ background:var(--sys-danger-soft) !important; border-color:color-mix(in srgb, var(--sys-danger) 35%, transparent) !important; color:var(--sys-danger) !important; }
.sys-status-badge.is-muted{ background:rgba(120,132,150,.14) !important; border-color:rgba(120,132,150,.28) !important; color:var(--adm-text-soft, #73849a) !important; }

/* Workspace: le shell Studio possède déjà logo + thème. Le sous-header Workspace ne doit pas les répéter. */
body[data-sysimple-shell="true"] .app-topbar .topbar-brand .brand-logo-image,
body[data-sysimple-shell="true"] .app-topbar .topbar-tools,
body[data-sysimple-shell="true"] .app-topbar .topbar-theme-picker{
  display:none !important;
}
body[data-sysimple-shell="true"] .app-topbar{
  top:auto !important;
  z-index:100 !important;
  min-height:46px !important;
}
body[data-sysimple-shell="true"] .topbar-brand-panel{
  padding-left:0 !important;
}

@media (max-width:1100px){
  .sys-studio-primary-actions{ order:4; width:100%; max-width:100%; justify-content:flex-start; }
}

/* Aucun logo de marque ne doit se retrouver dans les sous-menus d'action/outils. */
.sys-studio-menu-panel img.logo,
.sys-studio-menu-panel .brand-mark,
.sys-studio-menu-panel .logo-img,
.sys-studio-menu-panel .topbar-logo,
.sys-studio-menu-panel .sysimple-logo{
  display:none !important;
}


/* V4 - QueryBuilder: conformité header + support complet des thèmes */
body[data-theme] .app-shell{
  background:var(--adm-bg, #0b1830) !important;
  color:var(--adm-text, #ebf4ff) !important;
}
body[data-theme] .workspace{
  background:transparent !important;
}
body[data-theme] .app-shell,
body[data-theme] .workspace,
body[data-theme] .center-stack,
body[data-theme] .section-stack{
  --bg:var(--adm-bg, #0b1830);
  --bg-alt:var(--adm-bg-2, #0f2244);
  --panel:var(--adm-panel, #102344);
  --panel-alt:var(--adm-input-bg, #0f2137);
  --panel-soft:var(--adm-surface-2, #173257);
  --border:var(--adm-border, #284a79);
  --border-strong:color-mix(in srgb, var(--adm-border, #284a79) 78%, var(--adm-primary, #158bff));
  --text:var(--adm-text, #ebf4ff);
  --text-soft:var(--adm-text-soft, #9eb4d0);
  --muted:var(--adm-text-dim, #7189aa);
  --primary:var(--adm-primary, #158bff);
  --primary-soft:var(--adm-primary-soft, rgba(21,139,255,.14));
  --success:var(--adm-success, #2fb171);
  --warning:var(--adm-warning, #e0a54d);
  --danger:var(--adm-danger, #e15b6d);
  --shadow:var(--adm-shadow-soft, 0 10px 24px rgba(0,0,0,.18));
  --radius:var(--studio-radius);
  --radius-sm:var(--studio-radius);
}
body[data-theme] .brand__eyebrow,
body[data-theme] .brand__title,
body[data-theme] .brand__subtitle{
  color:var(--adm-header-text, #162235) !important;
}
body[data-theme] .brand__subtitle{ color:var(--adm-header-muted, #6f819b) !important; }
body[data-theme] .stat-card,
body[data-theme] .project-card,
body[data-theme] .query-card,
body[data-theme] .version-card,
body[data-theme] .mapping-card,
body[data-theme] .message-card,
body[data-theme] .check-item,
body[data-theme] .metric-card,
body[data-theme] .info-card,
body[data-theme] .contract-row,
body[data-theme] .editor-shell,
body[data-theme] .tabs,
body[data-theme] .checkbox-row,
body[data-theme] .table-wrap,
body[data-theme] .empty-state,
body[data-theme] .modal-card{
  background:var(--adm-panel, #102344) !important;
  color:var(--adm-text, #ebf4ff) !important;
  border-color:var(--adm-border, #284a79) !important;
  border-radius:var(--studio-radius) !important;
  box-shadow:none !important;
}
body[data-theme] .panel__header,
body[data-theme] .editor-toolbar{
  background:var(--adm-panel-2, #142b52) !important;
  border-color:var(--adm-border, #284a79) !important;
  color:var(--adm-text, #ebf4ff) !important;
}
body[data-theme] .editor-code-wrap,
body[data-theme] .editor-gutter,
body[data-theme] .editor-highlight,
body[data-theme] .editor-input,
body[data-theme] .editor-monaco,
body[data-theme] .table th{
  background:var(--adm-input-bg, #0f2137) !important;
  color:var(--adm-text, #ebf4ff) !important;
  border-color:var(--adm-border, #284a79) !important;
}
body[data-theme] .input,
body[data-theme] .select,
body[data-theme] .textarea{
  background:var(--adm-input-bg, #0f2137) !important;
  color:var(--adm-text, #ebf4ff) !important;
  border-color:var(--adm-border, #284a79) !important;
}
body[data-theme] .project-card__meta,
body[data-theme] .query-card__meta,
body[data-theme] .subtle,
body[data-theme] .hint,
body[data-theme] .muted,
body[data-theme] .metric-card__label,
body[data-theme] .info-card__label,
body[data-theme] .meta-row__label,
body[data-theme] .stat-card__label{
  color:var(--adm-text-soft, #9eb4d0) !important;
}
body[data-theme] .table td,
body[data-theme] .meta-row__value,
body[data-theme] .project-card__name,
body[data-theme] .query-card__name,
body[data-theme] .panel__title,
body[data-theme] .metric-card__value,
body[data-theme] .info-card__value,
body[data-theme] .stat-card__value{
  color:var(--adm-text, #ebf4ff) !important;
}
body[data-theme="light"] .app-shell,
body[data-theme="light"] .workspace,
body[data-theme="light"] .center-stack,
body[data-theme="light"] .section-stack{
  --bg:#f3f5f8;
  --bg-alt:#ffffff;
  --panel:#ffffff;
  --panel-alt:#ffffff;
  --panel-soft:#f8fafc;
  --border:#d9e0e8;
  --border-strong:#c8d3df;
  --text:#162235;
  --text-soft:#73849a;
  --muted:#8a99ac;
  --primary:#2563eb;
  --primary-soft:#eef4ff;
}
body[data-theme="light"] .editor-code-wrap,
body[data-theme="light"] .editor-gutter,
body[data-theme="light"] .editor-highlight,
body[data-theme="light"] .editor-input,
body[data-theme="light"] .editor-monaco{
  background:#ffffff !important;
  color:#162235 !important;
}
body[data-theme="light"] .editor-input{ caret-color:#162235 !important; }
body[data-theme="dark"] .sys-studio-header,
body[data-theme="sysimple"] .sys-studio-header{
  box-shadow:0 1px 0 rgba(255,255,255,.05) !important;
}


/* V5 - Mapper + QueryBuilder: thèmes complets, statuts et nettoyage des sous-menus */
body[data-theme] .badge--online,
body[data-theme] .status-online,
body[data-theme] .is-online{
  background:var(--sys-success-soft) !important;
  border-color:color-mix(in srgb, var(--sys-success) 40%, transparent) !important;
  color:var(--sys-success) !important;
}
body[data-theme] .badge--offline,
body[data-theme] .status-offline,
body[data-theme] .is-offline{
  background:var(--sys-danger-soft) !important;
  border-color:color-mix(in srgb, var(--sys-danger) 40%, transparent) !important;
  color:var(--sys-danger) !important;
}
body[data-theme] .badge--draft,
body[data-theme] .status-draft{
  background:var(--sys-warning-soft) !important;
  border-color:color-mix(in srgb, var(--sys-warning) 42%, transparent) !important;
  color:#7a5800 !important;
}
body[data-theme] .badge--published,
body[data-theme] .status-published{
  background:var(--sys-success-soft) !important;
  border-color:color-mix(in srgb, var(--sys-success) 40%, transparent) !important;
  color:var(--sys-success) !important;
}
body[data-theme] .badge--archived,
body[data-theme] .status-archived{
  background:rgba(120,132,150,.14) !important;
  border-color:rgba(120,132,150,.28) !important;
  color:var(--adm-text-soft, #73849a) !important;
}

/* StudioMapper utilise des variables --sys-*. On les branche au thème admin commun. */
body[data-theme] .app-shell,
body[data-theme] .main,
body[data-theme] .screen,
body[data-theme] .card,
body[data-theme] .flow-item,
body[data-theme] .mapping-card,
body[data-theme] .schema-panel,
body[data-theme] .transform-card,
body[data-theme] .mapper-header-card,
body[data-theme] .modal-card{
  --sys-bg:var(--adm-bg, #0b1830);
  --sys-surface:var(--adm-panel, #102344);
  --sys-surface-2:var(--adm-panel-2, #142b52);
  --sys-surface-3:var(--adm-input-bg, #0f2137);
  --sys-panel:var(--adm-panel, #102344);
  --sys-border:var(--adm-border, #284a79);
  --sys-border-strong:color-mix(in srgb, var(--adm-border, #284a79) 78%, var(--adm-primary, #158bff));
  --sys-text:var(--adm-text, #ebf4ff);
  --sys-text-muted:var(--adm-text-soft, #9eb4d0);
  --sys-primary:var(--adm-primary, #158bff);
  --sys-primary-2:color-mix(in srgb, var(--adm-primary, #158bff) 75%, #fff);
  --sys-accent:var(--adm-primary, #158bff);
  --sys-warning:var(--adm-warning, #f0ad00);
  --sys-danger:var(--adm-danger, #dc3545);
  --sys-success:var(--adm-success, #198754);
  --sys-radius:var(--studio-radius);
  --sys-radius-sm:var(--studio-radius);
}
body[data-theme] .main-header.is-replaced{ display:none !important; }
body[data-theme] .top-nav .brand-mark,
body[data-theme] .top-nav .logo,
body[data-theme] .top-nav img,
body[data-theme] .sys-studio-menu-panel .brand-mark,
body[data-theme] .sys-studio-menu-panel img{
  display:none !important;
}
body[data-theme] .topbar-compact,
body[data-theme] .mapper-topbar,
body[data-theme] .main > .topbar{
  background:var(--adm-panel, #102344) !important;
  color:var(--adm-text, #ebf4ff) !important;
  border-color:var(--adm-border, #284a79) !important;
  border-radius:var(--studio-radius) !important;
}
body[data-theme] .card,
body[data-theme] .flow-item,
body[data-theme] .mapping-card,
body[data-theme] .field-card,
body[data-theme] .schema-column,
body[data-theme] .transform-card,
body[data-theme] .value-map-row,
body[data-theme] .log-item{
  background:var(--adm-panel, #102344) !important;
  color:var(--adm-text, #ebf4ff) !important;
  border-color:var(--adm-border, #284a79) !important;
  border-radius:var(--studio-radius) !important;
  box-shadow:none !important;
}
body[data-theme] .input,
body[data-theme] .select,
body[data-theme] textarea,
body[data-theme] .search-box{
  background:var(--adm-input-bg, #0f2137) !important;
  color:var(--adm-text, #ebf4ff) !important;
  border-color:var(--adm-border, #284a79) !important;
}
body[data-theme] .badge,
body[data-theme] .pill,
body[data-theme] .transform-chip{
  border-radius:var(--studio-radius) !important;
}
body[data-theme="light"] .card,
body[data-theme="light"] .flow-item,
body[data-theme="light"] .mapping-card,
body[data-theme="light"] .field-card,
body[data-theme="light"] .schema-column,
body[data-theme="light"] .transform-card,
body[data-theme="light"] .value-map-row,
body[data-theme="light"] .log-item,
body[data-theme="light"] .topbar-compact,
body[data-theme="light"] .mapper-topbar,
body[data-theme="light"] .main > .topbar{
  background:#fff !important;
  color:#162235 !important;
  border-color:#d9e0e8 !important;
}
body[data-theme="light"] .input,
body[data-theme="light"] .select,
body[data-theme="light"] textarea,
body[data-theme="light"] .search-box{
  background:#fff !important;
  color:#162235 !important;
  border-color:#d9e0e8 !important;
}

/* Module command bars remain local; the Studio owns navigation and theme. */
body.query-builder-page[data-theme] {
  --bg:var(--adm-bg); --bg-alt:var(--adm-bg-2); --panel:var(--adm-panel);
  --panel-alt:var(--adm-panel-2); --panel-soft:var(--adm-surface-2);
  --border:var(--adm-border); --border-strong:var(--adm-border);
  --text:var(--adm-text); --text-soft:var(--adm-text-soft); --muted:var(--adm-text-dim);
  --primary:var(--adm-primary); --primary-soft:var(--adm-primary-soft);
}
body.query-builder-page .app-shell { min-height:calc(100vh - var(--studio-header-h)); }
body.query-builder-page .query-studio-topbar { background:var(--adm-panel); }
body.frm-page[data-theme] {
  --frm-bg:var(--adm-bg); --frm-surface:var(--adm-surface); --frm-surface-2:var(--adm-surface-2);
  --frm-line:var(--adm-border); --frm-line-strong:var(--adm-border);
  --frm-text:var(--adm-text); --frm-muted:var(--adm-text-soft);
  --frm-primary:var(--adm-primary); --frm-topbar:var(--adm-panel); --frm-soft:var(--adm-primary-soft);
}
body.frm-page .frm-shell { height:calc(100vh - var(--studio-header-h)); }
body.frm-page .frm-topbar { justify-content:flex-end; min-height:40px; padding:4px 14px; }
#homeLegacyForm { background:var(--adm-input-bg); color:var(--adm-text); border:1px solid var(--adm-border); }
#homeLegacyStatus { color:var(--adm-text-soft); font-size:12px; }
#homeLegacyOpen[hidden] { display:none !important; }

/* API and development tools share the Studio surfaces and palettes. */
body.tool-dashboard-page[data-theme] {
  --bg:var(--adm-bg); --bg2:var(--adm-bg-2); --panel:var(--adm-panel); --panel2:var(--adm-panel-2);
  --line:var(--adm-border); --line-soft:var(--adm-border-soft);
  --text:var(--adm-text); --muted:var(--adm-text-soft);
  --primary:var(--adm-primary); --primary2:var(--adm-primary-2);
  font-family:var(--adm-font) !important;
}
body.tool-dashboard-page[data-theme] > .app { height:calc(100vh - var(--studio-header-h)); }
body.tool-dashboard-page[data-theme] .main > .topbar,
body.tool-dashboard-page[data-theme] .panel,
body.tool-dashboard-page[data-theme] .panel-body,
body.tool-dashboard-page[data-theme] .sidebar-list,
body.tool-dashboard-page[data-theme] .sidebar-item,
body.tool-dashboard-page[data-theme] .code-viewer,
body.tool-dashboard-page[data-theme] .viewer {
  background:var(--adm-panel) !important; color:var(--adm-text) !important;
  border-color:var(--adm-border) !important;
}
body.tool-dashboard-page[data-theme] .brand-title,
body.tool-dashboard-page[data-theme] .page-title { color:var(--adm-text) !important; }
body.tool-dashboard-page[data-theme] .line-numbers {
  background:var(--adm-surface-2) !important; color:var(--adm-text-soft) !important;
}
body.tool-dashboard-page[data-theme] .btn-primary {
  background:var(--adm-primary) !important; color:#fff !important;
}
body.tool-dashboard-page[data-theme] #sysimpleApiCatalog { padding:0; }
body.tool-dashboard-page[data-theme] #sysimpleApiCatalog button:hover { background:var(--adm-primary-soft) !important; }
@media(max-width:820px) {
  body.api-tool-page[data-theme] { overflow:auto; }
  body.api-tool-page[data-theme] > .app { display:flex; flex-direction:column; height:auto; }
  body.api-tool-page[data-theme] .sidebar { width:100%; }
  body.api-tool-page[data-theme] .main { min-height:600px; }
}
.sys-studio-common-tools { display:flex; align-items:center; gap:3px; flex-wrap:wrap; position:relative; }
.sys-studio-common-tools > button { min-width:34px; min-height:34px; position:relative; }
.sys-studio-tools-status { position:absolute; top:100%; right:0; width:260px; padding:10px; z-index:11000; background:var(--adm-panel, #202328); color:var(--adm-text, #f5f7fa); border:1px solid var(--adm-border, #596169); }
.sys-studio-tools-status[hidden] { display:none; }
.sys-studio-header .sys-studio-common-tools > button { overflow:visible; }
.sys-studio-header .sys-studio-common-tools .sys-studio-unread-count {
  position:absolute; top:-7px; right:-5px; z-index:1;
  display:flex; align-items:center; justify-content:center; box-sizing:border-box;
  min-width:20px; height:20px; padding:0 4px;
  border:2px solid var(--adm-panel,#202328); border-radius:999px;
  background:#d83030 !important; color:#fff !important;
  font:700 11px/16px Arial,sans-serif; letter-spacing:0;
  box-shadow:0 1px 3px #0003; pointer-events:none;
}
.sys-studio-header .sys-studio-common-tools .sys-studio-unread-count[hidden] { display:none !important; }
.sys-studio-common-tools [data-studio-tool="ia"] { --studio-tool-color:#a78bfa; }
.sys-studio-common-tools [data-studio-tool="chat"] { --studio-tool-color:#55b9f3; }
.sys-studio-common-tools [data-studio-tool="notifications"] { --studio-tool-color:#f7bc55; }
.sys-studio-common-tools [data-studio-tool="favorite"] { --studio-tool-color:#f5c842; }
.sys-studio-common-tools [data-studio-tool="favorites"] { --studio-tool-color:#50cfa0; }
body[data-theme="light"] .sys-studio-common-tools [data-studio-tool="ia"] { --studio-tool-color:#7952b3; }
body[data-theme="light"] .sys-studio-common-tools [data-studio-tool="chat"] { --studio-tool-color:#237eaf; }
body[data-theme="light"] .sys-studio-common-tools [data-studio-tool="notifications"] { --studio-tool-color:#ab6800; }
body[data-theme="light"] .sys-studio-common-tools [data-studio-tool="favorite"] { --studio-tool-color:#a77800; }
body[data-theme="light"] .sys-studio-common-tools [data-studio-tool="favorites"] { --studio-tool-color:#00834b; }
.sys-studio-header .sys-studio-common-tools [data-studio-tool] > i { color:var(--studio-tool-color) !important; }
.sys-studio-header .sys-studio-common-tools [data-studio-tool]:hover { background:color-mix(in srgb,var(--studio-tool-color) 14%,transparent) !important; border-color:var(--studio-tool-color) !important; }
/* Shared shortcuts: colored icons without permanent button frames. */
body[data-theme] .sys-studio-header .sys-studio-common-tools :is(#sysSecureMailOpen,.sys-studio-link)[data-studio-tool] {
  border-color:transparent !important;
  background:transparent !important;
  box-shadow:none !important;
}
body[data-theme] .sys-studio-header .sys-studio-common-tools :is(#sysSecureMailOpen,.sys-studio-link)[data-studio-tool]:hover {
  background:color-mix(in srgb,var(--studio-tool-color,#3c8dbc) 12%,transparent) !important;
}
body[data-theme] .sys-studio-header .sys-studio-common-tools :is(#sysSecureMailOpen,.sys-studio-link)[data-studio-tool]:focus-visible {
  outline:2px solid var(--studio-tool-color,#3c8dbc) !important;
  outline-offset:2px;
}
.sys-studio-api-status { display:grid; grid-template-columns:16px 16px; flex:0 0 34px; width:34px; align-items:center; gap:2px; font:600 10px/1 "Segoe UI",sans-serif; }
.sys-studio-api-status span { display:flex; align-items:center; justify-content:center; box-sizing:border-box; width:16px; height:22px; border:1px solid currentColor; border-radius:3px; }
.sys-studio-api-status span:focus-visible { outline:2px solid currentColor; outline-offset:2px; }
@media (prefers-reduced-motion: reduce) { .sys-studio-api-status .fa-spin { animation:none; } }
.sys-studio-api-status [data-state="success"] { color:#008548; background:rgba(0,166,90,.12); }
.sys-studio-api-status [data-state="warning"] { color:#a56600; background:rgba(243,156,18,.14); }
.sys-studio-api-status [data-state="error"] { color:#c0392b; background:rgba(221,75,57,.12); }
body:not([data-theme="light"]) .sys-studio-api-status [data-state="success"] { color:#61d99f; }
body:not([data-theme="light"]) .sys-studio-api-status [data-state="warning"] { color:#f7bc55; }
body:not([data-theme="light"]) .sys-studio-api-status [data-state="error"] { color:#ff9287; }

/* Raised content cards; rows and navigation keep their existing density. */
body[data-theme] :is(.panel,.card,.surface-panel,.surface-card,.pane,.panel-card,.stat-card,.project-card,.query-card,.version-card,.mapping-card,.message-card,.metric-card,.info-card,.editor-shell,.table-wrap){
 border-radius:var(--sys-surface-radius)!important;
 box-shadow:var(--sys-surface-shadow)!important;
}
body[data-theme] .modal-card{border-radius:var(--sys-surface-radius)!important;box-shadow:var(--sys-dialog-shadow)!important;}
