/* NutriPrep Engine — tema industrial oscuro: gris pizarra y azul carbón, verde salvia y naranja cítrico. */
:root {
  --bg: #0a192f;          /* fondo: azul marino saturado */
  --bg-2: #112240;        /* tarjetas y contenedores: azul zafiro */
  --slate: #112240;
  --slate-2: #1d3a66;     /* zafiro claro: elementos elevados */
  --text: #ffffff;
  --text-2: #d6ecff;      /* azul hielo */
  --muted: #9fc4e8;
  --subtle: #7c9cc0;
  --accent: #00d2ff;      /* acción y elementos activos */
  --accent-2: #0077b6;
  --accent-bg: rgba(0, 210, 255, 0.14);
  --mint: #00ff9d;        /* confirmaciones */
  --mint-bg: rgba(0, 255, 157, 0.12);
  --coral: #ff6b6b;       /* alertas y temporizadores */
  --coral-bg: rgba(255, 107, 107, 0.15);
  --peach: #ffa69e;       /* caducidad cercana (menos urgente que el coral) */
  --red: #ff6b6b;
  --line: rgba(143, 190, 255, 0.15);
  --radius: 16px;
  --radius-lg: 24px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  font-size: 15px;
  line-height: 1.45;
  background:
    radial-gradient(900px 500px at -10% -10%, rgba(0, 210, 255, 0.09), transparent 60%),
    radial-gradient(700px 500px at 110% 110%, rgba(0, 119, 182, 0.14), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}
h1, h2, h3 { margin: 0; letter-spacing: -0.02em; line-height: 1.15; }
h1 { font-size: clamp(1.6rem, 3vw, 2.2rem); }
h2 { font-size: 1.05rem; font-weight: 600; margin-bottom: .6rem; display: flex; gap: .5rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }
p { margin: 0 0 .5rem; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .08); border-radius: 3px; }

.muted { color: var(--muted); }
.subtle { color: var(--subtle); }
.small { font-size: .82rem; }
.big { font-size: 2rem; font-weight: 650; margin: .2rem 0 .6rem; letter-spacing: -0.03em; }
.big span { font-size: .95rem; font-weight: 400; }
.eyebrow { font-size: .72rem; text-transform: uppercase; letter-spacing: .12em; color: var(--subtle); margin: 0 0 .2rem; }
.warn-text { color: var(--coral); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.row { display: flex; align-items: center; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.row.wrap, .wrap { flex-wrap: wrap; }
.row.gap, .gap { gap: .6rem; }
.stack { display: flex; flex-direction: column; gap: .8rem; }
.grow { flex: 1 1 140px; }
.narrow { width: 90px; }
.span-all { grid-column: 1 / -1; }
.grid { display: grid; gap: 1rem; grid-template-columns: 1fr; }
.grid.cols-2 { grid-template-columns: 1fr; }
.grid.cols-3 { grid-template-columns: 1fr; }

/* Superficies */
.glass {
  background: linear-gradient(225deg, rgba(17, 34, 64, .96), rgba(17, 34, 64, .82));
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}
.card { padding: 1.1rem; }
.empty { padding: 2.2rem 1rem; text-align: center; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: .8rem; }
.alert-border { border-color: rgba(255, 107, 107, .5); box-shadow: 0 0 0 1px rgba(255, 107, 107, .14) inset; }
.tile { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem; display: flex; flex-direction: column; gap: .6rem; }
.link-card { display: flex; flex-direction: column; gap: .5rem; color: var(--text); }
.link-card:hover { text-decoration: none; border-color: rgba(255, 255, 255, .18); }
.cta { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.totals { background: var(--bg-2); border-radius: var(--radius); padding: .8rem 1rem; display: flex; flex-direction: column; gap: .35rem; font-size: .9rem; }
.code-box { display: flex; align-items: center; justify-content: space-between; gap: 1rem; background: var(--bg-2); border-radius: var(--radius); padding: .9rem 1rem; }
.code, .big-code { font-family: ui-monospace, "JetBrains Mono", monospace; letter-spacing: .2em; font-weight: 600; }
.big-code { font-size: 1.6rem; }
.code { text-transform: uppercase; }
.inline-ic { display: inline-flex; vertical-align: middle; }
.ic { flex: none; }

/* Texto y entradas */
label { display: flex; flex-direction: column; gap: .35rem; font-size: .85rem; color: var(--text-2); }
label.check { flex-direction: row; align-items: center; gap: .5rem; }
input, select, textarea {
  background: rgba(255, 255, 255, .05);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: .7rem .85rem;
  min-height: 46px;
  width: 100%;
  font-size: 1rem;
}
input[type=checkbox] { width: 22px; height: 22px; min-height: 0; accent-color: var(--accent); }
input::placeholder { color: var(--subtle); }
input:focus, select:focus, textarea:focus { outline: none; border-color: rgba(0, 210, 255, .65); box-shadow: 0 0 0 3px rgba(0, 210, 255, .18); }
select option { background: var(--slate); }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem; margin: 0; }
legend { padding: 0 .4rem; }
.code { text-transform: uppercase; }
.search, .big-select, .toolbar select { max-width: 320px; }
.big-select { min-height: 56px; font-size: 1.05rem; }
.toolbar { display: flex; gap: .7rem; align-items: center; flex-wrap: wrap; margin: .2rem 0 1rem; }
.toolbar .search { flex: 1 1 200px; }

/* Botones (áreas de toque grandes) */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 46px; padding: .6rem 1.1rem; border-radius: 999px;
  border: 1px solid var(--line); background: rgba(255, 255, 255, .06); color: var(--text);
  font-weight: 600; font-size: .92rem; transition: transform .15s, background .2s, opacity .2s;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); text-decoration: none; background: rgba(255, 255, 255, .1); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--accent); color: #0a192f; border-color: transparent; box-shadow: 0 6px 20px rgba(0, 210, 255, .22); }
.btn.primary:hover { background: #4be0ff; }
.btn.ok { background: var(--mint); color: #0a192f; border-color: transparent; box-shadow: 0 6px 20px rgba(0, 255, 157, .2); }
.btn.danger { background: var(--red); color: #0a192f; border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.danger-ghost { background: transparent; color: var(--red); border-color: rgba(255, 107, 107, .4); }
.btn.sm { min-height: 36px; padding: .4rem .8rem; font-size: .82rem; }
.btn.big { min-height: 56px; padding: .8rem 1.4rem; font-size: 1rem; }
.btn.xl { min-height: 60px; font-size: 1.05rem; width: 100%; }
.btn.xxl { min-height: 80px; font-size: 1.25rem; width: 100%; border-radius: 22px; }
.link { background: none; border: 0; padding: .4rem 0; color: var(--accent); font-size: .9rem; }
.link:hover { text-decoration: underline; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 14px; border: 1px solid var(--line);
  background: rgba(255, 255, 255, .05); color: var(--text-2); flex: none;
}
.icon-btn:hover { background: rgba(255, 255, 255, .1); }
.seg { display: inline-flex; background: rgba(255, 255, 255, .05); border: 1px solid var(--line); border-radius: 999px; padding: 4px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: .5rem .9rem; border-radius: 999px; color: var(--muted); font-weight: 600; font-size: .88rem; min-height: 40px; }
.seg button.on { background: var(--slate-2); color: var(--text); }

/* Etiquetas, avisos, barras */
.tag { display: inline-flex; align-items: center; gap: .3rem; padding: .2rem .6rem; border-radius: 999px; font-size: .74rem; font-weight: 600; background: rgba(255, 255, 255, .07); color: var(--text-2); white-space: nowrap; }
.tag.ok { background: var(--mint-bg); color: var(--mint); }
.tag.soon { background: rgba(255, 166, 158, .13); color: var(--peach); }
.tag.urgent, .tag.expired { background: var(--coral-bg); color: var(--coral); }
.pill { font-size: .8rem; color: var(--text-2); background: rgba(255, 255, 255, .06); border: 1px solid var(--line); border-radius: 999px; padding: .35rem .8rem; text-transform: capitalize; }
.notice { border-radius: 12px; padding: .7rem .9rem; font-size: .9rem; border: 1px solid; }
.notice.err { background: rgba(255, 107, 107, .12); border-color: rgba(255, 107, 107, .4); color: #ffd0d0; }
.notice.warn { background: var(--coral-bg); border-color: rgba(255, 107, 107, .4); color: #ffd0d0; }
.notice.ok { background: var(--mint-bg); border-color: rgba(0, 255, 157, .35); color: #c9ffe6; }
.meter { height: 8px; border-radius: 999px; background: rgba(255, 255, 255, .07); overflow: hidden; margin: .35rem 0 .6rem; }
.meter span { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width .4s ease; }
.meter.sage span { background: var(--mint); }
.meter.over span { background: var(--coral); }
.bar-row { margin-bottom: .5rem; }
.progress { height: 10px; }

/* Listas y tablas */
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.list li { display: flex; align-items: center; justify-content: space-between; gap: .8rem; padding: .7rem 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.list li > div:first-child { flex: 1; min-width: 0; }
.table-wrap { overflow-x: auto; padding: .2rem; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: .75rem .7rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--subtle); font-weight: 600; }
tr.urgent td:first-child, tr.expired td:first-child { box-shadow: inset 3px 0 0 var(--coral); }
tr.soon td:first-child { box-shadow: inset 3px 0 0 var(--peach); }
td.actions { white-space: nowrap; text-align: right; }
td.actions .btn + .btn { margin-left: .3rem; }
.stepper { display: inline-flex; align-items: center; gap: .4rem; }
.stepper span { min-width: 4.5rem; text-align: center; font-variant-numeric: tabular-nums; }
.check-list label { flex-direction: row; align-items: center; gap: .6rem; color: var(--text); }
.check-list li s { color: var(--subtle); }
details summary { cursor: pointer; padding: .4rem 0; }
.who { display: flex; align-items: center; gap: .7rem; }
.avatar { width: 38px; height: 38px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--accent-bg); color: var(--accent); font-weight: 700; flex: none; }
.avatar.sm { width: 32px; height: 32px; font-size: .85rem; }

/* Marca */
.brand { display: flex; align-items: center; gap: .7rem; margin-bottom: 1rem; }
.brand strong { display: block; }
.brand .muted { display: block; }
.logo { width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #0a192f; flex: none; }

/* Shell de la app */
.app-root { min-height: 100vh; }
.center-screen { min-height: 100vh; display: grid; place-items: center; padding: 1.2rem; }
.auth { width: min(440px, 100%); padding: 1.6rem; }
.auth .stack { margin-top: .4rem; }
.tupper { text-align: center; display: flex; flex-direction: column; align-items: center; gap: .6rem; }
.tupper .big { font-size: 2.6rem; }
.spinner { width: 36px; height: 36px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; margin: 2rem auto; }
@keyframes spin { to { transform: rotate(360deg); } }

.shell { min-height: 100vh; display: grid; grid-template-columns: 1fr; }
.side { display: none; }
main { padding: 1rem 1rem calc(var(--badge-gap) + var(--tabbar-h) + 2.5rem + env(safe-area-inset-bottom)); min-width: 0; }
.view { max-width: 1280px; margin: 0 auto; display: flex; flex-direction: column; gap: 1rem; animation: fadeUp .35s ease both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.page-head .btn { margin-left: auto; }

/* La barra flota ~56 px sobre el borde para no tapar la insignia "Built with frögex.ai". */
:root { --badge-gap: 56px; --tabbar-h: 68px; }
.tabbar {
  position: fixed; left: 8px; right: 8px; bottom: calc(var(--badge-gap) + env(safe-area-inset-bottom)); z-index: 20;
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: .4rem;
  background: rgba(10, 25, 47, .92); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--line); border-radius: 22px;
}
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .15rem; min-height: 60px; color: var(--subtle); font-size: .7rem; font-weight: 600; border-radius: 14px; }
.tabbar a.on { color: var(--accent); background: var(--accent-bg); text-decoration: none; }

/* Modal y toasts */
.modal-bg { position: fixed; inset: 0; z-index: 50; background: rgba(5, 8, 12, .6); backdrop-filter: blur(6px); display: grid; place-items: end center; padding: 0; animation: fade .2s ease both; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal { width: 100%; max-height: 92vh; overflow: auto; border-radius: 24px 24px 0 0; background: var(--bg-2); padding: 1.1rem 1.1rem calc(1.1rem + env(safe-area-inset-bottom)); }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .8rem; }
.modal-head h3 { font-size: 1.15rem; }
.modal-body { display: flex; flex-direction: column; gap: .8rem; }
#toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--badge-gap) + var(--tabbar-h) + 1rem + env(safe-area-inset-bottom)); z-index: 60; display: flex; flex-direction: column; gap: .5rem; width: min(440px, calc(100% - 2rem)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; justify-content: space-between; gap: .8rem; background: var(--slate-2); border: 1px solid var(--line); border-radius: 14px; padding: .8rem 1rem; box-shadow: 0 10px 30px rgba(0, 0, 0, .35); animation: fadeUp .25s ease both; font-size: .92rem; }
.toast.ok { border-color: rgba(0, 255, 157, .45); }
.toast.err { border-color: rgba(255, 107, 107, .55); color: #ffd0d0; }
.toast-act { background: none; border: 0; color: var(--accent); font-weight: 700; padding: .4rem; min-height: 40px; }

/* Línea de ensamblaje */
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .7rem; }
.step { display: flex; align-items: center; justify-content: space-between; gap: .8rem; padding: 1rem; border-radius: var(--radius-lg); background: var(--bg-2); border: 1px solid var(--line); flex-wrap: wrap; }
.step.en_curso { border-color: rgba(255, 107, 107, .6); background: rgba(255, 107, 107, .08); }
.step.hecho { opacity: .55; }
.step-main { display: flex; flex-direction: column; gap: .25rem; flex: 1 1 260px; min-width: 0; }
.step-title { font-size: 1.05rem; }
.step-kind { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--subtle); }
.step-kind.passive { color: var(--coral); }
.step-act { display: flex; align-items: center; gap: .7rem; }
.step-act .btn.big { min-width: 150px; min-height: 64px; font-size: 1.1rem; }
.step.hecho .tag.ok { font-size: .85rem; }
.timer { font-variant-numeric: tabular-nums; font-size: 1.9rem; font-weight: 700; color: var(--coral); min-width: 5.2ch; text-align: center; }
.timer.urgent { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }

/* Desktop: barra lateral y dashboard amplio */
@media (min-width: 900px) {
  body { font-size: 15.5px; }
  .shell { grid-template-columns: 240px 1fr; }
  .side { display: flex; flex-direction: column; gap: 1.2rem; position: sticky; top: 0; height: 100vh; padding: 1.2rem; border-radius: 0; border-top: 0; border-bottom: 0; border-left: 0; }
  .side nav { display: flex; flex-direction: column; gap: .25rem; }
  .side nav a { display: flex; align-items: center; gap: .7rem; padding: .7rem .8rem; border-radius: 12px; color: var(--muted); font-weight: 600; }
  .side nav a:hover { background: rgba(255, 255, 255, .05); text-decoration: none; color: var(--text); }
  .side nav a.on { background: var(--accent-bg); color: var(--accent); }
  .side-foot { margin-top: auto; padding-top: 1rem; border-top: 1px solid var(--line); }
  .tabbar { display: none; }
  main { padding: 2rem 2.2rem; padding-bottom: 2rem; }
  .grid.cols-2 { grid-template-columns: 1fr 1fr; }
  .grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
  .grid.cols-2.wide { grid-template-columns: 1.1fr .9fr; }
  .modal-bg { place-items: center; }
  .modal { border-radius: 24px; max-width: 620px; }
  .step { flex-wrap: nowrap; }
  .card { padding: 1.4rem; }
  .auth { padding: 2rem; }
  .side-foot .who span { display: block; }
  #toasts { bottom: 2rem; }
}
@media (min-width: 1280px) {
  .grid.cols-3 { grid-template-columns: repeat(4, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
