/* Plantwide Integration - light mode application styles.
   Industrial reference-tool aesthetic: white surfaces, steel-blue accent,
   high-contrast text for shop-floor legibility. */

:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #eef1f4;
  --border: #d7dee5;
  --text: #1a2430;
  --text-muted: #5c6b7a;
  --accent: #2a8fba;
  --accent-strong: #14547a;
  --accent-soft: #e7f1f7;
  --danger: #b5321f;
  --danger-soft: #fbe9e6;
  --warn: #c47f18;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(20, 40, 60, 0.06), 0 4px 16px rgba(20, 40, 60, 0.06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Static-data banner - persistent honesty guarantee. */
.static-banner {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  background: var(--warn);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  padding: 0.4rem 1rem;
  text-align: center;
  justify-content: center;
}
.static-banner__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.35);
}

/* Retired-site notice: this hosted copy has moved to Plantwide's own server. */
.moved-banner {
  background: #b3261e;
  color: #fff;
  padding: 12px 16px;
  font-size: 15px;
  line-height: 1.5;
  text-align: center;
}
.moved-banner a {
  color: #fff;
  font-weight: 700;
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  /* Wrap onto a second line instead of overflowing. Eight nav links do not fit
     a phone, and a header you have to scroll sideways hides its last item -
     which here is Sign out. */
  flex-wrap: wrap;
  row-gap: .5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.7rem 1.25rem;
}
.app-header__brand { display: flex; align-items: center; gap: 0.6rem; }
.app-header__mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
}
.app-header__title { font-weight: 700; font-size: 1.05rem; }
.app-header__nav { display: flex; flex-wrap: wrap; gap: .45rem 1rem; justify-content: flex-end; }
.app-header__link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
}
.app-header__link:hover { color: var(--accent-strong); }

/* Main */
.app-main {
  flex: 1;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1.25rem;
}

/* Reading pages want a 960px measure; a working surface wants the whole window.
   Opt in per page with {% block main_class %}app-main--full{% endblock %} rather
   than a 100vw escape hatch, which fights the scrollbar and overflows. */
.app-main--full {
  max-width: none;
  padding: 0;
}

/* Footer */
.app-footer {
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 1rem 1.25rem;
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
}
.app-footer__sep { opacity: 0.5; }

/* Login */
.login {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 3rem;
}
.login__card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem;
  width: 100%;
  max-width: 380px;
}
.login__title { margin: 0 0 0.35rem; font-size: 1.35rem; }
.login__subtitle { margin: 0 0 1.4rem; color: var(--text-muted); font-size: 0.92rem; }
.login__form { display: flex; flex-direction: column; gap: 0.55rem; }
.login__label { font-size: 0.82rem; font-weight: 600; color: var(--text-muted); }
.login__input {
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 1rem;
  background: var(--surface);
  color: var(--text);
}
/* Deliberately :focus, not :focus-visible. That pseudo-class exists to stop
   buttons and links drawing a ring on mouse click; a text input SHOULD show
   where typing will land however it was reached, and this rule replaces the
   outline it removes with an equally visible box-shadow. :focus-visible is
   used where it belongs - app.css .result__view and workspace.css .ws-tab. */
.login__input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.login__button {
  margin-top: 0.4rem;
  padding: 0.7rem 1rem;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-size: 0.98rem;
  font-weight: 600;
  cursor: pointer;
}
.login__button:hover { background: var(--accent-strong); }
.login__error {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid #eecac3;
  border-radius: 6px;
  padding: 0.55rem 0.75rem;
  font-size: 0.88rem;
  margin-bottom: 1rem;
}
.login__note { margin: 1.2rem 0 0; font-size: 0.78rem; color: var(--text-muted); }

/* Home */
.home__hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2.25rem;
}
.home__title { margin: 0 0 0.6rem; font-size: 1.7rem; }
.home__lead { margin: 0 0 1.5rem; color: var(--text-muted); max-width: 60ch; }
.home__search { display: flex; gap: 0.5rem; }
.home__search-input {
  flex: 1;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 1rem;
}
.home__search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.home__search-button {
  padding: 0.75rem 1.4rem;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}
.home__search-button:hover { background: var(--accent-strong); }
.home__hint { margin: 1rem 0 0; font-size: 0.8rem; color: var(--text-muted); }

/* Search */
.search__bar { display: flex; gap: 0.5rem; margin-bottom: 1.25rem; }
.search__input {
  flex: 1; padding: 0.7rem 0.9rem; border: 1px solid var(--border);
  border-radius: 6px; font-size: 1rem; background: var(--surface); color: var(--text);
}
.search__input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search__button {
  padding: 0.7rem 1.3rem; border: none; border-radius: 6px; background: var(--accent);
  color: #fff; font-weight: 600; cursor: pointer;
}
.search__button:hover { background: var(--accent-strong); }
.search__hint, .search__empty { color: var(--text-muted); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; }

.search__layout { display: grid; grid-template-columns: 190px 1fr; gap: 1.25rem; align-items: start; }
.facets { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0.75rem; position: sticky; top: 0.75rem; }
.facets__title { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted); font-weight: 700; margin-bottom: 0.5rem; }
.facet { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem;
  padding: 0.4rem 0.55rem; border-radius: 6px; text-decoration: none; color: var(--text);
  font-size: 0.9rem; }
.facet:hover { background: var(--surface-2); }
.facet--on { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }
.facet__n { color: var(--text-muted); font-size: 0.8rem; }

.results__count { color: var(--text-muted); font-size: 0.9rem; margin: 0.2rem 0 1rem; }
.broadened { color: var(--warn); font-style: italic; }
.result { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1rem 1.15rem; margin-bottom: 0.85rem; }
.result__head { display: flex; align-items: center; gap: 0.55rem; flex-wrap: wrap; margin-bottom: 0.4rem; }
.result__title { margin: 0; font-size: 1.02rem; font-weight: 600; flex: 1 1 60%; }
.result__snippet { margin: 0.2rem 0 0.6rem; color: var(--text); font-size: 0.92rem; line-height: 1.5; }
.result__snippet mark { background: #fdeeb8; color: inherit; padding: 0 1px; border-radius: 2px; }
.result__meta { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
  font-size: 0.8rem; color: var(--text-muted); }
.chip { background: var(--surface-2); border-radius: 999px; padding: 0.1rem 0.6rem; font-size: 0.76rem; }
.source { margin-left: auto; display: flex; align-items: center; gap: 0.4rem; }
.source__label { font-weight: 600; }
.source code { background: var(--surface-2); padding: 0.05rem 0.35rem; border-radius: 4px;
  font-size: 0.78rem; color: var(--accent-strong); }
.source__how { font-style: italic; }
.result__view { margin-left: 0.15rem; padding: 0.12rem 0.6rem; border: 1px solid var(--accent);
  border-radius: 999px; color: var(--accent-strong); text-decoration: none; font-size: 0.76rem;
  font-weight: 600; white-space: nowrap; }
.result__view:hover { background: var(--accent); color: #fff; }
.result__view:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }

.badge { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
  padding: 0.12rem 0.5rem; border-radius: 999px; color: #fff; white-space: nowrap; }
.badge-ticket { background: #2a8fba; }
.badge-plc { background: #7a3ea1; }
.badge-hmi { background: #2a8f6d; }
.badge-schem { background: #b5701f; }
.badge-io { background: #4a5a86; }
.badge-note { background: #5c6b7a; }
.sev { font-size: 0.68rem; font-weight: 700; text-transform: uppercase; padding: 0.1rem 0.45rem;
  border-radius: 4px; }
.sev--major { background: var(--danger-soft); color: var(--danger); }
.sev--warning { background: #fdeeb8; color: #8a5a00; }
.sev--minor { background: #eef7e6; color: #4a7a1a; }

@media (max-width: 640px) {
  .search__layout { grid-template-columns: 1fr; }
  .facets { position: static; display: flex; flex-wrap: wrap; gap: 0.4rem; }
  .facets__title { width: 100%; }
  .source { margin-left: 0; }
}

@media (max-width: 560px) {
  .app-header { padding: 0.6rem 1rem; }
  .app-header__nav { width: 100%; justify-content: flex-start; gap: .4rem .9rem; }
  .app-header__link { font-size: 0.86rem; }
  .app-main { padding: 1.25rem 1rem; }
  .home__hero { padding: 1.5rem; }
  .home__search { flex-direction: column; }
  .home__title { font-size: 1.4rem; }
}

/* ── Shared components ───────────────────────────────────────────────────────
   These were each copy-pasted into 5-6 template <style> blocks. Identical
   copies are worse than drifted ones: it means nobody has ever adjusted the
   component, which is exactly the sign it should live in one place. Two had
   already drifted by accident - .panel was a few pixels roomier on two of five
   screens, and .flag-ok was a badge on one screen and bare text on another. */

.missing { text-align: center; padding: 2.5rem 1.5rem; }
.missing__title { margin: 0 0 0.5rem; font-size: 1.25rem; }
.missing__lead { margin: 0 auto 1rem; color: var(--text-muted); max-width: 52ch; }
/* A provisional dossier is a real page, not the centred not-found panel:
   left-aligned and full width, or the copy sits in a ragged indent. */
.prov__lead { margin: 0 0 .75rem; color: var(--text-muted); max-width: 78ch; }

.panel { background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1.1rem 1.25rem; margin-bottom: 1rem; }
.panel__head { display: flex; align-items: baseline; gap: 0.5rem; margin-bottom: 0.7rem; }
.panel__title { margin: 0; font-size: 1.02rem; }
.panel__label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted); font-weight: 700; margin: 0 0 0.5rem; }

/* Extraction-quality meter. One component, two sizes: the list shows the compact
   variant, the detail page the full one. It used to be two unrelated widgets
   (.qmeter / .quality) rendering the SAME labelled-devices ratio, so a tech who
   learned to read one had to re-learn the other. */
.qmeter { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.qmeter__bar { position: relative; width: 84px; height: 8px; border-radius: 999px;
  background: var(--surface-2); overflow: hidden; flex: 0 0 auto; }
.qmeter__fill { position: absolute; inset: 0 auto 0 0; border-radius: 999px;
  background: #4a7a1a; }
.qmeter__fill--warn { background: var(--danger); }
.qmeter__text { font-size: 0.72rem; color: var(--text-muted); }
.qmeter--lg { gap: 1.3rem; }
.qmeter--lg .qmeter__bar { width: 160px; height: 10px; }
.qmeter--lg .qmeter__text { font-size: 0.8rem; }
.qmeter--review { border-left: 4px solid var(--danger); padding-left: 0.8rem; }
.qmeter--ok { border-left: 4px solid #4a7a1a; padding-left: 0.8rem; }

/* Sheet-QA status. All three are badges: "this one is fine" was previously bare
   muted text on the list and a full pill on the detail page - the state you most
   want to scan for was given the least visual weight, inconsistently. */
.flag-ok, .flag-review, .flag-mismatch {
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.03em; border-radius: 4px; padding: 0.15rem 0.5rem;
  display: inline-block; }
.flag-ok { background: #eef7e6; color: #4a7a1a; }
.flag-review { background: #fdf0dd; color: #8a5a00; }
.flag-mismatch { background: #fbe4e1; color: var(--danger); }

/* Pagination. Three screens had three implementations - /search omitted the
   total page count entirely, /sheets disabled the boundary link, /tickets just
   dropped it. One look, one behaviour. */
.pager { display: flex; align-items: center; gap: 0.8rem; margin: 1rem 0;
  font-size: 0.85rem; }
.pager__link { padding: 0.3rem 0.7rem; border: 1px solid var(--border);
  border-radius: var(--radius); text-decoration: none; color: var(--accent);
  background: var(--surface); }
.pager__link:hover { background: var(--surface-2); }
.pager__link--off { color: var(--text-muted); border-color: var(--border);
  opacity: 0.5; pointer-events: none; }
.pager__count { color: var(--text-muted); }

/* Accessible-name helpers. A compact control row (the /search scope bar, the
   feedback widget) has no room for visible labels, but a placeholder is not an
   accessible name: it disappears on input and speech-control cannot target it.
   A real <label> parked off-screen gives assistive tech and voice control the
   name while leaving the layout alone. */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
/* Skip link: visible only once focused, so keyboard users can jump the 8-link
   header nav that repeats on every page. */
.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--accent); color: #fff; padding: 0.6rem 1rem;
  border-radius: 0 0 5px 0; text-decoration: none;
}
.skip-link:focus { left: 0; }
