/* =========================================================
   MI SALUD — Interfaz de seguimiento personal · Soyfacuh
   Diseño responsive sin frameworks ni dependencias externas
   ========================================================= */

:root {
  color-scheme: light;
  --bg: #f5f8fb;
  --surface: #ffffff;
  --surface-alt: #f7fafb;
  --text: #182c38;
  --muted: #71808c;
  --muted-deep: #536874;
  --line: #e9eef1;
  --accent: #087f77;
  --accent-strong: #065e5a;
  --accent-soft: #e7f6f1;
  --shadow: 0 10px 35px rgba(26, 50, 65, 0.035);
  --radius: 20px;
  --focus: #1c9d93;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1a22;
  --surface: #182731;
  --surface-alt: #1e3039;
  --text: #eaf2f2;
  --muted: #9aadb8;
  --muted-deep: #bbcacd;
  --line: #30424c;
  --accent: #59cec1;
  --accent-strong: #8ce8da;
  --accent-soft: #204339;
  --shadow: 0 12px 35px rgba(0, 0, 0, 0.12);
}

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 90px;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--text);
  background: var(--bg);
  font: 15px/1.6 Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
}

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

button {
  cursor: pointer;
}

button:disabled {
  opacity: .4;
  cursor: not-allowed;
}

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

a, button, input, select, textarea {
  -webkit-tap-highlight-color: transparent;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

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

.icon {
  width: 19px;
  height: 19px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.skip-link {
  position: fixed;
  left: 12px;
  top: -80px;
  z-index: 90;
  background: var(--surface);
  color: var(--text);
  padding: 12px;
  border-radius: 10px;
}

.skip-link:focus {
  top: 12px;
}

/* --- Estructura general --- */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  align-self: flex-start;
  width: 258px;
  flex: 0 0 258px;
  height: 100vh;
  min-height: 700px;
  padding: 37px 19px 23px;
  background: var(--surface);
  border-right: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 11px;
  width: fit-content;
}

.brand-icon {
  width: 39px;
  height: 39px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: #0e9184;
  color: #fff;
  box-shadow: 0 8px 14px #0e91842b;
}

.brand-icon .icon {
  width: 24px;
  height: 24px;
  stroke-width: 2.1;
}

.brand strong {
  display: block;
  font-size: 22px;
  line-height: 1.07;
  letter-spacing: -.9px;
  font-weight: 800;
}

.brand strong span {
  color: #149689;
}

.brand small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  letter-spacing: 1.5px;
  font-size: 8.6px;
  font-weight: 800;
}

.nav-title {
  margin: 59px 15px 13px;
  font-size: 10px;
  letter-spacing: 1.5px;
  color: var(--muted);
  font-weight: 800;
}

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

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 15px;
  border-radius: 10px;
  color: var(--muted-deep);
  font-size: 13px;
  font-weight: 600;
  transition: background .2s, color .2s;
}

.nav-link .icon {
  width: 18px;
  height: 18px;
}

.nav-link.active, .nav-link:hover {
  color: var(--accent);
  background: var(--accent-soft);
}

.sidebar-bottom {
  margin-top: auto;
  display: grid;
  gap: 22px;
}

.local-note {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  border-radius: 12px;
  padding: 13px 11px;
  background: var(--surface-alt);
  border: 1px solid var(--line);
}

.local-dot, .eyebrow-dot, .pulse-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #37b897;
  flex: none;
}

.local-dot {
  margin-top: 6px;
}

.local-note strong, .local-note span:not(.local-dot) {
  display: block;
}

.local-note strong {
  font-size: 11px;
}

.local-note div span {
  font-size: 10.7px;
  line-height: 1.5;
  color: var(--muted);
  margin-top: 3px;
}

.sidebar-credit {
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  padding: 21px 4px 0;
  font-size: 11px;
}

.sidebar-credit strong {
  color: var(--text);
  font-weight: 800;
}

.sidebar-credit .icon {
  width: 13px;
  height: 13px;
  margin-left: auto;
}

.work-area {
  flex: 1;
  min-width: 0;
}

.topbar {
  height: 81px;
  padding: 0 clamp(24px, 4vw, 68px);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
}

.topbar-context {
  display: flex;
  align-items: center;
  gap: 11px;
  font-size: 10px;
  color: var(--muted);
  font-weight: 800;
  letter-spacing: 1.2px;
}

.separator {
  color: #cdd7d9;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 15px;
}

.private-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 100px;
  padding: 7px 12px;
  font-size: 11px;
  color: var(--muted-deep);
}

.private-pill .icon {
  width: 14px;
  height: 14px;
  color: var(--accent);
}

.icon-button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 11px;
}

.main-content {
  margin: 0 auto;
  max-width: 1540px;
  padding: 36px clamp(24px, 4vw, 68px) 65px;
}

.section {
  scroll-margin-top: 24px;
  margin-bottom: 66px;
}

/* --- Hero --- */

.hero {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  min-height: 290px;
  background: linear-gradient(108deg, #e5f5f0 0%, #edf9f5 56%, #d9eee9 100%);
  border-radius: 22px;
  display: flex;
  align-items: center;
  padding: 36px clamp(28px, 4.4vw, 67px);
}

.hero-content {
  z-index: 1;
  max-width: 590px;
}

.hero-kicker {
  color: #208b7c;
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 10px;
  letter-spacing: 1.5px;
  font-weight: 850;
}

.pulse-dot {
  box-shadow: 0 0 0 5px rgba(55, 184, 151, .16);
  width: 7px;
  height: 7px;
}

.hero h1 {
  font-size: clamp(33px, 3.5vw, 49px);
  font-weight: 780;
  line-height: 1.13;
  margin: 19px 0 13px;
  letter-spacing: -1.9px;
  color: #1b4544;
}

.hero h1 em {
  font-style: normal;
  color: #0c9d88;
}

.hero p {
  max-width: 490px;
  margin: 0;
  color: #547976;
  font-size: 13.5px;
  line-height: 1.8;
}

.hero-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 22px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  font-size: 12.5px;
  font-weight: 750;
  min-height: 41px;
  border-radius: 10px;
  padding: 10px 17px;
  transition: transform .2s, box-shadow .2s, background .2s;
  border: 1px solid transparent;
}

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

.btn .icon {
  width: 16px;
  height: 16px;
}

.btn-primary {
  background: #078a7d;
  color: white;
  box-shadow: 0 8px 17px rgba(4, 139, 120, .13);
}

.btn-primary:hover {
  background: #056f67;
  box-shadow: 0 10px 18px rgba(4, 139, 120, .18);
}

.btn-ghost {
  color: #14776e;
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, .5);
}

.btn-outline {
  background: var(--surface);
  border-color: var(--line);
  color: var(--accent);
}

.btn-outline:hover {
  border-color: var(--accent);
}

.btn-muted {
  background: var(--surface-alt);
  border-color: var(--line);
  color: var(--muted-deep);
}

.btn-danger {
  background: #fff1f0;
  border-color: #ffd6d4;
  color: #b83b40;
}

.btn-danger:hover {
  background: #fce7e7;
}

.hero-art {
  position: absolute;
  z-index: 0;
  right: 8%;
  top: 50%;
  transform: translateY(-50%);
  height: 240px;
  width: 260px;
  color: #53bbac;
}

.art-orbit {
  position: absolute;
  border: 1px solid rgba(72, 167, 147, .18);
  border-radius: 50%;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.orbit-one {
  height: 235px;
  width: 235px;
}

.orbit-two {
  height: 190px;
  width: 190px;
}

.art-ring {
  width: 148px;
  height: 148px;
  background: linear-gradient(140deg, #d6f4e8, #fff);
  box-shadow: 0 16px 40px rgba(14, 117, 99, .17), inset 0 0 0 13px rgba(255, 255, 255, .63);
  border: 1px solid white;
  border-radius: 50%;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) rotate(-8deg);
  display: grid;
  place-items: center;
}

.art-ring svg {
  width: 102px;
  height: 80px;
  filter: drop-shadow(0 3px 6px #16a18d42);
}

.art-spark {
  position: absolute;
  color: #5fc5af;
}

.spark-a {
  right: 12px;
  top: 17px;
  font-size: 33px;
}

.spark-b {
  bottom: 13px;
  left: 13px;
  font-size: 28px;
}

:root[data-theme="dark"] .hero {
  background: linear-gradient(115deg, #174f4b, #1a373b);
}

:root[data-theme="dark"] .hero h1 {
  color: #e3f8ef;
}

:root[data-theme="dark"] .hero h1 em, :root[data-theme="dark"] .hero-kicker {
  color: #72e3cb;
}

:root[data-theme="dark"] .hero p {
  color: #b1d4cd;
}

:root[data-theme="dark"] .btn-ghost {
  color: #c0faf0;
}

/* --- Títulos y tarjetas --- */

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 15px;
  margin: 0 0 20px;
}

.metrics-heading {
  margin-top: 32px;
}

.overline {
  margin: 0 0 5px;
  font-size: 10px;
  color: var(--accent);
  font-weight: 850;
  letter-spacing: 1.4px;
}

.section-heading h2, .panel h2 {
  font-size: 20px;
  line-height: 1.35;
  letter-spacing: -.6px;
  margin: 0;
  font-weight: 760;
}

.meta-text, .section-description, .subtext {
  color: var(--muted);
  font-size: 12px;
}

.section-description {
  margin: 6px 0 0;
}

.section-counter {
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 1.2px;
}

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

.metric-card {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: 17px;
  min-height: 177px;
  padding: 17px 18px;
}

.metric-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 7px;
}

.metric-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--tone-bg);
  color: var(--tone-color);
}

.metric-icon .icon {
  width: 18px;
  height: 18px;
}

.metric-type {
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .9px;
  text-align: right;
}

.metric-value {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin: 18px 0 0;
  white-space: nowrap;
}

.metric-value strong {
  font-weight: 800;
  font-size: clamp(24px, 2.5vw, 33px);
  line-height: 1.1;
  letter-spacing: -1.3px;
}

.metric-value span {
  font-size: 11px;
  color: var(--muted);
}

.metric-card p {
  font-size: 11px;
  color: var(--muted);
  margin: 6px 0 0;
}

.metric-card .mini-line {
  position: absolute;
  right: 11px;
  bottom: 4px;
  width: 92px;
  height: 42px;
  opacity: .62;
}

.mini-line svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.tone-coral {
  --tone-bg: #fff0ea;
  --tone-color: #e77c70;
}

.tone-amber {
  --tone-bg: #fff5e6;
  --tone-color: #d5a04b;
}

.tone-blue {
  --tone-bg: #e9f3ff;
  --tone-color: #5f95df;
}

.tone-violet {
  --tone-bg: #f0edff;
  --tone-color: #967ee7;
}

:root[data-theme="dark"] .tone-coral {
  --tone-bg: #4e3539;
  --tone-color: #f49c92;
}

:root[data-theme="dark"] .tone-amber {
  --tone-bg: #4c3c2e;
  --tone-color: #f4c979;
}

:root[data-theme="dark"] .tone-blue {
  --tone-bg: #293f58;
  --tone-color: #a2c8fc;
}

:root[data-theme="dark"] .tone-violet {
  --tone-bg: #413955;
  --tone-color: #c6b7ff;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.insights-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.63fr) minmax(275px, 1fr);
  gap: 17px;
  margin-top: 18px;
}

.chart-panel, .quick-panel {
  padding: 22px 23px;
  min-height: 329px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 15px;
}

.panel-header h2 {
  font-size: 17px;
}

.panel-header .subtext {
  margin: 4px 0 0;
  font-size: 11px;
}

.chart-controls {
  display: flex;
  gap: 8px;
  margin: 21px 0 5px;
}

.chart-controls select, .toolbar-controls select {
  padding: 9px 30px 9px 11px;
  border: 1px solid var(--line);
  background: var(--surface-alt);
  color: var(--text);
  border-radius: 9px;
  font-size: 11px;
  font-weight: 650;
  max-width: 100%;
}

.chart-container {
  height: 170px;
  display: grid;
  place-items: center;
  min-width: 0;
}

.chart-container svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.chart-container .chart-label {
  font-size: 10px;
  fill: var(--muted);
}

.chart-container .chart-grid {
  stroke: var(--line);
  stroke-dasharray: 4 4;
}

.chart-empty {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  max-width: 280px;
}

.chart-empty .icon {
  display: block;
  margin: 0 auto 8px;
  width: 30px;
  height: 30px;
  color: var(--accent);
}

.chart-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 10px;
  color: var(--muted);
}

.chart-footer span:last-child {
  white-space: nowrap;
}

.text-link {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 750;
  white-space: nowrap;
}

.text-link .icon {
  width: 14px;
  height: 14px;
}

.recent-list {
  min-height: 200px;
  padding-top: 15px;
}

.recent-item {
  display: flex;
  gap: 11px;
  align-items: center;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}

.recent-bullet {
  width: 33px;
  height: 33px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 10px;
  display: grid;
  place-items: center;
}

.recent-bullet .icon {
  width: 17px;
  height: 17px;
}

.recent-data {
  min-width: 0;
  flex: 1;
}

.recent-data strong, .recent-data span {
  display: block;
}

.recent-data strong {
  font-size: 12px;
  font-weight: 750;
}

.recent-data span {
  font-size: 10.5px;
  color: var(--muted);
}

.recent-right {
  font-size: 11px;
  font-weight: 700;
}

.demo-tag {
  font-size: 9px;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 2px 6px;
  border-radius: 20px;
  font-weight: 700;
  white-space: nowrap;
}

.recent-empty {
  padding: 51px 10px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

.quick-bottom {
  display: flex;
  gap: 27px;
  padding-top: 14px;
}

.quick-stat strong {
  display: block;
  font-size: 20px;
  line-height: 1.1;
}

.quick-stat span {
  color: var(--muted);
  font-size: 10px;
}

/* --- Formulario --- */

.entry-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(255px, 1fr);
  gap: 19px;
}

.form-panel {
  padding: 24px 26px;
}

.form-subhead {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 21px;
}

.step-count {
  width: 33px;
  height: 33px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: var(--accent);
  background: var(--accent-soft);
  font-size: 11px;
  font-weight: 800;
}

.form-subhead h3 {
  margin: 0;
  font-size: 14px;
}

.form-subhead p {
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--muted);
}

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

.field {
  min-width: 0;
}

.field label {
  display: block;
  font-size: 11.5px;
  font-weight: 700;
  margin-bottom: 7px;
}

.field label > span:not(.optional) {
  color: #d36a55;
}

.field .optional {
  color: var(--muted);
  font-size: 10px;
  font-weight: 500;
}

.field input, .field textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--surface-alt);
  padding: 10px 12px;
  color: var(--text);
  border-radius: 9px;
  outline: none;
  font-size: 12px;
}

.field input:focus, .field textarea:focus, .search-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(14, 145, 132, .12);
}

.field input::placeholder, .field textarea::placeholder {
  color: #93a4ad;
}

.field input[aria-invalid="true"] {
  border-color: #d74b53;
}

.input-unit {
  position: relative;
}

.input-unit input {
  padding-right: 53px;
}

.input-unit span {
  position: absolute;
  right: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 11px;
  pointer-events: none;
}

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

.field textarea {
  resize: vertical;
  min-height: 72px;
  max-height: 165px;
}

.field small {
  display: block;
  font-size: 10px;
  text-align: right;
  color: var(--muted);
  margin-top: 5px;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 23px;
}

.form-message {
  margin: 18px 0 0;
  font-size: 12px;
  color: #b64148;
  padding: 11px 13px;
  border-radius: 10px;
  background: #fff1f0;
}

.help-panel {
  background: linear-gradient(155deg, #e4f5f0, #eff8f5);
  border: 1px solid #d6ebe5;
  border-radius: 19px;
  padding: 29px 25px;
  align-self: start;
}

.help-symbol {
  border-radius: 13px;
  width: 41px;
  height: 41px;
  background: white;
  display: grid;
  place-items: center;
  color: #128c7d;
}

.help-panel h3 {
  font-size: 21px;
  line-height: 1.35;
  letter-spacing: -.6px;
  color: #235950;
  margin: 18px 0 10px;
}

.help-panel h4 {
  color: #235950;
  font-size: 13px;
  margin: 19px 0 5px;
}

.help-panel p {
  font-size: 12px;
  line-height: 1.9;
  color: #54796d;
  margin: 0;
}

.help-divider {
  height: 1px;
  background: #c8e1d8;
  margin-top: 21px;
}

.help-panel .btn {
  margin-top: 18px;
  white-space: normal;
  text-align: center;
}

:root[data-theme="dark"] .help-panel {
  background: linear-gradient(145deg, #214740, #1a3535);
  border-color: #356257;
}

:root[data-theme="dark"] .help-panel h3, :root[data-theme="dark"] .help-panel h4 {
  color: #c5ede3;
}

:root[data-theme="dark"] .help-panel p {
  color: #afcfc5;
}

:root[data-theme="dark"] .help-symbol {
  background: #305a4f;
  color: #c1f4e9;
}

:root[data-theme="dark"] .help-divider {
  background: #355e54;
}

/* --- Historial --- */

.history-panel {
  padding: 20px 22px 0;
  overflow: hidden;
}

.history-toolbar, .history-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 13px;
}

.search-wrap {
  height: 40px;
  max-width: 350px;
  min-width: 210px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 0 11px;
}

.search-wrap .icon {
  width: 15px;
  height: 15px;
  color: var(--muted);
}

.search-wrap input {
  width: 100%;
  min-width: 0;
  font-size: 11.5px;
  outline: none;
  border: none;
  background: transparent;
  color: var(--text);
}

.toolbar-controls, .export-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
}

.history-actions {
  padding: 17px 0 11px;
}

.text-button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--line);
  color: var(--muted-deep);
  border-radius: 8px;
  padding: 7px 9px;
  background: var(--surface);
  font-size: 10.7px;
  font-weight: 700;
}

.text-button .icon {
  height: 14px;
  width: 14px;
}

.text-button:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
}

th {
  text-align: left;
  white-space: nowrap;
  font-size: 10px;
  color: var(--muted);
  font-weight: 800;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--line);
  padding: 12px 10px;
}

td {
  border-bottom: 1px solid var(--line);
  padding: 13px 10px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

td:first-child {
  font-weight: 700;
}

td .small-date {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 400;
}

td.note-cell {
  max-width: 155px;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--muted-deep);
}

th.actions-th, td:last-child {
  text-align: right;
}

.row-actions {
  display: inline-flex;
  gap: 3px;
}

.row-action {
  display: inline-grid;
  place-items: center;
  height: 28px;
  width: 28px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 7px;
  color: var(--muted-deep);
}

.row-action .icon {
  width: 14px;
  height: 14px;
}

.row-action:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.row-action.delete:hover {
  color: #d35a5e;
  border-color: #d35a5e;
}

.history-mobile {
  display: none;
}

.history-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 15px;
  padding: 15px 0;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted-deep);
  font-size: 11px;
}

.page-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  width: 30px;
  height: 30px;
  border-radius: 7px;
  font-size: 21px;
  line-height: 1;
}

.page-btn:hover:not(:disabled) {
  border-color: var(--accent);
}

.empty-state {
  text-align: center;
  border-top: 1px solid var(--line);
  padding: 40px 10px 35px;
}

.empty-icon {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  margin: auto;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
}

.empty-state h3 {
  margin: 13px 0 5px;
  font-size: 15px;
}

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

/* --- Privacidad, pie, confirmaciones --- */

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

.privacy-card {
  border: 1px solid var(--line);
  border-radius: 17px;
  padding: 23px;
  background: var(--surface);
}

.privacy-icon {
  display: grid;
  place-items: center;
  border-radius: 10px;
  width: 34px;
  height: 34px;
  background: var(--accent-soft);
  color: var(--accent);
}

.privacy-card h3 {
  font-size: 14px;
  margin: 14px 0 6px;
}

.privacy-card p {
  font-size: 12px;
  color: var(--muted-deep);
  line-height: 1.8;
  margin: 0;
}

.danger-zone {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 17px;
  padding: 23px;
}

.danger-zone h3 {
  font-size: 14px;
  margin: 0 0 5px;
}

.danger-zone p {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
}

.danger-zone .btn {
  flex-shrink: 0;
}

.site-footer {
  border-top: 1px solid var(--line);
  padding: 27px clamp(24px, 4vw, 68px) 75px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 15px;
  color: var(--muted);
  font-size: 11px;
}

.site-footer a {
  color: var(--accent);
  font-weight: 800;
}

.site-footer .icon {
  vertical-align: middle;
  width: 12px;
  height: 12px;
}

.floating-credit {
  position: fixed;
  z-index: 20;
  right: 20px;
  bottom: 16px;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 8px 12px;
  border-radius: 100px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: 0 5px 24px #142f3222;
  color: var(--muted);
  font-size: 10px;
}

.floating-credit strong {
  color: var(--accent);
}

.floating-credit .icon {
  width: 12px;
  height: 12px;
}

.confirm-dialog {
  width: min(420px, calc(100% - 28px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 19px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 24px 100px #0717194a;
}

.confirm-dialog::backdrop {
  background: rgba(10, 24, 28, .53);
  backdrop-filter: blur(4px);
}

.dialog-inner {
  padding: 26px;
}

.dialog-symbol {
  display: grid;
  place-items: center;
  height: 44px;
  width: 44px;
  border-radius: 13px;
  background: var(--accent-soft);
  color: var(--accent);
}

.confirm-dialog h2 {
  font-size: 20px;
  margin: 15px 0 6px;
}

.confirm-dialog p {
  color: var(--muted-deep);
  margin: 0;
  font-size: 13px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 24px;
}

.toast {
  pointer-events: none;
  position: fixed;
  z-index: 80;
  left: 50%;
  bottom: 32px;
  transform: translate(-50%, 25px);
  opacity: 0;
  transition: opacity .2s, transform .2s;
  max-width: min(520px, calc(100% - 28px));
  padding: 12px 17px;
  background: #142d31;
  color: white;
  font-size: 12px;
  border-radius: 10px;
  text-align: center;
  box-shadow: 0 11px 35px #0d263840;
}

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

/* --- Móvil y pantallas medianas --- */

@media (max-width: 1220px) {
  .sidebar {
    width: 220px;
    flex-basis: 220px;
  }
  .main-content {
    padding-inline: 28px;
  }
  .topbar {
    padding-inline: 28px;
  }
  .hero-art {
    right: 1%;
    opacity: .56;
  }
  .metric-card {
    padding: 16px 13px;
  }
  .metric-type {
    font-size: 8px;
  }
  .metric-value strong {
    font-size: 27px;
  }
}

@media (max-width: 1040px) {
  .metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .insights-grid, .entry-grid {
    grid-template-columns: 1fr;
  }
  .chart-panel {
    min-height: 330px;
  }
  .help-panel {
    display: grid;
    grid-template-columns: 1fr;
  }
  .sidebar {
    width: 192px;
    flex-basis: 192px;
  }
  .sidebar-credit {
    flex-wrap: wrap;
  }
}

@media (max-width: 760px) {
  html {
    scroll-padding-top: 95px;
  }
  .app-shell {
    display: block;
  }
  .sidebar {
    position: static;
    width: 100%;
    height: auto;
    min-height: 0;
    padding: 16px 18px 0;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .brand {
    padding: 0;
  }
  .brand-icon {
    width: 35px;
    height: 35px;
  }
  .brand strong {
    font-size: 19px;
  }
  .nav-title, .sidebar-bottom {
    display: none;
  }
  .sidebar-nav {
    margin-top: 14px;
    display: flex;
    overflow-x: auto;
    gap: 7px;
    padding-bottom: 11px;
    scrollbar-width: none;
  }
  .sidebar-nav::-webkit-scrollbar {
    display: none;
  }
  .nav-link {
    flex-shrink: 0;
    padding: 9px 11px;
    font-size: 11px;
    gap: 6px;
  }
  .nav-link .icon {
    width: 15px;
    height: 15px;
  }
  .topbar {
    height: 55px;
    padding: 0 18px;
  }
  .topbar-context {
    font-size: 8px;
    letter-spacing: .6px;
    gap: 6px;
  }
  .private-pill {
    font-size: 0;
    width: 33px;
    height: 33px;
    padding: 0;
    display: grid;
    place-items: center;
  }
  .private-pill .icon {
    width: 17px;
    height: 17px;
  }
  .topbar-actions {
    gap: 8px;
  }
  .main-content {
    padding: 18px 16px 40px;
  }
  .hero {
    min-height: 281px;
    border-radius: 17px;
    padding: 27px 23px;
  }
  .hero-art {
    right: -70px;
    opacity: .25;
  }
  .hero h1 {
    font-size: clamp(30px, 7vw, 40px);
    margin-top: 15px;
  }
  .hero p {
    font-size: 12px;
    max-width: 340px;
  }
  .hero-actions {
    margin-top: 17px;
  }
  .metrics-heading {
    margin-top: 25px;
  }
  .section {
    margin-bottom: 46px;
  }
  .section-heading h2 {
    font-size: 19px;
  }
  .section-counter {
    display: none;
  }
  .metrics-grid {
    gap: 11px;
  }
  .metric-card {
    min-height: 153px;
  }
  .metric-top {
    gap: 5px;
  }
  .metric-type {
    font-size: 8px;
  }
  .metric-value {
    margin-top: 18px;
  }
  .metric-value strong {
    font-size: clamp(22px, 5vw, 31px);
  }
  .metric-card .mini-line {
    width: 60px;
    bottom: 2px;
    opacity: .33;
  }
  .chart-panel, .quick-panel {
    padding: 20px 18px;
  }
  .form-panel {
    padding: 21px 17px;
  }
  .help-panel {
    padding: 23px;
  }
  .privacy-grid {
    grid-template-columns: 1fr;
  }
  .danger-zone {
    align-items: flex-start;
    flex-direction: column;
  }
  .history-panel {
    padding: 17px 13px 0;
  }
  .history-toolbar {
    align-items: stretch;
  }
  .search-wrap {
    max-width: none;
    width: 100%;
  }
  .toolbar-controls {
    flex: 1;
  }
  .toolbar-controls select {
    flex: 1;
  }
  .history-actions {
    align-items: flex-start;
  }
  .export-buttons {
    gap: 5px;
  }
  .table-scroll {
    display: none;
  }
  .history-mobile {
    display: grid;
    gap: 10px;
    margin-top: 10px;
  }
  .history-mobile-card {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 14px;
    background: var(--surface-alt);
  }
  .mobile-card-head, .mobile-card-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
  }
  .mobile-card-head strong {
    font-size: 12px;
  }
  .mobile-card-head span {
    font-size: 11px;
    color: var(--muted);
  }
  .mobile-card-values {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin: 15px 0;
  }
  .mobile-card-values div span {
    display: block;
    font-size: 10px;
    color: var(--muted);
  }
  .mobile-card-values div strong {
    display: block;
    font-size: 14px;
    font-weight: 750;
  }
  .mobile-card-note {
    word-break: break-word;
    font-size: 11px;
    color: var(--muted-deep);
    margin: 0 0 10px;
  }
  .history-bottom {
    gap: 8px;
  }
  .history-bottom .meta-text {
    font-size: 10px;
  }
  .site-footer {
    padding: 18px 16px 75px;
  }
}

@media (max-width: 460px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
  .field-wide {
    grid-column: auto;
  }
  .metrics-grid {
    gap: 9px;
  }
  .metric-card {
    padding: 13px 11px;
  }
  .metric-type {
    font-size: 7px;
    letter-spacing: .2px;
  }
  .metric-icon {
    width: 29px;
    height: 29px;
  }
  .metric-value strong {
    font-size: 22px;
    letter-spacing: -.8px;
  }
  .metric-value span {
    font-size: 9px;
  }
  .metric-card p {
    font-size: 10px;
  }
  .chart-controls select {
    min-width: 0;
    font-size: 10px;
    padding-right: 22px;
  }
  .chart-footer {
    flex-wrap: wrap;
  }
  .history-bottom .meta-text {
    display: none;
  }
  .history-bottom {
    justify-content: flex-end;
  }
  .floating-credit {
    bottom: 11px;
    right: 11px;
  }
}

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

@media print {
  :root {
    color-scheme: light !important;
  }
  body {
    background: #fff !important;
    color: #111 !important;
  }
  .sidebar, .topbar, .hero, .metrics-grid, .insights-grid, #registrar, #privacidad, .history-toolbar, .history-actions, .history-bottom, .site-footer, .floating-credit, .row-actions, .toast, dialog {
    display: none !important;
  }
  .app-shell, .work-area {
    display: block;
  }
  .main-content {
    max-width: none;
    padding: 0;
  }
  #resumen {
    display: none;
  }
  .section-heading, .panel {
    page-break-inside: avoid;
  }
  .history-panel {
    border: 0;
    box-shadow: none;
    padding: 0;
  }
  .table-scroll {
    display: block !important;
  }
  .history-mobile {
    display: none !important;
  }
  td, th {
    white-space: normal;
    font-size: 10px;
    padding: 7px 4px;
  }
  th:last-child, td:last-child {
    display: none;
  }
  .section {
    margin: 0;
  }
  #historial::before {
    content: 'Mi Salud · Registro educativo · No es un informe médico';
    display: block;
    margin-bottom: 16px;
    color: #777;
    font-size: 11px;
  }
}
