/* Design language borrowed from oegglobal.com:
   Inter body / Plus Jakarta Sans headings, ink #1d2630, brand blue #1a5789,
   deep navy #102237 panels, sky #bae6fd accents, 8-12px radii. */
:root {
  --bg: #f3f5f7;
  --surface: #ffffff;
  --border: #e2e5ea;
  --text: #1d2630;
  --muted: #64748b;
  --accent: #1a5789;
  --navy: #102237;
  --navy-2: #16304b;
  --sky: #bae6fd;
  --sky-2: #7dd3fc;
  --green: #12925c;
  --red: #d43a4c;
  --heading: "Plus Jakarta Sans", "Inter", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

/* ---------- app shell: fixed left sidebar + contextual top bar ---------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 248px; flex: 0 0 248px;
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-2) 100%);
  color: #dbe7f2;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.side-logo {
  display: block; margin: 16px 14px 10px;
  background: #fff; border-radius: 10px; padding: 10px 12px;
}
.side-logo img { display: block; width: 100%; height: auto; }
.side-app-title {
  font-family: var(--heading);
  text-align: center; color: #fff;
  font-size: 13.5px; font-weight: 700;
  letter-spacing: .18em; text-transform: uppercase;
  margin: 0 14px 4px; padding-bottom: 10px;
  border-bottom: 1px solid rgba(255,255,255,.12);
}

.side-nav { flex: 1; overflow-y: auto; padding: 6px 10px 12px; }
.side-label {
  font-family: var(--heading);
  font-size: 10.5px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  color: var(--sky-2); margin: 18px 10px 6px;
}
.side-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; margin: 2px 0;
  color: #cfdcea; text-decoration: none;
  font-size: 14px; font-weight: 500;
  border-radius: 8px; border-left: 3px solid transparent;
  transition: background .15s ease, color .15s ease;
}
.side-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.side-item.active {
  background: rgba(26,87,137,.55);
  color: #fff; font-weight: 600;
  border-left-color: var(--sky-2);
}
.side-item .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: rgba(186,230,253,.4); flex: 0 0 7px;
}
.side-item.active .dot, .side-item.mod .dot { background: var(--sky-2); }
.side-item.mod { font-weight: 600; }

.side-foot {
  padding: 14px 20px 16px;
  border-top: 1px solid rgba(255,255,255,.12);
  font-size: 13px;
}
.who-name { font-weight: 600; color: #fff; }
.who-role { color: var(--sky-2); font-size: 12px; margin: 2px 0 8px; }

.shell { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 22px; flex-wrap: wrap;
  background: rgba(255,255,255,.95); border-bottom: 1px solid var(--border);
  padding: 0 24px; min-height: 56px;
  position: sticky; top: 0; z-index: 10; backdrop-filter: blur(6px);
}
.module-title {
  font-family: var(--heading);
  font-size: 15px; font-weight: 700; color: var(--navy);
  padding-right: 18px; border-right: 1px solid var(--border);
}
.topbar nav { display: flex; gap: 4px; flex-wrap: wrap; align-self: stretch; }
.topbar nav a {
  display: flex; align-items: center;
  color: var(--muted); text-decoration: none;
  font-size: 14px; font-weight: 600;
  padding: 0 14px; border-bottom: 3px solid transparent; border-top: 3px solid transparent;
}
.topbar nav a:hover { color: var(--accent); }
.topbar nav a.active { color: var(--accent); border-bottom-color: var(--accent); }
.signout { display: flex; align-items: center; gap: 10px; }
.who { color: var(--muted); font-size: 13px; }
button.link {
  background: none; border: none; color: var(--sky-2);
  cursor: pointer; font-size: 13px; padding: 0; font-weight: 600;
}
button.link:hover { text-decoration: underline; }

main { width: 100%; max-width: 1160px; margin: 0 auto; padding: 26px 26px 60px; }

/* ---------- login (anonymous) ---------- */
body.anon {
  background:
    radial-gradient(1000px 500px at 85% -10%, rgba(26,87,137,.55), transparent 60%),
    radial-gradient(700px 420px at -10% 110%, rgba(125,211,252,.18), transparent 55%),
    var(--navy);
  min-height: 100vh;
}
.anon-main { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; }
.login-wrap { width: 100%; max-width: 400px; }
.login-card {
  background: var(--surface); border-radius: 14px;
  padding: 30px 30px 26px;
  box-shadow: 0 24px 60px rgba(4,12,24,.45);
}
.login-brand { margin-bottom: 18px; }
.login-brand img { width: 200px; max-width: 70%; height: auto; display: block; }
.login-card h1 {
  font-family: var(--heading);
  font-size: 21px; font-weight: 800; color: var(--navy);
  letter-spacing: -.01em; margin-bottom: 2px;
}
.login-sub { color: var(--muted); font-size: 13.5px; }
.login-foot { text-align: center; color: rgba(219,231,242,.55); font-size: 12.5px; margin-top: 18px; letter-spacing: .04em; }
button.primary.wide { width: 100%; text-align: center; }
.anon-main .flash { width: 100%; max-width: 400px; margin-bottom: 14px; }
.anon-main .flash.error { background: rgba(212,58,76,.92); color: #fff; }

.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-wrap { overflow-x: auto; margin-top: 8px; }
.po-block { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.po-block:first-of-type { border-top: none; padding-top: 0; }
.po-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 4px; }
.vendor-form select { max-width: 640px; }
code { font-size: 12.5px; background: #eef0f4; padding: 1px 5px; border-radius: 4px; }
input.qty { width: 5.5rem; padding: 6px 8px; }
a.button.compact { margin: 0 0 0 8px; padding: 4px 10px; font-size: 12px; }
.filelist { list-style: none; }
.filelist li { padding: 6px 0; border-bottom: 1px solid var(--border); }
.filelist li:last-child { border-bottom: none; }
pre.ocr-notes {
  white-space: pre-wrap; font-size: 12.5px; background: #f1f2f4;
  padding: 10px 12px; border-radius: 8px; overflow-x: auto;
}

h1 {
  font-family: var(--heading);
  font-size: 24px; font-weight: 800; color: var(--navy);
  letter-spacing: -.015em; margin-bottom: 14px;
}
h2 {
  font-family: var(--heading);
  font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em;
  color: var(--accent); margin-bottom: 12px;
}
h3 { font-family: var(--heading); font-size: 15px; font-weight: 700; color: var(--navy); margin: 16px 0 8px; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 20px; margin-bottom: 18px;
  box-shadow: 0 1px 2px rgba(16,34,55,.05);
}
.card.narrow { max-width: 380px; margin: 60px auto; }

label { display: block; font-size: 13px; font-weight: 600; margin: 14px 0 5px; }
input, select, textarea {
  width: 100%; padding: 10px 11px; font-size: 15px;
  border: 1px solid var(--border); border-radius: 8px; background: #fff; font-family: inherit;
}
input:disabled { background: #f1f2f4; color: var(--muted); }
button:disabled, button.primary:disabled {
  opacity: .45; cursor: not-allowed; filter: grayscale(.2);
}
input[type=checkbox] { width: auto; margin-right: 8px; }
label.check { display: flex; align-items: center; font-weight: 400; font-size: 14px; }

button.primary, a.primary.button {
  display: inline-block; margin-top: 16px; padding: 10px 20px;
  background: var(--accent); color: #fff; border: none; border-radius: 8px;
  font-size: 15px; font-weight: 600; cursor: pointer; text-decoration: none;
  transition: background .15s ease;
}
button.primary:hover, a.primary.button:hover { background: var(--navy-2); }
a.button {
  display: inline-block; margin-top: 16px; margin-left: 8px; padding: 10px 18px;
  border: 1px solid var(--border); border-radius: 8px; text-decoration: none; color: var(--text);
}

.hint { font-size: 12.5px; color: var(--muted); margin-top: 5px; }

/* ---------- onboarding & guide components ---------- */

/* process flow strip: boxes joined by arrows */
.flow { display: flex; align-items: stretch; flex-wrap: wrap; gap: 12px 26px; margin: 14px 0 6px; }
.flow-step {
  position: relative; flex: 1 1 150px; min-width: 150px; max-width: 240px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 11px 13px;
}
.flow-step:not(:last-child)::after {
  content: '➜'; position: absolute; right: -22px; top: 50%;
  transform: translateY(-50%); color: var(--accent); font-size: 15px;
}
.flow-step .stepno {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 11.5px; font-weight: 700;
  margin-bottom: 6px;
}
.flow-step .t { display: block; font-family: var(--heading); font-weight: 700; font-size: 13px; color: var(--navy); }
.flow-step .d { display: block; font-size: 12px; color: var(--muted); margin-top: 3px; line-height: 1.35; }
.flow-step.sap { border-style: dashed; border-color: rgba(26,87,137,.5); background: #f4f8fc; }
.flow-step.sap .stepno { background: var(--navy); }
.flow-step.auto .stepno { background: var(--green); }
.flow-legend { display: flex; gap: 18px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 10px; }
.flow-legend .k { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.flow-legend .k.app { background: var(--accent); }
.flow-legend .k.sap { background: #f4f8fc; border: 1px dashed rgba(26,87,137,.6); }
.flow-legend .k.auto { background: var(--green); }

/* collapsible "how this works" explainer */
details.howto {
  background: #eef5fb; border: 1px solid rgba(26,87,137,.25);
  border-radius: 12px; margin-bottom: 18px;
}
details.howto summary {
  cursor: pointer; list-style: none; padding: 13px 18px;
  font-family: var(--heading); font-weight: 700; font-size: 14px; color: var(--accent);
}
details.howto summary::-webkit-details-marker { display: none; }
details.howto summary::before { content: 'ℹ '; }
details.howto[open] summary { border-bottom: 1px solid rgba(26,87,137,.15); }
details.howto .howto-body { padding: 14px 18px 16px; font-size: 14px; }
details.howto .howto-body p { margin-bottom: 8px; }
ol.steps { margin: 8px 0 4px 0; padding-left: 0; list-style: none; counter-reset: s; }
ol.steps li {
  counter-increment: s; position: relative; padding: 6px 0 6px 34px; line-height: 1.45;
}
ol.steps li::before {
  content: counter(s); position: absolute; left: 0; top: 6px;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
ol.steps li b { color: var(--navy); }

/* before / after value comparison */
.value-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 14px; margin-top: 10px; }
.value-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.value-card .vt { font-family: var(--heading); font-weight: 700; font-size: 13.5px; color: var(--navy); margin-bottom: 8px; }
.value-card .before, .value-card .after { font-size: 13px; padding-left: 20px; position: relative; margin-bottom: 6px; line-height: 1.4; }
.value-card .before { color: var(--muted); }
.value-card .before::before { content: '✕'; position: absolute; left: 0; color: var(--red); font-weight: 700; }
.value-card .after::before { content: '✓'; position: absolute; left: 0; color: var(--green); font-weight: 700; }
.guide-link-card { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.flash { padding: 11px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 14px; }
.flash.error { background: rgba(212,58,76,.1); color: var(--red); }
.flash.success { background: rgba(18,146,92,.1); color: var(--green); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px;
     color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--border); }
td { padding: 9px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: none; }
tr.inactive { opacity: .55; }
td.sites { max-width: 320px; font-size: 13px; color: var(--muted); }

.pill { font-size: 11.5px; font-weight: 600; padding: 2px 10px; border-radius: 999px;
        background: rgba(26,87,137,.1); color: var(--accent); white-space: nowrap; }
.pill.ok { background: rgba(18,146,92,.12); color: var(--green); }

.stats { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
        padding: 12px 18px; min-width: 120px; }
.stat .num { font-size: 22px; font-weight: 700; }
.stat .lbl { font-size: 12px; color: var(--muted); }

fieldset { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin-top: 16px; }
legend { font-size: 13px; font-weight: 600; padding: 0 6px; }
.sitegrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
            gap: 6px; max-height: 320px; overflow-y: auto; margin-top: 8px; }

.grpo-meta {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px 18px;
  margin-top: 10px;
}
.grpo-meta .lbl { display: block; font-size: 11.5px; text-transform: uppercase;
                  letter-spacing: .4px; color: var(--muted); margin-bottom: 2px; }
.grpo-meta .span2 { grid-column: span 2; }
.grpo-meta .num { font-weight: 700; }

.attach-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 10px;
}
.attach-card { margin: 0; }
.attach-card figcaption { font-size: 13px; margin-bottom: 8px; }
.attach-img { width: 100%; max-height: 420px; object-fit: contain;
              background: #0f1419; border: 1px solid var(--border); border-radius: 8px; }
.attach-frame { width: 100%; height: 420px; border: 1px solid var(--border);
                border-radius: 8px; background: #fff; }

/* Variance Desk */
.variance-hero { margin-bottom: 18px; max-width: 40rem; }
.variance-hero.compact { max-width: 48rem; }
.variance-hero .eyebrow {
  font-size: 12px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 6px;
}
.variance-hero h1 { font-size: 28px; letter-spacing: -0.02em; margin-bottom: 8px; }
.variance-hero .lede { color: var(--muted); font-size: 15px; }
.variance-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 18px; }
.vstat {
  display: block; text-decoration: none; color: inherit;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 16px; transition: border-color .15s ease, transform .15s ease;
}
.vstat:hover { border-color: #b8c0cc; transform: translateY(-1px); }
.vstat .num { display: block; font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.vstat .lbl { display: block; font-size: 12px; color: var(--muted); margin-top: 4px; line-height: 1.3; }
.vstat.excess { border-color: rgba(212,58,76,.35); }
.vstat.excess .num { color: var(--red); }
.vstat.short { border-color: rgba(47,111,237,.35); }
.vstat.short .num { color: var(--accent); }
.howto { margin: 0; padding-left: 1.2rem; color: var(--text); font-size: 14px; }
.howto li { margin: 8px 0; }
.tabs { display: flex; gap: 14px; margin: 8px 0 14px; flex-wrap: wrap; }
.tabs a { text-decoration: none; color: var(--muted); font-weight: 600; font-size: 14px; padding-bottom: 4px; border-bottom: 2px solid transparent; }
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); }
.variance-table-card { padding-top: 8px; }
.variance-table td, .variance-table th { vertical-align: middle; }
.variance-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.big-num { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }
.crumb { margin-bottom: 10px; font-size: 13px; }
.pill.warn { background: rgba(212,58,76,.12); color: var(--red); }
.pill.info { background: rgba(47,111,237,.12); color: var(--accent); }
.variance-banner h2 { margin-bottom: 8px; }

@media (max-width: 800px) {
  .variance-stats { grid-template-columns: 1fr 1fr; }
  .variance-grid { grid-template-columns: 1fr; }
  .variance-hero h1 { font-size: 24px; }
}

/* The upload form is used one-handed on a phone, so controls get bigger
   targets and the layout drops to a single column early. */
/* Sidebar collapses to a horizontal module bar on small screens. */
@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; }
  .side-logo { width: 170px; margin: 12px auto 4px; }
  .side-nav { display: flex; align-items: center; gap: 2px; overflow-x: auto; padding: 6px 10px 10px; }
  .side-label { display: none; }
  .side-item { white-space: nowrap; border-left: none; border-bottom: 3px solid transparent; border-radius: 8px 8px 0 0; }
  .side-item.active { border-left: none; border-bottom-color: var(--sky-2); }
  .side-foot { display: flex; align-items: baseline; gap: 10px; padding: 8px 16px; }
  .who-role { margin: 0; }
  .topbar { padding: 0 14px; }
  main { padding: 18px 14px 50px; }
}

@media (max-width: 640px) {
  main { padding: 16px 12px 50px; }
  input, select, textarea { font-size: 16px; padding: 12px; }
  button.primary, a.primary.button { width: 100%; text-align: center; padding: 14px; }
  .sitegrid { grid-template-columns: 1fr; }
  table { font-size: 13px; }
  .grpo-meta .span2 { grid-column: span 1; }
  .attach-frame, .attach-img { max-height: 280px; height: 280px; }
  .variance-stats { grid-template-columns: 1fr; }
}
