:root {
  --bg: #eef3f7;
  --surface: #ffffff;
  --surface-alt: #f7fafc;
  --line: #dbe3ea;
  --text: #122033;
  --muted: #607087;
  --primary: #155eef;
  --primary-dark: #0e4ac4;
  --success: #16794b;
  --danger: #b42318;
  --warning: #b54708;
  --sidebar: #0f172a;
  --sidebar-soft: #16213a;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 18px 50px rgba(16, 24, 40, 0.08);
  --font: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(21, 94, 239, 0.08), transparent 32%),
    linear-gradient(180deg, #f8fbfd 0%, var(--bg) 100%);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

.guest-body {
  min-height: 100vh;
}

.guest-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
}

.login-card,
.state-card {
  width: min(100%, 460px);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(219, 227, 234, 0.9);
  border-radius: 28px;
  padding: 32px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.login-card__brand {
  margin-bottom: 24px;
}

.login-card h1,
.state-card h1 {
  margin: 8px 0 10px;
  font-size: 1.9rem;
}

.login-card p,
.state-card p,
.section-copy,
.module-card p,
.role-card p,
.empty-state,
.sidebar-brand small {
  color: var(--muted);
}

.app-layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
  position: relative;
}

.sidebar {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 25%),
    linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-soft) 100%);
  color: #f8fbff;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  color: #f8fbff;
  padding: 10px 12px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.08));
  font-weight: 700;
  flex-shrink: 0;
}

.sidebar-brand-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.sidebar-brand-copy strong {
  font-size: 1.1rem;
  line-height: 1.1;
}

.sidebar-brand-copy small {
  font-size: 0.84rem;
  line-height: 1.35;
  color: rgba(248, 251, 255, 0.62);
}

.sidebar-nav {
  display: grid;
  gap: 18px;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
}

.sidebar-group {
  display: grid;
  gap: 10px;
}

.sidebar-group-label {
  padding: 0 12px;
  color: rgba(248, 251, 255, 0.55);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.69rem;
  font-weight: 700;
}

.sidebar-subnav {
  display: grid;
  gap: 4px;
  padding-left: 10px;
  border-left: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-link {
  padding: 7px 10px;
  border-radius: 14px;
  color: rgba(248, 251, 255, 0.88);
  font-weight: 600;
  transition: background 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.sidebar-sublink {
  padding: 6px 8px 6px 10px;
  border-radius: 12px;
  color: rgba(248, 251, 255, 0.72);
  font-size: 0.95rem;
  line-height: 1.35;
  transition: background 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.sidebar-link:hover,
.sidebar-link.is-active,
.sidebar-sublink:hover,
.sidebar-sublink.is-active {
  background: rgba(255, 255, 255, 0.09);
  color: #fff;
  transform: translateX(1px);
}

.sidebar-link.is-active,
.sidebar-sublink.is-active {
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.sidebar-foot {
  margin-top: auto;
  padding: 14px 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-label,
.page-kicker,
.field label,
.field-caption,
.stat-card span,
.permission-group strong,
.topbar-user small,
.timeline-item small,
.role-code,
.module-card strong,
.section-heading-tight .page-kicker {
  display: block;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.74rem;
}

.page-kicker {
  color: var(--primary);
  font-weight: 700;
}

.app-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sidebar-overlay {
  display: none;
}

.topbar-head {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.topbar-menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  min-width: 0;
  border: 1px solid rgba(21, 94, 239, 0.12);
  border-radius: 14px;
  padding: 10px 13px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

.topbar-title-block {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.topbar-title-link {
  display: block;
  color: inherit;
}

.topbar-title-link h1 {
  overflow-wrap: anywhere;
  margin: 0;
}

.topbar-subtitle {
  color: var(--muted);
  font-size: 0.88rem;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 20px 28px 10px;
}

.topbar h1 {
  font-size: 2rem;
  line-height: 1.05;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.topbar-company-form {
  min-width: min(100%, 280px);
}

.topbar-company-form .compact-select {
  min-width: 250px;
  padding-right: 40px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.06);
}

.topbar-user-card {
  min-width: 0;
  display: grid;
  gap: 2px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.66);
  border: 1px solid rgba(219, 227, 234, 0.9);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.05);
}

.topbar-user-name {
  line-height: 1.1;
}

.topbar-user-role {
  color: var(--muted);
}

.topbar-logout-form {
  min-width: 0;
}

.topbar-logout-btn {
  border-radius: 16px;
  padding-inline: 18px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.05);
}

.page-shell {
  padding: 0 28px 28px;
  min-width: 0;
}

.page-section {
  margin-top: 16px;
}

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

.section-heading h2,
.section-heading h3 {
  margin: 6px 0 0;
}

.section-heading-tight {
  margin-bottom: 16px;
}

.panel-card,
.stat-card,
.module-card,
.role-card {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(219, 227, 234, 0.9);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.stat-card {
  padding: 22px;
}

.stat-card strong {
  display: block;
  font-size: 1.9rem;
  margin: 8px 0;
}

.page-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 18px;
  margin-top: 18px;
}

.panel-card {
  padding: 22px;
  min-width: 0;
}

.module-list,
.role-list {
  display: grid;
  gap: 14px;
}

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

.quick-action-card {
  display: block;
  padding: 18px;
  border-radius: 16px;
  border: 1px solid rgba(219, 227, 234, 0.9);
  background: rgba(248, 251, 255, 0.95);
  transition: 0.18s ease;
}

.quick-action-card:hover {
  transform: translateY(-1px);
  border-color: rgba(21, 94, 239, 0.28);
}

.quick-action-card strong {
  display: block;
  margin-bottom: 8px;
}

.quick-action-card p {
  margin: 0;
  color: var(--muted);
}

.quick-action-card-primary {
  border-color: rgba(21, 94, 239, 0.24);
  background: linear-gradient(180deg, rgba(21, 94, 239, 0.08), rgba(255, 255, 255, 0.96));
}

.module-card,
.role-card {
  padding: 16px;
}

.role-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.role-permission-summary {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(215, 224, 234, 0.88);
  background: rgba(248, 251, 255, 0.9);
}

.role-permission-kpis,
.role-module-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.role-module-pill {
  display: inline-flex;
  align-items: center;
  padding: 7px 11px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  background: rgba(15, 95, 215, 0.08);
  color: var(--primary-dark);
}

.app-dialog {
  width: min(920px, calc(100vw - 32px));
  max-width: 100%;
  padding: 0;
  border: 0;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 28px 64px rgba(15, 23, 42, 0.24);
}

.app-dialog::backdrop {
  background: rgba(15, 23, 42, 0.58);
  backdrop-filter: blur(4px);
}

.app-dialog__header,
.app-dialog__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px;
  border-bottom: 1px solid rgba(215, 224, 234, 0.84);
}

.app-dialog__header h3,
.app-dialog__footer h3 {
  margin: 6px 0 0;
}

.app-dialog__header p {
  margin: 6px 0 0;
  color: var(--muted);
}

.app-dialog__body {
  display: grid;
  gap: 18px;
  max-height: min(70vh, 760px);
  overflow: auto;
  padding: 22px;
}

.app-dialog__footer {
  border-top: 1px solid rgba(215, 224, 234, 0.84);
  border-bottom: 0;
}

.role-dialog-groups {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.timeline-list {
  display: grid;
  gap: 12px;
}

.timeline-item {
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.timeline-item:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.alerts-stack {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.alert {
  border-radius: 14px;
  padding: 14px 16px;
  border: 1px solid transparent;
}

.alert-success {
  background: rgba(22, 121, 75, 0.08);
  border-color: rgba(22, 121, 75, 0.2);
  color: var(--success);
}

.alert-error {
  background: rgba(180, 35, 24, 0.08);
  border-color: rgba(180, 35, 24, 0.2);
  color: var(--danger);
}

.field {
  display: grid;
  gap: 6px;
}

.form-grid {
  display: grid;
  gap: 10px;
}

.form-grid-inline {
  grid-template-columns: minmax(0, 1.6fr) 220px auto;
  align-items: end;
}

.form-grid-two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field-full,
.form-actions {
  grid-column: 1 / -1;
}

input,
select,
textarea {
  width: 100%;
  padding: 7px 10px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(21, 94, 239, 0.45);
  box-shadow: 0 0 0 4px rgba(21, 94, 239, 0.1);
}

.checkbox-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.checkbox-row input {
  width: auto;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 12px;
  padding: 6px 12px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: 0.18s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  background: #fff;
  border-color: var(--line);
  color: var(--text);
}

.btn-ghost {
  background: var(--surface-alt);
  color: var(--text);
}

.btn-small {
  padding: 5px 8px;
  border-radius: 10px;
  font-size: 0.8rem;
}

.btn-block {
  width: 100%;
}

.align-end {
  align-self: end;
}

.table-wrap {
  overflow: auto;
  max-width: 100%;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
}

.data-table th,
.data-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.data-table th {
  color: var(--muted);
  font-weight: 600;
}

.data-table td small {
  display: block;
  color: var(--muted);
  margin-top: 4px;
}

.table-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.table-icon-actions {
  vertical-align: middle;
  white-space: nowrap;
}

.table-icon-actions > a,
.table-icon-actions > form,
.table-icon-actions > button {
  display: inline-flex;
  vertical-align: middle;
}

.table-icon-actions > * + * {
  margin-left: 8px;
}

.table-icon-actions form {
  margin: 0;
  display: inline-flex;
}

.table-icon-btn {
  width: 28px;
  min-width: 28px;
  min-height: 28px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.table-icon-btn svg {
  width: 14px;
  height: 14px;
  display: block;
}

.table-icon-actions--lg > * + * {
  margin-left: 10px;
}

.table-icon-actions--lg .table-icon-btn {
  width: 36px;
  min-width: 36px;
  min-height: 36px;
}

.table-icon-actions--lg .table-icon-btn svg {
  width: 18px;
  height: 18px;
}

.table-icon-btn--danger {
  background: rgba(180, 35, 24, 0.1);
  color: var(--danger);
  border-color: rgba(180, 35, 24, 0.14);
}

.table-icon-btn--success {
  background: rgba(22, 121, 75, 0.12);
  color: var(--success);
  border-color: rgba(22, 121, 75, 0.16);
}

.status-chip,
.mini-pill,
.status-badge,
.document-badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  background: var(--surface-alt);
  white-space: nowrap;
}

.status-success {
  background: rgba(22, 121, 75, 0.12);
  color: var(--success);
}

.status-warning {
  background: rgba(181, 71, 8, 0.12);
  color: var(--warning);
}

.status-reading {
  background: rgba(21, 94, 239, 0.12);
  color: var(--primary);
}

.status-error {
  background: rgba(180, 35, 24, 0.1);
  color: var(--danger);
}

.status-idle {
  background: rgba(96, 112, 135, 0.12);
  color: var(--muted);
}

.status-active {
  background: rgba(22, 121, 75, 0.12);
  color: var(--success);
}

.status-inactive {
  background: rgba(180, 35, 24, 0.1);
  color: var(--danger);
}

.status-neutral {
  background: rgba(96, 112, 135, 0.12);
  color: var(--muted);
}

.table-state-row td:first-child {
  position: relative;
  padding-left: 20px;
}

.table-state-row td:first-child::before {
  content: "";
  position: absolute;
  left: 0;
  top: 12px;
  bottom: 12px;
  width: 4px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.9);
}

.table-state-row--status-warning td:first-child::before {
  background: var(--warning);
}

.table-state-row--status-reading td:first-child::before {
  background: var(--primary);
}

.table-state-row--status-success td:first-child::before,
.table-state-row--status-active td:first-child::before {
  background: var(--success);
}

.table-state-row--status-error td:first-child::before,
.table-state-row--status-inactive td:first-child::before {
  background: var(--danger);
}

.table-state-row--status-neutral td:first-child::before,
.table-state-row--status-idle td:first-child::before {
  background: var(--muted);
}

.table-state-meta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

.table-state-meta--standalone {
  margin-top: 0;
  font-size: 0.86rem;
}

.table-state-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: currentColor;
  flex: 0 0 8px;
}

.table-state-meta.status-warning {
  color: var(--warning);
}

.table-state-meta.status-reading {
  color: var(--primary);
}

.table-state-meta.status-success,
.table-state-meta.status-active {
  color: var(--success);
}

.table-state-meta.status-error,
.table-state-meta.status-inactive {
  color: var(--danger);
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.permission-groups {
  display: grid;
  gap: 16px;
}

.permission-groups.compact {
  gap: 14px;
}

.permission-group ul {
  margin: 10px 0 0;
  padding-left: 18px;
  color: var(--muted);
}

.inline-form {
  margin: 0;
}

.compact-select {
  min-width: 220px;
  max-width: 100%;
}

.empty-cell,
.empty-state {
  color: var(--muted);
}

.empty-callout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.empty-callout p {
  margin: 0;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 18px;
}

.detail-grid.compact {
  gap: 12px;
}

.info-card {
  padding: 16px 18px;
  border: 1px solid rgba(21, 94, 239, 0.16);
  background: rgba(21, 94, 239, 0.05);
  border-radius: 16px;
}

.info-card strong {
  display: block;
  margin-bottom: 6px;
}

.info-card p,
.credentials-card p,
.field-help {
  margin: 0;
  color: var(--muted);
}

.checkbox-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
}

.checkbox-card input[type="checkbox"] {
  margin-top: 4px;
}

.checkbox-card span {
  display: grid;
  gap: 4px;
}

.checkbox-card small {
  color: var(--muted);
}

.checkbox-card-deny {
  border-color: rgba(180, 35, 24, 0.16);
  background: rgba(180, 35, 24, 0.04);
}

.permission-editor-grid {
  align-items: start;
}

.permission-preview-card {
  position: sticky;
  top: 18px;
}

.permission-split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.permission-split-column {
  display: grid;
  gap: 12px;
}

.credentials-card {
  margin-bottom: 18px;
}

.credentials-card__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.credentials-card__header h3 {
  margin: 6px 0 0;
}

.credentials-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.copy-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.copy-row input {
  flex: 1;
}

.document-badge-active {
  background: rgba(21, 94, 239, 0.12);
  color: var(--primary);
}

.document-badge-error {
  background: rgba(180, 35, 24, 0.1);
  color: var(--danger);
}

.document-badge-idle {
  background: rgba(96, 112, 135, 0.12);
  color: var(--muted);
}

@media (max-width: 1100px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .page-grid {
    grid-template-columns: 1fr;
  }

  .form-grid-inline {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 920px) {
  .app-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(300px, calc(100vw - 44px));
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 30;
  }

  .app-layout.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .app-layout.sidebar-open .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 25;
    border: 0;
    padding: 0;
    background: rgba(15, 23, 42, 0.48);
  }

  .topbar-menu-btn {
    display: inline-flex;
  }

  .topbar {
    padding-left: 20px;
    padding-right: 20px;
  }

  .topbar-actions {
    gap: 10px;
  }

  .topbar-company-form {
    min-width: 220px;
  }

  .topbar-company-form .compact-select {
    min-width: 220px;
  }
}

@media (max-width: 760px) {
  .topbar,
  .page-shell {
    padding-left: 16px;
    padding-right: 16px;
  }

  .topbar {
    padding-top: 18px;
  }

  .topbar h1 {
    font-size: 1.55rem;
  }

  .topbar-actions,
  .section-heading,
  .form-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar-actions {
    align-items: stretch;
  }

  .topbar-company-form,
  .topbar-company-form .compact-select,
  .topbar-user-card,
  .topbar-logout-form,
  .topbar-logout-btn {
    width: 100%;
  }

  .stats-grid,
  .form-grid-two,
  .detail-grid,
  .credentials-grid,
  .permission-split {
    grid-template-columns: 1fr;
  }

  .copy-row,
  .credentials-card__header {
    flex-direction: column;
    align-items: stretch;
  }

  .login-card,
  .state-card,
  .panel-card {
    padding: 18px;
    border-radius: 20px;
  }

  .sidebar-link,
  .sidebar-sublink {
    width: 100%;
  }

  .sidebar {
    padding: 18px 14px;
  }

  .sidebar-brand {
    padding: 10px;
  }
}

/* Fase 9: rediseño visual global, responsive y españolización */
:root {
  --bg: #edf3f9;
  --surface: #ffffff;
  --surface-alt: #f5f8fc;
  --line: #d7e0ea;
  --line-strong: #bed0e0;
  --text: #102033;
  --muted: #5e7088;
  --primary: #0f5fd7;
  --primary-dark: #0c469d;
  --primary-soft: #e8f1ff;
  --success: #157347;
  --danger: #b42318;
  --warning: #b45309;
  --sidebar: #0d1b32;
  --sidebar-soft: #122645;
  --teal: #0f766e;
  --radius: 24px;
  --radius-sm: 16px;
  --shadow: 0 18px 46px rgba(15, 23, 42, 0.08);
  --shadow-soft: 0 12px 24px rgba(15, 23, 42, 0.06);
  --font: "Aptos", "Segoe UI", Tahoma, sans-serif;
  --font-heading: "Bahnschrift", "Aptos Display", "Segoe UI Semibold", sans-serif;
  --border: var(--line);
}

html {
  scroll-behavior: smooth;
  width: 100%;
  max-width: 100%;
  font-size: 87.5%;
}

body {
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(15, 95, 215, 0.11), transparent 30%),
    radial-gradient(circle at right top, rgba(15, 118, 110, 0.07), transparent 24%),
    linear-gradient(180deg, #f8fbff 0%, #edf3f9 48%, #e7eef7 100%);
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

body.sidebar-lock {
  overflow: hidden;
}

body.dialog-lock {
  overflow: hidden;
}

.app-body::before,
.guest-body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.24), transparent 35%),
    radial-gradient(circle at bottom right, rgba(15, 95, 215, 0.06), transparent 20%);
  z-index: -1;
}

.guest-shell {
  padding: 28px 16px;
}

.login-card,
.state-card {
  position: relative;
  overflow: hidden;
  width: min(100%, 540px);
  padding: 36px;
  border-radius: 30px;
  border: 1px solid rgba(215, 224, 234, 0.88);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.12);
}

.login-card::before,
.state-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 6px;
  background: linear-gradient(90deg, var(--primary), var(--teal));
}

.login-card__brand {
  display: grid;
  gap: 10px;
  margin-bottom: 26px;
}

.login-card__wordmark {
  width: min(100%, 280px);
  height: auto;
}

.login-card h1,
.state-card h1,
.topbar h1,
.section-heading h2,
.section-heading h3,
.role-card strong,
.module-card strong,
.stat-card strong,
.quick-action-card strong {
  font-family: var(--font-heading);
  letter-spacing: -0.03em;
}

.app-layout {
  grid-template-columns: 300px 1fr;
  gap: 0;
}

.sidebar {
  gap: 12px;
  padding: 12px 10px 10px;
  background:
    radial-gradient(circle at top right, rgba(255, 255, 255, 0.14), transparent 28%),
    linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-soft) 100%);
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.04);
}

.sidebar-head {
  display: grid;
  gap: 12px;
}

.sidebar-brand {
  gap: 12px;
  padding: 14px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.sidebar-close-btn {
  display: none;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  color: #f8fbff;
  padding: 10px 14px;
}

.sidebar-mark {
  width: 46px;
  height: 46px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0.08));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.sidebar-context-card,
.sidebar-foot {
  padding: 14px 14px 15px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: grid;
  gap: 4px;
}

.sidebar-context-card strong,
.sidebar-foot strong {
  font-size: 0.98rem;
}

.sidebar-context-card small,
.sidebar-foot small {
  color: rgba(248, 251, 255, 0.7);
  line-height: 1.45;
}

.sidebar-nav {
  gap: 16px;
  padding-right: 6px;
}

.sidebar-nav::-webkit-scrollbar {
  width: 8px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
}

.sidebar-link,
.sidebar-sublink {
  position: relative;
}

.sidebar-link.is-active,
.sidebar-sublink.is-active {
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.07));
}

.sidebar-link.is-active::before,
.sidebar-sublink.is-active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 4px;
  border-radius: 999px;
  background: linear-gradient(180deg, #7dd3fc, #38bdf8);
}

.app-main {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 10px 16px 8px;
  backdrop-filter: blur(18px);
  background: linear-gradient(180deg, rgba(248, 251, 255, 0.9), rgba(248, 251, 255, 0.72));
  border-bottom: 1px solid rgba(190, 208, 224, 0.6);
}

.topbar-menu-btn {
  gap: 10px;
  padding: 11px 14px;
  border-radius: 16px;
  font-weight: 700;
}

.topbar-menu-icon {
  display: inline-grid;
  gap: 4px;
}

.topbar-menu-icon span {
  display: block;
  width: 16px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
}

.topbar-title-block {
  gap: 4px;
}

.topbar h1 {
  font-size: clamp(1.85rem, 2vw, 2.45rem);
}

.topbar-subtitle {
  font-size: 0.92rem;
}

.topbar-actions {
  align-items: stretch;
  gap: 12px;
}

.topbar-company-card,
.topbar-user-card {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 18px;
  border: 1px solid rgba(215, 224, 234, 0.9);
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow-soft);
}

.topbar-company-card {
  display: grid;
  gap: 5px;
  min-width: min(100%, 330px);
}

.topbar-card-label {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.topbar-company-name {
  font-size: 0.98rem;
  line-height: 1.2;
}

.topbar-company-form {
  min-width: 0;
}

.topbar-company-form .compact-select {
  min-width: 100%;
  border-radius: 14px;
  min-height: 48px;
  border-color: rgba(190, 208, 224, 0.88);
}

.topbar-user-card {
  gap: 14px;
}

.topbar-user-avatar {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, rgba(15, 95, 215, 0.14), rgba(15, 118, 110, 0.14));
  color: var(--primary-dark);
  font-weight: 800;
}

.topbar-user-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.topbar-user-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-logout-btn {
  min-height: 38px;
  padding-inline: 16px;
}

.page-shell {
  padding: 18px 28px 32px;
  overflow-x: clip;
}

.page-shell > * {
  width: 100%;
  max-width: 1480px;
  margin-inline: auto;
}

.page-section {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.section-heading {
  align-items: center;
  margin-bottom: 0;
  padding: 20px 22px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid rgba(215, 224, 234, 0.84);
  box-shadow: var(--shadow-soft);
}

.section-heading p,
.section-copy {
  margin: 8px 0 0;
}

.section-heading > div,
.topbar-head,
.topbar-company-card,
.topbar-user-card,
.topbar-user-copy,
.panel-card,
.role-card,
.module-card,
.stat-card,
.info-card {
  min-width: 0;
}

.panel-card,
.stat-card,
.module-card,
.role-card {
  border: 1px solid rgba(215, 224, 234, 0.88);
  box-shadow: var(--shadow);
}

.panel-card {
  padding: 24px;
}

.stats-grid {
  gap: 10px;
}

.stat-card {
  position: relative;
  overflow: hidden;
  padding: 24px;
}

.stat-card::after {
  content: "";
  position: absolute;
  inset: auto -28px -28px auto;
  width: 92px;
  height: 92px;
  border-radius: 28px;
  background: linear-gradient(180deg, rgba(15, 95, 215, 0.08), rgba(15, 118, 110, 0.05));
}

.stat-card strong {
  font-size: clamp(1.7rem, 2vw, 2.2rem);
}

.quick-actions-grid,
.module-list,
.role-list,
.timeline-list {
  gap: 16px;
}

.quick-action-card {
  padding: 20px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(248, 251, 255, 0.98), rgba(241, 246, 252, 0.96));
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.04);
}

.quick-action-card-primary {
  background: linear-gradient(180deg, rgba(15, 95, 215, 0.13), rgba(255, 255, 255, 0.98));
}

.timeline-item {
  padding: 16px 0;
}

.form-grid {
  gap: 20px;
}

.field {
  gap: 6px;
}

input,
select,
textarea {
  min-height: 34px;
  border-radius: 14px;
  border-color: rgba(190, 208, 224, 0.92);
  background: rgba(255, 255, 255, 0.98);
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

textarea {
  min-height: 80px;
}

input::placeholder,
textarea::placeholder {
  color: #8a99ac;
}

.btn {
  min-height: 32px;
  border-radius: 14px;
  font-weight: 700;
}

.btn-primary {
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
  box-shadow: 0 10px 22px rgba(15, 95, 215, 0.24);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.98);
  border-color: rgba(190, 208, 224, 0.92);
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.05);
}

.btn-ghost {
  background: rgba(15, 95, 215, 0.08);
  color: var(--primary-dark);
}

.btn-small {
  min-height: 28px;
  padding: 5px 8px;
}

.table-wrap {
  border: 1px solid rgba(215, 224, 234, 0.9);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
  -webkit-overflow-scrolling: touch;
}

.table-wrap::-webkit-scrollbar {
  height: 10px;
}

.table-wrap::-webkit-scrollbar-thumb {
  background: rgba(96, 112, 135, 0.25);
  border-radius: 999px;
}

.data-table {
  min-width: 880px;
}

.data-table th {
  position: sticky;
  top: 0;
  background: rgba(248, 251, 255, 0.98);
  z-index: 1;
}

.data-table th,
.data-table td,
.field-help,
.section-copy {
  overflow-wrap: break-word;
}

.data-table tr:hover td {
  background: rgba(15, 95, 215, 0.03);
}

.status-chip,
.mini-pill,
.status-badge,
.document-badge,
.status-pill {
  border: 1px solid transparent;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
}

.chip-list {
  gap: 10px;
}

.mini-pill {
  background: rgba(15, 95, 215, 0.08);
  color: var(--primary-dark);
}

.role-code {
  margin-top: 4px;
  color: var(--muted);
}

.info-card {
  border-color: rgba(15, 95, 215, 0.14);
  background: linear-gradient(180deg, rgba(15, 95, 215, 0.06), rgba(255, 255, 255, 0.95));
}

.checkbox-card {
  padding: 14px 16px;
  border-color: rgba(215, 224, 234, 0.88);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.03);
}

.empty-callout {
  padding: 10px 2px;
}

.dashboard-shell {
  display: grid;
  gap: 18px;
}

.dashboard-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.9fr);
  gap: 18px;
  overflow: hidden;
}

.dashboard-hero-copy {
  display: grid;
  gap: 14px;
}

.dashboard-hero-copy h2 {
  margin: 0;
  font-size: clamp(2rem, 2.5vw, 3rem);
  line-height: 1;
}

.dashboard-hero-copy p {
  margin: 0;
  max-width: 62ch;
  color: var(--muted);
}

.dashboard-hero-side {
  display: grid;
  gap: 12px;
}

.dashboard-pill-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.dashboard-pill {
  padding: 16px;
  border-radius: 18px;
  background: rgba(248, 251, 255, 0.92);
  border: 1px solid rgba(215, 224, 234, 0.84);
}

.dashboard-pill strong {
  display: block;
  font-size: 1.35rem;
  margin-top: 8px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(320px, 0.9fr);
  gap: 18px;
}

.dashboard-side-grid {
  display: grid;
  gap: 18px;
}

.dashboard-card-accent {
  background:
    radial-gradient(circle at top right, rgba(15, 95, 215, 0.08), transparent 35%),
    rgba(255, 255, 255, 0.92);
}

.dashboard-card-soft {
  background:
    radial-gradient(circle at top right, rgba(15, 118, 110, 0.08), transparent 35%),
    rgba(255, 255, 255, 0.92);
}

@media (max-width: 1280px) {
  .dashboard-hero,
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1100px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar-actions {
    justify-content: stretch;
  }
}

@media (max-width: 920px) {
  .app-layout {
    grid-template-columns: 1fr;
    width: 100%;
    max-width: 100%;
  }

  .app-main,
  .page-shell,
  .page-shell > *,
  .page-section,
  .section-heading,
  .panel-card,
  .stat-card,
  .module-card,
  .role-card,
  .dashboard-shell,
  .dashboard-hero,
  .dashboard-grid {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .page-shell > * {
    margin-inline: 0;
  }

  .sidebar {
    width: min(320px, calc(100vw - 30px));
    box-shadow: 0 28px 60px rgba(0, 0, 0, 0.22);
  }

  .sidebar-close-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .topbar {
    padding: 16px 20px 14px;
  }
}

@media (max-width: 760px) {
  .page-shell {
    padding: 14px 16px 24px;
  }

  .page-shell > * {
    max-width: none;
  }

  .section-heading,
  .panel-card,
  .stat-card,
  .topbar-company-card,
  .topbar-user-card {
    border-radius: 20px;
  }

  .section-heading {
    padding: 18px;
  }

  .dashboard-pill-grid {
    grid-template-columns: 1fr;
  }

  .table-wrap {
    border-radius: 16px;
  }

  .topbar-company-card,
  .topbar-user-card {
    width: 100%;
  }

  .topbar-logout-btn {
    width: 100%;
  }

  .table-actions {
    align-items: stretch;
  }

  .table-actions .btn,
  .table-actions form,
  .table-actions form .btn {
    width: 100%;
  }

  .app-dialog {
    width: min(100vw - 20px, 100%);
    border-radius: 20px;
  }

  .app-dialog__header,
  .app-dialog__footer {
    flex-direction: column;
    align-items: stretch;
    padding: 18px;
  }

  .app-dialog__body {
    padding: 18px;
  }

  .role-dialog-groups {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .login-card,
  .state-card,
  .panel-card,
  .stat-card {
    padding: 18px;
  }

  .topbar h1 {
    font-size: 1.55rem;
  }

  .sidebar {
    width: min(92vw, 320px);
  }

  .btn,
  input,
  select,
  textarea {
    min-height: 46px;
  }

  .topbar-menu-btn {
    width: 100%;
    justify-content: center;
  }
}

/* Selector compacto de servicios (usuarios: crear/editar) */
.service-picker {
  border: 1px solid rgba(190, 208, 224, 0.9);
  border-radius: 16px;
  background: #fff;
  overflow: hidden;
}

.service-picker__toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(190, 208, 224, 0.7);
  background: rgba(21, 94, 239, 0.03);
}

.service-picker__search-wrap {
  flex: 1 1 220px;
  min-width: 180px;
}

.service-picker__search {
  min-height: 38px !important;
  padding: 8px 12px !important;
  border-radius: 10px !important;
  font-size: 0.92rem;
}

.service-picker__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.service-picker__action-btn {
  border: none;
  background: none;
  padding: 4px 2px;
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--primary);
  cursor: pointer;
}

.service-picker__action-btn:hover {
  text-decoration: underline;
}

.service-picker__divider {
  color: var(--muted);
  font-size: 0.8rem;
}

.service-picker__list {
  max-height: 280px;
  overflow-y: auto;
  padding: 6px;
}

.service-picker__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.12s ease;
}

.service-picker__item:hover {
  background: rgba(21, 94, 239, 0.05);
}

.service-picker__item.is-hidden {
  display: none;
}

.service-picker__item--checked {
  background: rgba(21, 94, 239, 0.07);
}

.service-picker__item input[type="checkbox"] {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  min-height: 0;
  margin: 0;
}

.service-picker__code {
  flex: 0 0 auto;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--primary-dark);
  background: rgba(21, 94, 239, 0.08);
  padding: 2px 7px;
  border-radius: 6px;
  letter-spacing: 0.02em;
}

.service-picker__name {
  flex: 1 1 auto;
  font-size: 0.88rem;
  color: var(--text);
  line-height: 1.3;
}

.service-picker__empty {
  padding: 20px;
  text-align: center;
  color: var(--muted);
  font-size: 0.88rem;
}

.service-picker__footer {
  padding: 8px 14px;
  border-top: 1px solid rgba(190, 208, 224, 0.7);
  font-size: 0.8rem;
  color: var(--muted);
  background: rgba(21, 94, 239, 0.02);
}

@media (max-width: 560px) {
  .service-picker__toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .service-picker__actions {
    justify-content: flex-end;
  }
}

/* Selector compacto de permisos adicionales/bloqueados (usuarios: crear/editar) */
.permission-filter-bar {
  margin: 4px 0 4px;
}

.permission-filter-bar__search {
  min-height: 40px !important;
  padding: 9px 12px !important;
  border-radius: 10px !important;
  font-size: 0.92rem;
}

.permission-picker {
  border: 1px solid rgba(190, 208, 224, 0.9);
  border-radius: 14px;
  background: #fff;
  max-height: 360px;
  overflow-y: auto;
  padding: 6px;
}

.permission-picker--deny {
  border-color: rgba(180, 35, 24, 0.22);
}

.permission-picker__group + .permission-picker__group {
  border-top: 1px dashed rgba(190, 208, 224, 0.65);
  margin-top: 2px;
}

.permission-picker__group.is-hidden {
  display: none;
}

.permission-picker__group-header {
  padding: 8px 8px 3px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.permission-picker__item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.86rem;
  color: var(--text);
  line-height: 1.3;
}

.permission-picker__item:hover {
  background: rgba(21, 94, 239, 0.05);
}

.permission-picker--deny .permission-picker__item:hover {
  background: rgba(180, 35, 24, 0.05);
}

.permission-picker__item input[type="checkbox"] {
  width: 15px;
  height: 15px;
  min-height: 0;
  margin: 0;
  flex: 0 0 auto;
}

.permission-picker__item.is-hidden {
  display: none;
}

.permission-picker__empty {
  padding: 16px;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}

.permission-picker-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 0.78rem;
  color: var(--muted);
}

.permission-picker__clear-btn {
  border: none;
  background: none;
  padding: 2px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--primary);
  cursor: pointer;
}

.permission-picker__clear-btn:hover {
  text-decoration: underline;
}

/* Refinamiento de tablas de datos (admisiones, consentimientos, medicos
   referentes, servicios, reportes): jerarquia tipografica en encabezados,
   cebreado sutil para seguir filas con contenido multilinea, utilidades para
   columnas numericas que no deben partirse, y estados vacios mas cuidados. */
.data-table th {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding-top: 8px;
  padding-bottom: 8px;
}

.data-table tbody tr:nth-child(even) td {
  background: rgba(15, 23, 42, 0.014);
}

.data-table td small {
  font-size: 0.78rem;
}

.data-table .text-right {
  text-align: right;
}

.data-table .text-nowrap,
.data-table .text-right {
  white-space: nowrap;
}

.empty-cell {
  text-align: center;
  padding: 30px 16px !important;
  font-size: 0.92rem;
}

.empty-callout {
  justify-content: center;
  text-align: center;
  flex-direction: column;
  padding: 22px 16px !important;
}

/* Rediseno "compacto corporativo" a nivel de sistema: menos padding, menos
   protagonismo tipografico en numeros y textos explicativos, para que la
   informacion realmente util no compita con relleno visual. Aplica a todo el
   sistema via clases compartidas (panel-card, stat-card, info-card,
   section-heading, section-copy). */
.panel-card {
  padding: 12px 14px;
}

.stat-card {
  padding: 10px 12px;
}

.stat-card::after {
  width: 52px;
  height: 52px;
  inset: auto -16px -16px auto;
}

.stat-card strong {
  font-size: clamp(1.15rem, 1.4vw, 1.4rem);
  margin: 4px 0;
}

.stat-card small {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.35;
  margin-top: 2px;
}

.dashboard-pill {
  padding: 14px 16px;
}

.section-heading {
  padding: 8px 12px;
}

.section-heading h2 {
  font-size: 1.15rem;
}

.section-heading h3 {
  font-size: 0.98rem;
}

.info-card {
  padding: 12px 14px;
  border-radius: 12px;
}

.info-card strong {
  font-size: 0.88rem;
}

.info-card p {
  font-size: 0.84rem;
  line-height: 1.45;
}

.section-copy,
.section-heading p {
  font-size: 0.86rem;
  line-height: 1.4;
}

.module-card,
.quick-action-card {
  padding: 14px 16px;
}

/* Rediseno de /roles: tarjeta de rol mas compacta, resumen de permisos sin
   "caja dentro de caja" (se integra al flujo de la tarjeta en vez de tener su
   propio fondo/borde), y el mismo indicador de punto+texto ya usado en
   /users para el estado, en vez del pill de color solido. */
.role-card {
  padding: 14px 16px;
}

.role-permission-summary {
  margin-top: 4px;
  padding: 0;
  border: none;
  background: none;
}

.role-module-pill {
  padding: 5px 10px;
  font-size: 0.78rem;
}

/* Dashboard: graficas de operacion (admisiones por dia, distribucion por
   estado, servicios mas solicitados). Reutiliza los mismos tokens de color
   de estado ya usados en toda la aplicacion (status-chip, table-state-dot),
   no una paleta nueva. */
.chart-card {
  display: grid;
  gap: 12px;
}

.chart-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.chart-toolbar h3 {
  margin: 4px 0 0;
}

.range-selector {
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.04);
}

.range-selector__option {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  line-height: 1.2;
}

.range-selector__option:hover {
  color: var(--text);
}

.range-selector__option.is-active {
  background: #fff;
  color: var(--primary-dark);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.12);
}

.chart-svg {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
}

.chart-bar {
  fill: var(--primary);
  cursor: pointer;
  transition: opacity 0.12s ease;
}

.chart-bar:hover,
.chart-bar:focus {
  opacity: 0.78;
  outline: none;
}

.chart-hit {
  fill: transparent;
  cursor: pointer;
  outline: none;
}

.chart-hit:hover,
.chart-hit:focus {
  fill: rgba(15, 95, 215, 0.06);
}

.chart-bar--status-warning { fill: var(--warning); }
.chart-bar--status-reading { fill: var(--primary); }
.chart-bar--status-success { fill: var(--success); }
.chart-bar--status-inactive { fill: var(--danger); }

.chart-axis-label {
  font-size: 9px;
  fill: var(--muted);
  font-family: inherit;
}

.chart-gridline {
  stroke: rgba(15, 23, 42, 0.08);
  stroke-width: 1;
}

.chart-empty-note {
  font-size: 0.82rem;
  color: var(--muted);
  margin: 0;
}

.hbar-list {
  display: grid;
  gap: 10px;
}

.hbar-row {
  display: grid;
  grid-template-columns: 108px 1fr 44px;
  align-items: center;
  gap: 10px;
}

.hbar-row__label {
  font-size: 0.82rem;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hbar-row__track {
  position: relative;
  height: 16px;
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.05);
  overflow: hidden;
}

.hbar-row__fill {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: 6px;
  transition: opacity 0.12s ease;
}

.hbar-row:hover .hbar-row__fill,
.hbar-row__fill:focus {
  opacity: 0.82;
}

.hbar-row__value {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.chart-tooltip {
  position: fixed;
  z-index: 60;
  pointer-events: none;
  background: var(--text);
  color: #fff;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 0.78rem;
  line-height: 1.35;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.22);
  opacity: 0;
  transform: translate(-50%, -100%);
  transition: opacity 0.1s ease;
  max-width: 220px;
  white-space: nowrap;
}

.chart-tooltip.is-visible {
  opacity: 1;
}

.chart-tooltip strong {
  font-weight: 700;
}

/* Sidebar "super pro": iconos por item, avatar de iniciales, insignia de
   empresa activa. Todo sobre la misma base visual ya existente (fondo,
   tarjetas, indicador de activo) -- no se reescribe el layout. */
.sidebar-link,
.sidebar-sublink {
  display: flex;
  align-items: center;
  gap: 11px;
}

.sidebar-icon {
  width: 19px;
  height: 19px;
  flex-shrink: 0;
  opacity: 0.75;
  transition: opacity 0.16s ease;
}

.sidebar-sublink .sidebar-icon {
  width: 16px;
  height: 16px;
}

.sidebar-link:hover .sidebar-icon,
.sidebar-link.is-active .sidebar-icon,
.sidebar-sublink:hover .sidebar-icon,
.sidebar-sublink.is-active .sidebar-icon {
  opacity: 1;
}

.sidebar-group-label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-group-label::after {
  content: "";
  flex: 1 1 auto;
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
}

.sidebar-context-card,
.sidebar-foot {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-context-card__body,
.sidebar-foot__body {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.sidebar-context-card__body strong,
.sidebar-foot__body strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-badge {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.06));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.sidebar-badge svg {
  width: 19px;
  height: 19px;
  opacity: 0.9;
}

.sidebar-avatar {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.86rem;
  letter-spacing: 0.02em;
  background: linear-gradient(160deg, #38bdf8, #0f5fd7);
  color: #fff;
  box-shadow: 0 4px 12px rgba(15, 95, 215, 0.35);
}
