* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: "IBM Plex Sans", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
a { color: var(--link); }
.skip-link { position: absolute; left: -999px; top: 0; }
.skip-link:focus { left: 12px; top: 12px; z-index: 10; padding: 8px 12px; background: var(--surface); border-radius: 6px; }
.topbar { min-height: 60px; display: flex; align-items: center; gap: 10px; padding: 0 20px; background: var(--banner); color: #fff; }
.topbar-user { margin-left: auto; display: flex; align-items: center; gap: 12px; font-size: .8rem; }
.topbar-user form { margin: 0; }
.topbar-user button { border: 1px solid rgba(255,255,255,.55); border-radius: 6px; background: transparent; color: #fff; padding: .35rem .55rem; cursor: pointer; }
.topbar-logo { width: 30px; height: 30px; }
.product-name, .product-section { margin: 0; }
.product-name { font-size: .75rem; font-weight: 700; letter-spacing: .12em; }
.product-section { font-size: .95rem; font-weight: 600; }
.app-layout { display: flex; min-height: calc(100vh - 60px); }
.sidebar { width: 224px; padding: 18px 12px; background: var(--surface); border-right: 1px solid var(--border); }
.sidebar nav { display: grid; gap: 4px; }
.nav-link { display: block; padding: 11px 12px; border-radius: 8px; color: var(--ink-soft); text-decoration: none; font-size: .9rem; font-weight: 600; }
.nav-link:hover, .nav-link:focus-visible, .nav-link.active { color: var(--navy); background: var(--sidebar-active-bg); outline: none; }
.main-content { flex: 1; min-width: 0; padding: 32px 28px 60px; }
.page-header, .card, .error-card { max-width: 760px; }
.eyebrow { margin: 0 0 8px; color: var(--green-dark); font-size: .78rem; font-weight: 700; letter-spacing: .08em; }
h1, h2 { margin-top: 0; }
h1 { margin-bottom: 12px; font-size: clamp(1.7rem, 3vw, 2.25rem); }
h2 { margin-bottom: 10px; font-size: 1.15rem; }
.page-intro, .card p, .error-card p { margin: 0; max-width: 660px; color: var(--ink-soft); line-height: 1.6; }
.card, .error-card { margin-top: 28px; padding: 24px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); }
.btn-secondary { display: inline-flex; align-items: center; justify-content: center; padding: .55rem 1.1rem; border: 1px solid #BEDBF7; border-radius: 8px; background: var(--sidebar-active-bg); color: var(--navy); font-size: .88rem; font-weight: 600; text-decoration: none; }
.btn-secondary:hover, .btn-secondary:focus-visible { background: #c7e1fa; outline: 2px solid var(--navy); outline-offset: 2px; }
.card > .btn-secondary, .error-card > .btn-secondary { margin-top: 20px; }
.btn-primary { display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 8px; background: var(--green); color: #fff; padding: .62rem 1rem; font-size: .88rem; font-weight: 700; text-decoration: none; cursor: pointer; }
.btn-primary:hover, .btn-primary:focus-visible { background: var(--green-dark); outline: 2px solid var(--green-dark); outline-offset: 2px; }
.btn-danger { border: 1px solid #b42318; border-radius: 8px; background: #fff; color: #b42318; padding: .55rem 1rem; font-weight: 700; cursor: pointer; }
.toolbar { display:flex; align-items:center; gap:12px; margin: 20px 0; }
.data-table { width:100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); }
.data-table th,.data-table td { text-align:left; padding:12px; border-bottom:1px solid var(--border); font-size:.9rem; }
.form-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:14px; }
.form-grid label { display:grid; gap:6px; font-size:.85rem; font-weight:600; }
.form-grid input,.form-grid select { width:100%; padding:.55rem; border:1px solid var(--border); border-radius:7px; font:inherit; }
.actions { display:flex; flex-wrap:wrap; gap:10px; margin-top:18px; }
.status { display:inline-block; padding:.15rem .5rem; border-radius:999px; background:var(--sidebar-active-bg); color:var(--navy); font-size:.78rem; font-weight:700; }
.status-active { background: var(--green-soft); color: var(--green-dark); }

/* Acceso: misma marca y jerarquía del login de historiales-medicos. */
.auth-page { min-height: 100vh; background: #EEF7F4; }
.auth-content { min-height: 100vh; display: grid; place-items: center; padding: 32px 20px; }
.auth-frame { width: 100%; max-width: 760px; }
.login-shell { width: 100%; max-width: 420px; margin: 0 auto; text-align: center; }
.login-brand { display: flex; flex-direction: column; align-items: center; margin-bottom: 26px; }
.login-brand img { width: 68px; height: 68px; margin-bottom: 12px; }
.login-wordmark { font-size: 1.8rem; font-weight: 600; line-height: 1; }
.login-wordmark b { color: #2B3B39; }
.login-wordmark i { color: var(--green); font-style: normal; }
.login-product { margin-top: 7px; color: var(--ink-soft); font-size: .78rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.login-heading .eyebrow { margin-bottom: 10px; }
.login-heading h1 { margin-bottom: 10px; font-size: 1.8rem; }
.login-heading > p:last-child { margin: 0 auto; color: var(--ink-soft); font-size: .92rem; line-height: 1.55; }
.login-card { margin-top: 22px; padding: 20px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); }
.login-button { width: 100%; min-height: 48px; border: 0; border-radius: 8px; background: var(--green); color: #fff; font-weight: 700; cursor: pointer; }
.login-button:hover, .login-button:focus-visible { background: var(--green-dark); outline: 2px solid var(--green-dark); outline-offset: 2px; }
.login-unavailable { margin: 0; color: var(--ink-soft); line-height: 1.5; }
.bootstrap-link { display: inline-block; margin-top: 18px; font-size: .85rem; font-weight: 600; }
.login-security { margin: 22px 0 0; color: var(--ink-faint); font-size: .78rem; }

/* Listados: patrón de búsqueda y tabla de pacientes. */
.compact-header h1 { margin-bottom: 4px; font-size: 1.55rem; }
.list-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 20px 0; flex-wrap: wrap; }
.search-box { display: flex; align-items: center; gap: 8px; width: 320px; max-width: 100%; padding: .6rem 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; }
.search-box svg { flex-shrink: 0; color: var(--ink-faint); }
.search-box input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: .9rem; }
.search-box input::placeholder { color: var(--ink-faint); }
.search-box:focus-within { border-color: var(--navy); box-shadow: 0 0 0 2px rgba(27, 95, 168, .12); }
.toolbar-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.table-card { overflow: hidden; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); }
.table-card .data-table { border: 0; }
.data-table th { color: var(--ink-soft); background: #FAFBFC; font-size: .7rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.data-table tbody tr:hover { background: #FAFBFC; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table .view-column { width: 68px; }
.btn-view { display: inline-flex; padding: .4rem .9rem; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); color: var(--navy); font-size: .8rem; font-weight: 600; text-decoration: none; }
.btn-view:hover, .btn-view:focus-visible { border-color: var(--navy); background: var(--sidebar-active-bg); outline: none; }
.record-name { font-weight: 600; }
.secondary-cell { color: var(--ink-soft); }
.empty-state { padding: 56px 20px; color: var(--ink-soft); font-size: .9rem; text-align: center; }

/* Alta/edición: patrón de formulario de pacientes. */
.breadcrumbs { margin-bottom: 16px; font-size: .85rem; }
.breadcrumbs a { color: var(--navy); text-decoration: none; }
.breadcrumbs a:hover { text-decoration: underline; }
.form-card { max-width: 880px; padding: 30px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); }
.form-card > h1 { color: var(--navy); font-size: 1.35rem; }
.form-section { margin-top: 26px; }
.form-section h2 { margin-bottom: 16px; padding-bottom: 6px; border-bottom: 2px solid var(--sidebar-active-bg); color: var(--navy); font-size: .85rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.form-card .form-grid { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px 20px; }
.form-card .form-grid label { color: var(--ink); font-size: .8rem; }
.form-card .form-grid .full-width { grid-column: 1 / -1; }
.form-card .form-grid input { padding: .6rem .75rem; border-radius: 6px; background: var(--surface); }
.form-card .form-grid input:focus { border-color: var(--navy); outline: none; box-shadow: 0 0 0 2px rgba(27, 95, 168, .1); }
.required { color: var(--danger); }
.form-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 26px; padding-top: 16px; border-top: 1px solid var(--border); }
@media (max-width: 720px) { .form-grid { grid-template-columns:1fr; } }
@media (max-width: 720px) {
  .app-layout { display: block; }
  .sidebar { width: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  .sidebar nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .main-content { padding: 28px 18px 48px; }
  .topbar-user { font-size: 0; }
  .topbar-user button { font-size: .8rem; }
  .list-toolbar, .toolbar-actions { align-items: stretch; }
  .search-box, .toolbar-actions { width: 100%; }
  .toolbar-actions > * { flex: 1 1 0; min-width: 0; padding-left: .6rem; padding-right: .6rem; }
  .table-card { overflow-x: auto; }
  .data-table { min-width: 680px; }
  .form-card { padding: 22px 18px; }
}
@media (max-width: 480px) {
  .toolbar-actions { flex-direction: column; }
  .toolbar-actions > * { width: 100%; }
}

/* Ficha de cliente: un único bloque con cabecera y secciones. */
.client-profile { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); }
.client-profile-banner { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; padding: 30px 32px; background: var(--banner); color: #fff; }
.client-profile-banner > div { min-width: 0; }
.client-profile-banner p { margin: 0 0 10px; color: #dfedff; font-size: .95rem; }
.client-profile-banner h1 { margin: 0; font-size: clamp(1.6rem, 2.5vw, 2rem); overflow-wrap: anywhere; }
.client-back { display: inline-flex; flex-shrink: 0; padding: 10px 16px; border: 1px solid rgba(255,255,255,.45); border-radius: 8px; background: rgba(255,255,255,.12); color: #fff; text-decoration: none; font-size: .9rem; font-weight: 600; }
.client-back:hover, .client-back:focus-visible { background: rgba(255,255,255,.22); outline: 2px solid #fff; outline-offset: 3px; }
.client-information, .client-clinics { padding: 28px 32px 32px; }
.client-section-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.client-section-heading h2 { margin: 0; color: var(--navy); font-size: 1.2rem; }
.client-section-heading > a { flex-shrink: 0; }
.client-data-group { padding: 24px 0; border-bottom: 1px solid var(--border); }
.client-data-group:last-of-type { border-bottom: 0; padding-bottom: 0; }
.client-data-group h3 { margin: 0 0 20px; font-size: .88rem; font-weight: 600; color: var(--ink-soft); }
.client-data-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 22px 28px; margin: 0; }
.client-data-grid dt { color: var(--ink); font-size: .85rem; font-weight: 600; margin-bottom: 8px; }
.client-data-grid dd { margin: 0; color: var(--ink-soft); overflow-wrap: anywhere; font-size: .95rem; line-height: 1.5; }
.client-clinics { border-top: 12px solid var(--bg); }
.client-clinics .table-card { border-radius: 0; box-shadow: none; border-left: 0; border-right: 0; }
.client-management-actions { padding-top: 20px; border-top: 1px solid var(--border); }
@media (max-width: 1100px) { .client-data-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 720px) {
  .client-profile-banner { flex-direction: column; padding: 24px 20px; gap: 18px; }
  .client-information, .client-clinics { padding: 24px 20px; }
  .client-data-grid { gap: 20px; }
}
@media (max-width: 480px) { .client-data-grid { grid-template-columns: 1fr; } }
