:root {
  --border: #d8dce0;
  --bg: #f5f6f8;
  --text: #1f2933;
  --muted: #6b7280;
  --accent: #1f6f4f;
  --accent-dark: #164f38;
  --error: #b3261e;
  --error-bg: #fbeaea;
  --success: #1f6f4f;
  --success-bg: #e8f5ee;
  --white: #ffffff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

nav.topnav {
  background: var(--accent-dark);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  flex-wrap: wrap;
}

nav.topnav a {
  color: var(--white);
  text-decoration: none;
  margin-right: 16px;
  font-size: 0.92rem;
}

nav.topnav a:hover { text-decoration: underline; }

nav.topnav .brand { font-weight: 700; font-size: 1.05rem; margin-right: 24px; }

nav.topnav form { display: inline; }

nav.topnav .navlinks { display: flex; align-items: center; flex-wrap: wrap; }

nav.topnav .navright { display: flex; align-items: center; gap: 12px; }

.container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

h1 { font-size: 1.5rem; margin-bottom: 4px; }
h2 { font-size: 1.2rem; margin-top: 28px; }
.subtitle { color: var(--muted); margin-top: 0; margin-bottom: 20px; }

.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; font-size: 0.92rem; }
.flash.error { background: var(--error-bg); color: var(--error); border: 1px solid #f0c6c3; }
.flash.success { background: var(--success-bg); color: var(--success); border: 1px solid #bfe3cf; }

table { border-collapse: collapse; width: 100%; margin-bottom: 20px; background: var(--white); }
th, td { border: 1px solid var(--border); padding: 8px 10px; text-align: left; font-size: 0.92rem; }
th { background: #eef0f2; }

.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px 20px;
  margin-bottom: 20px;
}

form.stacked label { display: block; margin: 12px 0 4px; font-size: 0.88rem; color: var(--muted); }
form.stacked input, form.stacked select, form.stacked textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 0.95rem;
}
form.inline { display: inline; }
form.inline-row { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }

button, .btn {
  background: var(--accent);
  color: var(--white);
  border: none;
  border-radius: 5px;
  padding: 8px 16px;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  margin-top: 14px;
}
button:hover, .btn:hover { background: var(--accent-dark); }
.btn-secondary { background: var(--muted); }
.btn-danger { background: var(--error); }
.btn-small { padding: 4px 10px; font-size: 0.8rem; margin-top: 0; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 0.75rem; font-weight: 600; }
.badge.current { background: var(--success-bg); color: var(--success); }
.badge.low-stock { background: var(--error-bg); color: var(--error); }
.badge.role-admin { background: #e6e9fb; color: #3a3ea8; }
.badge.role-user { background: #eef0f2; color: var(--muted); }

.tabs { display: flex; gap: 6px; margin-bottom: 18px; }
.tabs a {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  text-decoration: none;
  color: var(--text);
  background: #eef0f2;
}
.tabs a.active { background: var(--white); font-weight: 600; }

.stage-block { border: 1px solid var(--border); border-radius: 6px; padding: 12px 14px; margin-bottom: 12px; background: #fbfbfc; }
.stage-block h3 { margin: 0 0 6px; font-size: 1rem; }
.muted { color: var(--muted); font-size: 0.88rem; }
.result-number { font-size: 2rem; font-weight: 700; color: var(--accent-dark); }
.variance-bad { color: var(--error); font-weight: 600; }
.variance-ok { color: var(--success); font-weight: 600; }


/* --- formulation summary / calculator --- */
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.total td { font-weight: 700; background: #f3f5f4; }
.metrics { display: flex; flex-wrap: wrap; gap: 12px; margin: 8px 0 16px; }
.metric { flex: 1 1 180px; border: 1px solid var(--border); border-radius: 6px; padding: 10px 12px; background: #fbfbfc; }
.metric-label { display: block; font-size: 0.8rem; color: var(--muted); }
.metric-value { display: block; font-size: 1.35rem; font-weight: 700; color: var(--accent-dark); }
label.check { display: inline-flex !important; align-items: center; gap: 6px; color: var(--text) !important; }
form.stacked label.check input { width: auto; }
details { margin-top: 8px; }
details summary { cursor: pointer; color: var(--accent); font-size: 0.88rem; }
.container { max-width: 1150px; }


/* ===== v1.1 layout: left icon sidebar (CFS-style) ===== */
:root { --brand-red: #c8102e; --brand-red-dark: #9e0c24; --sidebar-w: 92px; }

.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar-w);
  background: #f1f1f1; border-right: 2px solid #3a3a3a;
  display: flex; flex-direction: column; align-items: center;
  padding: 8px 0 6px; z-index: 10; overflow-y: auto;
}
.side-logo { display: block; margin-bottom: 10px; }
.side-logo img { width: 62px; height: 62px; object-fit: contain; border-radius: 50%; background: #fff; padding: 6px; border: 1px solid #d6d6d6; }
.side-item {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  width: 100%; padding: 8px 0; color: #2f2f2f; text-decoration: none;
  font-size: 0.8rem; font-weight: 600; background: none; border: none;
  margin: 0; border-radius: 0; cursor: pointer; font-family: inherit;
}
.side-item:hover { background: #e2e2e2; color: #000; }
.side-item.active { color: var(--brand-red); background: #fff; box-shadow: inset 4px 0 0 var(--brand-red); }
.sidebar form { width: 100%; margin: 0; }
button.side-item:hover { background: #e2e2e2; }
.side-spacer { flex: 1; }
.side-foot { width: 70px; margin-top: 6px; opacity: 0.9; }

main.with-sidebar { margin-left: var(--sidebar-w); }
.topright { position: fixed; top: 10px; right: 16px; font-size: 0.8rem; color: #1f3a5f; z-index: 5; }

/* landing splash */
body.landing { background: #fff; }
body.landing .container { max-width: none; }
.watermark {
  position: fixed; top: 0; bottom: 0; left: var(--sidebar-w); right: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 28px; opacity: 0.16; pointer-events: none; user-select: none;
}
.wm-peach { width: min(36vw, 420px); }
.wm-name { width: min(62vw, 900px); }
.version-tag { position: fixed; right: 16px; bottom: 14px; font-size: 0.8rem; color: #333; }

/* login portal */
body.login-page {
  min-height: 100vh; margin: 0;
  background: linear-gradient(180deg, #45484d 0%, #1b1c1e 55%, #050505 100%);
  display: flex; align-items: center; justify-content: center;
}
.login-wrap { width: min(720px, calc(100vw - 32px)); }
.login-title { color: #fff; text-align: center; font-size: 1.25rem; letter-spacing: 0.04em; margin-bottom: 14px; }
.login-card { margin: 0; box-shadow: 0 10px 40px rgba(0,0,0,.5); }
.login-top {
  height: 80px; position: relative;
  background: linear-gradient(180deg, #6d6d6d 0%, #111 100%);
}
.login-badge {
  position: absolute; left: 50%; top: 12px; transform: translateX(-50%);
  width: 104px; height: 104px; object-fit: contain;
  background: #fff; border-radius: 50%; padding: 12px;
  box-shadow: 0 4px 14px rgba(0,0,0,.45);
}
.login-body {
  background: linear-gradient(180deg, #ececec 0%, #cfcfcf 100%);
  padding: 70px 20px 60px; display: flex; flex-direction: column; align-items: center; gap: 28px;
}
.login-body .flash { width: min(334px, 100%); margin: 0; }
.login-field { display: flex; width: min(334px, 100%); height: 46px; }
.login-icon {
  width: 46px; flex: 0 0 46px; background: var(--brand-red); color: #111;
  display: flex; align-items: center; justify-content: center;
}
.login-field input {
  flex: 1; min-width: 0; border: 1px solid #d0d0d0; border-left: none;
  padding: 0 12px; font-size: 1rem; background: #fff;
}
.login-field input:focus { outline: 2px solid var(--brand-red); outline-offset: -2px; }
.login-foot {
  background: #000; padding: 16px 12px 16px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.login-logos { display: flex; align-items: center; gap: 14px; }
.foot-gmf { height: 26px; filter: brightness(0) invert(1); }
.foot-sep { width: 1px; height: 30px; background: #555; }
.foot-rr { height: 52px; margin: -8px 0; }
.login-btn {
  background: var(--brand-red); color: #fff; font-weight: 700; letter-spacing: 0.03em;
  padding: 9px 26px; margin: 0; border-radius: 3px;
}
.login-btn:hover { background: var(--brand-red-dark); }
.login-version { text-align: right; color: #888; font-size: 0.75rem; margin-top: 8px; }

@media (max-width: 640px) {
  :root { --sidebar-w: 72px; }
  .side-item { font-size: 0.7rem; }
  .side-logo img { width: 48px; height: 48px; }
  .topright { display: none; }
}


/* landing ticker */
.ticker {
  position: fixed; left: var(--sidebar-w); right: 0; bottom: 0; height: 40px;
  display: flex; align-items: stretch; background: #111; color: #eee;
  font-size: 0.9rem; z-index: 6; border-top: 3px solid var(--brand-red);
}
.ticker[hidden] { display: none; }
.ticker-label {
  flex: 0 0 auto; display: flex; align-items: center; padding: 0 16px;
  background: var(--brand-red); color: #fff; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; font-size: 0.8rem;
}
.ticker-viewport { flex: 1; overflow: hidden; position: relative; }
.ticker-track {
  position: absolute; top: 0; bottom: 0; left: 0; display: flex; align-items: center;
  white-space: nowrap; animation: ticker-scroll 120s linear infinite; will-change: transform;
}
.ticker:hover .ticker-track { animation-play-state: paused; }
@keyframes ticker-scroll { from { transform: translateX(0); } to { transform: translateX(-50%); } }
.tick { padding: 0 28px; color: #eee; text-decoration: none; border-right: 1px solid #333; }
a.tick:hover { color: #fff; text-decoration: underline; }
.tick b { font-weight: 700; margin-right: 4px; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; }
.tick-weather b { color: #7cc6ff; }
.tick-date b { color: #f5a36c; }
.tick-fact b { color: #8fd18a; }
.tick-news b { color: #ff7a8a; }
body.landing .version-tag { bottom: 52px; }
@media (prefers-reduced-motion: reduce) {
  .ticker-track { animation: none; position: static; overflow-x: auto; }
}


/* EN / ES toggle */
.lang-toggle { display: flex; border: 1px solid #bbb; border-radius: 14px; overflow: hidden; margin: 6px 0 8px; font-size: 0.72rem; font-weight: 700; }
.lang-toggle a { padding: 3px 9px; color: #444; text-decoration: none; background: #fff; }
.lang-toggle a.on { background: var(--brand-red); color: #fff; }
.lang-toggle a:not(.on):hover { background: #e6e6e6; }
.login-lang { display: flex; justify-content: flex-end; margin-bottom: 6px; }
.login-lang .lang-toggle { border-color: #666; margin: 0; }
.login-lang .lang-toggle a { background: #222; color: #ccc; }
.login-lang .lang-toggle a.on { background: var(--brand-red); color: #fff; }
.draft-note { font-size: 0.78rem; color: #8a5a00; background: #fff6e0; border: 1px solid #f0dca8; border-radius: 5px; padding: 4px 10px; margin-bottom: 12px; display: inline-block; }
body.landing .draft-note { position: fixed; top: 34px; right: 16px; z-index: 5; }
.test-banner { font-weight: 700; color: #fff; background: #b3261e; border-radius: 5px; padding: 6px 12px; margin-bottom: 12px; text-align: center; letter-spacing: 0.02em; }


/* Predicted Usage Calculator */
.btn-usage { margin: 0 0 0 auto; background: var(--brand-red); white-space: nowrap; }
.btn-usage:hover { background: var(--brand-red-dark); }
.usage-head { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 14px; }
.usage-head label, form.card > label { display: block; margin: 0 0 4px; font-size: 0.88rem; color: var(--muted); }
.usage-head input, .usage-lines select, .usage-lines input, form.card > textarea {
  width: 100%; padding: 7px 9px; border: 1px solid var(--border); border-radius: 5px; font-size: 0.95rem;
}
.usage-lines td { padding: 5px 8px; }

.print-bar { display: flex; gap: 8px; margin-bottom: 14px; }
.print-bar button, .print-bar .btn { margin-top: 0; }
.sheet { background: #fff; border: 1px solid var(--border); padding: 22px 26px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 3px solid var(--brand-red); padding-bottom: 10px; margin-bottom: 8px; }
.sheet-logo { height: 30px; }
.sheet-logo.rr { height: 54px; }
.sheet-title { text-align: center; flex: 1; }
.sheet-title h1 { margin: 0; font-size: 1.45rem; }
.sheet-sub { font-size: 0.9rem; color: #333; }
.sheet h2 { font-size: 1.05rem; margin: 18px 0 6px; }
.sheet h3 { font-size: 0.95rem; margin: 16px 0 6px; }
.sheet table { margin-bottom: 8px; }
.sheet table.compact td, .sheet table.compact th { padding: 4px 8px; font-size: 0.82rem; }
.check-col { width: 70px; text-align: center; }
.sheet-notes { white-space: pre-wrap; border: 1px solid var(--border); padding: 8px 10px; }
.sheet-foot { font-size: 0.78rem; color: #555; margin-top: 14px; }
.signoff { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; margin-top: 34px; font-size: 0.82rem; }
.signoff span { display: block; border-bottom: 1px solid #000; height: 28px; margin-bottom: 4px; }
.sheet-version { text-align: right; font-size: 0.7rem; color: #888; margin-top: 12px; }

@media print {
  @page { size: letter portrait; margin: 0.45in; }
  .sidebar, .topright, .no-print, .draft-note, .flash { display: none !important; }
  main.with-sidebar { margin-left: 0; }
  body { background: #fff; }
  .container { max-width: none; padding: 0; }
  .sheet { border: none; padding: 0; }
  th { background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  tr.total td { background: #f0f0f0 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .sheet-head { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  tr, .signoff { page-break-inside: avoid; }
  h2, h3 { page-break-after: avoid; }
}


@media print {
  .sheet th, .sheet td { padding: 3px 7px; font-size: 0.78rem; }
  .sheet table.compact th, .sheet table.compact td { padding: 2px 6px; font-size: 0.72rem; }
  .sheet h2 { font-size: 0.95rem; margin: 10px 0 4px; }
  .sheet h3 { font-size: 0.85rem; margin: 10px 0 4px; }
  .sheet-head { padding-bottom: 6px; }
  .sheet-title h1 { font-size: 1.25rem; }
  .sheet-notes { padding: 4px 8px; font-size: 0.8rem; margin: 0; }
  .sheet-foot { margin-top: 8px; font-size: 0.7rem; }
  .signoff { margin-top: 22px; }
  .signoff span { height: 22px; }
}


/* Predicted Usage: lines & shifts */
tr.subtotal td { font-weight: 600; background: #f7f7f7; font-style: italic; }
.usage-matrix td.col-total, .usage-matrix th.col-total { background: #f6f6f6; font-weight: 600; }
.usage-matrix td.col-day, .usage-matrix th.col-day { background: #fdecef; }
.crew-page { margin-top: 24px; }
@media print {
  .crew-page { page-break-before: always; break-before: page; margin-top: 0; }
  .usage-matrix td.col-total, .usage-matrix th.col-total,
  .usage-matrix td.col-day, .usage-matrix th.col-day,
  tr.subtotal td { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

.nowrap { white-space: nowrap; }

.flash.warn { background: #fff6e0; color: #7a5200; border: 1px solid #f0dca8; }

.components td.stage-cell { vertical-align: top; min-width: 150px; }
.muted.small { font-size: 0.75rem; }
.calc-note { font-size: 0.82rem; color: #444; background: #f6f8f7; border: 1px solid var(--border); border-left: 4px solid var(--accent); padding: 8px 12px; margin: -10px 0 18px; }

/* v1.6: page locator and room for the info bar on every page */
.crumbs { font-size: 0.95rem; margin: 0 0 10px; }
.crumbs a { color: var(--brand-red); font-weight: 600; text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
.crumbs .here { color: #222; font-weight: 700; }
.crumbs .sep { margin: 0 6px; color: #999; }
/* one back button on every page, right of the locator (10/19/2026) */
.crumbs { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0; }
.crumbs a.crumb-back { order: 2; margin-left: auto; padding-left: 16px; font-weight: 600; white-space: nowrap; }
body.has-ticker main { padding-bottom: 56px; }


/* ===== v1.7 layout: top bar + tile navigation (replaces the left rail) ===== */
:root { --sidebar-w: 0px; --topbar-h: 58px; }
.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-h); z-index: 10;
  display: flex; align-items: center; gap: 6px; padding: 0 12px;
  background: #f1f1f1; border-bottom: 2px solid #3a3a3a;
}
.tb-logo img { width: 44px; height: 44px; object-fit: contain; border-radius: 50%; background: #fff; padding: 4px; border: 1px solid #d6d6d6; display: block; }
.tb-item {
  display: flex; align-items: center; gap: 6px; padding: 8px 12px; margin: 0;
  color: #2f2f2f; text-decoration: none; font: 600 0.9rem/1 inherit; font-family: inherit;
  background: none; border: none; border-radius: 6px; cursor: pointer;
}
.tb-item svg, .tb-user svg { width: 22px; height: 22px; }
.tb-item:hover, button.tb-item:hover { background: #e2e2e2; color: #000; }
.tb-item.active { color: var(--brand-red); background: #fff; box-shadow: inset 0 -3px 0 var(--brand-red); }
.topbar form { margin: 0; }
.tb-spacer { flex: 1; }
.tb-user { display: flex; align-items: center; gap: 4px; font-size: 0.85rem; color: #1f3a5f; margin-right: 6px; }
.topbar .lang-toggle { margin: 0 6px; }
.tb-rr { height: 40px; margin-left: 6px; }
main.with-topbar { padding-top: var(--topbar-h); }
.watermark { top: var(--topbar-h); }
body.landing .draft-note { top: calc(var(--topbar-h) + 8px); }

/* tiles: Home groups and group landing pages (same look as Improve) */
.hub-wrap { position: relative; max-width: 1150px; margin: 0 auto; }
.hub-wrap h1 { margin: 6px 0 14px; }
.hubtiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin: 12px 0 22px; }
.hubtiles.home { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.hubtile {
  display: flex; flex-direction: column; background: #fff; color: inherit; text-decoration: none;
  border: 1px solid #e3e5e8; border-left: 5px solid var(--brand-red); border-radius: 8px;
  padding: 14px 16px; min-height: 122px; box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.hubtile:hover { border-color: var(--brand-red); background: #fffaf9; }
.hubtile:focus-visible { outline: 3px solid var(--brand-red); outline-offset: 2px; }
.hubtile .ic { color: var(--brand-red); }
.hubtile .ic svg { width: 34px; height: 34px; }
.hubtile h2 { margin: 6px 0 4px; font-size: 1.15rem; }
.hubtile .b { font-size: 0.85rem; color: #6b7280; line-height: 1.35; flex: 1; }
.hubtile.big { min-height: 210px; padding: 18px 20px; }
.hubtile.big .ic svg { width: 48px; height: 48px; }
.hubtile.big h2 { font-size: 1.45rem; }
.hubtile .mods { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 12px; }
.hubtile .mods span { font-size: 0.75rem; padding: 2px 9px; border-radius: 10px; background: #f3ece4; color: #444; }
.hub-title { display: flex; align-items: center; gap: 10px; }
.hub-title .ic { color: var(--brand-red); display: flex; }
.hub-title .ic svg { width: 32px; height: 32px; }

@media (max-width: 640px) {
  .tb-item span, .tb-user { display: none; }
  .tb-rr { display: none; }
}
@media print {
  .topbar { display: none !important; }
  main.with-topbar { padding-top: 0; }
}
