/* Juspit brand foundation — shared tokens and application shell.
   The brand book palette is achromatic and has exactly three values:
   #F3F3F3 (light), #000000 (black), #3C3C3B (warm dark gray). Production adds
   restrained semantic state colours and one approved chromatic exception for
   Host performance and bonus chart marks only. */

/* The brand typeface is Helvetica Neue LT Com Extended, which we have no
   webfont licence for. Archivo (SIL OFL) is the substitute: it carries a real
   width axis, so the display voice can stay extended while UI text stays at
   normal width. See --stretch-display / --stretch-ui below. */
@font-face {
  font-family: "Archivo";
  font-style: normal;
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
  src: url("fonts/archivo-variable-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Archivo";
  font-style: normal;
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
  src: url("fonts/archivo-variable-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: light;
  --bg-canvas: #F3F3F3;
  --bg-surface: #FFFFFF;
  --bg-subtle: #EAEAE8;
  --bg-rail: #000000;
  --bg-rail-hover: #1A1A1A;
  --bg-rail-selected: #FFFFFF;
  --bg-accent: #000000;
  --bg-accent-hover: #3C3C3B;
  --bg-accent-subtle: #EAEAE8;
  --chart-bonus-mark: #1473E6;
  --chart-pph-line: #0057D9;
  --chart-pph-point: #003F9E;
  --bg-hover: #EAEAE8;
  --bg-disabled: #E0E0DE;
  --bg-success: #EBF5F0;
  --bg-danger: #FDECEA;
  --bg-warning: #FBF3E2;
  --bg-scrim: rgba(0, 0, 0, 0.6);
  --text-primary: #000000;
  --text-secondary: #5B5B58;
  --text-on-dark: #F3F3F3;
  --text-on-dark-muted: #A3A3A0;
  --text-on-dark-faint: #7A7A78;
  --text-disabled: #A3A3A0;
  --text-inverse: #FFFFFF;
  --text-accent: #000000;
  --text-success: #0F7B4F;
  --text-danger: #B42318;
  --text-warning: #8A6100;
  --border-default: #D7D7D3;
  --border-strong: #3C3C3B;
  --border-dark: #2A2A2A;
  --border-accent-soft: #3C3C3B;
  --border-success: #0F7B4F;
  --border-danger: #B42318;
  --focus-ring: #000000;
  --font-ui: "Archivo", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-display: "Archivo", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-data: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --stretch-display: 125%;
  --stretch-ui: 100%;
  --text-xs: 0.75rem; --text-sm: 0.875rem; --text-md: 1rem;
  --text-lg: 1.125rem; --text-xl: 1.5rem; --text-2xl: clamp(2rem, 4vw, 2.75rem);
  --leading-tight: 1.1; --leading-normal: 1.5;
  --weight-medium: 500;
  --weight-strong: 700;
  --weight-emphasis: 750;
  --weight-display: 900;
  --tracking-label: 0.1em;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-8: 4rem;
  --radius-xs: 0.625rem;
  --radius-sm: 0.875rem;
  --radius-pill: 999rem;
  --shadow-raised: 0 0.0625rem 0.125rem rgba(0, 0, 0, 0.04), 0 0.25rem 0.75rem rgba(0, 0, 0, 0.04);
  --control-min: 2.75rem;
  --mobile-nav-clearance: 6rem;
  --mobile-nav-clearance-compact: 9rem;
  --mobile-nav-columns-compact: repeat(2, minmax(0, 1fr));
  --rail-width: 15rem;
  --content-form: 44rem;
  --content-max: 90rem;
  --daily-record-columns: minmax(6.5rem, 0.85fr) minmax(7rem, 1fr) auto;
  --daily-metric-columns: repeat(4, minmax(0, 1fr));
  --motion-fast: 120ms;
  --rule: 0.0625rem;
}

* { box-sizing: border-box; }
html { background: var(--bg-canvas); }
body {
  min-width: 20rem;
  margin: 0;
  color: var(--text-primary);
  background: var(--bg-canvas);
  font-family: var(--font-ui);
  font-size: var(--text-md);
  font-stretch: var(--stretch-ui);
  line-height: var(--leading-normal);
}
button, input, select { font: inherit; }
button, input, select, a { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 0.1875rem solid var(--focus-ring); outline-offset: 0.1875rem; }
/* The accent is black, so links cannot be told apart from body text by colour.
   The underline is the non-colour cue and must survive. */
a { color: var(--text-accent); text-underline-offset: 0.2em; }

.visually-hidden {
  position: absolute;
  width: 0.0625rem;
  height: 0.0625rem;
  margin: -0.0625rem;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  z-index: 30;
  top: var(--space-2);
  left: var(--space-2);
  min-height: var(--control-min);
  padding: var(--space-2) var(--space-4);
  color: var(--text-primary);
  background: var(--bg-surface);
  border: var(--rule) solid var(--border-strong);
  border-radius: var(--radius-xs);
  box-shadow: var(--shadow-raised);
  transform: translateY(-200%);
}
.skip-link:focus { transform: translateY(0); }
.shell { min-height: 100vh; }
.control-rail {
  --focus-ring: var(--text-on-dark);
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 10;
  width: var(--rail-width);
  display: flex;
  flex-direction: column;
  padding: var(--space-6) var(--space-4);
  color: var(--text-on-dark);
  background: var(--bg-rail);
  border-right: var(--rule) solid var(--border-dark);
}
.wordmark { margin: 0 0 var(--space-8); }
/* The logotipo is painted with a mask so it inherits currentColor: black on
   the light mobile header, --text-on-dark on the black rail. */
.wordmark-logo {
  display: block;
  width: min(100%, 9rem);
  aspect-ratio: 1682.74 / 536.1;
  background-color: currentColor;
  -webkit-mask: url("brand/juspit-logotipo.svg") no-repeat center / contain;
  mask: url("brand/juspit-logotipo.svg") no-repeat center / contain;
}
.wordmark small {
  display: block;
  margin-top: var(--space-3);
  color: var(--text-on-dark-muted);
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  font-weight: var(--weight-strong);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
}
.rail-nav { display: grid; gap: var(--space-2); }
.rail-nav a {
  min-height: var(--control-min);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  color: var(--text-on-dark-muted);
  text-decoration: none;
  border-left: 0.1875rem solid transparent;
}
.rail-nav a:hover { color: var(--text-on-dark); background: var(--bg-rail-hover); }
.rail-nav a[aria-current="page"] {
  --focus-ring: var(--text-primary);
  color: var(--text-primary);
  background: var(--bg-rail-selected);
  border-left-color: var(--bg-rail-selected);
  font-weight: var(--weight-strong);
}
.nav-index {
  order: -1;
  color: var(--text-on-dark-faint);
  font-family: var(--font-data);
  font-size: var(--text-xs);
}
.rail-nav a:hover .nav-index, .rail-nav a[aria-current="page"] .nav-index { color: inherit; }
.control-rail > form { margin-top: auto; }
.control-rail > form .button { width: 100%; }
.control-rail .button-secondary {
  color: var(--text-on-dark);
  background: transparent;
  border-color: var(--text-on-dark-faint);
}
.control-rail .button-secondary:hover { color: var(--text-primary); background: var(--bg-rail-selected); }
.rail-note {
  margin: var(--space-4) 0 0;
  padding-top: var(--space-4);
  color: var(--text-on-dark-muted);
  border-top: var(--rule) solid var(--border-dark);
  font-size: var(--text-sm);
}
.mobile-shell-head { display: none; }
main {
  width: min(calc(100% - var(--rail-width)), var(--content-max));
  min-height: 100vh;
  margin-left: var(--rail-width);
  padding: var(--space-8);
}

.page-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: var(--space-6);
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-5);
  border-bottom: var(--rule) solid var(--border-strong);
}
/* Three labels, three tiers. .eyebrow names the page, .section-kicker names a
   panel and sits beside an h2, .record-label names a cell on mobile. Only the
   page-level one earns uppercase and tracking. */
.eyebrow {
  margin: 0;
  color: var(--text-secondary);
  font-size: var(--text-xs);
  font-weight: var(--weight-emphasis);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
}
.section-kicker {
  margin: 0;
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: var(--weight-strong);
}
h1 {
  margin: var(--space-1) 0 0;
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: var(--weight-display);
  font-stretch: var(--stretch-display);
  line-height: var(--leading-tight);
  letter-spacing: -0.01em;
}
h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: var(--weight-display);
  font-stretch: var(--stretch-display);
  line-height: var(--leading-tight);
}
h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: var(--weight-display);
  font-stretch: var(--stretch-display);
  line-height: var(--leading-tight);
}
.date-stamp, .version-stamp { margin: 0; text-align: right; }
.date-stamp span, .version-stamp span {
  display: block;
  color: var(--text-secondary);
  font-size: var(--text-xs);
  font-weight: var(--weight-strong);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
}
.date-stamp strong, .version-stamp strong {
  display: block;
  margin-top: var(--space-1);
  font-family: var(--font-data);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
}
.status-region { min-height: var(--space-1); }
.notice {
  margin: 0 0 var(--space-4);
  padding: var(--space-3) var(--space-4);
  border: var(--rule) solid;
  border-radius: var(--radius-xs);
  font-size: var(--text-sm);
  font-weight: var(--weight-strong);
}
.notice-success { color: var(--text-success); background: var(--bg-success); border-color: var(--border-success); }
.notice-error { color: var(--text-danger); background: var(--bg-danger); border-color: var(--border-danger); }
.workspace-grid {
  display: grid;
  grid-template-columns: minmax(18rem, 0.72fr) minmax(34rem, 1.28fr);
  gap: var(--space-6);
  align-items: start;
}
.panel {
  min-width: 0;
  overflow: hidden;
  background: var(--bg-surface);
  border: var(--rule) solid var(--border-default);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-raised);
}
.entry-panel { border-top-color: var(--border-strong); }
.panel-head {
  min-height: 4.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  border-bottom: var(--rule) solid var(--border-default);
}
.panel-body { padding: var(--space-5); }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
.field { display: grid; align-content: start; gap: var(--space-2); }
.field-wide { grid-column: 1 / -1; }
label { overflow-wrap: anywhere; font-size: var(--text-sm); font-weight: var(--weight-strong); }
input:not([type="checkbox"]):not([type="radio"]), select {
  width: 100%;
  min-height: var(--control-min);
  padding: var(--space-2) var(--space-3);
  color: var(--text-primary);
  background: var(--bg-surface);
  border: var(--rule) solid var(--border-strong);
  border-radius: var(--radius-xs);
}
input:not([type="checkbox"]):not([type="radio"]):hover, select:hover { border-color: var(--text-primary); }
input[aria-invalid="true"] { border: 0.125rem solid var(--text-danger); }
select[aria-invalid="true"] { border: 0.125rem solid var(--text-danger); }
input[type="checkbox"] {
  width: 1.25rem;
  height: 1.25rem;
  margin: 0;
  flex: 0 0 auto;
  accent-color: var(--bg-accent);
}
.checkbox-control {
  min-height: var(--control-min);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding-block: var(--space-2);
  cursor: pointer;
}
summary {
  min-height: var(--control-min);
  padding-block: var(--space-3);
  overflow-wrap: anywhere;
  cursor: pointer;
}
.duration-field { margin: 0; padding: 0; border: 0; }
.duration-field legend { margin-bottom: var(--space-2); font-size: var(--text-sm); font-weight: var(--weight-strong); }
.duration-options { display: grid; gap: var(--space-2); }
.duration-option {
  min-height: var(--control-min);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border: var(--rule) solid var(--border-strong);
  border-radius: var(--radius-xs);
  cursor: pointer;
}
.duration-option:hover { background: var(--bg-hover); }
.duration-option:has(input:checked) { border-color: var(--bg-accent); background: var(--bg-subtle); }
input[type="radio"] {
  width: var(--space-5);
  height: var(--space-5);
  margin: 0;
  flex: 0 0 auto;
  accent-color: var(--bg-accent);
}
.precise-times { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
.precise-times[hidden] { display: none; }
.field-error { margin: 0; color: var(--text-danger); font-size: var(--text-xs); font-weight: var(--weight-strong); }
.form-actions { display: flex; gap: var(--space-3); margin-top: var(--space-5); }
.button {
  min-width: 0;
  min-height: var(--control-min);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border: var(--rule) solid transparent;
  border-radius: var(--radius-xs);
  font-weight: var(--weight-emphasis);
  line-height: 1.2;
  overflow-wrap: anywhere;
  text-decoration: none;
  white-space: normal;
  cursor: pointer;
  transition: background-color var(--motion-fast), transform var(--motion-fast);
}
.button-primary { color: var(--text-inverse); background: var(--bg-accent); }
.button-primary:hover { background: var(--bg-accent-hover); }
.button-secondary { color: var(--text-primary); background: transparent; border-color: var(--border-strong); }
.button-secondary:hover { background: var(--bg-subtle); }
.button-danger { color: var(--text-danger); background: transparent; border-color: var(--border-danger); }
.button-danger:hover { background: var(--bg-danger); }
.button:active { transform: translateY(0.0625rem); }
.button:disabled { color: var(--text-disabled); background: var(--bg-disabled); border-color: var(--border-default); cursor: not-allowed; }
.records { display: grid; margin: 0; padding: 0; list-style: none; }
.record {
  display: grid;
  gap: var(--space-4);
  align-items: center;
  padding: var(--space-4) var(--space-5);
  border-bottom: var(--rule) solid var(--border-default);
}
.record:last-child { border-bottom: 0; }
.record:hover { background: var(--bg-hover); }
.record-data { font-family: var(--font-data); font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
.record-data, .record-primary { min-width: 0; }
.record-data strong, .record-primary strong { display: block; }
.record-data span:not(.record-label), .record-primary > span:not(.record-label):not(.status-pill) {
  display: block;
  color: var(--text-secondary);
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
}
.record-label {
  display: none;
  margin: 0 0 var(--space-1);
  color: var(--text-secondary);
  font-size: var(--text-xs);
}
.status-pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: var(--space-1) var(--space-2);
  color: var(--text-success);
  background: var(--bg-success);
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: var(--weight-emphasis);
}
.record-primary .status-pill { margin-top: var(--space-1); }
.text-action {
  min-width: var(--control-min);
  min-height: var(--control-min);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--weight-emphasis);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}
.empty-state { padding: var(--space-8) var(--space-6); text-align: center; }
.empty-state strong { display: block; }
.empty-state p { margin: var(--space-1) 0 var(--space-4); color: var(--text-secondary); font-size: var(--text-sm); }
.mobile-nav { display: none; }

/* The sheet's only min-width breakpoints. Everything else here is
   desktop-first, so these are declared *before* the max-width blocks: media
   queries carry no specificity, and this source order keeps the narrow
   overrides winning if a boundary is ever loosened by mistake. */

/* Centre the column once the viewport is wider than the rail plus the cap;
   without this the whole slack lands on the right and the page reads as
   broken. max() is self-disabling — with no slack it returns the rail width,
   so narrower desktops render exactly as before. Scoped to the range where
   .control-rail actually exists: below 48rem the rail is display: none and
   main resets to width: 100%; margin: 0, which this must never outrank. */
@media (min-width: 48.0625rem) {
  main {
    margin-left: max(var(--rail-width), calc((100% - var(--content-max)) / 2));
    margin-right: auto;
  }
}

/* Past 1600px a 90rem cap starves the data grids while the viewport keeps
   growing. Only the custom property moves: main's width and the centring
   calc both read it, so no geometry is restated. --content-form deliberately
   stays at 44rem — data grids gain columns, text fields do not gain width. */
@media (min-width: 100rem) {
  :root { --content-max: 120rem; }
}

@media (max-width: 76rem) {
  .workspace-grid { grid-template-columns: 1fr; }
  .entry-panel { max-width: 44rem; }
}
@media (max-width: 48rem) {
  html { scroll-padding-bottom: calc(var(--mobile-nav-clearance) + var(--space-5) + env(safe-area-inset-bottom)); }
  body { padding-bottom: calc(var(--mobile-nav-clearance) + var(--space-5) + env(safe-area-inset-bottom)); }
  .control-rail { display: none; }
  .mobile-shell-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: var(--bg-surface);
    border-bottom: var(--rule) solid var(--border-default);
  }
  .mobile-shell-head .wordmark { margin: 0; }
  .mobile-shell-head .wordmark-logo { width: min(100%, 6.5rem); }
  .mobile-shell-head .button { min-height: var(--control-min); padding-inline: var(--space-3); }
  main { width: 100%; margin: 0; padding: var(--space-5) var(--space-4); }
  .page-head { align-items: start; margin-bottom: var(--space-5); }
  .date-stamp, .version-stamp { text-align: left; }
  .record { grid-template-columns: 1fr 1fr; gap: var(--space-3) var(--space-4); }
  .record-label { display: block; }
  .mobile-nav {
    --focus-ring: var(--text-on-dark-faint);
    position: fixed;
    inset: auto var(--space-3) calc(var(--space-3) + env(safe-area-inset-bottom));
    z-index: 20;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    gap: var(--space-1);
    padding: var(--space-1) var(--space-1) max(var(--space-1), env(safe-area-inset-bottom));
    background: var(--bg-rail);
    border: var(--rule) solid var(--border-dark);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-raised);
  }
  .mobile-nav a {
    min-height: var(--control-min);
    display: grid;
    place-items: center;
    padding: var(--space-2);
    color: var(--text-on-dark-muted);
    text-decoration: none;
    border-radius: var(--radius-xs);
    font-size: var(--text-sm);
  }
  .mobile-nav a:hover { color: var(--text-on-dark); background: var(--bg-rail-hover); }
  .mobile-nav a[aria-current="page"] { color: var(--text-primary); background: var(--bg-rail-selected); font-weight: var(--weight-emphasis); }
}
@media (max-width: 24rem) {
  html { scroll-padding-bottom: calc(var(--mobile-nav-clearance-compact) + var(--space-5) + env(safe-area-inset-bottom)); }
  body { padding-bottom: calc(var(--mobile-nav-clearance-compact) + var(--space-5) + env(safe-area-inset-bottom)); }
  main { padding: var(--space-3); }
  .page-head { display: grid; }
  .field-grid { grid-template-columns: 1fr; }
  .field-wide { grid-column: auto; }
  .precise-times { grid-template-columns: 1fr; }
  .form-actions { flex-direction: column; }
  .form-actions .button { width: 100%; }
  .panel-head, .panel-body, .record { padding-left: var(--space-4); padding-right: var(--space-4); }
  .mobile-nav {
    grid-template-columns: var(--mobile-nav-columns-compact);
    grid-auto-flow: row;
  }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

@media (forced-colors: active) {
  .button, .panel, .mobile-nav { border-color: CanvasText; }
  .notice, .status-pill, .checkbox-control, summary { border: var(--rule) solid CanvasText; }
}

.chart-table-wrap:focus-visible { outline: 0.1875rem solid var(--focus-ring); outline-offset: 0.1875rem; }
