/* ==========================================================================
   UI Refresh · base visual global
   Capa final, no funcional, sobre style.css y ui-uniform.css.
   ========================================================================== */

:root {
  color-scheme: light;
  --refresh-bg: #f3f7f9;
  --refresh-bg-accent: #e8f2f4;
  --refresh-surface: #ffffff;
  --refresh-surface-muted: #f7fafb;
  --refresh-text: #172b35;
  --refresh-text-muted: #526a75;
  --refresh-text-subtle: #6c818a;
  --refresh-primary: #176b7a;
  --refresh-primary-hover: #115763;
  --refresh-primary-active: #0c4650;
  --refresh-primary-soft: #e2f2f4;
  --refresh-success: #247a54;
  --refresh-success-soft: #e7f5ed;
  --refresh-warning: #9a6412;
  --refresh-warning-soft: #fff4d8;
  --refresh-danger: #b43a3a;
  --refresh-danger-hover: #942f2f;
  --refresh-danger-soft: #fbeaea;
  --refresh-info: #246b9b;
  --refresh-info-soft: #e8f2fa;
  --refresh-border: #cfdae0;
  --refresh-border-strong: #adbec6;
  --refresh-radius-sm: 6px;
  --refresh-radius: 10px;
  --refresh-radius-lg: 14px;
  --refresh-shadow-sm: 0 1px 2px rgba(18, 48, 59, 0.06);
  --refresh-shadow: 0 8px 24px rgba(18, 48, 59, 0.08);
  --refresh-focus: 0 0 0 3px rgba(23, 107, 122, 0.24);
  --refresh-space-1: 0.25rem;
  --refresh-space-2: 0.5rem;
  --refresh-space-3: 0.75rem;
  --refresh-space-4: 1rem;
  --refresh-space-5: 1.5rem;
  --refresh-space-6: 2rem;

  /* Variables heredadas consumidas por las hojas anteriores. */
  --ui-bg: var(--refresh-bg);
  --ui-surface: var(--refresh-surface);
  --ui-surface-soft: var(--refresh-surface-muted);
  --ui-text: var(--refresh-text);
  --ui-muted: var(--refresh-text-muted);
  --ui-primary: var(--refresh-primary);
  --ui-primary-strong: var(--refresh-primary-hover);
  --ui-primary-soft: var(--refresh-primary-soft);
  --ui-border: var(--refresh-border);
  --ui-border-soft: #e2e9ed;
  --ui-radius: var(--refresh-radius);
  --ui-radius-small: var(--refresh-radius-sm);
  --ui-shadow: var(--refresh-shadow-sm);
}

/* ==========================================================================
   Shell clínico canónico
   Esta rama usa una única identidad visual, independiente del tema guardado.
   La especificidad deliberada neutraliza las generaciones heredadas del shell.
   ========================================================================== */

html[data-ui-theme="clinical-shell"] {
  --shell-sidebar-width: 252px;
  --shell-sidebar-bg: #0d2c3f;
  --shell-sidebar-surface: #12384c;
  --shell-sidebar-hover: #173f54;
  --shell-sidebar-active: #1e5168;
  --shell-accent: #43b7b3;
  --shell-canvas: #edf2f5;
  --shell-header: #ffffff;
  --shell-ink: #172f3d;
  --shell-muted: #617681;
  --shell-line: #d5dfe4;
  background: var(--shell-canvas);
}

html[data-ui-theme="clinical-shell"] body:not(.login-page):not(.public-message-page) {
  min-height: 100dvh;
  overflow: hidden;
  background: var(--shell-canvas) !important;
  color: var(--shell-ink);
}

html[data-ui-theme="clinical-shell"] body:not(.login-page):not(.public-message-page) .app-shell--clinical {
  display: block;
  min-height: 100dvh;
  background: var(--shell-canvas);
}

html[data-ui-theme="clinical-shell"] body:not(.login-page):not(.public-message-page) .app-shell--clinical > .sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 100;
  display: flex;
  width: var(--shell-sidebar-width) !important;
  height: 100dvh;
  padding: 16px 13px 13px;
  flex-direction: column;
  overflow: hidden;
  border: 0 !important;
  border-right: 1px solid #173d50 !important;
  background: var(--shell-sidebar-bg) !important;
  box-shadow: 4px 0 16px rgba(7, 28, 40, 0.14) !important;
  color: #e9f2f5;
}

html[data-ui-theme="clinical-shell"] body:not(.login-page):not(.public-message-page) .app-shell--clinical .sidebar-brand {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  grid-template-rows: auto auto;
  gap: 2px 10px;
  margin: 0 1px 12px;
  padding: 11px 12px;
  align-items: center;
  border: 0 !important;
  border-radius: 8px;
  background: var(--shell-sidebar-surface) !important;
  box-shadow: none !important;
}

html[data-ui-theme="clinical-shell"] body:not(.login-page):not(.public-message-page) .app-shell--clinical .sidebar-brand::before {
  content: "+";
  display: grid;
  grid-row: 1 / 3;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 7px;
  background: #269ca1;
  color: #fff;
  font-size: 1.4rem;
  line-height: 1;
}

html[data-ui-theme="clinical-shell"] body:not(.login-page):not(.public-message-page) .app-shell--clinical :where(.brand-title, .brand-sub) {
  grid-column: 2;
}

html[data-ui-theme="clinical-shell"] body:not(.login-page):not(.public-message-page) .app-shell--clinical .brand-title {
  color: #fff !important;
  font-size: 0.98rem;
  font-weight: 750;
}

html[data-ui-theme="clinical-shell"] body:not(.login-page):not(.public-message-page) .app-shell--clinical .brand-sub {
  color: #b9ced8 !important;
  font-size: 0.7rem;
}

html[data-ui-theme="clinical-shell"] body:not(.login-page):not(.public-message-page) .app-shell--clinical .sidebar-user {
  margin: 0 1px 12px;
  padding: 10px 11px;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  border-radius: 8px;
  background: var(--shell-sidebar-surface) !important;
  box-shadow: none !important;
}

html[data-ui-theme="clinical-shell"] body:not(.login-page):not(.public-message-page) .app-shell--clinical .sidebar-user__label {
  color: #a9c2cd !important;
  font-size: 0.65rem;
  letter-spacing: 0.075em;
}

html[data-ui-theme="clinical-shell"] body:not(.login-page):not(.public-message-page) .app-shell--clinical .sidebar-user__name {
  color: #fff !important;
  font-size: 0.84rem;
}

html[data-ui-theme="clinical-shell"] body:not(.login-page):not(.public-message-page) .app-shell--clinical .sidebar-nav {
  display: flex;
  min-height: 0;
  padding: 0 2px 8px 0;
  flex: 1 1 auto;
  gap: 2px;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-color: #527487 transparent;
  scrollbar-width: thin;
}

html[data-ui-theme="clinical-shell"] body:not(.login-page):not(.public-message-page) .app-shell--clinical .nav-link {
  min-height: 38px;
  padding: 8px 10px;
  gap: 9px;
  border: 0 !important;
  border-radius: 6px;
  background: transparent !important;
  color: #d3e2e8 !important;
  box-shadow: none !important;
  font-size: 0.82rem;
  font-weight: 600;
  transform: none !important;
}

html[data-ui-theme="clinical-shell"] body:not(.login-page):not(.public-message-page) .app-shell--clinical .nav-link i {
  width: 18px;
  color: #91b9c5 !important;
  font-size: 0.85rem;
  text-align: center;
}

html[data-ui-theme="clinical-shell"] body:not(.login-page):not(.public-message-page) .app-shell--clinical .nav-link:hover,
html[data-ui-theme="clinical-shell"] body:not(.login-page):not(.public-message-page) .app-shell--clinical .nav-link:focus-visible {
  background: var(--shell-sidebar-hover) !important;
  color: #fff !important;
}

html[data-ui-theme="clinical-shell"] body:not(.login-page):not(.public-message-page) .app-shell--clinical .nav-link.active,
html[data-ui-theme="clinical-shell"] body:not(.login-page):not(.public-message-page) .app-shell--clinical .nav-group.open > .nav-group-toggle {
  background: var(--shell-sidebar-active) !important;
  color: #fff !important;
}

html[data-ui-theme="clinical-shell"] body:not(.login-page):not(.public-message-page) .app-shell--clinical .nav-link.active::before,
html[data-ui-theme="clinical-shell"] body:not(.login-page):not(.public-message-page) .app-shell--clinical .nav-group.open > .nav-group-toggle::before {
  background: var(--shell-accent) !important;
}

html[data-ui-theme="clinical-shell"] body:not(.login-page):not(.public-message-page) .app-shell--clinical .nav-group-menu {
  margin: 2px 0 3px 14px;
  padding: 2px 0 2px 9px;
  border-left: 1px solid #31586b;
}

html[data-ui-theme="clinical-shell"] body:not(.login-page):not(.public-message-page) .app-shell--clinical .nav-sublink {
  min-height: 34px;
  padding-block: 6px;
  color: #b9ced7 !important;
  font-size: 0.77rem;
}

html[data-ui-theme="clinical-shell"] body:not(.login-page):not(.public-message-page) .app-shell--clinical .nav-badge {
  min-width: 20px;
  height: 19px;
  padding: 0 6px;
  border: 0 !important;
  background: #c97921 !important;
  color: #fff !important;
  font-size: 0.65rem;
}

html[data-ui-theme="clinical-shell"] body:not(.login-page):not(.public-message-page) .app-shell--clinical .sidebar-foot {
  margin-top: 0;
  padding: 10px 3px 0;
  border-top: 1px solid #294c5d !important;
}

html[data-ui-theme="clinical-shell"] body:not(.login-page):not(.public-message-page) .app-shell--clinical .sidebar-meta {
  color: #91aebb !important;
  font-size: 0.68rem;
}

html[data-ui-theme="clinical-shell"] body:not(.login-page):not(.public-message-page) .app-shell--clinical > .app-main {
  display: flex;
  width: auto !important;
  min-width: 0;
  height: 100dvh;
  min-height: 100dvh;
  margin-left: var(--shell-sidebar-width) !important;
  flex-direction: column;
  overflow-x: hidden;
  overflow-y: auto;
  background: var(--shell-canvas) !important;
}

html[data-ui-theme="clinical-shell"] body:not(.login-page):not(.public-message-page) .app-shell--clinical > .app-main::before,
html[data-ui-theme="clinical-shell"] body:not(.login-page):not(.public-message-page) .app-shell--clinical .topbar-particles {
  display: none !important;
}

html[data-ui-theme="clinical-shell"] body:not(.login-page):not(.public-message-page) .app-shell--clinical .header.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  width: 100%;
  min-height: 58px;
  padding: 0 20px;
  flex: 0 0 58px;
  align-items: center;
  border: 0 !important;
  border-bottom: 1px solid var(--shell-line) !important;
  background: var(--shell-header) !important;
  box-shadow: 0 1px 3px rgba(12, 39, 52, 0.05) !important;
  overflow: visible;
}

html[data-ui-theme="clinical-shell"] body:not(.login-page):not(.public-message-page) .app-shell--clinical .topbar-inner {
  display: flex;
  width: 100%;
  max-width: none;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

html[data-ui-theme="clinical-shell"] body:not(.login-page):not(.public-message-page) .app-shell--clinical .topbar-title {
  padding: 0;
}

html[data-ui-theme="clinical-shell"] body:not(.login-page):not(.public-message-page) .app-shell--clinical :where(.topbar-title__eyebrow, .topbar-title__sub) {
  display: none;
}

html[data-ui-theme="clinical-shell"] body:not(.login-page):not(.public-message-page) .app-shell--clinical .topbar-title__main {
  color: #193f53 !important;
  font-size: 0.94rem;
  font-weight: 730;
}

html[data-ui-theme="clinical-shell"] body:not(.login-page):not(.public-message-page) .app-shell--clinical .topbar-meta {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: flex-end;
  gap: 0;
}

html[data-ui-theme="clinical-shell"] body:not(.login-page):not(.public-message-page) .app-shell--clinical :where(.topbar-chip, .topbar-date) {
  min-height: 30px;
  padding: 0 10px;
  border: 0 !important;
  border-left: 1px solid var(--shell-line) !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  color: var(--shell-muted) !important;
  font-size: 0.72rem;
}

html[data-ui-theme="clinical-shell"] body:not(.login-page):not(.public-message-page) .app-shell--clinical .topbar-chip--role {
  color: #176a70 !important;
  font-weight: 700;
}

html[data-ui-theme="clinical-shell"] body:not(.login-page):not(.public-message-page) .app-shell--clinical :where(
  .main-container,
  .container
) {
  width: 100%;
  max-width: none;
  min-width: 0;
  margin-inline: 0;
  background: var(--shell-canvas) !important;
}

html[data-ui-theme="clinical-shell"] body:not(.login-page):not(.public-message-page) .app-shell--clinical :where(
  .main-container .content-wrap,
  .main-container .content-wrap.page-stage
) {
  width: 100%;
  max-width: 1540px;
  min-width: 0;
  margin-inline: auto;
}

/* Encabezado de página reutilizable para migraciones progresivas. */
.page-heading {
  display: flex;
  min-width: 0;
  padding: 18px clamp(16px, 2.2vw, 28px);
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--shell-line);
  background: #fff;
}

.page-heading__context {
  color: #178087;
  font-size: 0.68rem;
  font-weight: 750;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.page-heading__title {
  margin: 2px 0 0;
  color: var(--shell-ink);
  font-size: clamp(1.25rem, 2vw, 1.75rem);
  line-height: 1.2;
}

.page-heading__description,
.page-heading__meta {
  margin: 4px 0 0;
  color: var(--shell-muted);
}

.page-heading__actions,
.page-heading__pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

@media (max-width: 768px) {
  html[data-ui-theme="clinical-shell"] body:not(.login-page):not(.public-message-page) {
    overflow: auto;
  }

  html[data-ui-theme="clinical-shell"] body:not(.login-page):not(.public-message-page) .app-shell--clinical > .sidebar {
    width: min(86vw, 292px) !important;
    transform: translateX(-105%);
    transition: transform 180ms ease;
  }

  html[data-ui-theme="clinical-shell"] body.sidebar-open:not(.login-page):not(.public-message-page) .app-shell--clinical > .sidebar {
    transform: translateX(0);
  }

  html[data-ui-theme="clinical-shell"] body:not(.login-page):not(.public-message-page) .app-shell--clinical > .app-main {
    width: 100% !important;
    height: auto;
    min-height: 100dvh;
    margin-left: 0 !important;
    overflow: visible;
  }

  html[data-ui-theme="clinical-shell"] body:not(.login-page):not(.public-message-page) .app-shell--clinical .header.topbar {
    min-height: 56px;
    padding-inline: 12px;
    flex-basis: 56px;
  }

  html[data-ui-theme="clinical-shell"] body:not(.login-page):not(.public-message-page) .app-shell--clinical .header.topbar .menu-toggle {
    display: inline-flex;
    flex: 0 0 auto;
  }

  html[data-ui-theme="clinical-shell"] body:not(.login-page):not(.public-message-page) .app-shell--clinical .topbar-meta {
    gap: 0;
  }

  html[data-ui-theme="clinical-shell"] body:not(.login-page):not(.public-message-page) .app-shell--clinical :where(.topbar-chip--role, .topbar-date) {
    display: none;
  }

  html[data-ui-theme="clinical-shell"] body:not(.login-page):not(.public-message-page) .app-shell--clinical .topbar-chip--user {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .page-heading {
    padding: 15px 16px;
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .page-heading__actions,
  .page-heading__pagination {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }
}

/* Base y tipografía -------------------------------------------------------- */

html {
  background: var(--refresh-bg);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

body {
  background: var(--refresh-bg);
  color: var(--refresh-text);
  font-family: inherit;
  line-height: 1.5;
}

::selection {
  background: #bfe1e6;
  color: #0b3540;
}

a {
  color: var(--refresh-primary);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.16em;
}

a:hover {
  color: var(--refresh-primary-hover);
}

:where(h1, h2, h3, h4, h5, h6) {
  color: var(--refresh-text);
  font-family: inherit;
  font-weight: 700;
  letter-spacing: -0.018em;
  line-height: 1.25;
}

:where(p, ul, ol) + :where(h2, h3, h4) {
  margin-top: var(--refresh-space-5);
}

/* Estructura autenticada -------------------------------------------------- */

body:not(.login-page):not(.public-message-page) .app-main {
  background:
    linear-gradient(180deg, rgba(226, 242, 244, 0.44), transparent 190px),
    var(--refresh-bg);
}

body:not(.login-page):not(.public-message-page) .sidebar {
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  background: linear-gradient(180deg, #123e49 0%, #102f38 100%);
  box-shadow: 8px 0 28px rgba(9, 37, 44, 0.12);
}

body:not(.login-page):not(.public-message-page) .sidebar-brand {
  border-bottom-color: rgba(255, 255, 255, 0.12);
}

body:not(.login-page):not(.public-message-page) .brand-title,
body:not(.login-page):not(.public-message-page) .sidebar-user__name {
  color: #ffffff;
}

body:not(.login-page):not(.public-message-page) .brand-sub,
body:not(.login-page):not(.public-message-page) .sidebar-user__label,
body:not(.login-page):not(.public-message-page) .sidebar-meta {
  color: #b9d4da;
}

body:not(.login-page):not(.public-message-page) .sidebar-user {
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: var(--refresh-radius);
  background: rgba(255, 255, 255, 0.06);
}

body:not(.login-page):not(.public-message-page) .nav-link {
  border-radius: 7px;
  color: #dbeaec;
  transition: background-color 160ms ease, color 160ms ease, transform 160ms ease;
}

body:not(.login-page):not(.public-message-page) .nav-link:hover {
  background: rgba(255, 255, 255, 0.09);
  color: #ffffff;
}

body:not(.login-page):not(.public-message-page) .nav-link.active,
body:not(.login-page):not(.public-message-page) .nav-group.open > .nav-group-toggle {
  background: #ffffff;
  color: #124d59;
  box-shadow: var(--refresh-shadow-sm);
}

body:not(.login-page):not(.public-message-page) .nav-link.active::before {
  background: #45a7b6;
}

body:not(.login-page):not(.public-message-page) .nav-badge {
  background: var(--refresh-warning-soft);
  color: #71470a;
}

body:not(.login-page):not(.public-message-page) .header.topbar {
  border-bottom: 1px solid var(--refresh-border);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 2px 12px rgba(18, 48, 59, 0.06);
}

body:not(.login-page):not(.public-message-page) .topbar-particles {
  opacity: 0.18;
}

body:not(.login-page):not(.public-message-page) .topbar-title__main {
  color: #174e5a;
}

body:not(.login-page):not(.public-message-page) :where(.topbar-chip, .topbar-date) {
  border-color: var(--refresh-border);
  background: var(--refresh-surface-muted);
  color: var(--refresh-text-muted);
}

body:not(.login-page):not(.public-message-page) .topbar-chip--role {
  border-color: #b8d9df;
  background: var(--refresh-primary-soft);
  color: var(--refresh-primary-hover);
}

body:not(.login-page):not(.public-message-page) .main-container {
  color: var(--refresh-text);
}

body:not(.login-page):not(.public-message-page) :where(.page-title, .page-title-strip__text) {
  color: #153f49;
  font-weight: 750;
}

/* Superficies compactas --------------------------------------------------- */

body :where(
  .card,
  .panel,
  .form-card,
  .table-card,
  .summary-card,
  .planning-surface,
  .calendar-card,
  .filters-card,
  .stats-card,
  .dashboard-hero,
  .login-card,
  .public-message-card
) {
  border-color: var(--refresh-border);
  border-radius: var(--refresh-radius);
  background-color: var(--refresh-surface);
  box-shadow: var(--refresh-shadow-sm);
}

body :where(.card, .panel, .form-card, .table-card):hover {
  border-color: #bdccd3;
}

body :where(.card-header, .panel-header, .section-header) {
  border-bottom-color: #e3eaed;
}

body :where(.section-title-card, .dashboard-eyebrow, .eyebrow, .auth-eyebrow) {
  color: var(--refresh-primary);
  font-weight: 700;
  letter-spacing: 0.065em;
}

/* Formularios ------------------------------------------------------------- */

body :where(input, select, textarea) {
  border-color: var(--refresh-border-strong);
  border-radius: var(--refresh-radius-sm);
  background-color: #ffffff;
  color: var(--refresh-text);
  font-family: inherit;
}

body :where(input, textarea)::placeholder {
  color: var(--refresh-text-subtle);
  opacity: 1;
}

body :where(input, select, textarea):hover:not(:disabled) {
  border-color: #819da7;
}

body :where(input, select, textarea):focus {
  border-color: var(--refresh-primary);
  outline: none;
  box-shadow: var(--refresh-focus);
}

body :where(input, select, textarea):disabled {
  background: #edf2f4;
  color: #71858d;
  cursor: not-allowed;
}

body :where(label, .form-label, .filter-label) {
  color: #294955;
  font-weight: 650;
}

/* Botones ----------------------------------------------------------------- */

body :where(.btn, button, input[type="submit"], input[type="button"]) {
  border-radius: var(--refresh-radius-sm);
  font-family: inherit;
  font-weight: 650;
}

body :where(.btn-primary, input[type="submit"]),
body .login-form button[type="submit"] {
  border-color: var(--refresh-primary);
  background: var(--refresh-primary);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(23, 107, 122, 0.2);
}

body :where(.btn-primary, input[type="submit"]):hover,
body .login-form button[type="submit"]:hover {
  border-color: var(--refresh-primary-hover);
  background: var(--refresh-primary-hover);
  color: #ffffff;
}

body :where(.btn-secondary, .btn-outline, a.btn-secondary) {
  border-color: #afc4cc;
  background: #f2f7f8;
  color: #235b66;
}

body :where(.btn-secondary, .btn-outline, a.btn-secondary):hover {
  border-color: #779ba5;
  background: #e5f0f2;
  color: #163f48;
}

body :where(.btn-danger, .btn-delete, .btn-eliminar) {
  border-color: var(--refresh-danger);
  background: var(--refresh-danger);
  color: #ffffff;
}

body :where(.btn-danger, .btn-delete, .btn-eliminar):hover {
  border-color: var(--refresh-danger-hover);
  background: var(--refresh-danger-hover);
  color: #ffffff;
}

/* Tablas y datos ---------------------------------------------------------- */

body :where(.table-responsive, .table-wrap, .responsive-table) {
  border-color: var(--refresh-border);
  border-radius: var(--refresh-radius);
  background: var(--refresh-surface);
}

body table {
  color: var(--refresh-text);
}

body table th {
  border-color: #d8e2e6;
  background: #eaf3f5;
  color: #234f59;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.025em;
}

body table td {
  border-color: #e1e8eb;
}

body table tbody tr:nth-child(even) {
  background: #fafcfc;
}

body table tbody tr:hover {
  background: #edf6f7;
}

/* Estados, alertas y badges ---------------------------------------------- */

body :where(.alert, .success-msg, .error-msg, .info-msg, .warning-msg) {
  border: 1px solid transparent;
  border-radius: var(--refresh-radius-sm);
  box-shadow: none;
}

body :where(.alert-success, .success-msg) {
  border-color: #b9dfca;
  background: var(--refresh-success-soft);
  color: #18583c;
}

body :where(.alert-warning, .warning-msg) {
  border-color: #efd59a;
  background: var(--refresh-warning-soft);
  color: #704708;
}

body :where(.alert-danger, .alert-error, .error-msg) {
  border-color: #efc0c0;
  background: var(--refresh-danger-soft);
  color: #862d2d;
}

body :where(.alert-info, .info-msg, .panel-note) {
  border-color: #bfd9eb;
  background: var(--refresh-info-soft);
  color: #1d567d;
}

body :where(.badge, .status-badge, .tag, .chip, .pill) {
  border-radius: 999px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

body :where(.badge-aceptada, .badge-success) {
  background: var(--refresh-success);
  color: #ffffff;
}

body :where(.badge-pendiente, .badge-warning) {
  background: var(--refresh-warning);
  color: #ffffff;
}

body :where(.badge-rechazada, .badge-danger) {
  background: var(--refresh-danger);
  color: #ffffff;
}

body :where(.empty-state, .no-results, .empty-message, .sin-resultados) {
  border: 1px dashed var(--refresh-border-strong);
  border-radius: var(--refresh-radius);
  background: var(--refresh-surface-muted);
  color: var(--refresh-text-muted);
}

/* Modales ----------------------------------------------------------------- */

body .modal {
  background: rgba(8, 30, 36, 0.54);
  backdrop-filter: blur(2px);
}

body .modal-dialog {
  border: 1px solid var(--refresh-border);
  border-radius: var(--refresh-radius-lg);
  background: var(--refresh-surface);
  box-shadow: 0 24px 60px rgba(8, 30, 36, 0.2);
}

body :where(.modal-header, .modal-footer, .modal-actions) {
  border-color: #e0e8eb;
}

/* Acceso ------------------------------------------------------------------ */

body.login-page {
  background:
    radial-gradient(circle at 12% 10%, rgba(81, 161, 174, 0.16), transparent 34%),
    linear-gradient(145deg, #eef6f7 0%, #f7fafb 52%, #e8f1f3 100%);
}

.login-page .login-screen {
  padding: clamp(1rem, 4vw, 2.5rem);
}

.login-page .login-card {
  border: 1px solid #cadadf;
  border-radius: var(--refresh-radius-lg);
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 18px 48px rgba(18, 48, 59, 0.13);
}

.login-page .login-logo {
  filter: saturate(0.9) contrast(1.02);
}

.login-page .login-title {
  color: #153f49;
  font-weight: 750;
}

.login-page .auth-subtitle,
.login-page .login-remember-mobile small {
  color: var(--refresh-text-muted);
}

.login-page .login-back a {
  color: var(--refresh-primary);
  font-weight: 650;
}

/* Pie y accesibilidad ----------------------------------------------------- */

body .footer {
  border-top-color: var(--refresh-border);
  background: rgba(255, 255, 255, 0.82);
  color: var(--refresh-text-muted);
}

body :where(
  a,
  button,
  input,
  select,
  textarea,
  summary,
  [tabindex]:not([tabindex="-1"])
):focus-visible {
  outline: 3px solid rgba(23, 107, 122, 0.34);
  outline-offset: 2px;
  box-shadow: var(--refresh-focus);
}

/* Adaptación básica ------------------------------------------------------- */

@media (max-width: 900px) {
  body:not(.login-page):not(.public-message-page) .main-container {
    padding-top: var(--refresh-space-3);
  }

  body :where(.card, .panel, .form-card, .table-card, .summary-card) {
    border-radius: 8px;
  }
}

@media (max-width: 640px) {
  body {
    font-size: 15px;
  }

  body:not(.login-page):not(.public-message-page) .topbar-meta {
    gap: var(--refresh-space-2);
  }

  body :where(.form-actions, .button-row, .actions-row, .modal-actions) {
    gap: var(--refresh-space-2);
  }

  body :where(.table-responsive, .table-wrap, .responsive-table) {
    border-radius: var(--refresh-radius-sm);
  }

  .login-page .login-screen {
    padding: var(--refresh-space-4);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ==========================================================================
   Segunda pasada · jerarquía y carácter visual
   Refuerza el lenguaje sanitario sin alterar estructura ni comportamiento.
   ========================================================================== */

:root {
  --refresh-bg: #edf2f5;
  --refresh-bg-accent: #e3edf0;
  --refresh-surface-muted: #f5f8fa;
  --refresh-text: #172a35;
  --refresh-text-muted: #526671;
  --refresh-primary: #15557a;
  --refresh-primary-hover: #104462;
  --refresh-primary-active: #0b354d;
  --refresh-primary-soft: #e4f0f5;
  --refresh-accent: #17848a;
  --refresh-accent-soft: #e1f2f1;
  --refresh-border: #ccd8de;
  --refresh-border-strong: #9fb2bc;
  --refresh-radius-sm: 7px;
  --refresh-radius: 11px;
  --refresh-radius-lg: 16px;
  --refresh-shadow-sm: 0 1px 3px rgba(15, 42, 55, 0.08);
  --refresh-shadow: 0 7px 22px rgba(15, 42, 55, 0.09);
  --refresh-focus: 0 0 0 3px rgba(21, 85, 122, 0.26);
  --sidebar-width: 268px;
}

body:not(.login-page):not(.public-message-page) {
  background: var(--refresh-bg);
  font-size: 0.9375rem;
}

body:not(.login-page):not(.public-message-page) .app-main {
  background: var(--refresh-bg);
}

body:not(.login-page):not(.public-message-page) .app-main::before,
body:not(.login-page):not(.public-message-page) .main-container::before,
body:not(.login-page):not(.public-message-page) .topbar-particles {
  display: none;
}

/* Navegación lateral ------------------------------------------------------ */

body:not(.login-page):not(.public-message-page) .sidebar {
  width: var(--sidebar-width);
  padding: 18px 14px 14px;
  border-right: 0;
  background: #102f43;
  box-shadow: 5px 0 18px rgba(10, 34, 48, 0.16);
}

body:not(.login-page):not(.public-message-page) .sidebar-brand {
  gap: 5px;
  margin: 0 2px 14px;
  padding: 12px 13px 14px;
  border: 0;
  border-left: 3px solid #39a9ad;
  border-radius: 8px;
  background: #153b50;
}

body:not(.login-page):not(.public-message-page) .sidebar-logo {
  max-height: 52px;
}

body:not(.login-page):not(.public-message-page) .brand-title {
  font-size: 1.08rem;
  font-weight: 750;
  letter-spacing: 0.01em;
}

body:not(.login-page):not(.public-message-page) .brand-sub {
  color: #b7ccd6;
  font-size: 0.78rem;
}

body:not(.login-page):not(.public-message-page) .sidebar-user {
  gap: 7px;
  margin: 0 2px 14px;
  padding: 11px 12px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.065);
}

body:not(.login-page):not(.public-message-page) .sidebar-user__label {
  color: #a9c3ce;
  font-size: 0.69rem;
  letter-spacing: 0.075em;
}

body:not(.login-page):not(.public-message-page) .sidebar-user__name {
  color: #ffffff;
  font-size: 0.91rem;
}

body:not(.login-page):not(.public-message-page) .role-switcher select {
  min-height: 38px;
  border-color: rgba(255, 255, 255, 0.2);
  background-color: #f8fbfc;
  color: #173b4d;
}

body:not(.login-page):not(.public-message-page) .sidebar-nav {
  gap: 3px;
  padding-right: 2px;
}

body:not(.login-page):not(.public-message-page) .nav-link {
  min-height: 42px;
  gap: 11px;
  padding: 9px 11px;
  border-radius: 7px;
  color: #d5e3e9;
  font-size: 0.87rem;
  font-weight: 590;
}

body:not(.login-page):not(.public-message-page) .nav-link i {
  width: 20px;
  color: #9fc4ce;
  font-size: 0.92rem;
}

body:not(.login-page):not(.public-message-page) .nav-link::before {
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  background: #42b4b4;
}

body:not(.login-page):not(.public-message-page) .nav-link:hover {
  background: #1a4358;
  color: #ffffff;
  transform: none;
}

body:not(.login-page):not(.public-message-page) .nav-link:hover i {
  color: #d9f2f1;
}

body:not(.login-page):not(.public-message-page) .nav-link.active,
body:not(.login-page):not(.public-message-page) .nav-group.open > .nav-group-toggle {
  background: #eaf4f6;
  color: #123d54;
  box-shadow: 0 2px 8px rgba(5, 23, 34, 0.18);
}

body:not(.login-page):not(.public-message-page) .nav-link.active i,
body:not(.login-page):not(.public-message-page) .nav-group.open > .nav-group-toggle i {
  color: #176b78;
}

body:not(.login-page):not(.public-message-page) .nav-group-menu {
  gap: 2px;
  margin: 2px 0 4px 17px;
  padding: 3px 0 3px 10px;
  border-left: 1px solid rgba(155, 194, 204, 0.28);
}

body:not(.login-page):not(.public-message-page) .nav-sublink {
  min-height: 37px;
  padding: 7px 9px;
  color: #b7ccd5;
  font-size: 0.82rem;
}

body:not(.login-page):not(.public-message-page) .nav-sublink:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #ffffff;
}

body:not(.login-page):not(.public-message-page) .nav-badge {
  min-width: 22px;
  height: 20px;
  padding: 0 6px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 999px;
  background: #d98b2b;
  color: #ffffff;
  font-size: 0.69rem;
}

body:not(.login-page):not(.public-message-page) .sidebar-foot {
  margin-top: auto;
  padding: 13px 2px 0;
  border-top-color: rgba(255, 255, 255, 0.12);
}

body:not(.login-page):not(.public-message-page) .nav-link-logout {
  margin-top: 7px;
  border-top-color: rgba(255, 255, 255, 0.12);
}

body:not(.login-page):not(.public-message-page) .sidebar-nav > a[href="/mi_perfil.php"] {
  margin-top: auto;
  padding-top: 11px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

body:not(.login-page):not(.public-message-page) .sidebar-nav > a[href="/logout.php"] {
  color: #f0c8c8;
}

/* Cabecera superior y título de página ---------------------------------- */

body:not(.login-page):not(.public-message-page) .header.topbar {
  min-height: 58px;
  padding: 0 22px;
  border-bottom: 1px solid #d7e0e4;
  background: #ffffff;
  box-shadow: 0 3px 12px rgba(15, 42, 55, 0.06);
  overflow: visible;
}

body:not(.login-page):not(.public-message-page) .topbar-inner {
  max-width: none;
  gap: 16px;
}

body:not(.login-page):not(.public-message-page) .topbar-title {
  padding: 8px 0;
}

body:not(.login-page):not(.public-message-page) .topbar-title__main {
  color: #173e52;
  font-size: 0.94rem;
  font-weight: 700;
  letter-spacing: 0.005em;
}

body:not(.login-page):not(.public-message-page) .topbar-meta {
  gap: 7px;
}

body:not(.login-page):not(.public-message-page) :where(.topbar-chip, .topbar-date) {
  min-height: 32px;
  padding: 0 10px;
  border: 0;
  border-left: 1px solid #d8e2e6;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  font-size: 0.75rem;
}

body:not(.login-page):not(.public-message-page) .topbar-chip--role {
  color: var(--refresh-primary);
}

body:not(.login-page):not(.public-message-page) .role-switcher--topbar select {
  min-height: 34px;
  padding-block: 0;
  border-color: #b8c8cf;
  background: #f7fafb;
  color: #1f4f63;
  font-size: 0.78rem;
  font-weight: 650;
}

body:not(.login-page):not(.public-message-page) .page-header,
body:not(.login-page):not(.public-message-page) .page-title-strip {
  position: relative;
  min-height: 72px;
  margin: 0;
  padding: 20px 24px 17px;
  border-bottom: 1px solid #d9e2e6;
  background: #ffffff;
  box-shadow: none;
}

body:not(.login-page):not(.public-message-page) .page-header::after,
body:not(.login-page):not(.public-message-page) .page-title-strip::after {
  content: "";
  position: absolute;
  left: 24px;
  bottom: -1px;
  width: 52px;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--refresh-accent);
}

body:not(.login-page):not(.public-message-page) .page-title,
body:not(.login-page):not(.public-message-page) .page-title-strip__text {
  max-width: none;
  margin: 0;
  color: #14384b;
  font-size: clamp(1.55rem, 2.1vw, 2rem);
  font-weight: 760;
  letter-spacing: -0.025em;
  line-height: 1.16;
}

body:not(.login-page):not(.public-message-page) .main-container {
  padding: 20px 24px 0;
}

body:not(.login-page):not(.public-message-page) .content-wrap {
  max-width: 1540px;
  margin-inline: auto;
}

/* Superficies, controles y datos ---------------------------------------- */

body:not(.login-page):not(.public-message-page) :where(
  .card, .panel, .form-card, .table-card, .summary-card, .planning-surface,
  .calendar-card, .filters-card, .stats-card, .dashboard-card,
  .request-composer__main, .request-composer__aside, .users-edit-panel
) {
  border: 1px solid var(--refresh-border);
  border-radius: var(--refresh-radius);
  background: #ffffff;
  box-shadow: var(--refresh-shadow-sm);
}

body:not(.login-page):not(.public-message-page) :where(.card, .panel, .form-card, .table-card):hover {
  border-color: #afc0c8;
  box-shadow: 0 5px 16px rgba(15, 42, 55, 0.07);
}

body :where(input:not([type="checkbox"]):not([type="radio"]), select, textarea) {
  min-height: 40px;
  border: 1px solid var(--refresh-border-strong);
  border-radius: 7px;
  background: #ffffff;
  color: var(--refresh-text);
  box-shadow: inset 0 1px 1px rgba(15, 42, 55, 0.025);
}

body :where(input:not([type="checkbox"]):not([type="radio"]), select, textarea):focus {
  border-color: var(--refresh-primary);
  box-shadow: var(--refresh-focus);
}

body :where(.btn, button, input[type="submit"], input[type="button"]) {
  min-height: 38px;
  border-radius: 7px;
  font-size: 0.83rem;
  font-weight: 680;
}

body :where(.btn-primary, .btn-aceptar, .btn-editar, .boton-primario, input[type="submit"]),
body .login-form button[type="submit"] {
  border-color: var(--refresh-primary);
  /* Compatibilidad: style.css fija el fondo heredado con !important. */
  background: var(--refresh-primary) !important;
  color: #ffffff;
  box-shadow: 0 2px 5px rgba(21, 85, 122, 0.22);
}

body :where(.btn-primary, .btn-aceptar, .btn-editar, .boton-primario, input[type="submit"]):hover,
body .login-form button[type="submit"]:hover {
  border-color: var(--refresh-primary-hover);
  background: var(--refresh-primary-hover) !important;
}

body :where(.btn-secondary, .btn-outline, .boton-secundario, .btn-back) {
  border-color: #aebfc7;
  background: #f5f8f9 !important;
  color: #254e60;
  box-shadow: none;
}

body :where(.btn-danger, .btn-borrar, .btn-rechazar, .btn-delete, .btn-eliminar) {
  border-color: var(--refresh-danger);
  background: var(--refresh-danger) !important;
  color: #ffffff;
}

body :where(.btn-danger, .btn-borrar, .btn-rechazar, .btn-delete, .btn-eliminar):hover {
  border-color: var(--refresh-danger-hover);
  background: var(--refresh-danger-hover) !important;
}

body :where(.btn, button, input[type="submit"], input[type="button"]):active {
  transform: translateY(1px);
}

body :where(.btn, button, input[type="submit"], input[type="button"]):disabled {
  border-color: #cfd9de;
  background: #e7edef;
  color: #71838c;
  box-shadow: none;
  cursor: not-allowed;
  opacity: 0.82;
}

body :where(.table-responsive, .table-wrap, .responsive-table, .table-wrapper, .tabla-scroll) {
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--refresh-border);
  border-radius: var(--refresh-radius);
  background: #ffffff;
  box-shadow: var(--refresh-shadow-sm);
  -webkit-overflow-scrolling: touch;
}

body table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

body table th {
  padding: 10px 12px;
  border-bottom: 1px solid #c4d2d8;
  background: #e8f0f3;
  color: #214656;
  font-size: 0.78rem;
  text-transform: none;
}

body table td {
  padding: 9px 12px;
  vertical-align: middle;
}

body table tbody tr:nth-child(even) {
  background: #f8fafb;
}

body table tbody tr:hover {
  background: #eef5f6;
}

body table td :where(.btn, button) {
  min-height: 34px;
  padding: 0.35rem 0.6rem;
  font-size: 0.77rem;
}

/* Visión general diaria -------------------------------------------------- */

body.admin-vision-dia-page .vision-dia-hero {
  display: grid;
  grid-template-columns: minmax(260px, 0.72fr) minmax(430px, 1.28fr);
  gap: 18px;
  padding: 0;
  border: 1px solid #cbd8de;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: var(--refresh-shadow-sm);
  overflow: hidden;
}

body.admin-vision-dia-page .vision-dia-hero .dashboard-hero__content {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 19px 21px;
  border: 0;
  border-left: 4px solid var(--refresh-accent);
  border-radius: 0;
  background: #ffffff;
  box-shadow: none;
}

body.admin-vision-dia-page .vision-dia-hero .dashboard-hero__content h2 {
  margin: 3px 0 2px;
  color: #143e53;
  font-size: 1.3rem;
  font-weight: 740;
}

body.admin-vision-dia-page .vision-dia-hero .dashboard-hero__content p {
  color: var(--refresh-text-muted);
}

body.admin-vision-dia-page .vision-dia-hero .dashboard-kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  padding: 0;
  border: 0;
  border-left: 1px solid #d8e1e5;
  border-radius: 0;
  background: #d8e1e5;
  box-shadow: none;
}

body.admin-vision-dia-page .vision-dia-hero .dashboard-kpi {
  display: flex;
  min-height: 88px;
  padding: 15px;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  border: 0;
  border-radius: 0;
  background: #f7fafb;
}

body.admin-vision-dia-page .vision-dia-hero .dashboard-kpi__label {
  color: #58707c;
  font-size: 0.73rem;
  letter-spacing: 0.025em;
}

body.admin-vision-dia-page .vision-dia-hero .dashboard-kpi__value {
  color: var(--refresh-primary);
  font-size: 1.65rem;
  line-height: 1.15;
}

body.admin-vision-dia-page .vision-dia-toolbar {
  margin: 13px 0;
}

body.admin-vision-dia-page .vision-dia-date-card {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px 14px;
  border: 1px solid #cbd8de;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: var(--refresh-shadow-sm);
}

body.admin-vision-dia-page .vision-dia-date-card .section-title-card {
  min-width: max-content;
  margin: 0;
  padding-right: 17px;
  border-right: 1px solid #dbe3e7;
  color: #315668;
}

body.admin-vision-dia-page .vision-dia-form__controls {
  margin-top: 0;
}

body.admin-vision-dia-page .vision-dia-form__controls :is(a, button, input) {
  min-height: 40px;
  height: 40px;
}

body.admin-vision-dia-page .vision-dia-grid {
  gap: 14px;
}

body.admin-vision-dia-page .vision-dia-card {
  padding: 17px 18px;
  border: 1px solid #ccd8de;
  border-top: 0;
  border-radius: 11px;
  background: #ffffff;
  box-shadow: var(--refresh-shadow-sm);
}

body.admin-vision-dia-page .vision-dia-card--guardias {
  border-left: 4px solid var(--refresh-primary);
}

body.admin-vision-dia-page .vision-dia-card--tarde {
  border-left: 4px solid #b97820;
}

body.admin-vision-dia-page .vision-dia-card--collapsible {
  padding: 0;
  overflow: hidden;
}

body.admin-vision-dia-page .vision-dia-card--adjuntos {
  border-left: 4px solid var(--refresh-primary);
}

body.admin-vision-dia-page .vision-dia-card--residentes {
  border-left: 4px solid var(--refresh-accent);
}

body.admin-vision-dia-page .vision-dia-summary {
  min-height: 58px;
  padding: 13px 16px;
  background: #f7fafb;
  color: #183e51;
  font-size: 1rem;
  font-weight: 720;
}

body.admin-vision-dia-page .vision-dia-summary:hover {
  background: #edf4f6;
}

body.admin-vision-dia-page .vision-dia-summary__title small,
body.admin-vision-dia-page .vision-dia-card__meta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 25px;
  height: 24px;
  margin-left: 7px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--refresh-primary-soft);
  color: var(--refresh-primary);
  font-size: 0.73rem;
  font-weight: 750;
}

body.admin-vision-dia-page .vision-dia-summary__arrow {
  display: inline-grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 1px solid #c5d3d9;
  border-radius: 7px;
  background: #ffffff;
}

body.admin-vision-dia-page .vision-dia-card__header {
  align-items: center;
  margin-bottom: 13px;
  padding-bottom: 12px;
  border-bottom: 1px solid #e0e7ea;
}

body.admin-vision-dia-page .vision-dia-card__header h3 {
  margin-top: 3px;
  color: #173e51;
  font-size: 1.08rem;
  font-weight: 730;
}

body.admin-vision-dia-page .vision-dia-card .section-title-card {
  margin: 0;
  color: var(--refresh-accent);
  font-size: 0.71rem;
}

body.admin-vision-dia-page .vision-tarde-block + .vision-tarde-block {
  padding-top: 14px;
  border-top: 1px solid #e1e8eb;
}

body.admin-vision-dia-page .vision-tarde-block h4 {
  margin-bottom: 6px;
  color: #2d5668;
  font-size: 0.87rem;
  font-weight: 720;
  text-transform: uppercase;
  letter-spacing: 0.035em;
}

body.admin-vision-dia-page .vision-person-list li {
  min-height: 42px;
  padding: 8px 2px;
  border-bottom-color: #e3eaed;
  font-size: 0.91rem;
}

body.admin-vision-dia-page .vision-person-list--with-role li,
body.admin-vision-dia-page .vision-person-list--detail li {
  grid-template-columns: minmax(0, 1fr) auto;
}

body.admin-vision-dia-page .vision-service-tag,
body.admin-vision-dia-page .vision-service-tag--long {
  width: auto;
  min-width: 0;
  max-width: min(240px, 44vw);
  height: auto;
  min-height: 26px;
  padding: 4px 9px;
  border: 1px solid #c4dce2;
  border-radius: 999px;
  background: #eaf4f6;
  color: #1f6070;
  font-size: 0.72rem;
  line-height: 1.2;
  white-space: normal;
}

body.admin-vision-dia-page .vision-dia-empty {
  display: flex;
  align-items: center;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px dashed #bdccd3;
  border-radius: 8px;
  background: #f7f9fa;
  color: #5b707a;
  font-size: 0.88rem;
}

body.admin-vision-dia-page .vision-dia-empty::before {
  content: "—";
  margin-right: 8px;
  color: var(--refresh-accent);
  font-weight: 800;
}

/* Acceso más definido ---------------------------------------------------- */

body.login-page {
  background: #eaf0f3;
}

.login-page .login-card {
  border: 1px solid #c4d2d8;
  border-top: 4px solid var(--refresh-primary);
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 18px 45px rgba(15, 42, 55, 0.16);
}

.login-page .auth-eyebrow {
  color: var(--refresh-accent);
  font-size: 0.72rem;
  letter-spacing: 0.09em;
}

.login-page .login-title {
  color: #13394d;
  font-size: clamp(1.6rem, 4vw, 2rem);
  letter-spacing: -0.025em;
}

.login-page .login-form :where(input, select) {
  min-height: 44px;
}

.login-page .login-form button[type="submit"] {
  min-height: 44px;
}

/* Adaptación ------------------------------------------------------------- */

@media (max-width: 1100px) {
  :root {
    --sidebar-width: 248px;
  }

  body:not(.login-page):not(.public-message-page) .header.topbar {
    padding-inline: 17px;
  }

  body:not(.login-page):not(.public-message-page) .topbar-date {
    display: none;
  }

  body.admin-vision-dia-page .vision-dia-hero {
    grid-template-columns: minmax(230px, 0.65fr) minmax(390px, 1.35fr);
  }
}

@media (max-width: 900px) {
  body:not(.login-page):not(.public-message-page) .sidebar {
    width: min(320px, 88vw);
    border-radius: 0 12px 12px 0;
    box-shadow: 16px 0 40px rgba(5, 25, 36, 0.34);
  }

  body:not(.login-page):not(.public-message-page) .sidebar-overlay {
    background: rgba(7, 25, 34, 0.58);
    backdrop-filter: blur(2px);
  }

  body:not(.login-page):not(.public-message-page) .header.topbar {
    min-height: 62px;
    padding: 0 14px 0 64px;
  }

  body:not(.login-page):not(.public-message-page) .menu-toggle {
    min-width: 43px;
    min-height: 42px;
    border-color: #b6c7ce;
    background: #f5f8f9;
    color: #19465b;
  }

  body:not(.login-page):not(.public-message-page) .topbar-meta {
    display: none;
  }

  body:not(.login-page):not(.public-message-page) .page-header,
  body:not(.login-page):not(.public-message-page) .page-title-strip {
    min-height: 66px;
    padding: 17px 18px 14px;
  }

  body:not(.login-page):not(.public-message-page) .page-header::after,
  body:not(.login-page):not(.public-message-page) .page-title-strip::after {
    left: 18px;
  }

  body:not(.login-page):not(.public-message-page) .main-container {
    padding: 16px 16px 0;
  }

  body.admin-vision-dia-page .vision-dia-hero {
    grid-template-columns: 1fr;
  }

  body.admin-vision-dia-page .vision-dia-hero .dashboard-kpis {
    border-top: 1px solid #d8e1e5;
    border-left: 0;
  }

  body.admin-vision-dia-page .vision-dia-date-card {
    align-items: flex-start;
    flex-direction: column;
    gap: 9px;
  }

  body.admin-vision-dia-page .vision-dia-date-card .section-title-card {
    width: 100%;
    padding: 0 0 7px;
    border-right: 0;
    border-bottom: 1px solid #e0e7ea;
  }
}

@media (max-width: 600px) {
  body:not(.login-page):not(.public-message-page) {
    font-size: 0.9rem;
  }

  body:not(.login-page):not(.public-message-page) .topbar-title__main {
    max-width: 46vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body:not(.login-page):not(.public-message-page) .page-title,
  body:not(.login-page):not(.public-message-page) .page-title-strip__text {
    font-size: 1.48rem;
  }

  body:not(.login-page):not(.public-message-page) .main-container {
    padding-inline: 12px;
  }

  body.admin-vision-dia-page .vision-dia-hero .dashboard-kpis {
    grid-template-columns: 1fr;
  }

  body.admin-vision-dia-page .vision-dia-hero .dashboard-kpi {
    min-height: 64px;
    padding: 10px 14px;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  body.admin-vision-dia-page .vision-dia-hero .dashboard-kpi__value {
    font-size: 1.35rem;
  }

  body.admin-vision-dia-page .vision-dia-form__controls {
    width: 100%;
  }

  body.admin-vision-dia-page .vision-person-list--with-role li,
  body.admin-vision-dia-page .vision-person-list--detail li {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
  }

  body.admin-vision-dia-page .vision-service-tag,
  body.admin-vision-dia-page .vision-service-tag--long {
    width: auto;
    min-width: 0;
    max-width: 46vw;
  }
}

@media (max-width: 420px) {
  body:not(.login-page):not(.public-message-page) .header.topbar {
    padding-right: 10px;
  }

  body:not(.login-page):not(.public-message-page) .menu-toggle__label {
    display: none;
  }

  body.admin-vision-dia-page .vision-dia-card {
    padding: 14px;
  }

  body.admin-vision-dia-page .vision-dia-card--collapsible {
    padding: 0;
  }

  body.admin-vision-dia-page .vision-dia-card--collapsible .vision-dia-card__body {
    padding: 0 14px 14px;
  }

  body.admin-vision-dia-page .vision-dia-summary {
    padding-inline: 13px;
  }
}

/* ==========================================================================
   Espacio operativo · Planificación semanal
   Página piloto para una composición de trabajo clínico de alta densidad.
   ========================================================================== */

body.planificacion-editor-page {
  --planning-grid-border: #cbd7dd;
  --planning-grid-line: #e2e9ec;
  --planning-weekend: #f2f5f6;
  --planning-today: #e6f3f3;
  --planning-sticky: #f7fafb;
  overflow-x: hidden;
}

body.planificacion-editor-page .app-main {
  min-width: 0;
}

body.planificacion-editor-page .planning-page-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 24px;
  min-height: 112px;
  padding-block: 19px;
}

body.planificacion-editor-page .planning-page-header__identity {
  min-width: 0;
}

body.planificacion-editor-page .planning-page-header__eyebrow {
  display: block;
  margin-bottom: 3px;
  color: var(--refresh-accent);
  font-size: 0.72rem;
  font-weight: 780;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

body.planificacion-editor-page .planning-page-header .page-title {
  font-size: clamp(1.8rem, 2.7vw, 2.55rem);
  line-height: 1.08;
}

body.planificacion-editor-page .planning-page-header__subtitle {
  margin: 6px 0 0;
  color: #556c77;
  font-size: 0.91rem;
  font-weight: 560;
}

body.planificacion-editor-page .planning-week-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

body.planificacion-editor-page .week-nav-btn {
  display: inline-flex;
  min-height: 40px;
  padding: 0 13px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid #aebfc7;
  border-radius: 7px;
  background: #ffffff;
  color: #254e60;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  box-shadow: 0 1px 2px rgba(15, 42, 55, 0.06);
}

body.planificacion-editor-page .week-nav-btn:hover {
  border-color: #7796a3;
  background: #eef4f6;
  color: #173f52;
}

body.planificacion-editor-page .week-nav-btn.is-disabled {
  border-color: #d4dde1;
  background: #f2f5f6;
  color: #87979f;
  box-shadow: none;
  cursor: not-allowed;
  opacity: 1;
}

/* Contexto operativo ----------------------------------------------------- */

body.planificacion-editor-page .planning-context {
  display: grid;
  grid-template-columns: minmax(260px, 1.25fr) minmax(150px, 0.55fr) minmax(260px, 1fr) auto;
  align-items: stretch;
  margin-bottom: 12px;
  border: 1px solid var(--planning-grid-border);
  border-radius: 10px;
  background: #ffffff;
  box-shadow: var(--refresh-shadow-sm);
  overflow: hidden;
}

body.planificacion-editor-page .planning-context__item {
  display: flex;
  min-width: 0;
  padding: 11px 14px;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  border-right: 1px solid #dfe7ea;
}

body.planificacion-editor-page .planning-context__label,
body.planificacion-editor-page .acciones-planificacion__label {
  color: #6a7d86;
  font-size: 0.68rem;
  font-weight: 760;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

body.planificacion-editor-page .planning-context__item strong {
  overflow: hidden;
  color: #1f4354;
  font-size: 0.82rem;
  font-weight: 680;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.planificacion-editor-page .planning-context__editable {
  display: flex;
  max-width: 230px;
  padding: 11px 14px;
  align-items: center;
  gap: 9px;
  background: #edf5f6;
  color: #245565;
  font-size: 0.78rem;
  font-weight: 650;
}

body.planificacion-editor-page .planning-context__editable i {
  color: var(--refresh-accent);
}

body.planificacion-editor-page .planning-legend {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

body.planificacion-editor-page .planning-legend__empty {
  color: #687b84;
  font-size: 0.78rem;
}

/* Cuadrícula principal --------------------------------------------------- */

body.planificacion-editor-page .planificacion-card {
  padding: 0;
  border: 1px solid var(--planning-grid-border);
  border-radius: 11px;
  background: #ffffff;
  box-shadow: 0 8px 24px rgba(15, 42, 55, 0.08);
  overflow: visible;
}

body.planificacion-editor-page .planificacion-desktop {
  display: block;
  min-width: 0;
}

body.planificacion-editor-page .tabla-fit-wrapper {
  width: 100%;
  height: clamp(360px, calc(100dvh - 310px), 720px);
  max-height: clamp(360px, calc(100dvh - 310px), 720px) !important;
  min-height: 0;
  padding: 0 !important;
  overflow: auto !important;
  border-radius: 10px 10px 0 0;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  scrollbar-color: #708d99 #e5ecef;
  scrollbar-width: auto;
}

body.planificacion-editor-page .tabla-fit-inner {
  display: contents !important;
  width: max-content !important;
  min-width: 100% !important;
  margin: 0 !important;
  overflow: visible !important;
  transform: none !important;
}

body.planificacion-editor-page #tablaPlanificacion {
  width: max-content !important;
  min-width: 1040px !important;
  table-layout: fixed !important;
  overflow: visible !important;
  border: 0;
  border-collapse: separate;
  border-spacing: 0;
  box-shadow: none;
}

body.planificacion-editor-page .tabla-fit-wrapper::-webkit-scrollbar {
  width: 14px;
  height: 14px;
}

body.planificacion-editor-page .tabla-fit-wrapper::-webkit-scrollbar-track {
  border-left: 1px solid #d2dde2;
  border-top: 1px solid #d2dde2;
  background: #e5ecef;
}

body.planificacion-editor-page .tabla-fit-wrapper::-webkit-scrollbar-thumb {
  min-height: 44px;
  border: 3px solid #e5ecef;
  border-radius: 999px;
  background: #708d99;
}

body.planificacion-editor-page .tabla-fit-wrapper::-webkit-scrollbar-thumb:hover {
  background: #4f707d;
}

body.planificacion-editor-page #tablaPlanificacion th,
body.planificacion-editor-page #tablaPlanificacion td {
  width: 112px;
  min-width: 112px;
  height: 45px;
  padding: 6px 8px;
  border: 0;
  border-right: 1px solid var(--planning-grid-line);
  border-bottom: 1px solid var(--planning-grid-line);
  background: #ffffff;
  color: #273f4b;
  font-size: 0.78rem;
  line-height: 1.2;
  text-align: center;
  vertical-align: middle;
}

body.planificacion-editor-page #tablaPlanificacion th:first-child,
body.planificacion-editor-page #tablaPlanificacion td:first-child {
  width: 232px;
  min-width: 232px;
  max-width: 232px;
  padding-inline: 13px;
  text-align: left;
}

body.planificacion-editor-page #tablaPlanificacion thead {
  position: sticky;
  top: 0;
  z-index: 8;
  background: #e9f0f3;
}

body.planificacion-editor-page #tablaPlanificacion thead th {
  position: sticky;
  top: 0;
  z-index: 9;
  height: 49px;
  border-bottom: 1px solid #adbec6;
  background: #e9f0f3;
  color: #204657;
  font-size: 0.75rem;
  font-weight: 780;
  letter-spacing: 0.015em;
  box-shadow: 0 1px 0 rgba(15, 42, 55, 0.05);
}

body.planificacion-editor-page #tablaPlanificacion :where(th:first-child, td:first-child) {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--planning-sticky);
  box-shadow: 1px 0 0 #cdd9de;
}

body.planificacion-editor-page #tablaPlanificacion thead th:first-child {
  z-index: 11;
  background: #dfe9ed;
}

body.planificacion-editor-page #tablaPlanificacion tbody td:first-child {
  color: #1f3f4e;
  font-size: 0.8rem;
  font-weight: 680;
}

body.planificacion-editor-page #tablaPlanificacion tbody tr:nth-child(even) td {
  background: #f9fbfc;
}

body.planificacion-editor-page #tablaPlanificacion tbody tr:nth-child(even) td:first-child {
  background: #f2f6f7;
}

body.planificacion-editor-page #tablaPlanificacion tbody tr:hover td {
  background: #eff6f7;
}

body.planificacion-editor-page #tablaPlanificacion tbody tr:hover td:first-child {
  background: #e5f0f2;
}

body.planificacion-editor-page #tablaPlanificacion :where(th.th-finde, td.es-finde),
body.planificacion-editor-page #tablaPlanificacion :where(th.th-festivo, td.es-festivo) {
  background: var(--planning-weekend) !important;
  color: #586a73 !important;
}

body.planificacion-editor-page #tablaPlanificacion :where(th.th-hoy, td.es-hoy) {
  background: var(--planning-today) !important;
  box-shadow: inset 2px 0 0 var(--refresh-accent), inset -2px 0 0 var(--refresh-accent);
}

body.planificacion-editor-page #tablaPlanificacion th.th-hoy::after {
  content: "Hoy";
  display: block;
  margin-top: 2px;
  color: #167078;
  font-size: 0.62rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

body.planificacion-editor-page #tablaPlanificacion td.editable {
  cursor: pointer;
}

body.planificacion-editor-page #tablaPlanificacion td.editable:hover {
  outline: 2px solid rgba(23, 132, 138, 0.28);
  outline-offset: -3px;
}

body.planificacion-editor-page #tablaPlanificacion td.editable:focus-visible,
body.planificacion-editor-page .dia-puesto.editable:focus-visible {
  outline: 3px solid rgba(21, 85, 122, 0.36);
  outline-offset: -3px;
}

body.planificacion-editor-page #tablaPlanificacion td.vacio {
  background: #fbfcfd !important;
}

body.planificacion-editor-page #tablaPlanificacion td.vacio::before,
body.planificacion-editor-page .dia-puesto.vacio::before {
  content: "—";
  color: #a2afb5;
}

body.planificacion-editor-page :where(
  #tablaPlanificacion td.puesto-rj,
  #tablaPlanificacion td.puesto-ilt,
  #tablaPlanificacion td.puesto-libre,
  #tablaPlanificacion td.puesto-vacaciones,
  #tablaPlanificacion td.puesto-formacion
) {
  background: #ffffff !important;
  color: #273f4b !important;
}

body.planificacion-editor-page .planning-cell-value,
body.planificacion-editor-page .planning-code-chip {
  display: inline-flex;
  max-width: 100%;
  min-height: 24px;
  padding: 3px 8px;
  align-items: center;
  justify-content: center;
  border: 1px solid #c8d5da;
  border-radius: 999px;
  background: #f1f5f6;
  color: #34515e;
  font-size: 0.69rem;
  font-weight: 760;
  line-height: 1.15;
  overflow-wrap: anywhere;
  text-align: center;
}

body.planificacion-editor-page :where(.planning-code--rj) {
  border-color: #b9d4ea;
  background: #eaf3fb;
  color: #205b8f;
}

body.planificacion-editor-page :where(.planning-code--ilt) {
  border-color: #e4b9bb;
  background: #f9e7e8;
  color: #8b3036;
}

body.planificacion-editor-page :where(.planning-code--guardia, .planning-code--urpa) {
  border-color: #a9d5d1;
  background: #e2f2f0;
  color: #176760;
}

body.planificacion-editor-page :where(.planning-code--saliente) {
  border-color: #efc2af;
  background: #fbece5;
  color: #96452a;
}

body.planificacion-editor-page :where(.planning-code--libre) {
  border-color: #d9cfb0;
  background: #f5f1e5;
  color: #6f5b25;
}

body.planificacion-editor-page :where(.planning-code--vacaciones) {
  border-color: #e2ca78;
  background: #fff2bd;
  color: #70570b;
}

body.planificacion-editor-page :where(.planning-code--formacion) {
  border-color: #b8cee5;
  background: #e7f0fa;
  color: #315d86;
}

body.planificacion-editor-page #tablaPlanificacion .fila-r4 td {
  border-top: 2px solid #68a7a4;
  background: #f0f8f7;
}

body.planificacion-editor-page #tablaPlanificacion .fila-r4 td:first-child {
  background: #e7f2f1;
  color: #28625f;
}

body.planificacion-editor-page #tablaPlanificacion .r4-selector {
  min-height: 34px;
  padding: 4px 7px;
  border-color: #9cbfbd;
  font-size: 0.74rem;
}

/* Resumen de capacidad --------------------------------------------------- */

body.planificacion-editor-page #tablaPlanificacion tfoot th,
body.planificacion-editor-page #tablaPlanificacion tfoot td {
  height: 48px;
  border-top: 0;
  border-bottom-color: #d5e0e4;
  background: #eef3f5;
}

body.planificacion-editor-page #tablaPlanificacion tfoot th {
  z-index: 3;
  color: #294c5c;
  font-size: 0.75rem;
  font-weight: 760;
}

body.planificacion-editor-page #tablaPlanificacion tfoot tr:first-child :where(th, td) {
  border-top: 2px solid #91aab5;
}

body.planificacion-editor-page .summary-label {
  margin-bottom: 2px;
  color: #697c85;
  font-size: 0.64rem;
  font-weight: 680;
}

body.planificacion-editor-page .summary-value {
  color: #213f4d;
  font-size: 0.98rem;
  line-height: 1;
}

body.planificacion-editor-page .summary-value.is-complete {
  color: #23704d;
}

body.planificacion-editor-page .summary-value.is-pending {
  color: #9a6412;
}

/* Barra de acciones ------------------------------------------------------ */

body.planificacion-editor-page .acciones-planificacion {
  display: grid;
  grid-template-columns: minmax(210px, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 12px 14px;
  border-top: 1px solid #cdd9de;
  border-radius: 0 0 10px 10px;
  background: #f7f9fa;
}

body.planificacion-editor-page .acciones-planificacion__context {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
}

body.planificacion-editor-page .acciones-planificacion__context small {
  color: #61747d;
  font-size: 0.74rem;
}

body.planificacion-editor-page .accion-izquierda,
body.planificacion-editor-page .accion-derecha {
  display: flex;
  align-items: center;
  gap: 8px;
}

body.planificacion-editor-page .planning-action {
  display: inline-flex;
  min-width: 108px;
  min-height: 40px;
  padding: 0 13px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: 10px;
  font-size: 0.8rem;
  text-decoration: none;
  text-transform: none;
}

body.planificacion-editor-page .planning-action--save {
  border: 1px solid var(--refresh-primary);
  background: var(--refresh-primary) !important;
  color: #ffffff;
}

body.planificacion-editor-page .planning-action--send {
  border: 1px solid #a7c2d5;
  background: #edf4f9 !important;
  color: #275779;
}

body.planificacion-editor-page .planning-action--pdf {
  min-width: 82px;
  border: 1px solid #aebfc7;
  background: #ffffff !important;
  color: #315665;
}

body.planificacion-editor-page .planning-action:hover {
  filter: brightness(0.96);
}

/* Editor de celda -------------------------------------------------------- */

body.planificacion-editor-page .td-editor-wrapper {
  width: 280px;
  max-width: calc(100vw - 20px);
  padding: 10px;
  border: 1px solid #9fb2bc;
  border-radius: 9px;
  background: #ffffff;
  box-shadow: 0 15px 36px rgba(15, 42, 55, 0.2);
}

body.planificacion-editor-page .td-editor-wrapper h4 {
  margin-bottom: 8px;
  color: #204657;
  font-size: 0.86rem;
}

body.planificacion-editor-page .td-editor-wrapper li {
  min-height: 34px;
  padding: 7px 9px;
  border-color: #d7e1e5;
  border-radius: 6px;
  font-size: 0.77rem;
}

/* Vista móvil por profesional ------------------------------------------- */

body.planificacion-editor-page .planificacion-mobile {
  display: none;
}

@media (max-width: 1024px) {
  body.planificacion-editor-page .planning-page-header {
    gap: 16px;
  }

  body.planificacion-editor-page .planning-context {
    grid-template-columns: minmax(240px, 1fr) minmax(140px, 0.55fr) minmax(230px, 0.9fr);
  }

  body.planificacion-editor-page .planning-context__item--legend {
    border-right: 0;
  }

  body.planificacion-editor-page .planning-context__editable {
    display: none;
  }

  body.planificacion-editor-page #tablaPlanificacion th:first-child,
  body.planificacion-editor-page #tablaPlanificacion td:first-child {
    width: 215px;
    min-width: 215px;
    max-width: 215px;
  }
}

@media (max-width: 768px) {
  body.planificacion-editor-page .planning-page-header {
    display: flex;
    min-height: 0;
    padding-block: 15px;
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  body.planificacion-editor-page .planning-page-header .page-title {
    font-size: clamp(1.65rem, 6vw, 2rem);
  }

  body.planificacion-editor-page .planning-page-header__subtitle {
    font-size: 0.83rem;
  }

  body.planificacion-editor-page .planning-week-nav {
    width: 100%;
  }

  body.planificacion-editor-page .week-nav-btn {
    flex: 1 1 0;
  }

  body.planificacion-editor-page .planning-context {
    grid-template-columns: 1fr 1fr;
  }

  body.planificacion-editor-page .planning-context__item {
    border-bottom: 1px solid #dfe7ea;
  }

  body.planificacion-editor-page .planning-context__item--count {
    border-right: 0;
  }

  body.planificacion-editor-page .planning-context__item--legend {
    grid-column: 1 / -1;
    border-bottom: 0;
  }

  body.planificacion-editor-page .planificacion-desktop {
    display: none;
  }

  body.planificacion-editor-page .planificacion-mobile {
    display: block;
    padding: 10px;
  }

  body.planificacion-editor-page .adjunto-card {
    margin: 0 0 7px;
    border: 1px solid #d0dce1;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: none;
  }

  body.planificacion-editor-page .adjunto-toggle {
    min-height: 44px;
    padding: 9px 11px;
    border-bottom: 0;
    border-radius: 0;
    background: #f3f7f8 !important;
    color: #234757;
    font-size: 0.82rem;
  }

  body.planificacion-editor-page .adjunto-card.is-open .adjunto-toggle {
    border-bottom: 1px solid #d7e1e5;
    background: #e9f2f4 !important;
  }

  body.planificacion-editor-page .adjunto-body {
    padding: 5px 10px 8px;
  }

  body.planificacion-editor-page .dia-row {
    grid-template-columns: minmax(0, 1fr) minmax(116px, auto);
    min-height: 46px;
    padding: 6px 0;
    border-bottom-color: #e3eaed;
  }

  body.planificacion-editor-page .dia-nombre {
    color: #3b5663;
    font-size: 0.78rem;
  }

  body.planificacion-editor-page .dia-puesto {
    width: auto;
    min-width: 116px;
    max-width: min(180px, 48vw);
    min-height: 34px;
    padding: 4px 6px;
    border-color: #c4d2d8;
    border-radius: 7px;
    background: #ffffff;
    font-size: 0.73rem;
  }

  body.planificacion-editor-page .dia-puesto.es-finde,
  body.planificacion-editor-page .dia-puesto.es-festivo {
    background: var(--planning-weekend) !important;
  }

  body.planificacion-editor-page .dia-puesto.es-hoy {
    border-color: var(--refresh-accent);
    background: var(--planning-today) !important;
  }

  body.planificacion-editor-page .dia-puesto.vacio {
    background: #fafcfc !important;
  }

  body.planificacion-editor-page .acciones-planificacion {
    grid-template-columns: 1fr auto;
    padding: 11px;
  }

  body.planificacion-editor-page .acciones-planificacion__context {
    grid-column: 1 / -1;
  }
}

@media (max-width: 480px) {
  body.planificacion-editor-page .planning-context {
    grid-template-columns: 1fr;
  }

  body.planificacion-editor-page .planning-context__item {
    border-right: 0;
  }

  body.planificacion-editor-page .planning-context__item--legend {
    grid-column: auto;
  }

  body.planificacion-editor-page .planning-context__item strong {
    white-space: normal;
  }

  body.planificacion-editor-page .acciones-planificacion {
    display: flex;
    align-items: stretch;
    flex-direction: column;
  }

  body.planificacion-editor-page .accion-izquierda,
  body.planificacion-editor-page .accion-derecha {
    width: 100%;
  }

  body.planificacion-editor-page .planning-action {
    flex: 1 1 0;
    min-width: 0;
  }

  body.planificacion-editor-page .planning-action--save {
    width: 100%;
  }

  body.planificacion-editor-page .dia-row {
    grid-template-columns: minmax(0, 1fr) minmax(108px, 46%);
  }

  body.planificacion-editor-page .dia-puesto {
    min-width: 0;
    max-width: 100%;
  }
}

/* ==========================================================================
   Sistema piloto · Gestión de semanas
   Composición específica para biblioteca de periodos de planificación.
   ========================================================================== */

/* Identidad y navegación con contraste definitivo. */
body:not(.login-page):not(.public-message-page) .sidebar {
  background: #0d2c3f !important;
  border-right-color: #0d2c3f !important;
}

body:not(.login-page):not(.public-message-page) .sidebar-brand {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  grid-template-rows: auto auto;
  column-gap: 10px;
  align-items: center;
  border-left: 0;
  background: #12384c !important;
}

body:not(.login-page):not(.public-message-page) .sidebar-user {
  background: #163c50 !important;
}

body:not(.login-page):not(.public-message-page) .sidebar-brand::before {
  content: "+";
  display: grid;
  grid-row: 1 / 3;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 8px;
  background: #2ba0a4;
  color: #ffffff;
  font-size: 1.45rem;
  font-weight: 500;
  line-height: 1;
}

body:not(.login-page):not(.public-message-page) .sidebar-brand .brand-title,
body:not(.login-page):not(.public-message-page) .sidebar-brand .brand-sub {
  grid-column: 2;
}

body:not(.login-page):not(.public-message-page) .nav-link.active,
body:not(.login-page):not(.public-message-page) .nav-group.open > .nav-group-toggle {
  background: #1e5168 !important;
  color: #ffffff !important;
  box-shadow: none;
}

body:not(.login-page):not(.public-message-page) .nav-link.active i,
body:not(.login-page):not(.public-message-page) .nav-group.open > .nav-group-toggle i {
  color: #8ed9d7;
}

body:not(.login-page):not(.public-message-page) .nav-link.active::before,
body:not(.login-page):not(.public-message-page) .nav-group.open > .nav-group-toggle::before {
  background: #43c1bd !important;
}

body.tutor-semanas-page {
  overflow-x: hidden;
}

body[data-ui-theme].tutor-semanas-page:not(.login-page):not(.public-message-page) .sidebar {
  background: #0d2c3f !important;
  border-right-color: #0d2c3f !important;
}

body[data-ui-theme].tutor-semanas-page:not(.login-page):not(.public-message-page) .sidebar-brand,
body[data-ui-theme].tutor-semanas-page:not(.login-page):not(.public-message-page) .sidebar-user {
  background: #12384c !important;
}

body[data-ui-theme].tutor-semanas-page:not(.login-page):not(.public-message-page) .sidebar .nav-link:hover,
body[data-ui-theme].tutor-semanas-page:not(.login-page):not(.public-message-page) .sidebar .nav-group-toggle:hover {
  background: #173f54 !important;
}

body[data-ui-theme].tutor-semanas-page:not(.login-page):not(.public-message-page) .sidebar .nav-link.active,
body[data-ui-theme].tutor-semanas-page:not(.login-page):not(.public-message-page) .sidebar .nav-group.open > .nav-group-toggle {
  background: #1e5168 !important;
  color: #ffffff !important;
}

body[data-ui-theme].tutor-semanas-page:not(.login-page):not(.public-message-page) .sidebar .nav-link::before,
body[data-ui-theme].tutor-semanas-page:not(.login-page):not(.public-message-page) .sidebar .nav-group-toggle::before {
  background: #43c1bd !important;
}

body[data-ui-theme].tutor-semanas-page:not(.login-page):not(.public-message-page) .weeks-page-header {
  border-color: #ccd8de !important;
  background: #ffffff !important;
}

body[data-ui-theme].tutor-semanas-page:not(.login-page):not(.public-message-page) .weeks-page-header::after {
  background: #209397 !important;
}

body[data-ui-theme].tutor-semanas-page:not(.login-page):not(.public-message-page) :where(.topbar-chip, .topbar-date) {
  border-color: #d8e2e6 !important;
  background: transparent !important;
  box-shadow: none !important;
}

body.tutor-semanas-page .app-main {
  min-width: 0;
  background: #edf2f5 !important;
}

body.tutor-semanas-page .app-main::before {
  display: none !important;
}

/* Cabecera de página ----------------------------------------------------- */

body.tutor-semanas-page .weeks-page-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  min-height: 124px;
  padding: 22px 28px 20px;
  align-items: center;
  gap: 24px;
  border-bottom-color: #ccd8de;
  background: #ffffff !important;
}

body.tutor-semanas-page .weeks-page-header::after {
  left: 28px;
  width: 58px;
  background: #209397 !important;
}

body.tutor-semanas-page .weeks-page-header__identity {
  min-width: 0;
}

body.tutor-semanas-page .weeks-page-header__eyebrow,
body.tutor-semanas-page .weeks-section-label {
  display: block;
  color: #168087;
  font-size: 0.7rem;
  font-weight: 780;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

body.tutor-semanas-page .weeks-page-header .page-title {
  margin-top: 3px;
  color: #12394d;
  font-size: clamp(2rem, 3vw, 2.7rem);
  font-weight: 780;
  letter-spacing: -0.035em;
  line-height: 1.06;
}

body.tutor-semanas-page .weeks-page-header__description {
  max-width: 680px;
  margin: 7px 0 0;
  color: #536a75;
  font-size: 0.93rem;
}

body.tutor-semanas-page .weeks-page-header__total {
  display: grid;
  min-width: 98px;
  padding: 10px 15px;
  grid-template-columns: auto auto;
  align-items: baseline;
  gap: 6px;
  border-left: 3px solid #209397;
  background: #edf5f6;
  color: #315766;
}

body.tutor-semanas-page .weeks-page-header__total strong {
  color: #15557a;
  font-size: 1.65rem;
  line-height: 1;
}

body.tutor-semanas-page .weeks-page-header__total span {
  font-size: 0.76rem;
  font-weight: 680;
}

body.tutor-semanas-page .main-container {
  padding-top: 20px;
}

body.tutor-semanas-page .content-wrap {
  display: flex;
  max-width: 1480px;
  flex-direction: column;
  gap: 16px;
}

/* Alta integrada --------------------------------------------------------- */

body.tutor-semanas-page .weeks-create {
  display: grid;
  grid-template-columns: minmax(270px, 0.72fr) minmax(430px, 1.28fr);
  align-items: stretch;
  border: 1px solid #c7d4da;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(15, 42, 55, 0.06);
  overflow: hidden;
}

body.tutor-semanas-page .weeks-create__intro {
  display: flex;
  padding: 19px 21px;
  flex-direction: column;
  justify-content: center;
  border-right: 1px solid #d8e2e6;
  background: #f5f8f9;
}

body.tutor-semanas-page .weeks-create__intro h2,
body.tutor-semanas-page .weeks-library__header h2 {
  margin: 3px 0 0;
  color: #173e51;
  font-size: 1.28rem;
  font-weight: 740;
  letter-spacing: -0.015em;
}

body.tutor-semanas-page .weeks-create__intro p,
body.tutor-semanas-page .weeks-library__header p {
  margin: 5px 0 0;
  color: #60737c;
  font-size: 0.82rem;
}

body.tutor-semanas-page .weeks-create__form {
  display: flex;
  padding: 16px 20px;
  align-items: center;
}

body.tutor-semanas-page .weeks-create__form form {
  width: 100%;
  margin: 0;
}

body.tutor-semanas-page .weeks-create__controls {
  display: grid;
  grid-template-columns: minmax(220px, 360px) auto;
  align-items: end;
  justify-content: start;
  gap: 12px;
}

body.tutor-semanas-page .weeks-create__field {
  display: flex;
  margin: 0;
  flex-direction: column;
  gap: 5px;
}

body.tutor-semanas-page .weeks-create__field label {
  color: #284b5b;
  font-size: 0.79rem;
  font-weight: 700;
}

body.tutor-semanas-page .weeks-create__field input {
  width: 100%;
  min-height: 42px;
}

body.tutor-semanas-page .weeks-create__field small {
  display: flex;
  align-items: center;
  gap: 5px;
  color: #677b84;
  font-size: 0.72rem;
}

body.tutor-semanas-page .weeks-create__field small i {
  color: #268e91;
}

body.tutor-semanas-page .weeks-create__action {
  margin: 0 0 22px;
}

body.tutor-semanas-page .weeks-create__action button {
  display: inline-flex;
  min-height: 42px;
  padding-inline: 17px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-color: #15557a;
  background: #15557a !important;
  color: #ffffff;
  white-space: nowrap;
}

/* Biblioteca de periodos ------------------------------------------------ */

body.tutor-semanas-page .weeks-library {
  border: 1px solid #c7d4da;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(15, 42, 55, 0.06);
  overflow: hidden;
}

body.tutor-semanas-page .weeks-library__header {
  display: flex;
  min-height: 78px;
  padding: 16px 20px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid #ccd8de;
}

body.tutor-semanas-page .weeks-library__summary {
  display: flex;
  align-items: center;
  gap: 14px;
  color: #61757e;
  font-size: 0.76rem;
}

body.tutor-semanas-page .weeks-library__summary span + span {
  padding-left: 14px;
  border-left: 1px solid #d4dfe3;
}

body.tutor-semanas-page .weeks-library__summary strong {
  color: #1e4b5e;
  font-size: 0.94rem;
}

body.tutor-semanas-page .weeks-periods {
  background: #ffffff;
}

body.tutor-semanas-page .weeks-period {
  border-bottom: 1px solid #dce5e8;
  background: #ffffff;
}

body.tutor-semanas-page .weeks-period:last-child {
  border-bottom: 0;
}

body.tutor-semanas-page .weeks-period__summary {
  display: flex;
  min-height: 62px;
  padding: 10px 18px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  list-style: none;
  background: #ffffff;
  color: #234858;
  cursor: pointer;
}

body.tutor-semanas-page .weeks-period__summary::-webkit-details-marker {
  display: none;
}

body.tutor-semanas-page .weeks-period__summary:hover {
  background: #f2f7f8;
}

body.tutor-semanas-page .weeks-period__summary:focus-visible {
  position: relative;
  z-index: 1;
  outline: 3px solid rgba(21, 85, 122, 0.3);
  outline-offset: -3px;
}

body.tutor-semanas-page .weeks-period[open] > .weeks-period__summary {
  border-bottom: 1px solid #d3dfe3;
  background: #edf5f6;
}

body.tutor-semanas-page .weeks-period__identity {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 11px;
}

body.tutor-semanas-page .weeks-period__identity > span:last-child {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
}

body.tutor-semanas-page .weeks-period__identity strong {
  color: #173e51;
  font-size: 0.92rem;
  font-weight: 730;
}

body.tutor-semanas-page .weeks-period__identity small {
  color: #657983;
  font-size: 0.71rem;
}

body.tutor-semanas-page .weeks-period__calendar {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid #bfd2d8;
  border-radius: 7px;
  background: #ffffff;
  color: #277884;
}

body.tutor-semanas-page .weeks-period__toggle {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid #c3d1d7;
  border-radius: 7px;
  background: #ffffff;
  color: #476572;
  transition: transform 160ms ease;
}

body.tutor-semanas-page .weeks-period[open] .weeks-period__toggle {
  transform: rotate(180deg);
}

body.tutor-semanas-page .weeks-period__content {
  padding: 0 18px 12px 63px;
  background: #f8fafb;
}

body.tutor-semanas-page .semanas-table-wrap {
  max-width: 100%;
  overflow-x: auto;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

body.tutor-semanas-page .semanas-table {
  width: 100%;
  min-width: 670px;
  border: 0;
  border-collapse: collapse;
  background: transparent;
  box-shadow: none;
}

body.tutor-semanas-page .semanas-table th {
  padding: 9px 10px;
  border-bottom: 1px solid #c8d5da;
  background: transparent;
  color: #687c85;
  font-size: 0.68rem;
  font-weight: 760;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

body.tutor-semanas-page .semanas-table th:nth-child(1) {
  width: 43%;
}

body.tutor-semanas-page .semanas-table th:nth-child(2) {
  width: 17%;
}

body.tutor-semanas-page .semanas-table th:last-child {
  text-align: right;
}

body.tutor-semanas-page .semanas-table td {
  padding: 9px 10px;
  border-bottom: 1px solid #e1e8eb;
  background: transparent;
  vertical-align: middle;
}

body.tutor-semanas-page .semanas-table tbody tr:last-child td {
  border-bottom: 0;
}

body.tutor-semanas-page .semanas-table tbody tr:hover td {
  background: #edf4f5;
}

body.tutor-semanas-page .week-row__period {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

body.tutor-semanas-page .week-row__date {
  color: #1b4052;
  font-size: 0.84rem;
  font-weight: 720;
  white-space: nowrap;
}

body.tutor-semanas-page .week-row__range {
  color: #6a7d86;
  font-size: 0.72rem;
  white-space: nowrap;
}

body.tutor-semanas-page .week-status {
  display: inline-flex;
  min-height: 25px;
  padding: 3px 8px;
  align-items: center;
  gap: 6px;
  border: 1px solid #cbd7dc;
  border-radius: 999px;
  background: #f4f7f8;
  color: #536a75;
  font-size: 0.7rem;
  font-weight: 700;
}

body.tutor-semanas-page .week-status__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

body.tutor-semanas-page .week-status--published {
  border-color: #b7dac7;
  background: #e8f5ed;
  color: #24704d;
}

body.tutor-semanas-page .week-status--draft {
  border-color: #d9d0b6;
  background: #f7f3e8;
  color: #7b6224;
}

body.tutor-semanas-page .semanas-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

body.tutor-semanas-page .week-action-form {
  display: inline-flex;
  margin: 0;
}

body.tutor-semanas-page .week-action {
  display: inline-flex;
  min-height: 34px;
  padding: 0 9px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 690;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
}

body.tutor-semanas-page .week-action--edit {
  border-color: #15557a;
  background: #15557a !important;
  color: #ffffff;
}

body.tutor-semanas-page .week-action--publish {
  border-color: #9eb8c2;
  background: #ffffff !important;
  color: #275467;
}

body.tutor-semanas-page .week-action--delete {
  border-color: transparent;
  background: transparent !important;
  color: #a23d3d;
}

body[data-ui-theme].tutor-semanas-page .semanas-actions .week-action--edit {
  border-color: #15557a !important;
  background: #15557a !important;
  color: #ffffff !important;
}

body[data-ui-theme].tutor-semanas-page .semanas-actions .week-action--publish {
  border-color: #9eb8c2 !important;
  background: #ffffff !important;
  color: #275467 !important;
}

body[data-ui-theme].tutor-semanas-page .semanas-actions .week-action--delete {
  border-color: transparent !important;
  background: transparent !important;
  color: #a23d3d !important;
}

body.tutor-semanas-page .week-action--delete:hover {
  border-color: #e3bcbc;
  background: #faeaea !important;
  color: #8d3030;
}

body.tutor-semanas-page .weeks-empty {
  display: flex;
  min-height: 150px;
  padding: 28px;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: #58707b;
  text-align: left;
}

body.tutor-semanas-page .weeks-empty__icon {
  display: grid;
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 10px;
  background: #e5f1f2;
  color: #23838a;
  font-size: 1.15rem;
}

body.tutor-semanas-page .weeks-empty h3,
body.tutor-semanas-page .weeks-empty p {
  margin: 0;
}

body.tutor-semanas-page .weeks-empty h3 {
  color: #254959;
  font-size: 1rem;
}

body.tutor-semanas-page .weeks-empty p {
  margin-top: 3px;
  font-size: 0.8rem;
}

@media (max-width: 1024px) {
  body.tutor-semanas-page .weeks-page-header {
    min-height: 112px;
    padding-inline: 22px;
  }

  body.tutor-semanas-page .weeks-page-header::after {
    left: 22px;
  }

  body.tutor-semanas-page .weeks-create {
    grid-template-columns: minmax(240px, 0.65fr) minmax(390px, 1.35fr);
  }

  body.tutor-semanas-page .weeks-create__controls {
    grid-template-columns: minmax(210px, 1fr) auto;
  }

  body.tutor-semanas-page .weeks-period__content {
    padding-left: 18px;
  }
}

@media (max-width: 768px) {
  body.tutor-semanas-page .weeks-page-header {
    min-height: 0;
    padding: 18px;
    gap: 16px;
  }

  body.tutor-semanas-page .weeks-page-header::after {
    left: 18px;
  }

  body.tutor-semanas-page .weeks-page-header .page-title {
    font-size: clamp(1.75rem, 6vw, 2.15rem);
  }

  body.tutor-semanas-page .weeks-page-header__description {
    font-size: 0.84rem;
  }

  body.tutor-semanas-page .weeks-page-header__total {
    min-width: 86px;
    padding: 9px 12px;
  }

  body.tutor-semanas-page .weeks-create {
    grid-template-columns: 1fr;
  }

  body.tutor-semanas-page .weeks-create__intro {
    padding: 16px 18px;
    border-right: 0;
    border-bottom: 1px solid #d8e2e6;
  }

  body.tutor-semanas-page .weeks-create__form {
    padding: 15px 18px;
  }

  body.tutor-semanas-page .weeks-library__header {
    align-items: flex-start;
  }

  body.tutor-semanas-page .weeks-library__summary {
    align-items: flex-end;
    flex-direction: column;
    gap: 4px;
  }

  body.tutor-semanas-page .weeks-library__summary span + span {
    padding-left: 0;
    border-left: 0;
  }

  body.tutor-semanas-page .weeks-period__summary {
    padding-inline: 14px;
  }

  body.tutor-semanas-page .weeks-period__content {
    padding-inline: 14px;
  }
}

@media (max-width: 560px) {
  body.tutor-semanas-page .weeks-page-header {
    grid-template-columns: 1fr;
  }

  body.tutor-semanas-page .weeks-page-header__total {
    width: max-content;
  }

  body.tutor-semanas-page .weeks-create__controls {
    grid-template-columns: 1fr;
  }

  body.tutor-semanas-page .weeks-create__action {
    margin: 0;
  }

  body.tutor-semanas-page .weeks-create__action button {
    width: 100%;
  }

  body.tutor-semanas-page .weeks-library__header {
    flex-direction: column;
    gap: 11px;
  }

  body.tutor-semanas-page .weeks-library__summary {
    width: 100%;
    align-items: center;
    flex-direction: row;
    justify-content: flex-start;
    gap: 12px;
  }

  body.tutor-semanas-page .weeks-library__summary span + span {
    padding-left: 12px;
    border-left: 1px solid #d4dfe3;
  }

  body.tutor-semanas-page .weeks-period__content {
    padding: 0 10px 10px;
  }

  body.tutor-semanas-page .semanas-table {
    min-width: 0;
  }

  body.tutor-semanas-page .semanas-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  body.tutor-semanas-page .semanas-table,
  body.tutor-semanas-page .semanas-table tbody,
  body.tutor-semanas-page .semanas-table tr,
  body.tutor-semanas-page .semanas-table td {
    display: block;
    width: 100%;
  }

  body.tutor-semanas-page .semanas-table tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    padding: 10px 4px;
    gap: 8px 12px;
    border-bottom: 1px solid #dce5e8;
  }

  body.tutor-semanas-page .semanas-table tr:last-child {
    border-bottom: 0;
  }

  body.tutor-semanas-page .semanas-table td {
    padding: 0;
    border: 0;
    background: transparent;
  }

  body.tutor-semanas-page .semanas-table td:nth-child(2) {
    display: flex;
    align-items: center;
    justify-content: flex-end;
  }

  body.tutor-semanas-page .semanas-table td:last-child {
    grid-column: 1 / -1;
  }

  body.tutor-semanas-page .week-row__period {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
  }

  body.tutor-semanas-page .semanas-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    justify-content: stretch;
    gap: 5px;
  }

  body.tutor-semanas-page .week-action {
    width: 100%;
    min-height: 36px;
    padding-inline: 5px;
  }

  body.tutor-semanas-page .week-action-form {
    width: 100%;
  }
}

@media (max-width: 400px) {
  body.tutor-semanas-page .weeks-page-header,
  body.tutor-semanas-page .weeks-create__intro,
  body.tutor-semanas-page .weeks-create__form,
  body.tutor-semanas-page .weeks-library__header {
    padding-inline: 14px;
  }

  body.tutor-semanas-page .weeks-period__calendar {
    display: none;
  }

  body.tutor-semanas-page .weeks-period__summary {
    min-height: 56px;
  }

  body.tutor-semanas-page .week-action {
    flex: 1 1 auto;
  }
}
