/*
 * OASIS UI — diseno unico de todo el ecosistema (Maestro, Login, Documental y modulos futuros).
 * Se publica en /_oasis/ui.css y el gateway lo inyecta en el HTML de cada modulo junto con
 * /_oasis/theme/<sistema>.css, que solo define los colores parametrizados en Maestro:
 *   --system-color       fondo del menu lateral (color del sistema)
 *   --system-foreground  texto sobre el color del sistema
 *   --system-accent      botones, pestanas, enlaces y foco
 * Los modulos NO redefinen estas reglas: solo agregan estilos de sus propias pantallas
 * usando los tokens de :root.
 */

:root {
  font-family: "DM Sans", "Segoe UI", sans-serif;
  font-size: 18px;
  font-weight: 400;
  color: var(--ink);
  background: var(--page);
  color-scheme: light;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-optical-sizing: auto;

  /* Tema (sobrescrito por /_oasis/theme/<sistema>.css) */
  --system-color: #142b40;
  --system-foreground: #ffffff;
  --system-accent: #2d668d;

  /* Derivados del tema */
  --accent: var(--system-accent);
  --accent-dark: color-mix(in srgb, var(--system-accent), #000 15%);
  --accent-pale: color-mix(in srgb, var(--system-accent) 8%, #fff);
  --accent-ring: color-mix(in srgb, var(--system-accent) 15%, transparent);

  /* Neutros */
  --ink: #192a3c;
  --ink-soft: #435a6d;
  --muted: #7a8998;
  --line: #e7edf2;
  --line-strong: #d9e2e9;
  --page: #f3f6f9;
  --paper: #fff;
  --surface: #fff;
  --shadow: 0 4px 14px rgb(24 49 70 / 4%), 0 1px 3px rgb(24 49 70 / 4%);

  /* Estados */
  --success: #216b44;
  --success-pale: #e7f4ec;
  --amber: #a86612;
  --amber-pale: #fff4e2;
  --red: #b84942;
  --red-pale: #fbeeed;
  --violet: #675ca7;
  --violet-pale: #f0eef9;

  /* Alias para estilos de modulos */
  --brand-color: var(--system-color);
  --brand-foreground: var(--system-foreground);
  --brand-dark: var(--accent-dark);
  --brand-pale: var(--accent-pale);
  --navy: var(--system-accent);
  --navy-light: var(--accent-dark);
  --blue: var(--system-accent);
  --blue-pale: var(--accent-pale);
  --teal: var(--system-accent);
  --green: var(--system-accent);
  --green-dark: var(--accent-dark);
  --green-pale: var(--accent-pale);
}

/* Base */
* { box-sizing: border-box; }
body { min-width: 320px; min-height: 100vh; margin: 0; background: var(--page); }
#root { width: 100%; min-height: 100vh; }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
button:disabled { cursor: not-allowed; opacity: .56; }
:is(button, a, input, select, textarea):focus-visible { outline: 3px solid var(--accent-ring); outline-color: var(--system-accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes slide-in { from { transform: translateX(24px); opacity: .8; } to { transform: translateX(0); opacity: 1; } }
@keyframes loading-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }

/* Estructura: menu lateral + area principal */
.app-shell { min-height: 100vh; }
.navigation-sidebar { position: fixed; z-index: 15; inset: 0 auto 0 0; display: flex; flex-direction: column; width: 64px; padding: 16px 8px; background: var(--system-color); color: var(--system-foreground); transition: width .18s ease, box-shadow .18s ease; }
.navigation-sidebar.navigation-expanded { width: min(260px, 90vw); box-shadow: 12px 0 30px rgb(15 38 54 / 18%); }
.navigation-heading { display: flex; width: 100%; flex-direction: column; align-items: center; gap: 12px; padding: 0; }
.navigation-expanded .navigation-heading { padding: 0 6px; }
.navigation-sidebar .brand { display: inline-flex; width: 100%; align-items: center; justify-content: center; gap: 10px; color: inherit; text-decoration: none; }
.navigation-sidebar .brand-mark { display: grid; flex: 0 0 auto; width: 39px; height: 39px; place-items: center; border: 1px solid color-mix(in srgb, var(--system-foreground) 20%, transparent); border-radius: 12px; background: color-mix(in srgb, var(--system-foreground) 10%, transparent); color: inherit; }
.navigation-sidebar .brand-name { display: none; flex-direction: column; color: inherit; font-size: 17px; font-weight: 720; letter-spacing: -.9px; line-height: 1.05; white-space: nowrap; }
.navigation-sidebar .brand-name small { margin-top: 4px; color: inherit; opacity: .72; font-size: 16px; font-weight: 700; letter-spacing: 1.05px; }
.navigation-expanded .brand-name { display: flex; }
.brand-icon-img { display: block; flex: 0 0 auto; width: 39px; height: 39px; border-radius: 12px; object-fit: cover; }
.brand-logo-img { display: none; max-width: 200px; max-height: 44px; overflow: hidden; border-radius: 12px; object-fit: contain; }
.navigation-expanded .brand-logo-img { display: block; }
.navigation-expanded .brand:has(.brand-logo-img) :is(.brand-icon-img, .brand-mark, .brand-name) { display: none; }

.sidebar-navigation { display: flex; flex: 1; min-height: 0; flex-direction: column; gap: 4px; margin-top: 18px; overflow-x: hidden; overflow-y: auto; }
.sidebar-navigation .nav-label { display: none; margin: 12px 10px 4px; opacity: .7; font-size: 16px; font-weight: 680; letter-spacing: 1.1px; white-space: nowrap; }
.navigation-expanded .sidebar-navigation .nav-label { display: block; }
.navigation-sidebar .nav-item { position: relative; display: flex; width: 100%; min-height: 48px; flex-shrink: 0; align-items: center; justify-content: center; gap: 11px; padding: 0; border: 0; border-radius: 6px; background: transparent; color: inherit; font-size: 16px; text-align: left; text-decoration: none; cursor: pointer; transition: background .15s, color .15s; }
.navigation-sidebar .nav-item svg { flex-shrink: 0; }
.navigation-sidebar .nav-item > span { display: none; white-space: nowrap; }
.navigation-sidebar .nav-item:disabled { cursor: not-allowed; opacity: .5; }
.navigation-sidebar .module-heading { margin: 4px 0; font-weight: 700; }
.navigation-sidebar :is(.nav-item:hover, .nav-active) { background: color-mix(in srgb, var(--system-foreground) 14%, transparent); color: inherit; }
.navigation-sidebar .nav-active { font-weight: 620; }
.navigation-sidebar .nav-active::before { position: absolute; inset: 8px auto 8px 0; width: 2px; border-radius: 0 2px 2px 0; background: var(--system-foreground); content: ""; }
.navigation-expanded .sidebar-navigation .nav-item { justify-content: flex-start; padding: 0 16px; }
.navigation-expanded .sidebar-navigation .nav-item > span { display: inline; }
.navigation-sidebar .nav-count { display: none; min-width: 22px; height: 19px; margin-left: auto; place-items: center; border-radius: 5px; background: color-mix(in srgb, var(--system-foreground) 12%, transparent); color: inherit; font-size: 16px; }
.navigation-expanded .sidebar-navigation .nav-item > .nav-count { display: grid; }
.navigation-sidebar .icon-button { color: inherit; }
.navigation-sidebar .icon-button:hover { background: color-mix(in srgb, var(--system-foreground) 10%, transparent); color: inherit; }
.navigation-sidebar :is(button, a):focus-visible { outline: 2px solid var(--system-foreground); outline-offset: -2px; }
.navigation-sidebar .sidebar-bottom { margin-top: auto; }

/* Cuenta del usuario (pie del menu) */
.navigation-account { position: relative; }
.navigation-account .account { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; padding: 12px 6px 0; border-top: 1px solid color-mix(in srgb, var(--system-foreground) 12%, transparent); }
.navigation-account .account-details { display: none; flex: 1; width: 100%; min-width: 0; max-width: none; gap: 2px; line-height: 1.2; }
.navigation-expanded .navigation-account .account-details { display: grid; }
.account-details :is(strong, span) { overflow: hidden; color: inherit; font-size: 16px; text-overflow: ellipsis; white-space: nowrap; }
.account-details strong { font-weight: 620; }
.account-details span { opacity: .75; }
.account-trigger { width: 100%; min-width: 0; padding: 0; border: 0; background: transparent; color: inherit; text-align: left; cursor: pointer; }
.navigation-expanded .account-trigger { display: flex; flex-direction: column; align-items: center; }
.navigation-expanded .account-trigger > :is(.account-person-name, span) { width: 100%; text-align: center; }
.account-person-name { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-popover { position: absolute; z-index: 30; bottom: calc(100% + 10px); left: 0; width: min(270px, calc(100vw - 24px)); overflow: hidden; border: 1px solid color-mix(in srgb, var(--system-foreground) 14%, transparent); border-radius: 10px; background: var(--system-color); color: var(--system-foreground); box-shadow: 0 12px 32px rgb(0 0 0 / 24%); }
.account-popover :is(strong, span) { color: inherit; }
.account-popover-heading { display: grid; gap: 2px; padding: 14px 15px; border-bottom: 1px solid color-mix(in srgb, var(--system-foreground) 10%, transparent); line-height: 1.2; }
.account-popover-heading strong { overflow: hidden; font-size: 16px; text-overflow: ellipsis; white-space: nowrap; }
.account-popover-heading span { opacity: .8; font-size: 16px; }
.account-popover form { margin: 0; }
.account-popover-action { display: flex; width: 100%; min-height: 44px; align-items: center; gap: 10px; padding: 0 15px; border: 0; background: transparent; color: inherit; font-size: 16px; text-align: left; text-decoration: none; cursor: pointer; }
.account-popover-action:hover { background: color-mix(in srgb, var(--system-foreground) 8%, transparent); }
.account-signout { border-top: 1px solid color-mix(in srgb, var(--system-foreground) 10%, transparent); }

.main-area { min-height: 100vh; background: var(--page); }
.app-shell > .main-area { margin-left: 64px; }
.topbar { position: sticky; z-index: 5; top: 0; display: flex; height: 58px; align-items: center; justify-content: space-between; gap: 14px; padding: 0 41px; border-bottom: 1px solid var(--line); background: rgb(255 255 255 / 94%); backdrop-filter: blur(9px); }
.page-container { width: 100%; max-width: none; margin: 0; padding: 32px clamp(18px, 2vw, 32px) 26px; }
.module-tabs { display: flex; gap: 6px; margin: 0 0 22px; overflow-x: auto; border-bottom: 1px solid var(--line); }
.module-tab { display: inline-flex; flex: 0 0 auto; align-items: center; gap: 7px; min-height: 40px; padding: 0 12px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: #667168; font: inherit; cursor: pointer; }
.module-tab[aria-current="page"] { border-bottom-color: var(--system-accent); color: var(--system-accent); font-weight: 620; }
.module-tab:focus-visible { outline-offset: -2px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 23px; }
.page-heading h1 { display: flex; align-items: center; gap: 11px; margin: 0; color: var(--ink); font-size: 25px; font-weight: 650; letter-spacing: -.85px; line-height: 1.2; }
.page-heading > :only-child { margin-left: auto; }
.page-heading p { margin: 8px 0 0; color: #65798a; font-size: 16px; line-height: 1.6; }
.breadcrumb-kicker { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; color: var(--muted); font-size: 16px; }

/* Botones */
.button { display: inline-flex; min-height: 34px; align-items: center; justify-content: center; gap: 7px; padding: 0 12px; border: 1px solid transparent; border-radius: 6px; font-size: 16px; font-weight: 560; text-decoration: none; white-space: nowrap; cursor: pointer; transition: background .15s, border-color .15s, transform .15s; }
.button:active:not(:disabled) { transform: translateY(1px); }
.button-primary { border-color: transparent; background: var(--system-accent); color: #fff; box-shadow: 0 1px 2px rgb(15 38 54 / 8%); }
.button-primary:hover:not(:disabled) { background: var(--accent-dark); }
.button-filter, .button-secondary, .button-icon-label { border-color: var(--line-strong); background: #fff; color: var(--ink-soft); }
.button-filter:hover:not(:disabled), .button-secondary:hover:not(:disabled), .button-icon-label:hover:not(:disabled) { border-color: #b9cbd3; background: #f8fafb; color: var(--accent-dark); }
.button-filter svg { color: var(--accent-dark); }
.button-small { min-height: 31px; padding: 0 10px; }
.button-text-danger { border: 0; background: transparent; color: var(--red); font-size: 16px; cursor: pointer; }
.button-text-danger:hover { background: var(--red-pale); }
.button-spinner { width: 12px; height: 12px; border: 2px solid #ffffff75; border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
.icon-button { display: inline-grid; width: 32px; height: 32px; flex: 0 0 auto; place-items: center; padding: 0; border: 0; border-radius: 6px; background: transparent; color: #7d857f; cursor: pointer; }
.icon-button:hover { background: #f2f4f1; color: var(--ink); }

/* Busqueda y formularios */
.search-box { display: flex; width: min(340px, 60%); height: 32px; align-items: center; gap: 8px; padding: 0 9px; border: 1px solid var(--line); border-radius: 5px; background: #fff; color: #989f99; }
.search-box:focus-within { border-color: var(--system-accent); box-shadow: 0 0 0 2px var(--accent-ring); }
.search-box input { width: 100%; min-width: 0; border: 0; outline: none; background: transparent; color: var(--ink); font-size: 16px; }
.search-box input::placeholder { color: #a0a69f; }
.form-error { padding: 9px 10px; border: 1px solid #f0ddda; border-radius: 5px; background: #fcf5f4; color: #974e45; font-size: 16px; line-height: 1.5; }

/* Estados vacios y carga */
.empty-state { display: flex; min-height: 210px; flex-direction: column; align-items: center; justify-content: center; padding: 25px; color: #8e968f; text-align: center; }
.empty-state > svg { margin-bottom: 11px; color: var(--accent); }
.empty-state :is(h3, strong) { margin: 0; color: #38433b; font-size: 16px; font-weight: 620; }
.empty-state :is(p, span) { max-width: 390px; margin: 6px 0 13px; color: #89928b; font-size: 16px; line-height: 1.65; }
.loading-screen, .auth-screen { display: flex; min-height: 100vh; flex-direction: column; align-items: center; justify-content: center; gap: 14px; background: var(--page); color: #818a83; font-size: 16px; }
.loading-logo { display: block; max-width: min(360px, 70vw); max-height: 40vh; object-fit: contain; animation: loading-pulse 1.6s ease-in-out infinite; }
.loading-mark, .auth-card .brand-mark { display: grid; width: 48px; height: 48px; place-items: center; border: 1px solid var(--line-strong); border-radius: 13px; background: var(--accent-pale); color: var(--accent); }
.auth-screen { padding: 24px; }
.auth-card { display: flex; width: min(420px, 100%); flex-direction: column; align-items: center; padding: 36px 31px 28px; border: 1px solid var(--line); border-radius: 11px; background: #fff; box-shadow: 0 12px 40px rgb(24 49 70 / 7%); text-align: center; }
.auth-card h1 { margin: 0; color: var(--ink); font-size: 19px; font-weight: 640; letter-spacing: -.45px; }
.auth-card > p { margin: 10px 0 19px; color: #808982; font-size: 16px; line-height: 1.7; }

/* Modales, paneles laterales y detalles */
.modal-overlay, .drawer-overlay { position: fixed; z-index: 20; inset: 0; display: flex; align-items: center; justify-content: center; padding: 20px; background: #18221ca8; backdrop-filter: blur(2px); }
.drawer-overlay { justify-content: flex-end; padding: 0; }
.modal { width: min(500px, 100%); max-height: min(760px, 94vh); overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; background: #fff; box-shadow: 0 22px 75px #14201640; }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 19px 21px 15px; border-bottom: 1px solid #eef0ed; }
.modal-header h2 { margin: 5px 0 0; color: var(--ink); font-size: 16px; font-weight: 650; letter-spacing: -.3px; }
.section-eyebrow { color: #879286; font-size: 16px; font-weight: 660; letter-spacing: 1px; }
.modal-form { display: grid; gap: 14px; padding: 17px 21px 20px; }
.modal-form > label, .form-row > label { display: grid; gap: 6px; color: #475249; font-size: 16px; font-weight: 570; }
.modal-form input:not([type="checkbox"]), .modal-form select { width: 100%; height: 36px; padding: 0 10px; border: 1px solid #e3e7e2; border-radius: 5px; outline: none; background: #fff; color: #38423b; font-size: 16px; }
.modal-form :is(input, select):focus { border-color: var(--system-accent); box-shadow: 0 0 0 2px var(--accent-ring); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 3px; }
.drawer-actions { display: flex; justify-content: center; gap: 8px; padding: 0 18px 20px; }
.drawer-actions .button { min-height: 32px; font-size: 16px; }
.detail-row { display: flex; align-items: center; justify-content: space-between; gap: 13px; min-height: 35px; }
.detail-row > span { color: #848d85; font-size: 16px; }
.detail-row strong { color: #485249; font-size: 16px; font-weight: 570; text-align: right; }

/* Notificaciones */
.toast { position: fixed; z-index: 100; right: 22px; bottom: 22px; display: flex; max-width: min(390px, calc(100vw - 32px)); align-items: flex-start; gap: 9px; padding: 12px 14px; border: 1px solid #e0e8df; border-radius: 7px; background: #fff; color: #4d5c4f; box-shadow: 0 8px 26px #18221d1a; font-size: 16px; line-height: 1.6; }
.toast > span:first-child { color: var(--accent); }
.toast-error { border-color: #efdedb; color: #854d46; }
.toast-error > span:first-child { color: #a86056; }

/* Paginas del gateway (inicio, entidad, no encontrado) */
.cloud-page { margin: 0; font-size: 16px; line-height: 1.5; }
.cloud-page a { color: inherit; }
.cloud-page .top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 12px clamp(16px, 4vw, 40px); border-bottom: 1px solid var(--line); background: var(--system-color); color: var(--system-foreground); }
.cloud-page .top .brand { display: flex; align-items: center; gap: 10px; color: inherit; font-weight: 700; text-decoration: none; }
.cloud-page .top .brand img { width: 32px; height: 32px; border-radius: 8px; }
.cloud-page .account { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; color: inherit; font-size: 15px; }
.cloud-page .account a { color: inherit; text-decoration: none; }
.cloud-page .account form { margin: 0; }
.cloud-page .account button { padding: 6px 12px; border: 1px solid color-mix(in srgb, var(--system-foreground) 30%, transparent); border-radius: 8px; background: transparent; color: inherit; cursor: pointer; }
.cloud-page main { max-width: 1100px; margin: 0 auto; padding: 32px clamp(16px, 4vw, 40px); }
.cloud-page h1 { margin: 0 0 20px; color: var(--ink); font-size: 25px; font-weight: 650; letter-spacing: -.85px; }
.cloud-page .crumb, .cloud-page .empty { margin: 0 0 6px; color: var(--muted); }
.cloud-page .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.cloud-page .card { display: flex; align-items: center; gap: 14px; padding: 18px; border: 1px solid var(--line); border-top: 4px solid var(--system-accent); border-radius: 12px; background: #fff; box-shadow: var(--shadow); text-decoration: none; transition: box-shadow .15s, transform .15s; }
.cloud-page .card:hover, .cloud-page .card:focus-visible { transform: translateY(-2px); box-shadow: 0 9px 24px rgb(24 49 70 / 9%); }
.cloud-page .card img, .cloud-page .card .dot { width: 44px; height: 44px; flex: none; border-radius: 10px; }
.cloud-page .card :is(strong, small) { display: block; }
.cloud-page .card small { color: var(--muted); }
.cloud-page .card.system { border-top-color: var(--system-color); background: #f7fafc; }

@media (max-width: 1150px) { .topbar { padding-right: 24px; padding-left: 24px; } }
@media (max-width: 580px) {
  .topbar { height: 53px; padding: 0 15px; }
  .page-container { padding: 25px 15px 22px; }
  .page-heading { align-items: flex-start; gap: 12px; margin-bottom: 18px; }
  .page-heading h1 { font-size: 22px; }
  .search-box { width: 100%; }
  .form-row { grid-template-columns: 1fr; }
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal { width: 100%; max-height: 91vh; border-radius: 11px 11px 0 0; }
}
@media (pointer: coarse) { .navigation-sidebar .nav-item { min-height: 44px; } }
@media (prefers-reduced-motion: reduce) { .navigation-sidebar { transition: none; } .loading-logo { animation: none; } }

/* Espacio de trabajo (Maestro): barra lateral en 3 secciones, paneles de modulo y pestanas tipo navegador.
   Solo aplica con las clases workspace-*; los demas modulos conservan su diseno actual. */
.workspace-sidebar { padding: 0 8px; }
.workspace-sidebar-section { display: flex; flex-direction: column; min-height: 0; }
.workspace-sidebar-section + .workspace-sidebar-section { border-top: 1px solid color-mix(in srgb, var(--system-foreground) 8%, transparent); }
.workspace-brand { flex: 0 0 auto; align-items: center; padding: 14px 0; }
.workspace-sidebar :is(.brand-icon-img, .brand-logo-img, .brand-mark) { border-radius: 0; }
.workspace-sidebar .brand-icon-img { width: 40px; height: 40px; object-fit: cover; }
.workspace-sidebar .brand-logo-img { max-width: 100%; max-height: 48px; }
.workspace-modules.sidebar-navigation { flex: 1 1 auto; gap: 2px; margin: 0; padding: 10px 0; overflow-y: auto; scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--system-foreground) 25%, transparent) transparent; }
.workspace-modules .module-heading { margin: 0; }
.workspace-sidebar .nav-item { min-height: 42px; }
.workspace-user { position: relative; flex: 0 0 auto; gap: 2px; padding: 8px 0 12px; }
.workspace-user > .nav-item { position: relative; display: flex; width: 100%; align-items: center; justify-content: center; gap: 11px; padding: 0; border: 0; border-radius: 6px; background: transparent; color: inherit; font: inherit; font-size: 16px; text-align: left; cursor: pointer; }
.workspace-user > .nav-item:hover { background: color-mix(in srgb, var(--system-foreground) 14%, transparent); }
.workspace-user .navigation-account { margin-top: 4px; }
.workspace-popover { padding-bottom: 6px; }
.workspace-popover-empty { margin: 0; padding: 14px 15px 8px; opacity: .8; font-size: 15px; }

.maestro-workspace .main-area { display: flex; flex-direction: column; }
.workspace-tabs { position: sticky; z-index: 6; top: 0; display: flex; align-items: flex-end; gap: 2px; padding: 8px 12px 0; overflow-x: auto; border-bottom: 1px solid var(--line-strong); background: color-mix(in srgb, var(--page), #000 3%); scrollbar-width: thin; }
.workspace-tab { display: flex; flex: 0 0 auto; max-width: 320px; align-items: center; border: 1px solid transparent; border-bottom: 0; border-radius: 9px 9px 0 0; color: var(--ink-soft); }
.workspace-tab:hover { background: color-mix(in srgb, var(--paper) 60%, transparent); }
.workspace-tab.is-active { margin-bottom: -1px; border-color: var(--line-strong); background: var(--page); color: var(--ink); }
.workspace-tab-open { display: flex; flex: 1; min-width: 0; height: 36px; align-items: center; gap: 8px; padding: 0 4px 0 12px; border: 0; background: transparent; color: inherit; font: inherit; font-size: 14px; text-align: left; cursor: pointer; }
.workspace-tab-open span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.workspace-tab.is-active .workspace-tab-open { font-weight: 620; }
.workspace-tab.is-active .workspace-tab-open svg { color: var(--system-accent); }
.workspace-tab-close { display: grid; flex: 0 0 auto; width: 22px; height: 22px; margin-right: 6px; place-items: center; border: 0; border-radius: 5px; background: transparent; color: inherit; cursor: pointer; opacity: .65; }
.workspace-tab-close:hover { background: var(--line); opacity: 1; }
.workspace-tab :is(button):focus-visible { outline: 2px solid var(--system-accent); outline-offset: -2px; }

.workspace-panel .page-heading > :only-child { margin-left: 0; }
.workspace-panel-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: 14px; }
.workspace-card { position: relative; display: flex; align-items: flex-start; gap: 14px; padding: 18px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow); color: var(--ink); font: inherit; text-align: left; cursor: pointer; transition: border-color .15s, box-shadow .15s, transform .15s; }
.workspace-card:hover { border-color: color-mix(in srgb, var(--system-accent) 45%, var(--line)); box-shadow: 0 8px 22px rgb(24 49 70 / 9%); transform: translateY(-1px); }
.workspace-card:focus-visible { outline: 2px solid var(--system-accent); outline-offset: 2px; }
.workspace-card-icon { display: grid; flex: 0 0 auto; width: 40px; height: 40px; place-items: center; border-radius: 8px; background: var(--accent-pale); color: var(--system-accent); }
.workspace-card-copy { display: grid; gap: 4px; min-width: 0; }
.workspace-card-copy strong { font-size: 16px; font-weight: 640; }
.workspace-card-copy small { color: var(--muted); font-size: 14px; line-height: 1.45; }
.workspace-card-open { position: absolute; top: 10px; right: 12px; padding: 1px 8px; border-radius: 999px; background: var(--accent-pale); color: var(--system-accent); font-size: 12px; font-weight: 600; }
@media (prefers-reduced-motion: reduce) { .workspace-card { transition: none; } .workspace-card:hover { transform: none; } }

/* Barra siempre recogida: el nombre aparece en una etiqueta con los colores del sistema. */
.workspace-sidebar { width: 64px; }
.workspace-sidebar .nav-item > span { display: none; }
.workspace-avatar-button { padding: 0; }
.workspace-sidebar .brand { padding: 2px; border-radius: 0; }
.workspace-sidebar .brand:focus-visible { outline: 2px solid var(--system-foreground); outline-offset: 2px; }
.workspace-tooltip { position: fixed; z-index: 40; left: 74px; padding: 6px 12px; border-radius: 6px; background: var(--system-color); color: var(--system-foreground); box-shadow: 0 8px 22px rgb(15 38 54 / 22%); font-size: 14px; font-weight: 620; white-space: nowrap; pointer-events: none; transform: translateY(-50%); }
.workspace-tooltip::before { position: absolute; top: 50%; left: -5px; width: 10px; height: 10px; background: inherit; content: ""; transform: translateY(-50%) rotate(45deg); }

/* Foto de perfil o icono de usuario */
.workspace-avatar { display: grid; flex: 0 0 auto; overflow: hidden; place-items: center; border-radius: 50%; background: color-mix(in srgb, var(--system-foreground) 12%, transparent); }
.workspace-avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-cell { display: flex; align-items: center; gap: 10px; }
.user-cell > span { display: grid; min-width: 0; }
.user-cell .workspace-avatar, .workspace-profile .workspace-avatar { background: var(--accent-pale); color: var(--system-accent); }

/* Pestana fija Panel: no se cierra */
.workspace-tab-home .workspace-tab-open { padding-right: 14px; }

/* Paneles laterales de perfil y notificaciones: blancos, sobrepuestos al contenido */
.workspace-drawer-backdrop { position: fixed; z-index: 34; inset: 0 0 0 64px; background: rgb(15 38 54 / 18%); }
.workspace-drawer { position: fixed; z-index: 35; inset: 0 auto 0 64px; display: flex; width: min(360px, calc(100vw - 64px)); flex-direction: column; border-right: 1px solid var(--line); background: #fff; color: var(--ink); box-shadow: 16px 0 36px rgb(15 38 54 / 16%); }
.workspace-drawer-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.workspace-drawer-header h2 { margin: 0; font-size: 18px; font-weight: 650; }
.workspace-drawer-close { display: grid; width: 32px; height: 32px; place-items: center; border: 0; border-radius: 6px; background: transparent; color: var(--ink-soft); cursor: pointer; }
.workspace-drawer-close:hover { background: var(--page); }
.workspace-drawer-body { flex: 1; overflow-y: auto; padding: 20px; }
.workspace-drawer-empty { display: grid; justify-items: center; gap: 8px; padding: 40px 10px; color: var(--muted); text-align: center; }
.workspace-drawer-empty p { margin: 0; }
.workspace-profile { display: grid; justify-items: center; gap: 4px; padding-bottom: 18px; border-bottom: 1px solid var(--line); text-align: center; }
.workspace-profile strong { margin-top: 8px; font-size: 17px; }
.workspace-profile span:not(.workspace-avatar) { color: var(--muted); font-size: 14px; }
.workspace-drawer-actions, .workspace-profile-edit { display: grid; gap: 4px; padding-top: 14px; }
.workspace-profile-edit { gap: 10px; }
.workspace-profile-edit p, .workspace-profile-edit small { margin: 0; color: var(--muted); font-size: 14px; }
.workspace-drawer-action { display: flex; width: 100%; min-height: 44px; align-items: center; gap: 12px; padding: 0 12px; border: 0; border-radius: 8px; background: transparent; color: var(--ink); font: inherit; font-size: 15px; text-align: left; text-decoration: none; cursor: pointer; }
.workspace-drawer-action:hover { background: var(--page); }
.workspace-drawer-action svg { color: var(--system-accent); }
.workspace-drawer-action.is-danger { margin-top: 8px; border-top: 1px solid var(--line); border-radius: 0 0 8px 8px; color: var(--red); }
.workspace-drawer-action.is-danger svg { color: var(--red); }

/* Encabezado permanente del espacio de trabajo (proporcional, 52 px) y pie de pagina */
.workspace-header { position: sticky; z-index: 8; top: 0; display: flex; height: 52px; flex: 0 0 auto; align-items: center; gap: 16px; padding: 0 clamp(14px, 2vw, 28px); border-bottom: 1px solid var(--line); background: #fff; }
.workspace-header-entity { display: flex; flex: 0 1 auto; min-width: 0; max-width: 220px; height: 36px; align-items: center; }
.workspace-header-entity img { display: block; max-width: 100%; max-height: 36px; object-fit: contain; }
.workspace-header-entity strong { overflow: hidden; color: var(--ink); font-size: 15px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.workspace-search { position: relative; display: flex; flex: 1 1 auto; max-width: 560px; height: 36px; align-items: center; gap: 8px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--page); color: var(--muted); }
.workspace-search:focus-within { border-color: var(--system-accent); background: #fff; box-shadow: 0 0 0 3px var(--accent-ring); }
.workspace-search input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent; color: var(--ink); font: inherit; font-size: 14px; }
.workspace-search input::-webkit-search-cancel-button { display: none; }
.workspace-search kbd { flex: 0 0 auto; padding: 1px 6px; border: 1px solid var(--line-strong); border-radius: 4px; background: #fff; color: var(--muted); font: inherit; font-size: 11px; }
.workspace-search-results { position: absolute; z-index: 20; top: calc(100% + 6px); right: 0; left: 0; max-height: 380px; margin: 0; padding: 6px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; background: #fff; box-shadow: 0 14px 34px rgb(15 38 54 / 16%); list-style: none; }
.workspace-search-results li { display: flex; align-items: flex-start; gap: 10px; padding: 9px 10px; border-radius: 7px; color: var(--ink); cursor: pointer; }
.workspace-search-results li.is-active { background: var(--accent-pale); }
.workspace-search-results li svg { flex: 0 0 auto; margin-top: 2px; color: var(--system-accent); }
.workspace-search-results li span { display: grid; min-width: 0; gap: 1px; }
.workspace-search-results li strong { font-size: 14px; font-weight: 620; }
.workspace-search-results li small { overflow: hidden; color: var(--muted); font-size: 12.5px; text-overflow: ellipsis; white-space: nowrap; }
.workspace-search-results .workspace-search-empty { color: var(--muted); font-size: 14px; cursor: default; }
.workspace-guide { display: inline-flex; flex: 0 0 auto; height: 34px; align-items: center; gap: 7px; margin-left: auto; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 8px; background: #fff; color: var(--ink-soft); font: inherit; font-size: 14px; font-weight: 560; cursor: pointer; }
.workspace-guide:hover { border-color: var(--system-accent); color: var(--system-accent); }
.workspace-guide svg { color: var(--system-accent); }
.workspace-header-user { display: flex; flex: 0 1 auto; min-width: 0; align-items: baseline; gap: 5px; color: var(--ink); font-size: 14px; white-space: nowrap; cursor: default; user-select: text; }
.workspace-header-name { overflow: hidden; font-weight: 620; text-overflow: ellipsis; }
.workspace-header-document { color: var(--muted); }
.maestro-workspace .workspace-tabs { top: 52px; }
.maestro-workspace .page-container { flex: 1 0 auto; }
.workspace-footer { padding: 8px 16px 10px; color: #a3adb6; font-size: 11px; font-weight: 300; letter-spacing: .2px; text-align: center; }
@media (max-width: 760px) {
  .workspace-header { gap: 10px; }
  .workspace-search kbd, .workspace-guide span, .workspace-header-document { display: none; }
  .workspace-header-entity { max-width: 110px; }
}

/* Logo de la entidad en la ficha del tenant */
.tenant-logo { display: grid; justify-items: center; gap: 8px; margin-right: 16px; }
.tenant-logo img, .tenant-logo-empty { display: grid; width: 96px; height: 64px; place-items: center; border: 1px solid var(--line); border-radius: 8px; background: #fff; object-fit: contain; color: var(--muted); }
