:root {
  color-scheme: light;
  --bg: #f4f7f3;
  --surface: #ffffff;
  --surface-soft: #edf3ee;
  --surface-muted: #e6ece7;
  --text: #20322d;
  --muted: #6b7973;
  --line: #d8e2da;
  --accent: #547763;
  --accent-strong: #355c49;
  --sea: #5b8e9b;
  --good: #5f937b;
  --amber: #c58c39;
  --amber-soft: #fbf1df;
  --neutral: #98a49e;
  --shadow: 0 14px 38px rgba(43, 69, 57, .08);
  --radius: 16px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
}

:root[data-theme="oscuro"], :root:not([data-theme="claro"])[data-system-dark="true"] {
  color-scheme: dark;
  --bg: #17221e;
  --surface: #21302a;
  --surface-soft: #293a32;
  --surface-muted: #31443a;
  --text: #e8f0eb;
  --muted: #a9b8af;
  --line: #3b5045;
  --accent: #98c1a8;
  --accent-strong: #b9d8c4;
  --sea: #8fc5d0;
  --good: #9bc6a5;
  --amber: #e2b467;
  --amber-soft: #4b3d28;
  --neutral: #a5b0aa;
  --shadow: 0 14px 38px rgba(0, 0, 0, .2);
}

* { box-sizing: border-box; }
html { min-width: 0; background: var(--bg); }
body { margin: 0; min-width: 0; overflow-x: hidden; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 15px; line-height: 1.45; }
button, input, select, textarea { font: inherit; }
button, input, select { min-height: 44px; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible { outline: 3px solid color-mix(in srgb, var(--sea) 56%, transparent); outline-offset: 2px; }
button[disabled] { cursor: not-allowed; opacity: .55; }

.app-shell { display: flex; min-height: 100vh; }
.sidebar { position: sticky; top: 0; align-self: flex-start; display: flex; flex: 0 0 264px; flex-direction: column; height: 100vh; padding: 26px 18px 20px; border-right: 1px solid var(--line); background: var(--surface); }
.brand, .mobile-brand, .sidebar-profile, .topbar-actions, .section-heading, .page-actions, .card-head, .field-row, .inline-actions, .kpi-label, .setting-row, .meal-row, .plan-row, .status-line { display: flex; align-items: center; }
.brand { gap: 10px; padding: 0 8px 28px; }
.brand strong, .mobile-brand strong { display: block; letter-spacing: .04em; font-size: .78rem; }
.brand span { display: block; color: var(--muted); font-size: .74rem; }
.brand-mark { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 12px; background: var(--accent-strong); color: #f4f7f3; font-size: 1.2rem; }
.sidebar-profile { gap: 10px; padding: 13px 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-soft); }
.avatar { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 50%; background: var(--accent); color: white; font-weight: 700; }
.sidebar-profile strong, .sidebar-profile small { display: block; }
.sidebar-profile small { color: var(--muted); font-size: .72rem; }
.nav-list { display: grid; gap: 5px; margin-top: 22px; }
.nav-button { display: flex; width: 100%; align-items: center; gap: 11px; padding: 11px 12px; border: 1px solid transparent; border-radius: 12px; background: transparent; color: var(--muted); text-align: left; transition: .18s ease; }
.nav-button:hover { background: var(--surface-soft); color: var(--text); }
.nav-button.active { border-color: color-mix(in srgb, var(--accent) 24%, var(--line)); background: color-mix(in srgb, var(--accent) 12%, var(--surface)); color: var(--accent-strong); font-weight: 700; }
.nav-icon { display: inline-grid; width: 22px; place-items: center; font-size: 1rem; }
.sidebar-foot { margin-top: auto; color: var(--muted); font-size: .74rem; }
.privacy-dot { display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: var(--good); vertical-align: middle; }
.main-area { min-width: 0; flex: 1; }
.topbar { display: flex; min-height: 72px; align-items: center; justify-content: space-between; padding: 14px clamp(18px, 4vw, 52px); border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 90%, transparent); }
.mobile-brand { display: none; gap: 9px; }
.mobile-brand .brand-mark { width: 28px; height: 28px; border-radius: 9px; font-size: 1rem; }
.topbar-actions { gap: 10px; }
.connection-pill, .tag, .status-pill { display: inline-flex; align-items: center; min-height: 30px; padding: 5px 10px; border-radius: 999px; background: var(--surface-soft); color: var(--muted); font-size: .75rem; }
.connection-pill.ready { background: color-mix(in srgb, var(--good) 18%, var(--surface)); color: var(--accent-strong); }
.connection-pill.offline { background: var(--amber-soft); color: #8d662b; }
.icon-button { width: 44px; padding: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text); }
.content { width: min(1420px, 100%); margin: 0 auto; padding: 32px clamp(16px, 4vw, 52px) 40px; }
.app-footer { padding: 0 clamp(18px, 4vw, 52px) 28px; color: var(--muted); font-size: .76rem; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 24px; }
.eyebrow { margin: 0 0 7px; color: var(--accent); font-size: .73rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(1.8rem, 4vw, 2.6rem); letter-spacing: -.035em; line-height: 1.05; }
h2 { margin-bottom: 6px; font-size: 1.22rem; letter-spacing: -.02em; }
h3 { margin-bottom: 5px; font-size: .97rem; }
.lede, .muted, .helper, .small-note { color: var(--muted); }
.lede { max-width: 700px; margin-bottom: 0; }
.small-note, .helper { font-size: .8rem; }
.page-actions { flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.button { display: inline-flex; min-height: 44px; align-items: center; justify-content: center; gap: 7px; padding: 10px 15px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); color: var(--text); font-weight: 650; text-decoration: none; }
.button:hover { border-color: var(--accent); }
.button.primary { border-color: var(--accent); background: var(--accent); color: white; }
.button.secondary { background: var(--surface-soft); color: var(--accent-strong); }
.button.ghost { border-color: transparent; background: transparent; color: var(--accent-strong); }
.button.warn { border-color: color-mix(in srgb, var(--amber) 40%, var(--line)); background: var(--amber-soft); color: #8d662b; }
.button.danger-neutral { background: var(--surface-muted); color: var(--text); }
.fictional-banner { display: flex; min-height: 46px; align-items: center; justify-content: center; gap: 10px; padding: 8px 14px; background: var(--amber-soft); color: #8d662b; font-size: .82rem; text-align: center; }
.fictional-banner button { min-height: 30px; padding: 4px 9px; border: 1px solid color-mix(in srgb, var(--amber) 35%, transparent); border-radius: 8px; background: transparent; color: inherit; font-weight: 700; }
.hidden { display: none !important; }
.app-status { position: fixed; right: 22px; bottom: 22px; z-index: 20; max-width: min(420px, calc(100vw - 32px)); padding: 11px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); color: var(--text); font-size: .82rem; opacity: 0; pointer-events: none; transform: translateY(10px); transition: .2s ease; }
.app-status.visible { opacity: 1; transform: translateY(0); }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card { min-width: 0; padding: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.card.soft { background: var(--surface-soft); box-shadow: none; }
.card-head { justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h2, .card-head h3 { margin-bottom: 0; }
.section-heading { justify-content: space-between; gap: 12px; margin: 28px 0 13px; }
.section-heading h2 { margin-bottom: 0; }
.section-heading a { color: var(--accent-strong); font-size: .83rem; font-weight: 700; text-decoration: none; }
.hero-card { position: relative; overflow: hidden; padding: clamp(22px, 4vw, 34px); background: linear-gradient(130deg, var(--surface) 0%, color-mix(in srgb, var(--accent) 10%, var(--surface)) 100%); }
.hero-card:after { position: absolute; top: -85px; right: -50px; width: 230px; height: 230px; border: 30px solid color-mix(in srgb, var(--accent) 12%, transparent); border-radius: 50%; content: ""; }
.hero-card > * { position: relative; z-index: 1; }
.progress-track { width: 100%; height: 9px; overflow: hidden; border-radius: 999px; background: var(--surface-muted); }
.progress-track > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), var(--sea)); }
.hero-progress { max-width: 620px; margin: 25px 0 9px; }
.hero-meta { display: flex; flex-wrap: wrap; gap: 14px 22px; color: var(--muted); font-size: .84rem; }
.scope-switcher { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.scope-switcher button { min-height: 34px; padding: 5px 10px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: .78rem; }
.scope-switcher button.active { background: var(--accent); color: white; font-weight: 700; }
.kpi-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
.kpi-card { min-width: 0; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.kpi-label { justify-content: space-between; gap: 6px; color: var(--muted); font-size: .76rem; }
.kpi-value { margin: 10px 0 4px; font-variant-numeric: tabular-nums; font-size: clamp(1.22rem, 2vw, 1.75rem); font-weight: 800; letter-spacing: -.04em; }
.kpi-foot { color: var(--muted); font-size: .75rem; }
.rings-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.ring-card { display: flex; min-height: 150px; align-items: center; gap: 16px; padding: 18px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); }
.ring { display: grid; width: 88px; height: 88px; flex: 0 0 auto; place-items: center; border-radius: 50%; background: conic-gradient(var(--accent) var(--ring, 0%), var(--surface-muted) 0); }
.ring:after { display: grid; width: 68px; height: 68px; place-items: center; border-radius: 50%; background: var(--surface); content: attr(data-label); font-size: .86rem; font-weight: 800; }
.ring-card h3 { margin-bottom: 3px; }
.ring-card p { margin-bottom: 0; color: var(--muted); font-size: .78rem; }
.alert-list { display: grid; gap: 10px; }
.alert-item { padding: 13px 15px; border-left: 4px solid var(--amber); border-radius: 10px; background: var(--amber-soft); }
.alert-item.info { border-left-color: var(--sea); background: color-mix(in srgb, var(--sea) 10%, var(--surface)); }
.alert-item strong, .alert-item span { display: block; }
.alert-item span { color: var(--muted); font-size: .8rem; }
.empty-state { padding: 24px; border: 1px dashed var(--line); border-radius: 13px; background: var(--surface-soft); color: var(--muted); text-align: center; }
.empty-state strong { display: block; margin-bottom: 4px; color: var(--text); }
.welcome-card { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 22px; align-items: start; max-width: 900px; padding: clamp(24px, 5vw, 44px); background: linear-gradient(135deg, var(--surface) 0%, color-mix(in srgb, var(--accent) 12%, var(--surface)) 100%); }
.welcome-mark { display: grid; width: 72px; height: 72px; place-items: center; border-radius: 22px; background: var(--accent-strong); color: #f4f7f3; font-size: 2rem; box-shadow: var(--shadow); }
.welcome-card h2 { font-size: clamp(1.35rem, 3vw, 1.8rem); }
.welcome-card p { max-width: 650px; color: var(--muted); }
.welcome-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 22px; }
.import-preview { max-width: 900px; margin-top: 16px; }
.import-counts { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.import-counts span { padding: 7px 10px; border-radius: 999px; background: var(--surface-muted); color: var(--muted); font-size: .78rem; font-weight: 700; }

.form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 14px; }
.span-12 { grid-column: span 12; }
.span-8 { grid-column: span 8; }
.span-6 { grid-column: span 6; }
.span-5 { grid-column: span 5; }
.span-4 { grid-column: span 4; }
.span-3 { grid-column: span 3; }
label.field { display: grid; gap: 6px; color: var(--muted); font-size: .79rem; font-weight: 700; }
label.field input, label.field select, label.field textarea, .input { width: 100%; min-width: 0; padding: 10px 11px; border: 1px solid var(--line); border-radius: 10px; outline: none; background: var(--surface); color: var(--text); }
label.field textarea { min-height: 80px; resize: vertical; }
label.field input:focus, label.field select:focus, label.field textarea:focus { border-color: var(--accent); }
input[type="range"] { accent-color: var(--accent); }
.range-value { display: inline-flex; min-width: 44px; justify-content: center; padding: 4px 7px; border-radius: 8px; background: var(--surface-muted); color: var(--text); font-size: .76rem; }
.form-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 9px; margin-top: 17px; }
.collapsible { overflow: hidden; }
.collapsible summary { display: flex; min-height: 44px; align-items: center; justify-content: space-between; cursor: pointer; list-style: none; font-weight: 800; }
.collapsible summary::-webkit-details-marker { display: none; }
.collapsible summary:after { color: var(--muted); content: "＋"; font-size: 1.1rem; }
.collapsible[open] summary:after { content: "−"; }
.meal-entry { margin-bottom: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); }
.meal-entry .field-row { align-items: flex-end; gap: 10px; }
.field-row { gap: 10px; flex-wrap: wrap; }
.field-row > * { flex: 1 1 120px; }
.field-row > .compact { flex: 0 1 116px; }
.session-entry, .plan-row, .setting-row { gap: 10px; flex-wrap: wrap; padding: 12px 0; border-bottom: 1px solid var(--line); }
.session-entry:last-child, .plan-row:last-child, .setting-row:last-child { border-bottom: 0; }
.session-entry > *, .plan-row > * { flex: 1 1 120px; }
.tiny-button { min-height: 36px; padding: 5px 9px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--text); }
.tiny-button:hover { border-color: var(--accent); }
.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; min-width: 620px; font-size: .82rem; }
th, td { padding: 11px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: var(--surface-soft); color: var(--muted); font-size: .72rem; letter-spacing: .04em; text-transform: uppercase; }
tr:last-child td { border-bottom: 0; }
.status-good { color: var(--good); font-weight: 750; }
.status-attention { color: #9b702c; font-weight: 750; }
.status-neutral { color: var(--muted); }
.heatmap { display: grid; grid-template-columns: repeat(7, minmax(24px, 1fr)); gap: 5px; }
.heat-cell { display: grid; min-height: 28px; place-items: center; border-radius: 6px; background: var(--surface-muted); color: var(--muted); font-size: .67rem; }
.heat-cell.has-data { background: color-mix(in srgb, var(--accent) var(--heat, 20%), var(--surface-muted)); color: var(--text); }
.heat-cell small { font-size: .6rem; }
.chart-box { position: relative; min-height: 250px; }
.chart-box canvas { display: block; width: 100% !important; height: 250px !important; }
.chart-fallback { display: flex; min-height: 180px; align-items: center; justify-content: center; padding: 20px; border: 1px dashed var(--line); border-radius: 12px; background: var(--surface-soft); color: var(--muted); text-align: center; }
.chart-fallback.hidden { display: none; }
.metric-list { display: grid; gap: 8px; }
.metric-line { display: flex; justify-content: space-between; gap: 14px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.metric-line:last-child { border-bottom: 0; }
.metric-line span:first-child { color: var(--muted); }
.big-score { font-variant-numeric: tabular-nums; font-size: 2.6rem; font-weight: 850; letter-spacing: -.06em; }
.score-bar { height: 8px; margin: 9px 0 14px; overflow: hidden; border-radius: 99px; background: var(--surface-muted); }
.score-bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--sea), var(--accent)); }
.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.tabs button { min-height: 38px; padding: 6px 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--muted); }
.tabs button.active { background: var(--accent); color: white; }
.definition { padding: 12px 14px; border-radius: 10px; background: var(--surface-soft); color: var(--muted); font-size: .8rem; }
.definition strong { color: var(--text); }
.callout { padding: 15px; border-left: 4px solid var(--sea); border-radius: 10px; background: color-mix(in srgb, var(--sea) 10%, var(--surface)); }
.callout.amber { border-left-color: var(--amber); background: var(--amber-soft); }
.profile-notice, .backup-reminder { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 0 0 16px; }
.profile-notice a { color: inherit; font-weight: 800; }
.backup-reminder span { flex: 1 1 260px; color: var(--muted); }
.check-list { display: grid; gap: 7px; margin: 0; padding: 0; list-style: none; }
.check-list li:before { margin-right: 7px; color: var(--muted); content: "·"; font-weight: 800; }
.toggle { display: inline-flex; align-items: center; gap: 8px; color: var(--text); font-weight: 650; }
.toggle input { width: 20px; height: 20px; accent-color: var(--accent); }
.settings-section { scroll-margin-top: 24px; }
.setting-row > label:first-child { flex: 1 1 260px; color: var(--text); font-weight: 700; }
.setting-row > label:first-child small { display: block; margin-top: 3px; color: var(--muted); font-weight: 400; }
.setting-control { flex: 0 1 180px; }
.rule-row { align-items: flex-start; }
.rule-controls { display: grid; grid-template-columns: repeat(3, minmax(140px, 1fr)); flex: 1 1 560px; gap: 10px; }
.value-chip { display: inline-flex; padding: 4px 8px; border-radius: 999px; background: var(--surface-muted); color: var(--muted); font-size: .74rem; }
.agent-card { min-height: 128px; }
.agent-card strong, .agent-card span { display: block; }
.agent-card span { margin-top: 7px; color: var(--muted); font-size: .8rem; }
.print-only { display: none; }
.bottom-nav { display: none; }
.noscript { margin: 20px; padding: 20px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }

@media (max-width: 1180px) {
  .sidebar { flex-basis: 226px; }
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .sidebar { display: none; }
  .mobile-brand { display: flex; }
  .topbar { min-height: 62px; }
  .content { padding-top: 24px; padding-bottom: 98px; }
  .app-footer { padding-bottom: 82px; }
  .bottom-nav { position: fixed; right: 0; bottom: 0; left: 0; z-index: 10; display: grid; grid-template-columns: repeat(5, 1fr); gap: 3px; padding: 7px 8px calc(7px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 95%, transparent); box-shadow: 0 -8px 20px rgba(20, 40, 30, .07); }
  .bottom-nav .nav-button { min-height: 52px; flex-direction: column; justify-content: center; gap: 2px; padding: 3px; text-align: center; font-size: .67rem; }
  .bottom-nav .nav-icon { height: 20px; }
  .page-head { flex-direction: column; }
  .page-actions { justify-content: flex-start; }
}

@media (max-width: 620px) {
  .topbar-actions .connection-pill { max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .grid-2, .grid-3, .grid-4, .rings-grid { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .kpi-card { padding: 13px; }
  .ring-card { min-height: 126px; }
  .ring { width: 72px; height: 72px; }
  .ring:after { width: 56px; height: 56px; font-size: .74rem; }
  .span-8, .span-6, .span-5, .span-4, .span-3 { grid-column: span 12; }
  .card { padding: 16px; }
  .hero-card { padding: 20px; }
  .welcome-card { grid-template-columns: 1fr; }
  .welcome-mark { width: 58px; height: 58px; border-radius: 18px; }
  .welcome-actions .button { width: 100%; }
  .rule-controls { grid-template-columns: 1fr; }
  .scope-switcher { width: 100%; }
  .scope-switcher button { flex: 1 1 auto; }
  h1 { font-size: 1.95rem; }
  .fictional-banner { align-items: flex-start; flex-direction: column; }
  .fictional-banner button { align-self: center; }
  .page-actions .button { width: 100%; }
  .heatmap { gap: 3px; }
  .heat-cell { min-height: 25px; }
}

@media print {
  body { background: white; color: #20322d; }
  .sidebar, .topbar, .bottom-nav, .app-footer, .page-actions, .fictional-banner, .app-status, button { display: none !important; }
  .content { padding: 0; }
  .card { box-shadow: none; break-inside: avoid; }
  .print-only { display: block; }
}
.alert-action{display:block;font-size:.86em;margin-top:4px}

.more-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}
.more-tile{display:flex;flex-direction:column;align-items:flex-start;gap:10px;min-height:96px;padding:18px;text-align:left;font:inherit;font-weight:700;color:var(--text,inherit);cursor:pointer}
.more-icon{font-size:1.4rem;color:var(--accent,currentColor)}
