:root {
  --bg: #071426;
  --panel: #0d2036;
  --panel-2: #102942;
  --line: #25465f;
  --text: #edf8ff;
  --muted: #9db5c6;
  --cyan: #36d5e8;
  --cyan-dark: #087f91;
  --green: #66e3b4;
  --orange: #ffb86b;
  --yellow: #ffe287;
  --danger: #ff7f8e;
  --shadow: 0 22px 55px rgba(0, 0, 0, .28);
  font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 16px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { min-width: 290px; margin: 0; color: var(--text); background: radial-gradient(circle at 82% 0, rgba(54, 213, 232, .14), transparent 34rem), linear-gradient(180deg, #06111f, var(--bg) 45rem); line-height: 1.5; }
button, input, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.app-header { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 78px; padding: .7rem max(1rem, calc((100vw - 1120px) / 2)); border-bottom: 1px solid rgba(37, 70, 95, .85); background: rgba(6, 17, 31, .88); backdrop-filter: blur(18px); }
.brand { display: flex; align-items: center; gap: .8rem; color: inherit; text-decoration: none; }
.brand__logo { width: 56px; height: 56px; border: 1px solid rgba(54, 213, 232, .45); border-radius: 17px; object-fit: cover; box-shadow: 0 0 25px rgba(54, 213, 232, .13); }
.brand > span { display: grid; }
.eyebrow { color: var(--cyan); font-size: .68rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.brand strong { font-size: 1.23rem; line-height: 1.1; }
.brand strong em { color: var(--cyan); font-style: normal; }
.brand small { color: var(--muted); }
.header-actions { display: flex; gap: .3rem; padding: .28rem; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.icon-button { min-width: 43px; min-height: 43px; padding: .35rem .5rem; border: 0; border-radius: 9px; color: var(--cyan); background: transparent; font-weight: 800; cursor: pointer; }
.icon-button:hover, .icon-button:focus-visible { background: rgba(54, 213, 232, .1); outline: none; }

.shell { width: min(1120px, calc(100% - 2rem)); margin: 0 auto; padding: 2.2rem 0 3rem; }
.hero { display: grid; grid-template-columns: 1.4fr .8fr; gap: 2rem; align-items: end; padding: clamp(1rem, 4vw, 2rem) 0 2.3rem; }
.kicker { margin: 0 0 .75rem; color: var(--cyan); font-size: .8rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.kicker span { display: inline-block; width: 8px; height: 8px; margin-right: .35rem; border-radius: 50%; background: var(--green); box-shadow: 0 0 14px var(--green); }
h1, h2, p { margin-top: 0; }
h1 { max-width: 760px; margin-bottom: .7rem; font-size: clamp(2rem, 5.5vw, 4.2rem); line-height: .98; letter-spacing: -.045em; }
.hero > div > p:last-child { max-width: 730px; margin-bottom: 0; color: var(--muted); font-size: clamp(1rem, 2vw, 1.16rem); }
.hero-stats { display: grid; grid-template-columns: repeat(3, 1fr); overflow: hidden; border: 1px solid var(--line); border-radius: 18px; background: rgba(13, 32, 54, .72); box-shadow: var(--shadow); }
.hero-stats div { padding: 1rem .7rem; border-right: 1px solid var(--line); text-align: center; }
.hero-stats div:last-child { border: 0; }
.hero-stats strong { display: block; color: var(--cyan); font-size: 1.65rem; }
.hero-stats span { color: var(--muted); font-size: .72rem; }

.workflow-card, .results-card, .history-card, .reference-grid details { margin-bottom: 1rem; border: 1px solid var(--line); border-radius: 20px; background: linear-gradient(145deg, rgba(16, 41, 66, .95), rgba(10, 28, 48, .96)); box-shadow: var(--shadow); }
.workflow-card, .results-card, .history-card { padding: clamp(1rem, 3vw, 1.6rem); }
.section-heading { display: flex; align-items: flex-start; gap: .8rem; margin-bottom: 1.2rem; }
.section-heading--progress { align-items: center; }
.section-heading h2 { margin-bottom: .15rem; font-size: 1.25rem; }
.section-heading p { margin-bottom: 0; color: var(--muted); }
.step { display: grid; flex: 0 0 40px; width: 40px; height: 40px; place-items: center; border: 1px solid rgba(54, 213, 232, .4); border-radius: 12px; color: var(--cyan); background: rgba(54, 213, 232, .08); font-size: .78rem; font-weight: 900; }
.progress-wrap { width: 180px; margin-left: auto; }
.progress-wrap strong { display: block; margin-bottom: .35rem; color: var(--cyan); text-align: right; }
.progress-track { height: 7px; overflow: hidden; border-radius: 99px; background: #061424; }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--cyan-dark), var(--cyan)); transition: width .2s ease; }

.metadata-grid, .measure-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .9rem; }
.field--wide { grid-column: span 2; }
.field { min-width: 0; }
.field label { display: block; margin-bottom: .35rem; color: #dff5ff; font-size: .86rem; font-weight: 750; }
.field label span { color: var(--cyan); font-size: .72rem; }
.field input, .field select { width: 100%; min-height: 48px; padding: .72rem .8rem; border: 1px solid #365970; border-radius: 10px; color: var(--text); background: #071b2d; outline: none; }
.field input::placeholder { color: #6f8ba0; }
.field input:focus, .field select:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(54, 213, 232, .12); }
.input-unit { position: relative; }
.input-unit input { padding-right: 3rem; }
.input-unit > span { position: absolute; top: 50%; right: .8rem; color: var(--muted); transform: translateY(-50%); pointer-events: none; }
.field small { display: block; min-height: 1rem; margin-top: .25rem; color: #819daf; font-size: .72rem; }
.field.is-warning input { border-color: var(--yellow); }
.field.is-warning small { color: var(--yellow); }
.field.is-invalid input { border-color: var(--danger); box-shadow: 0 0 0 2px rgba(255, 127, 142, .1); }
.field.is-invalid small { color: var(--danger); }
.field--optional { padding: .7rem; border: 1px dashed #365970; border-radius: 12px; background: rgba(6, 20, 36, .4); }

.message { margin-top: 1rem; padding: .8rem 1rem; border-left: 4px solid var(--danger); border-radius: 9px; color: #ffdce0; background: rgba(127, 25, 41, .25); }
.actions { display: flex; flex-wrap: wrap; gap: .65rem; margin-top: 1.2rem; }
.button { min-height: 48px; padding: .72rem 1rem; border: 1px solid transparent; border-radius: 10px; font-weight: 800; cursor: pointer; }
.button:focus-visible { outline: 3px solid rgba(54, 213, 232, .3); outline-offset: 2px; }
.button--primary { color: #03242a; background: var(--cyan); }
.button--primary:hover { background: #74e4ef; }
.button--secondary { color: var(--text); border-color: #2b7183; background: #123e54; }
.button--quiet { color: var(--text); border-color: var(--line); background: #0a1c30; }
.button--danger { color: #ffdbe0; border-color: #7e3340; background: #3c1722; }

.summary { display: grid; grid-template-columns: 1.2fr repeat(3, .55fr); gap: .65rem; margin-bottom: 1rem; }
.summary > div { padding: 1rem; border: 1px solid var(--line); border-radius: 14px; background: #081b2d; }
.summary .summary-main { border-color: rgba(54, 213, 232, .38); background: linear-gradient(135deg, rgba(54, 213, 232, .12), #081b2d); }
.summary span { display: block; color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; }
.summary strong { display: block; margin-top: .15rem; color: var(--cyan); font-size: 1.55rem; }
.summary-main strong { color: var(--text); font-size: 1.1rem; }
.summary-main p { margin: .3rem 0 0; color: var(--muted); font-size: .8rem; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 13px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .78rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: #a8c3d5; background: #091a2b; font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; }
tbody tr:last-child td { border-bottom: 0; }
td small { display: block; color: var(--muted); }
.code { color: var(--cyan); font-weight: 900; }
.signal { display: inline-block; padding: .25rem .55rem; border-radius: 99px; font-size: .74rem; font-weight: 850; white-space: nowrap; }
.signal--carne { color: #ffd3a3; background: rgba(255, 184, 107, .13); }
.signal--leche { color: #bdf6df; background: rgba(102, 227, 180, .12); }
.signal--neutral { color: #c4d2dc; background: rgba(157, 181, 198, .12); }
.record-count { display: grid; width: 38px; height: 38px; margin-left: auto; place-items: center; border-radius: 50%; color: var(--cyan); background: rgba(54, 213, 232, .1); font-weight: 850; }
.empty-state { padding: 1.25rem; border: 1px dashed #365970; border-radius: 12px; color: var(--muted); text-align: center; }
.mini-button { min-width: 42px; min-height: 38px; border: 1px solid #7e3340; border-radius: 8px; color: #ffdbe0; background: #3c1722; cursor: pointer; }

.reference-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.reference-grid details { margin: 0; padding: 1rem 1.1rem; box-shadow: none; }
.reference-grid summary { color: var(--cyan); font-weight: 850; cursor: pointer; }
.reference-grid p, .reference-grid li { color: var(--muted); font-size: .88rem; }
.formula-item { margin-top: .7rem; padding-top: .7rem; border-top: 1px solid var(--line); }
.formula-item:first-child { border-top: 0; }
.formula-item strong { color: var(--text); }
.formula-item code { color: var(--cyan); }
footer { padding: 0 1rem 2rem; color: #7893a6; text-align: center; font-size: .8rem; }
.toast { position: fixed; right: 1rem; bottom: 1rem; z-index: 30; max-width: min(360px, calc(100% - 2rem)); padding: .8rem 1rem; border: 1px solid rgba(54, 213, 232, .4); border-radius: 11px; color: var(--text); background: #0d2b3d; box-shadow: var(--shadow); }
[hidden] { display: none !important; }

@media (max-width: 850px) {
  .hero { grid-template-columns: 1fr; }
  .metadata-grid, .measure-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .reference-grid { grid-template-columns: 1fr; }
  .summary { grid-template-columns: repeat(3, 1fr); }
  .summary-main { grid-column: 1 / -1; }
}

@media (max-width: 560px) {
  .app-header { position: static; align-items: flex-start; }
  .brand small { display: none; }
  .brand__logo { width: 48px; height: 48px; }
  .header-actions { position: fixed; right: .65rem; bottom: .65rem; z-index: 25; box-shadow: var(--shadow); }
  .shell { width: min(100% - 1rem, 1120px); padding-top: 1rem; }
  .hero { padding-top: .5rem; }
  .hero-stats { grid-template-columns: 1fr; }
  .hero-stats div { display: flex; align-items: baseline; justify-content: space-between; border-right: 0; border-bottom: 1px solid var(--line); }
  .metadata-grid, .measure-grid { grid-template-columns: 1fr; }
  .field--wide { grid-column: auto; }
  .section-heading--progress { flex-wrap: wrap; }
  .progress-wrap { width: 100%; }
  .summary { grid-template-columns: 1fr; }
  .summary-main { grid-column: auto; }
  .actions .button { flex: 1 1 100%; }
}

@media print {
  body { color: #111; background: #fff; }
  .app-header, .hero, form, .history-card, .reference-grid, footer, .results-card .actions { display: none !important; }
  .shell { width: 100%; padding: 0; }
  .results-card { border: 0; color: #111; background: #fff; box-shadow: none; }
  .summary > div, th { color: #111; background: #fff; }
  .summary strong, .code { color: #111; }
  th, td, .table-wrap, .summary > div { border-color: #aaa; }
}

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
.suite-home-link {
  position: fixed;
  left: max(14px, env(safe-area-inset-left));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 10000;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0.66rem 1rem;
  border: 1px solid rgba(41, 216, 255, 0.55);
  border-radius: 999px;
  background: rgba(3, 16, 29, 0.95);
  color: #f5f9fc;
  font: 700 0.84rem/1 Arial, sans-serif;
  text-decoration: none;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(12px);
  -webkit-tap-highlight-color: transparent;
}

.suite-home-link:hover {
  border-color: #29d8ff;
  color: #73e8ff;
}

.suite-home-link:focus-visible {
  outline: 3px solid #9eea43;
  outline-offset: 3px;
}
