:root {
  color-scheme: light;
  --font-sans: system-ui, -apple-system, "Segoe UI Variable", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font: 14px/1.55 var(--font-sans);
  color: #0B1B33;
  background-color: #F8FAFC;
  
  /* Gesprev Patagonia: paleta oficial aplicada al tema claro */
  --brand-cyan: #38BDF8;
  --brand-blue: #1E3A5F;
  --brand-base: #0B1B33;
  --brand-gray: #94A3B8;
  --brand-white: #F8FAFC;
  --green: var(--brand-blue);
  --green-hover: #152B49;
  --green-light: #E0F2FE;
  --green-glow: rgba(56, 189, 248, 0.2);
  --cyan: #0369A1;
  --cyan-light: #E0F2FE;
  --muted: #475A78;
  --muted-light: #64748B;
  --line: rgba(148, 163, 184, 0.32);
  --line-strong: rgba(30, 58, 95, 0.28);
  --red: #b91c1c;
  --red-light: #fee2e2;
  --amber: #A16207;
  --amber-light: #fef3c7;
  --orange: #c2410c;
  --orange-light: #ffedd5;
  --ok: #047857;
  --ok-light: #D1FAE5;
  
  /* Glassmorphism & Superficies */
  --surface-glass: rgba(255, 255, 255, 0.58);
  --surface-glass-card: rgba(255, 255, 255, 0.66);
  --surface-glass-solid: rgba(255, 255, 255, 0.86);
  --surface-glass-modal: rgba(255, 255, 255, 0.82);
  --blur-base: 18px;
  --blur-deep: 28px;
  --border-glass: rgba(255, 255, 255, 0.7);
  --glass-edge: inset 0 1px 0 rgba(255, 255, 255, 0.85), inset 0 0 0 1px rgba(255, 255, 255, 0.35);
  
  /* Elevación y sombras */
  --shadow-sm: 0 1px 3px rgba(30, 58, 95, 0.07);
  --shadow-md: 0 8px 24px -6px rgba(30, 58, 95, 0.12), 0 2px 6px -1px rgba(30, 58, 95, 0.05);
  --shadow-lg: 0 18px 44px -8px rgba(30, 58, 95, 0.18), 0 4px 12px -2px rgba(30, 58, 95, 0.07);
  --shadow-glow: 0 0 20px rgba(56, 189, 248, 0.2);
  
  /* Curvas de animación elásticas y fluidas */
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--brand-base);
  background: linear-gradient(160deg, #EEF3FA 0%, #F8FAFC 45%, #E8EDF6 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

[hidden] { display: none !important; }

body.auth-locked { overflow: hidden; }

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  overflow-y: auto;
  padding: 28px 16px;
  background: #eaf0f7;
}

.auth-shell {
  width: min(680px, 100%);
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  box-shadow: var(--shadow-lg);
}

.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.auth-brand > span:last-child { display: grid; }
.auth-brand strong { font-size: 17px; color: var(--brand-base); }
.auth-brand .brand-mark img { width: 100%; height: 100%; padding: 2px; object-fit: contain; }
.auth-copy { max-width: 520px; margin-bottom: 22px; }
.auth-copy h1 { margin: 4px 0 8px; }
.auth-copy p, .auth-foot { color: var(--muted); }
.auth-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.auth-submit { width: 100%; margin-top: 20px; justify-content: center; }
.auth-foot { margin: 18px 0 0; font-size: 12px; text-align: center; }
.central-waiting, .managed-note { display: flex; gap: 13px; align-items: flex-start; padding: 16px; border: 1px solid rgba(56,189,248,.35); border-radius: 12px; background: #f0f9ff; color: var(--brand-blue); }
.central-waiting p, .managed-note span { display: block; margin: 3px 0 0; color: var(--muted); font-size: 12.5px; }
.central-icon { display: grid; place-items: center; width: 34px; height: 34px; flex: none; border-radius: 9px; background: var(--brand-blue); color: white; font-weight: 800; }
.managed-note { margin: 0 0 18px; }
.auth-loading { min-height: 72px; color: var(--muted); }

/* Fondo ambiental: luz cian y azul detrás del cristal */
body::before,
body::after {
  content: '';
  position: fixed;
  z-index: -1;
  width: 62vmax;
  height: 62vmax;
  border-radius: 50%;
  filter: blur(70px);
  pointer-events: none;
  will-change: transform;
}

body::before {
  top: -24vmax;
  left: -14vmax;
  background: radial-gradient(circle, rgba(56, 189, 248, 0.32), transparent 68%);
  animation: drift-a 26s var(--ease-in-out) infinite alternate;
}

body::after {
  right: -22vmax;
  bottom: -26vmax;
  background: radial-gradient(circle, rgba(30, 58, 95, 0.26), transparent 68%);
  animation: drift-b 32s var(--ease-in-out) infinite alternate;
}

@keyframes drift-a {
  to { transform: translate3d(9vmax, 7vmax, 0) scale(1.08); }
}

@keyframes drift-b {
  to { transform: translate3d(-8vmax, -6vmax, 0) scale(1.1); }
}

html {
  scroll-behavior: smooth;
}

::selection {
  background: rgba(56, 189, 248, 0.35);
}

/* Control base y tipografía */
button, input, textarea, select {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: var(--green);
  text-decoration: none;
  transition: color 150ms var(--ease-smooth);
}

a:hover {
  color: var(--brand-base);
  text-decoration-color: var(--brand-cyan);
  text-decoration-line: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

button:disabled {
  cursor: wait;
  opacity: 0.6;
}

:is(button, a, summary, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

button, a {
  transition: background-color 160ms ease, color 160ms ease, border-color 160ms ease, transform 140ms var(--ease), box-shadow 160ms var(--ease);
}

button:active {
  transform: scale(0.975);
}

svg {
  width: 18px;
  height: 18px;
  flex: none;
  vertical-align: middle;
}

h1, h2, h3, p {
  margin-top: 0;
}

h1 {
  font-size: 27px;
  line-height: 1.25;
  letter-spacing: -0.035em;
  font-weight: 750;
  margin-bottom: 6px;
  color: var(--brand-base);
}

h2 {
  font-size: 18px;
  line-height: 1.35;
  letter-spacing: -0.02em;
  font-weight: 700;
  margin-bottom: 14px;
  color: var(--brand-blue);
}

h3 {
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.01em;
  margin-bottom: 6px;
  color: var(--brand-blue);
}

small, .muted {
  font-size: 12px;
  color: var(--muted);
}

small {
  display: block;
}

strong {
  font-weight: 650;
}

.skip {
  position: fixed;
  top: 10px;
  left: 10px;
  transform: translateY(-200%);
  z-index: 100;
  background: #ffffff;
  padding: 12px 18px;
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  font-weight: 600;
}

.skip:focus {
  transform: none;
}

/* Sidebar moderna con efecto Glassmorphism */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 240px;
  background: var(--surface-glass);
  backdrop-filter: blur(var(--blur-deep)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--blur-deep)) saturate(180%);
  border-right: 1px solid var(--line);
  box-shadow: 4px 0 32px -8px rgba(30, 58, 95, 0.12), inset -1px 0 0 rgba(255, 255, 255, 0.6);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  z-index: 30;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 17px;
  font-weight: 750;
  color: var(--brand-base);
  letter-spacing: -0.02em;
}

.brand small {
  font-weight: 450;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--brand-blue), var(--brand-base));
  color: white;
  border-radius: 11px;
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.3), 0 4px 12px rgba(30, 58, 95, 0.25);
  font-weight: 800;
  font-size: 18px;
}

.brand > .brand-mark {
  width: 64px;
  height: 64px;
  padding: 0;
  flex: none;
  border-radius: 12px;
  background: var(--brand-base);
  box-shadow: 0 3px 10px rgba(11, 27, 51, 0.18);
}

.brand > .brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 2px;
}

.sidebar nav {
  display: grid;
  gap: 5px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 10px;
  color: #475A78;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid transparent;
  transition: all 160ms var(--ease);
}

.nav-item:hover {
  background: rgba(56, 189, 248, 0.07);
  color: var(--green-hover);
  transform: translateX(3px);
}

.nav-item[aria-current=page] {
  background: linear-gradient(90deg, rgba(56, 189, 248, 0.2) 0%, rgba(255, 255, 255, 0.55) 100%);
  color: #1E3A5F;
  font-weight: 700;
  border-color: rgba(255, 255, 255, 0.8);
  box-shadow: var(--glass-edge), 0 4px 14px -4px rgba(30, 58, 95, 0.2);
  transform: none;
  position: relative;
}

.nav-item[aria-current=page]::before {
  content: '';
  position: absolute;
  left: 0;
  top: 25%;
  bottom: 25%;
  width: 3px;
  border-radius: 3px;
  background: linear-gradient(var(--brand-cyan), var(--brand-blue));
  animation: indicator-in 320ms var(--ease);
}

@keyframes indicator-in {
  from { transform: scaleY(0); }
  to { transform: scaleY(1); }
}

.nav-caption {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted-light);
  margin: 18px 12px 6px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.storage-note {
  font-size: 11.5px;
  margin: auto 8px 0;
  padding: 10px 12px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.75);
  box-shadow: var(--glass-edge);
  color: var(--muted);
  line-height: 1.4;
}

.storage-note small {
  font-size: 11px;
  margin-top: 2px;
  color: var(--muted-light);
}

/* Área de trabajo y cabecera superior */
.workspace {
  margin-left: 240px;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  min-height: 64px;
  padding: 12px 32px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--surface-glass);
  backdrop-filter: blur(var(--blur-deep)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--blur-deep)) saturate(180%);
  position: sticky;
  top: 0;
  z-index: 20;
  transition: box-shadow 220ms var(--ease), background-color 220ms var(--ease);
}

.topbar.is-scrolled {
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 8px 24px -12px rgba(30, 58, 95, 0.2);
}

.topbar nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 12.5px;
}

.topbar nav a {
  padding: 4px 8px;
  border-radius: 6px;
  color: var(--muted);
  font-weight: 550;
  transition: all 140ms ease;
}

.topbar nav a:hover {
  background: rgba(56, 189, 248, 0.08);
  color: var(--green);
}

.topbar nav [aria-current=page] {
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(56, 189, 248, 0.11);
  color: var(--green);
  font-weight: 650;
}

.local-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.7);
  padding: 5px 12px;
  border-radius: 9999px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  align-self: center;
}

.local-badge::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--brand-cyan);
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.5);
  animation: pulse-dot 2.8s ease-in-out infinite;
}

.account-menu { display: flex; align-items: center; gap: 12px; }
.account-user { display: grid; text-align: right; line-height: 1.25; }
.account-user strong { font-size: 12.5px; color: var(--brand-blue); }
.account-user small { font-size: 10.5px; }

@keyframes pulse-dot {
  50% { box-shadow: 0 0 0 5px rgba(56, 189, 248, 0); opacity: 0.7; }
}

main {
  max-width: 1500px;
  width: 100%;
  margin: 0 auto;
  padding: 28px 32px 84px;
  min-width: 0;
}

main.page-enter > * {
  animation: pageIn 420ms var(--ease) backwards;
}

main.page-enter > *:nth-child(2) { animation-delay: 50ms; }
main.page-enter > *:nth-child(3) { animation-delay: 100ms; }
main.page-enter > *:nth-child(4) { animation-delay: 150ms; }
main.page-enter > *:nth-child(n+5) { animation-delay: 200ms; }

main.page-enter .company-card,
main.page-enter .metric {
  animation: pageIn 480ms var(--ease) backwards;
}

main.page-enter .company-card:nth-child(2), main.page-enter .metric:nth-child(2) { animation-delay: 90ms; }
main.page-enter .company-card:nth-child(3), main.page-enter .metric:nth-child(3) { animation-delay: 140ms; }
main.page-enter .company-card:nth-child(4), main.page-enter .metric:nth-child(4) { animation-delay: 190ms; }
main.page-enter .company-card:nth-child(n+5), main.page-enter .metric:nth-child(n+5) { animation-delay: 230ms; }

main:focus, main:focus-visible {
  outline: none;
}

@keyframes pageIn {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.page-head-actions {
  justify-content: flex-end;
  margin-bottom: 16px;
}

.page-head p {
  color: var(--muted);
  margin: 0;
  font-size: 13.5px;
}

.dashboard-card {
  background: var(--surface-glass-card);
  border: 1px solid var(--border-glass);
  border-radius: 20px;
  padding: 26px;
  box-shadow: var(--shadow-lg), var(--glass-edge);
  backdrop-filter: blur(var(--blur-base)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--blur-base)) saturate(160%);
}

.daily-dashboard-card .page-head {
  margin-bottom: 26px;
}

.daily-dashboard-card .panel:last-child {
  margin-bottom: 0;
}

.agenda-overview-section {
  margin-bottom: 20px;
}

.agenda-overview-title {
  margin: 0 0 8px;
  font-size: 17px;
}

.agenda-overview {
  margin-bottom: 0;
  padding: 17px 22px;
  cursor: pointer;
  transition: box-shadow 180ms var(--ease), transform 180ms var(--ease), border-color 180ms var(--ease);
}

.agenda-overview:hover,
.agenda-overview:focus-visible {
  outline: none;
  border-color: rgba(30, 58, 95, .38);
  box-shadow: var(--shadow-lg);
}

.agenda-overview-feed h3 {
  margin: 0;
}
.agenda-overview-feed p {
  color: var(--muted);
  margin: 6px 0 0;
}

.settings-categories {
  display: flex;
  gap: 18px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.settings-category {
  padding: 10px 2px;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: 14px;
  text-decoration: none;
}

.settings-category[aria-current="page"] {
  border-color: var(--green);
  color: var(--green);
  font-weight: 700;
}

.settings-general > .panel-heading {
  margin-bottom: 8px;
}

.settings-general > p {
  margin: 0 0 18px;
}

.settings-general > .panel-heading > div > :last-child { margin-bottom: 0; }

.settings-list {
  display: grid;
  gap: 8px;
  max-width: 900px;
}

.settings-record {
  width: 100%;
  min-height: 70px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: inherit;
  background: rgba(255,255,255,.72);
  text-align: left;
  box-shadow: var(--shadow-sm);
}

.settings-record:hover { border-color: rgba(56,189,248,.65); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.settings-record > span:nth-child(2) { min-width: 0; display: grid; }
.settings-record strong, .settings-record small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.record-action { color: var(--cyan); font-size: 12px; font-weight: 700; }

.user-avatar {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--green-light);
  color: var(--brand-blue);
  font-weight: 800;
}

.status-dot { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 700; }
.status-dot::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status-dot.is-active { color: var(--ok); }
.status-dot.is-inactive { color: var(--muted-light); }

.agenda-overview-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
}

.agenda-overview-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-content: start;
  margin: 0;
}

.agenda-overview-stats > div {
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
}

.agenda-overview-stats dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.agenda-overview-stats dd {
  margin: 3px 0 0;
  color: var(--text);
  font-size: 19px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.agenda-overview-stats .is-warning dd,
.agenda-overview-alert.is-warning h3 {
  color: var(--amber-ink, #8a5700);
}

.agenda-overview-stats .is-danger dd,
.agenda-overview-alert.is-danger h3 {
  color: var(--red);
}

.agenda-overview-feed {
  display: grid;
  grid-template-columns: 1.3fr 1fr 1fr;
  align-content: start;
  gap: 14px 20px;
}

.agenda-overview-feed h3 {
  font-size: 14px;
}

.agenda-overview-feed p {
  font-size: 13px;
  line-height: 1.55;
}

.agenda-overview-alert {
  min-width: 0;
}

.agenda-overview-recent ul {
  display: grid;
  gap: 7px;
  margin: 7px 0 0;
  padding: 0;
  list-style: none;
}

.agenda-overview-recent li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--text);
  font-size: 12px;
}

.agenda-overview-recent li span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agenda-overview-recent time {
  flex: none;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.dashboard-companies {
  margin-top: 32px;
}

.eyebrow {
  display: inline-block;
  font-size: 11px;
  font-weight: 750;
  color: var(--green);
  margin-bottom: 6px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--green-light);
  padding: 3px 8px;
  border-radius: 5px;
}

/* Botones refinados */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #0B1B33;
  font-size: 13px;
  font-weight: 650;
  box-shadow: var(--shadow-sm);
  transition: all 160ms var(--ease);
}

.button:hover {
  background: #ffffff;
  border-color: rgba(30, 58, 95, 0.35);
  box-shadow: 0 4px 12px rgba(11, 27, 51, 0.08);
  transform: translateY(-1.5px);
}

.button.primary {
  background: linear-gradient(180deg, #7DD3FC, var(--brand-cyan));
  color: var(--brand-base);
  border-color: #0EA5E9;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55), 0 4px 14px -2px rgba(14, 165, 233, 0.45);
}

.button.primary:hover {
  background: #29B1F0;
  border-color: #0284C7;
  box-shadow: 0 6px 18px rgba(30, 58, 95, 0.2);
  transform: translateY(-1.5px);
}

.button.danger {
  color: var(--red);
  background: rgba(254, 242, 242, 0.85);
  border-color: #fca5a5;
}

.button.danger:hover {
  background: #fef2f2;
  border-color: var(--red);
  box-shadow: 0 4px 12px rgba(185, 28, 28, 0.15);
}

.button.quiet {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  color: var(--muted);
}

.button.quiet:hover {
  background: rgba(30, 58, 95, 0.06);
  color: var(--green);
  transform: none;
}

.button.icon {
  padding: 10px;
  min-width: 44px;
}

/* Paneles de cristal (Glassmorphic Panels) */
.panel {
  background: var(--surface-glass-card);
  backdrop-filter: blur(var(--blur-base)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--blur-base)) saturate(160%);
  border: 1px solid var(--border-glass);
  border-radius: 16px;
  margin-bottom: 22px;
  padding: 24px;
  box-shadow: var(--shadow-md), var(--glass-edge);
  transition: box-shadow 200ms var(--ease), border-color 200ms var(--ease);
}

@media (hover: hover) {
  .panel:hover {
    border-color: rgba(255, 255, 255, 0.95);
    box-shadow: var(--shadow-lg), var(--glass-edge);
  }
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.panel-heading h2 {
  margin: 0;
}

/* Métricas destacadas */
.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.metric {
  border: 1px solid var(--border-glass);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.78), rgba(255, 255, 255, 0.45));
  backdrop-filter: blur(12px);
  border-radius: 11px;
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  transition: transform 180ms var(--ease), box-shadow 180ms var(--ease), border-color 180ms var(--ease);
}

.metric:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: rgba(30, 58, 95, 0.2);
}

.metric span {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.metric strong {
  display: block;
  font-size: 28px;
  font-weight: 750;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  margin-top: 6px;
  color: #1E3A5F;
}

.metric.warning {
  border-left: 4px solid var(--amber);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.95), rgba(254, 252, 243, 0.85));
}

.metric.warning strong {
  color: var(--amber);
}

.metric.danger {
  border-left: 4px solid var(--red);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.95), rgba(254, 242, 242, 0.85));
}

.metric.danger strong {
  color: var(--red);
}

/* Tarjetas de Empresa y Categorías */
.company-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: 16px;
}

.company-card {
  display: block;
  background: var(--surface-glass-card);
  backdrop-filter: blur(var(--blur-base)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--blur-base)) saturate(160%);
  border: 1px solid var(--border-glass);
  border-radius: 16px;
  padding: 22px;
  color: inherit;
  box-shadow: var(--shadow-md), var(--glass-edge);
  transition: all 220ms var(--ease);
  position: relative;
  overflow: hidden;
}

.company-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--brand-cyan), var(--brand-blue));
  opacity: 0;
  transition: opacity 220ms ease;
}

.company-card:hover {
  transform: translateY(-4px);
  border-color: rgba(56, 189, 248, 0.6);
  box-shadow: 0 20px 44px -8px rgba(30, 58, 95, 0.22), 0 0 0 1px rgba(56, 189, 248, 0.35), var(--glass-edge);
}

.company-card:hover::after {
  opacity: 1;
}

.company-card :is(h2, h3) {
  margin: 0;
  font-size: 19px;
}

.company-card-heading {
  display: flex;
  align-items: center;
  gap: 14px;
}

.company-card-heading .brand-mark {
  flex: none;
}

.meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 18px;
  border-top: 1px solid var(--line);
  margin-top: 20px;
  padding-top: 14px;
}

.meta > div {
  min-width: 0;
}

.meta b {
  display: block;
  font-size: 17px;
  font-variant-numeric: tabular-nums;
  color: #1E3A5F;
}

.meta span {
  display: block;
  font-size: 11.5px;
  line-height: 1.35;
  color: var(--muted);
}

.company-indicators {
  display: grid;
  gap: 14px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.company-indicator {
  min-width: 0;
}

.company-indicator-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.company-indicator-heading strong {
  font-size: 12.5px;
  color: #1E3A5F;
}

.company-indicator-heading span {
  flex: none;
  color: var(--green);
  font-size: 12px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.progress-track {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(30, 58, 95, .14);
}

.progress-track > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--brand-cyan);
  transition: width 220ms var(--ease);
}

.company-indicators small {
  display: block;
  margin-top: 3px;
  font-size: 11.5px;
  line-height: 1.4;
}

/* Tarjeta de Información Consolidada Ultra-Compacta */
.panel-consolidated {
  padding: 14px 18px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.panel-consolidated .consolidated-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-consolidated .consolidated-top h2 {
  font-size: 12.5px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin: 0;
}

.panel-consolidated .metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
  margin-bottom: 0;
}

.panel-consolidated .metric {
  padding: 8px 12px;
  border-radius: 8px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.panel-consolidated .metric span {
  font-size: 11px;
  font-weight: 600;
  margin: 0;
}

.panel-consolidated .metric strong {
  font-size: 20px;
  margin: 0;
  line-height: 1;
}

/* Pestañas de categorías (Tabs de navegación modernas) */
.company-areas {
  min-width: 0;
}

.company-tabs {
  display: flex;
  overflow-x: auto;
  gap: 6px;
  background: rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  border: 1px solid var(--border-glass);
  box-shadow: var(--glass-edge);
  border-radius: 14px;
  padding: 5px;
  margin-bottom: 22px;
  scrollbar-width: thin;
}

.company-tabs [role=tab] {
  flex: none;
  max-width: 340px;
  min-height: 44px;
  padding: 10px 18px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  font-size: 13px;
  font-weight: 650;
  transition: all 180ms var(--ease);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.company-tabs [role=tab]:hover {
  color: var(--green);
  background: rgba(255, 255, 255, 0.6);
}

.company-tabs [aria-selected=true] {
  color: #1E3A5F;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 4px 12px -2px rgba(30, 58, 95, 0.18), inset 0 -2px 0 var(--brand-cyan);
  font-weight: 750;
}

.category-content {
  min-width: 0;
  animation: pageIn 200ms var(--ease) forwards;
}

.category-content > .page-head h2 {
  font-size: 22px;
  margin-bottom: 8px;
}

.category-functions {
  white-space: pre-wrap;
  line-height: 1.6;
}

.category-content > .page-head .eyebrow {
  display: none;
}

/* Barra de herramientas y filtros */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: end;
  margin-bottom: 18px;
}

.toolbar .field {
  flex: 1;
  min-width: 180px;
}

/* Campos de Formulario */
.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field label {
  font-size: 13px;
  font-weight: 650;
  color: #1E3A5F;
}

.field input, .field select, .field textarea {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  border: 1px solid rgba(100, 116, 139, 0.55);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.78);
  color: #0B1B33;
  padding: 10px 14px;
  font-size: 13.5px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: border-color 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 4px rgba(56, 189, 248, 0.22);
  outline: none;
  background: #ffffff;
}

.field textarea {
  min-height: 100px;
  resize: vertical;
  line-height: 1.5;
}

.field [aria-invalid=true] {
  border-color: var(--red);
  background-color: #fff8f8;
}

.error-text {
  font-size: 12px;
  color: var(--red);
  font-weight: 550;
}

.error-summary {
  padding: 14px 18px;
  background: rgba(254, 242, 242, 0.95);
  color: #7f1d1d;
  border: 1px solid #fecaca;
  border-left: 4px solid var(--red);
  border-radius: 10px;
  margin-bottom: 18px;
}

.error-summary a {
  color: #991b1b;
  text-decoration: underline;
  font-weight: 600;
}

.error-summary:empty {
  display: none;
}

.empty {
  padding: 44px 24px;
  text-align: center;
  background: rgba(250, 252, 250, 0.7);
  border: 2px dashed #94A3B8;
  border-radius: 12px;
}

.empty h3 {
  font-size: 16px;
  margin-bottom: 6px;
}

.empty p {
  margin: 0;
  color: var(--muted);
  font-size: 13.5px;
}

/* Tablas con acabado de cristal y filas suaves */
.table-wrap {
  max-height: 65vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-glass-solid);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--shadow-sm), var(--glass-edge);
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  table-layout: fixed;
}

th {
  position: sticky;
  top: 0;
  background: var(--brand-blue);
  z-index: 2;
  text-align: left;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--brand-white);
  border-bottom: 1px solid var(--line-strong);
}

th, td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  overflow-wrap: anywhere;
}

tbody tr {
  transition: background-color 140ms ease;
}

tbody tr:hover {
  background-color: rgba(56, 189, 248, 0.07);
}

tr:last-child td {
  border-bottom: 0;
}

td strong {
  color: #1E3A5F;
  font-size: 13.5px;
}

td small {
  margin-top: 4px;
  line-height: 1.4;
}

td details {
  margin-top: 10px;
}

summary {
  cursor: pointer;
  color: var(--green);
  min-height: 44px;
  display: flex;
  align-items: center;
  font-size: 13px;
  font-weight: 650;
  user-select: none;
}

summary::before {
  content: '›';
  font-size: 18px;
  line-height: 1;
  margin-right: 8px;
  font-weight: bold;
  transition: transform 180ms ease;
  display: inline-block;
}

details[open] > summary::before {
  content: '›';
  transform: rotate(90deg);
}

dl {
  margin: 12px 0 16px;
  display: grid;
  gap: 10px;
  background: rgba(30, 58, 95, 0.03);
  padding: 14px;
  border-radius: 9px;
  border: 1px solid rgba(30, 58, 95, 0.06);
}

dt {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 700;
  color: var(--muted);
}

dd {
  margin: 2px 0 0;
  white-space: pre-wrap;
  font-size: 13px;
  color: #1E3A5F;
}

/* Badges y Pills */
.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 6px;
  padding: 4px 9px;
  font-size: 11.5px;
  font-weight: 700;
  background: var(--green-light);
  color: #1E3A5F;
  border: 1px solid rgba(30, 58, 95, 0.18);
  letter-spacing: 0.02em;
}

.pill.amber {
  background: var(--amber-light);
  color: #78350f;
  border-color: rgba(180, 83, 9, 0.25);
}

.pill.green {
  background: var(--ok-light);
  color: #065F46;
  border-color: rgba(4, 120, 87, 0.28);
}

.pill.orange {
  background: var(--orange-light);
  color: #9a3412;
  border-color: rgba(194, 65, 12, 0.25);
}

.pill.red {
  background: var(--red-light);
  color: #991b1b;
  border-color: rgba(185, 28, 28, 0.25);
}

.pill.neutral {
  background: #E2E8F0;
  color: #475A78;
  border-color: rgba(75, 99, 87, 0.2);
}

/* Estado de Guardado (Save Status) flotante y translúcido */
.save-status {
  position: fixed;
  bottom: 0;
  left: 240px;
  right: 0;
  background: rgba(255, 255, 255, 0.62);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-top: 1px solid rgba(255, 255, 255, 0.8);
  padding: 10px 32px;
  min-height: 40px;
  font-size: 12px;
  font-weight: 550;
  color: var(--muted);
  z-index: 15;
  display: flex;
  align-items: center;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.03);
  padding-bottom: max(10px, env(safe-area-inset-bottom));
}

.save-status:empty {
  display: none;
}

.save-status.error {
  background: rgba(254, 242, 242, 0.95);
  color: var(--red);
}

/* Toast flotante moderno */
.toast {
  position: fixed;
  bottom: 56px;
  left: 50%;
  max-width: 90vw;
  background: rgba(30, 58, 95, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: #ffffff;
  padding: 12px 22px;
  border-radius: 9999px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 12px 32px rgba(11, 27, 51, 0.35);
  opacity: 0;
  transform: translate(-50%, 12px);
  pointer-events: none;
  transition: opacity 220ms var(--ease), transform 220ms var(--ease);
  z-index: 50;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* Diálogos y Modales */
dialog {
  border: 1px solid var(--border-glass);
  border-radius: 16px;
  padding: 0;
  max-height: 90dvh;
  width: min(780px, calc(100% - 32px));
  color: inherit;
  background: var(--surface-glass-modal);
  backdrop-filter: blur(32px) saturate(180%);
  -webkit-backdrop-filter: blur(32px) saturate(180%);
  box-shadow: 0 30px 80px -12px rgba(30, 58, 95, 0.4), 0 10px 20px -5px rgba(30, 58, 95, 0.12), var(--glass-edge);
}

dialog.agenda-dialog {
  width: min(1120px, calc(100% - 32px));
  max-height: 92dvh;
  overflow-y: auto;
  scrollbar-gutter: stable;
}

.agenda-dialog-content {
  padding: 22px;
}

.agenda-dialog-content .daily-dashboard-card {
  margin: 0;
}

dialog::backdrop {
  background: rgba(11, 27, 51, 0.42);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

dialog[open]::backdrop {
  animation: backdrop-in 260ms var(--ease-smooth);
}

@keyframes backdrop-in {
  from { opacity: 0; }
}

dialog[open] {
  animation: dialog-in 320ms var(--ease);
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.dialog-header {
  padding: 22px 26px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  background: rgba(255, 255, 255, 0.5);
}

.dialog-header h2 {
  margin: 0;
  font-size: 20px;
}

.dialog-header p {
  margin: 5px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}

.dialog-body {
  padding: 24px 26px;
}

.steps {
  display: flex;
  gap: 8px;
  margin: 0 0 22px;
  padding: 0;
  list-style: none;
  flex-wrap: wrap;
}

.steps li {
  font-size: 12px;
  padding: 7px 12px;
  border-radius: 7px;
  background: rgba(30, 58, 95, 0.05);
  color: var(--muted);
  font-weight: 600;
  transition: all 160ms ease;
}

.steps [aria-current=step] {
  background: var(--green-light);
  color: #1E3A5F;
  font-weight: 750;
  box-shadow: 0 1px 4px rgba(30, 58, 95, 0.12);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.field.wide {
  grid-column: 1 / -1;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 12px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
  margin-top: 16px;
}

.actions .action-left { margin-right: auto; }

.check-row {
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(255,255,255,.55);
}

.check-row input, .permission-grid input { width: 18px; height: 18px; accent-color: var(--brand-blue); }
.check-row span { display: grid; }
.permission-fieldset { margin: 22px 0 0; padding: 18px; border: 1px solid var(--line); border-radius: 12px; }
.permission-fieldset legend { padding: 0 6px; color: var(--brand-blue); font-weight: 750; }
.permission-fieldset > p { margin: 0 0 14px; color: var(--muted); font-size: 12.5px; }
.permission-fieldset:disabled { opacity: .55; }
.permission-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
.permission-grid label { min-height: 44px; display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 8px; background: rgba(30,58,95,.045); }

.step-section {
  border: 0;
  padding: 0;
  margin: 0;
}

.step-section legend {
  font-size: 16px;
  font-weight: 750;
  margin-bottom: 16px;
  color: #1E3A5F;
}

/* Calendario y Trabajo Diario */
.cal-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.cal-controls :is(h2, h3) {
  margin: 0;
  text-transform: capitalize;
  font-size: 20px;
}

.calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 1px;
  background: var(--line-strong);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  overflow: hidden;
}

.dow {
  background: #E2E8F0;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  padding: 10px 0;
  color: var(--brand-blue);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.day {
  border: 0;
  background: rgba(255, 255, 255, 0.82);
  min-width: 0;
  min-height: 72px;
  text-align: left;
  padding: 10px;
  color: inherit;
  transition: background-color 140ms ease, box-shadow 140ms ease;
  font-size: 13px;
  font-weight: 600;
}

.day:hover:not(:disabled) {
  background: rgba(30, 58, 95, 0.05);
}

.day[aria-pressed=true] {
  box-shadow: inset 0 0 0 2px var(--green), 0 2px 10px rgba(30, 58, 95, 0.15);
  background: rgba(56, 189, 248, 0.16);
  font-weight: 750;
}

.day:disabled {
  background: #F8FAFC;
  opacity: 1;
  cursor: default;
  color: #8c9e94;
}

.day small {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  margin-top: 6px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--green-light);
  color: var(--green);
  font-weight: 650;
}

.agenda-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
  transition: background-color 140ms ease;
}

.agenda-row:last-child {
  border-bottom: 0;
}

.agenda-row p {
  margin: 4px 0;
  color: var(--muted);
  font-size: 13px;
}

.segmented {
  display: flex;
  gap: 4px;
  background: rgba(30, 58, 95, 0.06);
  padding: 4px;
  border-radius: 10px;
}

.segmented .button {
  min-height: 44px;
  padding: 8px 16px;
  border: 0;
  box-shadow: none;
  border-radius: 8px;
}

.segmented [aria-pressed=true] {
  background: #ffffff;
  color: var(--green);
  font-weight: 700;
  box-shadow: var(--shadow-sm);
}

#confirm {
  padding: 26px;
  width: min(480px, calc(100% - 32px));
}

#confirm .actions {
  border-top: 0;
  margin-top: 10px;
  padding-top: 10px;
}

[hidden] {
  display: none !important;
}

.risk-preview {
  margin-top: 16px;
  padding: 14px 16px;
  background: rgba(30, 58, 95, 0.06);
  border: 1px solid rgba(30, 58, 95, 0.15);
  border-radius: 9px;
  font-size: 13.5px;
}

/* Accesibilidad y Teclado */
body.keyboard *, body.keyboard dialog[open] {
  animation: none !important;
  transition: none !important;
}

body.keyboard button:active {
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition-property: opacity, background-color, color !important;
    transition-duration: 80ms !important;
    scroll-behavior: auto !important;
  }
  body::before, body::after {
    animation: none !important;
  }
  button:active {
    transform: none;
  }
  .toast, .toast.show {
    transform: translateX(-50%);
  }
}

/* Responsive Breakpoints */
@media (max-width: 1100px) {
  .sidebar {
    width: 210px;
  }
  .workspace {
    margin-left: 210px;
  }
  .save-status {
    left: 210px;
  }
  main {
    padding: 24px 20px 80px;
  }
  .topbar {
    padding: 12px 20px;
  }
  .secondary-column {
    display: none;
  }
}

@media (max-width: 760px) {
  .auth-gate { align-items: start; padding: 0; background: #fff; }
  .auth-shell { min-height: 100dvh; padding: 24px 18px; border: 0; border-radius: 0; box-shadow: none; }
  .auth-fields, .permission-grid { grid-template-columns: 1fr; }
  body::before, body::after {
    filter: blur(50px);
    animation: none;
  }
  .agenda-overview {
    padding: 16px;
  }
  .agenda-dialog-content {
    padding: 12px;
  }
  .agenda-overview-body {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .agenda-overview-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .agenda-overview-feed {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
  }
  .agenda-overview-alert {
    grid-column: 1 / -1;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line);
  }
  .sidebar {
    position: static;
    width: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 12px 16px;
    gap: 12px;
  }
  .sidebar nav {
    display: flex;
    overflow-x: auto;
    gap: 6px;
    padding: 3px;
    scrollbar-width: none;
  }
  .sidebar nav::-webkit-scrollbar {
    display: none;
  }
  .nav-item {
    white-space: nowrap;
    flex: none;
  }
  .nav-caption, .storage-note {
    display: none;
  }
  .brand {
    font-size: 16px;
  }
  .brand small {
    display: none;
  }
  .brand-mark {
    width: 34px;
    height: 34px;
    font-size: 16px;
  }
  .workspace {
    margin-left: 0;
  }
  .topbar {
    min-height: 48px;
    padding: 10px 16px;
  }
  .account-user { display: none; }
  .account-menu .button { min-height: 44px; padding: 7px 10px; }
  main {
    padding: 20px 16px 72px;
  }
  .save-status {
    left: 0;
    padding: 10px 16px;
  }
  .page-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 14px;
  }
  h1 {
    font-size: 24px;
  }
  .panel {
    padding: 18px 16px;
  }
  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  .metric {
    padding: 12px;
  }
  .metric strong {
    font-size: 24px;
  }
  .panel-heading {
    align-items: flex-start;
    flex-wrap: wrap;
  }
  .table-wrap {
    max-height: none;
    overflow: visible;
    border: 0;
    background: transparent;
    box-shadow: none;
  }
  table, tbody, tr, td {
    display: block;
    width: 100%;
  }
  thead {
    display: none;
  }
  tr {
    border: 1px solid var(--line);
    background: var(--surface-glass-card);
    border-radius: 10px;
    margin-bottom: 14px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
  }
  td {
    border: 0;
    padding: 10px 14px;
  }
  td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    margin-bottom: 4px;
  }
  .secondary-column {
    display: none;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .settings-record { grid-template-columns: auto minmax(0,1fr); }
  .settings-record > :last-child { grid-column: 2; justify-self: start; }
  .dialog-header, .dialog-body {
    padding: 18px 16px;
  }
  .toolbar .field {
    min-width: 100%;
  }
  .day {
    min-height: 48px;
    padding: 6px;
    text-align: center;
  }
  .day .event-name {
    display: none;
  }
  .agenda-row {
    flex-wrap: wrap;
    align-items: flex-start;
  }
  .topbar nav {
    overflow-wrap: anywhere;
  }
  input, select, textarea {
    font-size: 16px !important;
  }
}

/* Tarjetas-enlace: sin subrayado en su contenido */
a.company-card:hover,
a.company-card:hover *,
a.area-chip:hover,
a.area-chip:hover * {
  text-decoration: none;
}

/* Formularios: transición entre pasos, pasos como progreso y selects */
.step-section {
  animation: step-in 360ms var(--ease) backwards;
}

.step-section .field {
  animation: step-in 420ms var(--ease) backwards;
}

.step-section .field:nth-child(2) { animation-delay: 40ms; }
.step-section .field:nth-child(3) { animation-delay: 80ms; }
.step-section .field:nth-child(4) { animation-delay: 120ms; }
.step-section .field:nth-child(n+5) { animation-delay: 160ms; }

@keyframes step-in {
  from {
    opacity: 0;
    transform: translateX(14px);
  }
}

.steps li {
  border: 1px solid transparent;
}

.steps [aria-current=step] {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.28), rgba(255, 255, 255, 0.7));
  border-color: rgba(56, 189, 248, 0.45);
}

.field select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231E3A5F' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
}

.field input:hover, .field select:hover, .field textarea:hover {
  border-color: var(--cyan);
}

.field [aria-invalid=true] {
  animation: shake 320ms var(--ease-smooth);
}

@keyframes shake {
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* Tablas: filas con acento de interacción y entrada escalonada */
tbody tr {
  position: relative;
}

tbody tr:hover td:first-child {
  box-shadow: inset 3px 0 0 var(--brand-cyan);
}

main.page-enter tbody tr,
.category-content tbody tr {
  animation: pageIn 360ms var(--ease) backwards;
}

tbody tr:nth-child(2) { animation-delay: 30ms; }
tbody tr:nth-child(3) { animation-delay: 60ms; }
tbody tr:nth-child(4) { animation-delay: 90ms; }
tbody tr:nth-child(5) { animation-delay: 120ms; }
tbody tr:nth-child(n+6) { animation-delay: 150ms; }

th:first-child { border-top-left-radius: 13px; }
th:last-child { border-top-right-radius: 13px; }

/* Estado vacío en cristal */
.empty {
  background: rgba(255, 255, 255, 0.5);
  border: 1.5px dashed rgba(30, 58, 95, 0.3);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: var(--glass-edge);
}

.pill {
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

/* Barra de progreso con brillo */
.progress-track > span {
  background: linear-gradient(90deg, var(--brand-cyan), #0EA5E9);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.45);
}

@media (prefers-reduced-motion: reduce) {
  .step-section, .step-section .field, tbody tr, .field [aria-invalid=true] {
    animation: none !important;
  }
}

@media (max-width: 760px) {
  .topbar nav {
    flex-wrap: nowrap;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
  }
  .topbar nav::-webkit-scrollbar {
    display: none;
  }
}

/* Categoría CEAL: tarjetas de centros de trabajo */
.ceal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
  gap: 16px;
}

.ceal-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px;
  border: 1px solid var(--border-glass);
  border-radius: 16px;
  background: var(--surface-glass-card);
  backdrop-filter: blur(var(--blur-base)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--blur-base)) saturate(160%);
  box-shadow: var(--shadow-md), var(--glass-edge);
  transition: transform 220ms var(--ease), box-shadow 220ms var(--ease), border-color 220ms var(--ease);
  animation: pageIn 420ms var(--ease) backwards;
}

.ceal-card:hover {
  transform: translateY(-3px);
  border-color: rgba(56, 189, 248, 0.6);
  box-shadow: 0 20px 44px -8px rgba(30, 58, 95, 0.22), var(--glass-edge);
}

.ceal-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.ceal-card-head h3 {
  margin: 0;
  font-size: 18px;
}

.ceal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.ceal-meta span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.ceal-meta svg {
  width: 16px;
  height: 16px;
}

.ceal-days {
  margin: 0;
  font-size: 13px;
  font-weight: 650;
  color: var(--green);
}

.ceal-steps {
  display: flex;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ceal-steps li {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.7);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 700;
  transition: background-color 200ms var(--ease), transform 200ms var(--ease);
}

.ceal-steps .is-done {
  background: var(--green-light);
  border-color: rgba(56, 189, 248, 0.6);
  color: var(--green);
}

.ceal-steps [aria-current=step] {
  background: var(--brand-cyan);
  border-color: #0EA5E9;
  color: var(--brand-base);
  box-shadow: 0 4px 12px -2px rgba(14, 165, 233, 0.5);
}

.ceal-actions {
  display: flex;
  gap: 10px;
  margin-top: auto;
}

.ceal-actions .button {
  flex: 1;
}

@media (prefers-reduced-motion: reduce) {
  .ceal-card { animation: none !important; }
}

/* Expediente CEAL */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

a.button {
  text-decoration: none;
}

.ce-top {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.ce-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.ce-head h1 {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 4px 0;
}

.ce-days {
  display: grid;
  justify-items: end;
  padding: 14px 22px;
  border: 1px solid var(--border-glass);
  border-radius: 16px;
  background: var(--surface-glass-card);
  backdrop-filter: blur(var(--blur-base)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--blur-base)) saturate(160%);
  box-shadow: var(--shadow-md), var(--glass-edge);
}

.ce-days strong {
  font-size: 40px;
  line-height: 1;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  color: var(--brand-blue);
}

.ce-days span {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.ce-days.is-late strong {
  color: var(--red);
}

.ce-grid3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.ce-readonly {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  font-weight: 650;
  color: var(--brand-blue);
}

.field > input[data-ce-set],
.field > select[data-ce-set] {
  width: 100%;
  min-height: 44px;
  border: 1px solid rgba(100, 116, 139, 0.55);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.78);
  padding: 10px 14px;
  font-size: 13.5px;
  color: var(--brand-base);
}

.field > input[data-ce-set]:focus,
.field > select[data-ce-set]:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 4px rgba(56, 189, 248, 0.22);
  outline: none;
}

.ce-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.ce-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.85);
  box-shadow: var(--glass-edge);
  font-size: 12.5px;
}

.ce-plan {
  display: grid;
  gap: 12px;
}

.ce-plan-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.2fr) repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}

.ce-plan-name {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding-bottom: 12px;
  font-weight: 650;
  color: var(--brand-blue);
}

.ce-tabs [role=tab] {
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  max-width: none;
  white-space: normal;
}

.ce-tabs [role=tab] small {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.75;
}

.ce-tabs .is-done::after {
  content: '✓';
  align-self: flex-end;
  color: #047857;
  font-weight: 800;
}

.ce-form {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px;
  margin: 0 0 16px;
}

.ce-form .field {
  flex: 1 1 180px;
}

.ce-sub {
  margin-top: 26px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.ce-docs {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ce-docs li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.6);
}

.ce-doc-actions {
  display: flex;
  gap: 8px;
}

.ce-inline {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 16px;
  margin-top: 18px;
}

.ce-inline .field {
  flex: 0 1 240px;
}

.ce-validation {
  flex: 1 1 260px;
  margin: 0 0 6px;
  font-size: 13px;
}

.ce-note {
  padding: 12px 16px;
  border-radius: 10px;
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.3);
  font-size: 13px;
}

.ce-kanban {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.ce-col {
  padding: 12px;
  border-radius: 12px;
  background: rgba(30, 58, 95, 0.05);
}

.ce-col h4 {
  margin: 0 0 10px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.ce-measure {
  display: grid;
  gap: 6px;
  padding: 12px;
  margin-bottom: 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}

.ce-measure-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.ce-measure-actions select {
  flex: 1;
  min-height: 36px;
  border: 1px solid rgba(100, 116, 139, 0.45);
  border-radius: 8px;
  background: #fff;
  padding: 4px 8px;
}

.ce-log summary {
  font-weight: 700;
  color: var(--brand-blue);
}

.ce-log ul {
  display: grid;
  gap: 8px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
  font-size: 13px;
}

.ce-log time {
  margin-right: 8px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

@media (max-width: 760px) {
  .ce-plan-row {
    grid-template-columns: 1fr 1fr;
  }
  .ce-plan-name {
    grid-column: 1 / -1;
    padding-bottom: 0;
  }
}

@media print {
  .sidebar, .topbar, .save-status, .toast, .ce-noprint, dialog, .skip {
    display: none !important;
  }
  .workspace {
    margin-left: 0;
  }
  body {
    background: #fff;
  }
  body::before, body::after {
    display: none;
  }
  .panel, .ce-days {
    backdrop-filter: none;
    box-shadow: none;
    background: #fff;
    break-inside: avoid;
  }
  .ce-log {
    display: block;
  }
  main {
    padding: 0;
  }
}

/* Áreas de la empresa: chips compactos */
.panel-consolidated .consolidated-top .button {
  min-height: 36px;
  padding: 6px 14px;
}

.area-chips {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
  gap: 8px;
}

.area-chip {
  display: grid;
  gap: 1px;
  padding: 8px 12px;
  border: 1px solid var(--border-glass);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.55);
  box-shadow: var(--glass-edge);
  color: inherit;
  transition: transform 180ms var(--ease), border-color 180ms var(--ease), box-shadow 180ms var(--ease);
}

a.area-chip:hover {
  transform: translateY(-2px);
  border-color: rgba(56, 189, 248, 0.6);
  box-shadow: var(--shadow-md), var(--glass-edge);
}

.area-chip strong {
  font-size: 12.5px;
  color: var(--brand-blue);
}

.area-chip span {
  font-size: 11.5px;
  color: var(--muted);
}

.category-content .metrics {
  gap: 10px;
  margin-bottom: 16px;
}

.category-content .metric {
  padding: 10px 14px;
}

.category-content .metric strong {
  margin-top: 2px;
  font-size: 22px;
}

/* Menú: categoría fija Empresas y página propia por empresa */
.nav-company {
  min-height: 40px;
  padding: 7px 12px;
}

.nav-company > span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-initials {
  display: grid;
  place-items: center;
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--brand-blue), var(--brand-base));
  color: #fff;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.nav-empty {
  margin: 0 12px;
  font-size: 12px;
  color: var(--muted-light);
}

.nav-settings {
  margin-top: 14px;
}

.company-page-head {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

.company-page-head > div {
  flex: 1;
  min-width: 0;
}

.company-page-head h1 {
  margin: 0;
}

.company-page-head p {
  margin: 0;
}

.company-page-head .brand-mark {
  flex: none;
  width: 52px;
  height: 52px;
  border-radius: 14px;
}

.company-tabs-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 22px;
}

.company-tabs-row .company-tabs {
  flex: 1;
  min-width: 0;
  margin-bottom: 0;
}

.company-tabs-row > .button {
  flex: none;
  min-height: 52px;
}

@media (max-width: 760px) {
  .company-tabs-row {
    flex-direction: column;
    align-items: stretch;
  }
  .company-page-head {
    flex-wrap: wrap;
  }
  .nav-settings {
    margin-top: 0;
  }
}
