/* ===========================================================================
   AYG Cake Production ERP - interface
   ---------------------------------------------------------------------------
   Light theme only, on purpose: one theme is one thing to learn and one thing
   to maintain.

   The look: a quiet white shell, bold colour reserved for the numbers that
   matter and the things that need attention. Colour is never the only signal -
   every coloured card also carries a word and an icon.
   =========================================================================== */

:root {
  /* Planes */
  --plane: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #fafbfd;
  --surface-sunk: #f1f3f8;

  /* Ink */
  --ink: #0f172a;
  --ink-2: #475069;
  --ink-muted: #7a8396;
  --ink-faint: #a3abbb;

  /* Hairlines */
  --line: #e8eaf0;
  --line-2: #d6dae3;

  /* Brand */
  --brand: #2563eb;
  --brand-strong: #1d4ed8;
  --brand-soft: #3b82f6;
  --brand-wash: #eef4ff;
  --brand-wash-2: #dbe7fe;

  /* Status. Each ships with an icon and a word - never colour alone. */
  --ok: #047857;
  --ok-wash: #e7f6ef;
  --warn: #b45309;
  --warn-wash: #fdf2e3;
  --crit: #be123c;
  --crit-wash: #fdeaee;
  --info: #1d4ed8;
  --info-wash: #eef4ff;

  /* Chart ink. Marks stay thin and single-hue; the loud colour on this page
     belongs to the headline cards, not to the data. */
  --series-1: #2a78d6;
  --series-1-wash: #e8f1fd;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --grid: #ecedf3;
  --axis: #d6dae3;

  /* Elevation */
  --shadow-1: 0 1px 2px rgba(15, 23, 42, .05), 0 1px 3px rgba(15, 23, 42, .04);
  --shadow-2: 0 2px 4px rgba(15, 23, 42, .05), 0 8px 20px -6px rgba(15, 23, 42, .10);
  --shadow-3: 0 4px 10px rgba(15, 23, 42, .07), 0 20px 44px -12px rgba(15, 23, 42, .18);
  --ring: 0 0 0 3px var(--brand-wash-2);

  /* Geometry */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 22px;
  --r-pill: 999px;
  --sidebar-w: 262px;

  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* Bootstrap bridge - its components inherit the design system. */
:root {
  --bs-body-font-family: var(--font);
  --bs-body-bg: var(--plane);
  --bs-body-color: var(--ink);
  --bs-border-color: var(--line);
  --bs-primary: #2563eb;
  --bs-primary-rgb: 37, 99, 235;
  --bs-link-color: var(--brand-strong);
  --bs-link-hover-color: var(--brand);
  --bs-border-radius: var(--r-md);
  --bs-border-radius-sm: var(--r-sm);
  --bs-border-radius-lg: var(--r-lg);
}

/* ---------------------------------------------------------------- base */
* { -webkit-tap-highlight-color: transparent; }

body {
  background: var(--plane);
  color: var(--ink);
  font-family: var(--font);
  font-size: .9rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--brand-strong); text-decoration: none; }
a:hover { color: var(--brand); text-decoration: underline; }
hr { border-color: var(--line); opacity: 1; }
::selection { background: var(--brand-wash-2); }

:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: var(--r-sm); }

* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--line-2);
  border-radius: var(--r-pill);
  border: 3px solid transparent;
  background-clip: content-box;
}

/* =========================================================== app shell */
.erp-shell { display: flex; min-height: 100vh; }

.erp-sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--line);
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  z-index: 1030;
}

.erp-brand {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: 1.1rem 1.1rem .9rem;
  flex-shrink: 0;
}
.erp-brand-mark {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: var(--r-md);
  display: grid;
  place-items: center;
  font-size: 1.25rem;
  color: #fff;
  background: linear-gradient(145deg, #8b5cf6, #6d28d9);
  box-shadow: 0 6px 16px -4px rgba(109, 40, 217, .5);
}
.erp-brand-text { min-width: 0; }
.erp-brand-text strong {
  display: block;
  font-size: 1.02rem;
  font-weight: 750;
  letter-spacing: -0.022em;
  line-height: 1.2;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.erp-brand-text span {
  display: block;
  font-size: .76rem;
  color: var(--ink-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.erp-nav { padding: .25rem .7rem 1rem; flex: 1 1 auto; overflow-y: auto; }

.erp-nav-section {
  padding: 1.15rem .55rem .4rem;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.erp-nav-link {
  display: flex;
  align-items: center;
  gap: .72rem;
  padding: .58rem .7rem;
  margin-bottom: 2px;
  border-radius: var(--r-md);
  color: var(--ink-2);
  font-size: .93rem;
  font-weight: 550;
  transition: background-color .12s ease, color .12s ease;
}
.erp-nav-link:hover { background: var(--surface-sunk); color: var(--ink); text-decoration: none; }
.erp-nav-link i { font-size: 1.02rem; color: var(--ink-muted); width: 1.3rem; flex: 0 0 1.3rem; text-align: center; }
.erp-nav-link span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1 1 auto; }

.erp-nav-link.active {
  background: var(--brand);
  color: #fff;
  font-weight: 650;
  box-shadow: 0 4px 12px -3px rgba(37, 99, 235, .55);
}
.erp-nav-link.active i { color: #fff; }

.nav-count {
  font-size: .7rem;
  font-weight: 700;
  padding: .1rem .42rem;
  border-radius: var(--r-pill);
  background: var(--crit);
  color: #fff;
  flex-shrink: 0;
}
.erp-nav-link.active .nav-count { background: rgba(255, 255, 255, .25); }

/* The signed-in user, pinned to the bottom of the rail. */
.erp-user {
  margin: .5rem .7rem .8rem;
  padding: .75rem;
  border-radius: var(--r-md);
  background: var(--surface-sunk);
  flex-shrink: 0;
}
.erp-user-row { display: flex; align-items: center; gap: .6rem; }
.avatar {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border-radius: var(--r-md);
  display: grid;
  place-items: center;
  font-size: .8rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(145deg, #475069, #0f172a);
}
.erp-user-text { min-width: 0; }
.erp-user-text strong {
  display: block;
  font-size: .86rem;
  font-weight: 650;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.erp-user-text span { display: block; font-size: .75rem; color: var(--ink-muted); }
.signout {
  margin-top: .6rem;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  background: none;
  border: 0;
  padding: 0;
  font-size: .8rem;
  font-weight: 600;
  color: var(--brand-strong);
}
.signout:hover { color: var(--brand); text-decoration: underline; }

.erp-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }

/* ---------------------------------------------------------------- topbar */
.erp-topbar {
  display: flex;
  align-items: center;
  gap: .9rem;
  padding: .95rem 1.6rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 1020;
}
.erp-heading { flex: 1 1 auto; min-width: 0; }
.erp-heading h1 {
  font-size: 1.3rem;
  font-weight: 750;
  letter-spacing: -0.028em;
  margin: 0;
  color: var(--ink);
}
.erp-heading p { margin: .12rem 0 0; font-size: .85rem; color: var(--ink-muted); }
.erp-topbar-actions { display: flex; align-items: center; gap: .5rem; flex-shrink: 0; }

.erp-content { padding: 1.5rem 1.6rem 4rem; flex: 1 1 auto; }

.icon-btn {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 1rem;
}
.icon-btn:hover { background: var(--surface-sunk); color: var(--ink); text-decoration: none; }

@media (max-width: 991.98px) {
  .erp-sidebar {
    position: fixed;
    transform: translateX(-100%);
    transition: transform .22s cubic-bezier(.4, 0, .2, 1);
  }
  .erp-sidebar.open { transform: translateX(0); box-shadow: var(--shadow-3); }
  .erp-content { padding: 1rem 1rem 3rem; }
  .erp-topbar { padding: .8rem 1rem; }
  .scrim {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .45);
    z-index: 1025;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
  }
  .scrim.show { opacity: 1; pointer-events: auto; }
}

/* ================================================================= cards */
.erp-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  margin-bottom: 1.15rem;
  overflow: hidden;
}
.erp-card-head {
  padding: .9rem 1.15rem;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .8rem;
  flex-wrap: wrap;
}
.erp-card-head h2 {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.018em;
  margin: 0;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: .45rem;
}
.erp-card-head h2 > i { color: var(--ink-muted); }
.erp-card-body { padding: 1.15rem; }
.erp-card-body.flush { padding: 0; }

/* ======================================================= headline cards */
/* A tile is quiet by default and loud only when it is given a tone. That way
   every screen gets one or two headline numbers and the rest stay supporting
   detail, without each template having to say so.

   A tile is chrome, not a chart mark - which is why the loud ones can carry a
   saturated fill. Each still shows a word and an icon, so the colour decorates
   the meaning rather than carrying it. */
.erp-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(234px, 1fr));
  gap: 1rem;
  margin-bottom: 1.3rem;
}

/* ---- quiet by default ---- */
.erp-stat,
.erp-stat.plain {
  position: relative;
  border-radius: var(--r-lg);
  padding: 1.05rem 1.2rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-1);
  color: var(--ink);
  overflow: hidden;
  isolation: isolate;
  min-width: 0;
}
.erp-stat .label {
  font-size: .73rem;
  font-weight: 750;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--ink-muted);
  display: flex;
  align-items: center;
  gap: .4rem;
  margin-bottom: .3rem;
}
.erp-stat .value {
  font-size: 1.85rem;
  font-weight: 750;
  line-height: 1.08;
  letter-spacing: -0.032em;
  color: var(--ink);
  /* Proportional figures: tabular widths make a big number look loose. */
  font-variant-numeric: proportional-nums;
  display: flex;
  align-items: baseline;
  gap: .3rem;
  flex-wrap: wrap;
}
.erp-stat .value .unit {
  font-size: .9rem;
  font-weight: 650;
  letter-spacing: 0;
  color: var(--ink-muted);
}
.erp-stat .hint {
  margin-top: .4rem;
  font-size: .81rem;
  color: var(--ink-muted);
  line-height: 1.4;
}
.erp-stat .hint a { color: var(--brand-strong); font-weight: 600; }

/* ---- loud, when a tone is named ---- */
.erp-stat.violet, .erp-stat.accent,
.erp-stat.blue, .erp-stat.info,
.erp-stat.green, .erp-stat.ok,
.erp-stat.orange,
.erp-stat.red, .erp-stat.danger,
.erp-stat.amber, .erp-stat.warn,
.erp-stat.teal,
.erp-stat.slate {
  border: 0;
  color: #fff;
  padding: 1.15rem 1.25rem 1.2rem;
  box-shadow: var(--shadow-2);
}
/* The soft disc in the corner. Purely decorative. */
.erp-stat.violet::after, .erp-stat.accent::after,
.erp-stat.blue::after, .erp-stat.info::after,
.erp-stat.green::after, .erp-stat.ok::after,
.erp-stat.orange::after,
.erp-stat.red::after, .erp-stat.danger::after,
.erp-stat.amber::after, .erp-stat.warn::after,
.erp-stat.teal::after,
.erp-stat.slate::after {
  content: "";
  position: absolute;
  right: -34px;
  top: -46px;
  width: 168px;
  height: 168px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .11);
  z-index: -1;
}
.erp-stat.violet .label, .erp-stat.accent .label,
.erp-stat.blue .label, .erp-stat.info .label,
.erp-stat.green .label, .erp-stat.ok .label,
.erp-stat.orange .label,
.erp-stat.red .label, .erp-stat.danger .label,
.erp-stat.amber .label, .erp-stat.warn .label,
.erp-stat.teal .label,
.erp-stat.slate .label { color: rgba(255, 255, 255, .88); }

.erp-stat.violet .value, .erp-stat.accent .value,
.erp-stat.blue .value, .erp-stat.info .value,
.erp-stat.green .value, .erp-stat.ok .value,
.erp-stat.orange .value,
.erp-stat.red .value, .erp-stat.danger .value,
.erp-stat.amber .value, .erp-stat.warn .value,
.erp-stat.teal .value,
.erp-stat.slate .value { color: #fff; font-size: 2.45rem; letter-spacing: -0.035em; }

.erp-stat.violet .value .unit, .erp-stat.accent .value .unit,
.erp-stat.blue .value .unit, .erp-stat.info .value .unit,
.erp-stat.green .value .unit, .erp-stat.ok .value .unit,
.erp-stat.orange .value .unit,
.erp-stat.red .value .unit, .erp-stat.danger .value .unit,
.erp-stat.amber .value .unit, .erp-stat.warn .value .unit,
.erp-stat.teal .value .unit,
.erp-stat.slate .value .unit { color: rgba(255, 255, 255, .82); }

.erp-stat.violet .hint, .erp-stat.accent .hint,
.erp-stat.blue .hint, .erp-stat.info .hint,
.erp-stat.green .hint, .erp-stat.ok .hint,
.erp-stat.orange .hint,
.erp-stat.red .hint, .erp-stat.danger .hint,
.erp-stat.amber .hint, .erp-stat.warn .hint,
.erp-stat.teal .hint,
.erp-stat.slate .hint { color: rgba(255, 255, 255, .86); }

.erp-stat.violet .hint a, .erp-stat.accent .hint a,
.erp-stat.blue .hint a, .erp-stat.info .hint a,
.erp-stat.green .hint a, .erp-stat.ok .hint a,
.erp-stat.orange .hint a,
.erp-stat.red .hint a, .erp-stat.danger .hint a,
.erp-stat.amber .hint a, .erp-stat.warn .hint a,
.erp-stat.teal .hint a,
.erp-stat.slate .hint a { color: #fff; text-decoration: underline; }

/* The fills themselves. */
.erp-stat.violet, .erp-stat.accent { background: linear-gradient(135deg, #7c3aed 0%, #a855f7 100%); }
.erp-stat.blue, .erp-stat.info { background: linear-gradient(135deg, #1d4ed8 0%, #3b82f6 100%); }
.erp-stat.green, .erp-stat.ok { background: linear-gradient(135deg, #047857 0%, #10b981 100%); }
.erp-stat.orange { background: linear-gradient(135deg, #c2410c 0%, #f97316 100%); }
.erp-stat.red, .erp-stat.danger { background: linear-gradient(135deg, #be123c 0%, #f43f5e 100%); }
.erp-stat.amber, .erp-stat.warn { background: linear-gradient(135deg, #b45309 0%, #f59e0b 100%); }
.erp-stat.teal { background: linear-gradient(135deg, #0f766e 0%, #14b8a6 100%); }
.erp-stat.slate { background: linear-gradient(135deg, #334155 0%, #64748b 100%); }

/* ============================================ "what state is this in" strip */
/* Spelled out above every document, because "draft versus confirmed" is the
   one thing non-technical users get wrong. */
.state-strip {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.1rem 1.25rem;
  border-radius: var(--r-lg);
  margin-bottom: 1.15rem;
  border: 1px solid transparent;
}
.state-icon {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border-radius: var(--r-md);
  display: grid;
  place-items: center;
  font-size: 1.25rem;
  background: rgba(255, 255, 255, .6);
}
.state-body { flex: 1 1 auto; min-width: 0; }
.state-body strong { display: block; font-size: 1.02rem; font-weight: 700; margin-bottom: .15rem; }
.state-body p { margin: 0; font-size: .9rem; line-height: 1.55; max-width: 74ch; opacity: .92; }
.state-action { flex-shrink: 0; align-self: center; }

.state-draft { background: var(--warn-wash); border-color: rgba(180, 83, 9, .25); color: var(--warn); }
.state-done { background: var(--ok-wash); border-color: rgba(4, 120, 87, .22); color: var(--ok); }
.state-cancelled { background: var(--crit-wash); border-color: rgba(190, 18, 60, .22); color: var(--crit); }

@media (max-width: 767.98px) {
  .state-strip { flex-wrap: wrap; }
  .state-action { width: 100%; }
  .state-action .btn { width: 100%; justify-content: center; }
}

/* A short list of consequences, used in the finish and cancel dialogs. */
.plain-list { list-style: none; padding: 0; margin: 0; }
.plain-list li {
  display: flex;
  align-items: flex-start;
  gap: .6rem;
  padding: .4rem 0;
  font-size: .92rem;
}
.plain-list li > i { font-size: 1.05rem; line-height: 1.4; flex-shrink: 0; }

/* ================================================================ wizard */
/* Numbered steps across the top of a split-up form. */
.wizard {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem 1.6rem;
  list-style: none;
  padding: 1rem 1.25rem;
  margin: 0 0 1.15rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  counter-reset: wizard;
}
.wizard-step {
  display: flex;
  align-items: center;
  gap: .55rem;
  font-size: .9rem;
  color: var(--ink-faint);
  font-weight: 600;
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
}
/* The connecting rule between steps. */
.wizard-step:not(:last-child)::after {
  content: "";
  flex: 1 1 auto;
  height: 2px;
  background: var(--line);
  border-radius: 2px;
  margin-left: .35rem;
  min-width: 1rem;
}
.wizard-dot {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: .85rem;
  font-weight: 700;
  background: var(--surface-sunk);
  color: var(--ink-faint);
  border: 2px solid var(--line);
}
.wizard-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.wizard-step.is-done { color: var(--ok); }
.wizard-step.is-done .wizard-dot {
  background: var(--ok);
  border-color: var(--ok);
  color: #fff;
}
.wizard-step.is-done:not(:last-child)::after { background: var(--ok); }

.wizard-step.is-current { color: var(--ink); }
.wizard-step.is-current .wizard-dot {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  box-shadow: 0 0 0 4px var(--brand-wash-2);
}

@media (max-width: 767.98px) {
  .wizard { gap: .5rem; flex-direction: column; }
  .wizard-step:not(:last-child)::after { display: none; }
  .wizard-step { flex: 0 0 auto; }
}

/* ============================================================= task tiles */
/* The front door: big, obvious buttons for the handful of jobs people
   actually come here to do. */
.tasks {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(252px, 1fr));
  gap: .9rem;
  margin-bottom: 1.4rem;
}
.task {
  display: flex;
  align-items: center;
  gap: .9rem;
  padding: 1.05rem 1.15rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  color: var(--ink);
  transition: box-shadow .14s ease, transform .14s ease, border-color .14s ease;
}
.task:hover {
  text-decoration: none;
  color: var(--ink);
  border-color: var(--brand);
  box-shadow: var(--shadow-2);
  transform: translateY(-2px);
}
.task-icon {
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  border-radius: var(--r-md);
  display: grid;
  place-items: center;
  font-size: 1.3rem;
  color: #fff;
}
.task-text { min-width: 0; }
.task-text strong {
  display: block;
  font-size: .98rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.25;
}
.task-text span { display: block; font-size: .82rem; color: var(--ink-muted); line-height: 1.4; }
.task-go { margin-left: auto; color: var(--ink-faint); font-size: 1.1rem; flex-shrink: 0; }
.task:hover .task-go { color: var(--brand); }

.task-violet .task-icon { background: linear-gradient(145deg, #8b5cf6, #6d28d9); }
.task-blue .task-icon { background: linear-gradient(145deg, #3b82f6, #1d4ed8); }
.task-green .task-icon { background: linear-gradient(145deg, #10b981, #047857); }
.task-orange .task-icon { background: linear-gradient(145deg, #f97316, #c2410c); }
.task-red .task-icon { background: linear-gradient(145deg, #f43f5e, #be123c); }
.task-teal .task-icon { background: linear-gradient(145deg, #14b8a6, #0f766e); }

/* --------------------------------------------- help text people will read */
.help-note {
  display: flex;
  gap: .65rem;
  align-items: flex-start;
  padding: .8rem 1rem;
  background: var(--info-wash);
  border: 1px solid rgba(29, 78, 216, .18);
  border-radius: var(--r-md);
  font-size: .88rem;
  color: var(--ink-2);
  line-height: 1.55;
  margin-bottom: 1.15rem;
}
.help-note > i { color: var(--info); font-size: 1.05rem; flex-shrink: 0; line-height: 1.4; }
.help-note strong { color: var(--ink); }

/* A term and its meaning, on the glossary page. */
.glossary dt {
  font-size: .95rem;
  font-weight: 700;
  color: var(--ink);
  margin-top: 1.1rem;
}
.glossary dt:first-child { margin-top: 0; }
.glossary dd {
  margin: .2rem 0 0;
  font-size: .9rem;
  color: var(--ink-2);
  line-height: 1.6;
  max-width: 72ch;
}
.glossary .also { font-size: .82rem; color: var(--ink-muted); }

/* ======================================================= attention banner */
/* The one thing a person must act on today. */
.banner {
  position: relative;
  border-radius: var(--r-lg);
  padding: 1.5rem 1.6rem;
  color: #fff;
  overflow: hidden;
  isolation: isolate;
  margin-bottom: 1.3rem;
  background: linear-gradient(120deg, #9f1239 0%, #e11d48 100%);
  box-shadow: var(--shadow-2);
}
.banner::after {
  content: "";
  position: absolute;
  right: -60px;
  top: -70px;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .09);
  z-index: -1;
}
.banner-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--r-md);
  display: grid;
  place-items: center;
  font-size: 1.45rem;
  background: rgba(255, 255, 255, .2);
  margin-bottom: .9rem;
}
.banner h2 {
  font-size: 1.45rem;
  font-weight: 750;
  letter-spacing: -0.028em;
  margin: 0 0 .4rem;
  color: #fff;
}
.banner p {
  margin: 0;
  font-size: .95rem;
  color: rgba(255, 255, 255, .92);
  max-width: 68ch;
  line-height: 1.5;
}
.banner .btn-banner {
  margin-top: 1rem;
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  background: rgba(255, 255, 255, .22);
  border: 1px solid rgba(255, 255, 255, .3);
  color: #fff;
  font-weight: 650;
  font-size: .9rem;
  padding: .55rem 1.1rem;
  border-radius: var(--r-md);
}
.banner .btn-banner:hover { background: rgba(255, 255, 255, .32); color: #fff; text-decoration: none; }

.banner.calm { background: linear-gradient(120deg, #047857 0%, #10b981 100%); }
.banner.info { background: linear-gradient(120deg, #1d4ed8 0%, #3b82f6 100%); }

/* ------------------------------------------------------ plain-English intro */
.lede {
  font-size: .95rem;
  color: var(--ink-2);
  max-width: 76ch;
  line-height: 1.6;
  margin: 0 0 1.1rem;
}
.section-head { margin: 1.9rem 0 .9rem; }
.section-head:first-child { margin-top: 0; }
.section-head h2 {
  font-size: 1.22rem;
  font-weight: 750;
  letter-spacing: -0.025em;
  margin: 0 0 .3rem;
  color: var(--ink);
}
.section-head p { margin: 0; font-size: .92rem; color: var(--ink-muted); max-width: 76ch; line-height: 1.55; }

/* ================================================================ tables */
.table-erp {
  margin: 0;
  font-size: .875rem;
  color: var(--ink);
  --bs-table-bg: transparent;
  --bs-table-color: var(--ink);
  --bs-table-border-color: var(--line);
  --bs-table-hover-bg: var(--surface-sunk);
  --bs-table-hover-color: var(--ink);
  --bs-table-striped-bg: var(--surface-2);
}
.table-erp > thead > tr > th {
  background: var(--surface-2);
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-muted);
  font-weight: 700;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
  padding: .65rem .85rem;
}
.table-erp td, .table-erp th { padding: .62rem .85rem; vertical-align: middle; border-color: var(--line); }
.table-erp > tbody > tr:last-child > td { border-bottom: 0; }
.table-erp tfoot td { font-weight: 700; background: var(--surface-2); border-top: 1px solid var(--line-2); }

/* Columns of figures line up, so these get tabular figures. */
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .83rem; }
.table-erp a { font-weight: 600; }

.table-view > summary {
  cursor: pointer;
  font-size: .8rem;
  font-weight: 600;
  color: var(--ink-muted);
  padding: .6rem 1.15rem;
  border-top: 1px solid var(--line);
  list-style: none;
  display: flex;
  align-items: center;
  gap: .35rem;
}
.table-view > summary::-webkit-details-marker { display: none; }
.table-view > summary::before {
  content: "\F282";
  font-family: bootstrap-icons;
  font-size: .72rem;
  transition: transform .15s ease;
}
.table-view[open] > summary::before { transform: rotate(90deg); }
.table-view > summary:hover { color: var(--ink); background: var(--surface-sunk); }

/* ================================================================= chips */
.badge-status {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-weight: 650;
  font-size: .72rem;
  padding: .28em .62em;
  border-radius: var(--r-pill);
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge.text-bg-success { background: var(--ok-wash) !important; color: var(--ok) !important; border-color: rgba(4, 120, 87, .25); }
.badge.text-bg-warning { background: var(--warn-wash) !important; color: var(--warn) !important; border-color: rgba(180, 83, 9, .25); }
.badge.text-bg-danger { background: var(--crit-wash) !important; color: var(--crit) !important; border-color: rgba(190, 18, 60, .25); }
.badge.text-bg-primary,
.badge.text-bg-info { background: var(--info-wash) !important; color: var(--info) !important; border-color: rgba(29, 78, 216, .25); }
.badge.text-bg-secondary,
.badge.text-bg-light { background: var(--surface-sunk) !important; color: var(--ink-2) !important; border-color: var(--line); }
.badge.text-bg-dark { background: #1e293b !important; color: #fff !important; }

/* ============================================================== buttons */
.btn {
  font-weight: 600;
  font-size: .88rem;
  border-radius: var(--r-md);
  padding: .48rem .95rem;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  transition: background-color .12s ease, border-color .12s ease, box-shadow .12s ease;
}
.btn-sm { font-size: .82rem; padding: .36rem .72rem; border-radius: var(--r-sm); }

.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  box-shadow: 0 3px 10px -2px rgba(37, 99, 235, .45);
}
.btn-primary:hover, .btn-primary:focus {
  background: var(--brand-strong);
  border-color: var(--brand-strong);
  color: #fff;
  box-shadow: 0 5px 14px -3px rgba(37, 99, 235, .55);
}
.btn-success { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-success:hover { background: #036249; border-color: #036249; color: #fff; }
.btn-danger { background: var(--crit); border-color: var(--crit); color: #fff; }
.btn-danger:hover { background: #9f1239; border-color: #9f1239; color: #fff; }
.btn-outline-primary { color: var(--brand-strong); border-color: var(--brand-wash-2); background: var(--surface); }
.btn-outline-primary:hover { background: var(--brand-wash); border-color: var(--brand); color: var(--brand-strong); }
.btn-outline-secondary { color: var(--ink-2); border-color: var(--line-2); background: var(--surface); }
.btn-outline-secondary:hover { background: var(--surface-sunk); border-color: var(--ink-faint); color: var(--ink); }
.btn-outline-danger { color: var(--crit); border-color: rgba(190, 18, 60, .3); background: var(--surface); }
.btn-outline-danger:hover { background: var(--crit-wash); border-color: var(--crit); color: var(--crit); }
.btn-light { background: var(--surface-sunk); border-color: var(--line); color: var(--ink); }
.btn-light:hover { background: var(--plane); border-color: var(--line-2); color: var(--ink); }
.btn-link { color: var(--brand-strong); font-weight: 600; }

/* ================================================================= forms */
.form-label { color: var(--ink-2); margin-bottom: .3rem; font-weight: 600; }
.form-label.small { font-size: .78rem; }
.form-control, .form-select {
  background: var(--surface);
  border: 1px solid var(--line-2);
  color: var(--ink);
  border-radius: var(--r-sm);
  font-size: .89rem;
  padding: .48rem .7rem;
  transition: border-color .12s ease, box-shadow .12s ease;
}
.form-control::placeholder { color: var(--ink-faint); }
.form-control:focus, .form-select:focus { border-color: var(--brand); box-shadow: var(--ring); }
.form-control:disabled, .form-control[readonly] { background: var(--surface-sunk); color: var(--ink-muted); }
.form-control-sm, .form-select-sm { font-size: .83rem; padding: .34rem .6rem; }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.form-check-input:focus { border-color: var(--brand); box-shadow: var(--ring); }
.form-check-label { color: var(--ink-2); }
.form-text { color: var(--ink-muted); font-size: .76rem; }

/* The search field in the top bar. */
.search-field { position: relative; flex: 1 1 auto; max-width: 480px; }
.search-field i {
  position: absolute;
  left: .85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-faint);
  font-size: .95rem;
  pointer-events: none;
}
.search-field input {
  width: 100%;
  padding: .6rem .9rem .6rem 2.5rem;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: var(--surface-sunk);
  font-size: .9rem;
  color: var(--ink);
}
.search-field input:focus {
  outline: none;
  background: var(--surface);
  border-color: var(--brand);
  box-shadow: var(--ring);
}

.erp-filters { display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-end; }
.erp-filters .form-control, .erp-filters .form-select { min-width: 9.5rem; }
.erp-filters label { margin-bottom: .22rem; display: block; }

.erp-dl { display: grid; grid-template-columns: minmax(7rem, max-content) 1fr; gap: .55rem 1.1rem; margin: 0; align-items: baseline; }
.erp-dl dt { font-size: .78rem; color: var(--ink-muted); font-weight: 600; }
.erp-dl dd { margin: 0; font-size: .89rem; color: var(--ink); min-width: 0; }

/* ----------------------------------------------------------- line editor */
.formset-table { font-size: .85rem; }
.formset-table td { padding: .32rem .38rem; }
.formset-table input, .formset-table select { min-width: 5.6rem; }
.formset-table .form-control, .formset-table .form-select { padding: .3rem .5rem; font-size: .82rem; }
.formset-table .col-item { min-width: 13rem; }
.formset-table .col-narrow { width: 6.5rem; }
.formset-table .col-del { width: 3rem; text-align: center; }
.formset-table tbody tr:hover { background: var(--surface-2); }

/* =============================================================== alerts */
.alert {
  border-radius: var(--r-md);
  border: 1px solid transparent;
  font-size: .88rem;
  display: flex;
  align-items: flex-start;
  gap: .6rem;
  padding: .75rem .95rem;
}
.alert > i:first-child { font-size: 1.05rem; line-height: 1.3; flex-shrink: 0; }
.alert-success { background: var(--ok-wash); color: var(--ok); border-color: rgba(4, 120, 87, .22); }
.alert-warning { background: var(--warn-wash); color: var(--warn); border-color: rgba(180, 83, 9, .22); }
.alert-danger { background: var(--crit-wash); color: var(--crit); border-color: rgba(190, 18, 60, .22); }
.alert-info { background: var(--info-wash); color: var(--info); border-color: rgba(29, 78, 216, .22); }
.alert .btn-close { margin-left: auto; }

/* ========================================= dropdowns, modals, pagination */
.dropdown-menu {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-3);
  padding: .35rem;
  font-size: .88rem;
}
.dropdown-item { border-radius: var(--r-sm); color: var(--ink); padding: .45rem .65rem; }
.dropdown-item:hover { background: var(--surface-sunk); color: var(--ink); }
.dropdown-divider { border-color: var(--line); }

.modal-content { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-3); }
.modal-header, .modal-footer { border-color: var(--line); }
.modal-title { font-size: 1.05rem; font-weight: 700; }

.page-link { background: var(--surface); border-color: var(--line); color: var(--ink-2); font-size: .83rem; font-weight: 600; }
.page-link:hover { background: var(--surface-sunk); color: var(--ink); }
.page-item.active .page-link { background: var(--brand); border-color: var(--brand); color: #fff; }
.page-item.disabled .page-link { color: var(--ink-faint); }

/* ========================================================= empty states */
.empty { text-align: center; padding: 3.2rem 1.5rem; color: var(--ink-muted); }
.empty-icon {
  width: 58px;
  height: 58px;
  margin: 0 auto .9rem;
  border-radius: var(--r-lg);
  display: grid;
  place-items: center;
  font-size: 1.6rem;
  background: var(--surface-sunk);
  color: var(--ink-faint);
}
.empty p { margin: 0 0 .3rem; font-size: .96rem; color: var(--ink-2); font-weight: 550; }
.empty small { font-size: .84rem; }

/* ================================================================ charts */
/* Deliberately quiet: thin single-hue marks, hairline grid. The loud colour
   on this page belongs to the headline cards, never to the data. */
.chart { position: relative; padding: .4rem .5rem 0; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-grid line { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart-axis line { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.chart-tick { fill: var(--ink-muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.chart-xlabel { fill: var(--ink-muted); font-size: 10px; font-weight: 600; }
.chart-xlabel.is-today { fill: var(--brand-strong); font-weight: 750; }

/* One series, one colour - never a ramp by height, which would re-encode the
   bar length as hue. */
.bar-mark { fill: var(--series-1); rx: 4; transition: fill .12s ease; }
.bar-col:hover .bar-mark, .bar-col:focus-visible .bar-mark { fill: var(--brand-strong); }
.bar-col:focus { outline: none; }
.bar-hit { fill: transparent; }
.bar-col:focus-visible .bar-hit { fill: rgba(37, 99, 235, .09); rx: 5; }

/* Part-to-whole: a 2px gap of surface separates segments, not a stroke. */
.stack { display: flex; height: 13px; border-radius: var(--r-pill); overflow: hidden; background: var(--surface-sunk); gap: 2px; }
.stack span { display: block; height: 100%; min-width: 2px; }
.stack-1 { background: var(--series-1); }
.stack-2 { background: var(--series-2); }
.stack-3 { background: var(--series-3); }
.stack-4 { background: var(--series-4); }

.legend { display: flex; flex-wrap: wrap; gap: .35rem 1.1rem; font-size: .8rem; color: var(--ink-2); }
.legend-item { display: inline-flex; align-items: center; gap: .38rem; }
.legend-swatch { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 10px; }
.legend-swatch.stack-1 { background: var(--series-1); }
.legend-swatch.stack-2 { background: var(--series-2); }
.legend-swatch.stack-3 { background: var(--series-3); }
.legend-swatch.stack-4 { background: var(--series-4); }
.legend-value { color: var(--ink); font-weight: 650; font-variant-numeric: tabular-nums; }

/* Hover and keyboard tooltip. Enhances only - every value is also in the
   table view below the chart. */
.chart-tt {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -100%);
  transition: opacity .1s ease;
  background: #0f172a;
  color: #fff;
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-3);
  padding: .5rem .65rem;
  font-size: .79rem;
  line-height: 1.5;
  white-space: nowrap;
  min-width: 7.5rem;
}
.chart-tt.show { opacity: 1; }
.chart-tt .tt-head { font-weight: 700; margin-bottom: .15rem; }
.chart-tt .tt-row { display: flex; justify-content: space-between; gap: 1rem; color: rgba(255, 255, 255, .85); }
.chart-tt .tt-row span:last-child { font-variant-numeric: tabular-nums; font-weight: 650; color: #fff; }

/* A ratio against a limit. The unfilled track is a lighter step of the same
   hue, so the state reads across the whole bar. */
.meter { height: 8px; border-radius: var(--r-pill); background: var(--series-1-wash); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: var(--r-pill); background: var(--series-1); }
.meter.is-ok { background: var(--ok-wash); } .meter.is-ok > span { background: var(--ok); }
.meter.is-warn { background: var(--warn-wash); } .meter.is-warn > span { background: var(--warn); }
.meter.is-crit { background: var(--crit-wash); } .meter.is-crit > span { background: var(--crit); }

/* ============================================================ utilities */
.text-muted { color: var(--ink-muted) !important; }
.text-danger { color: var(--crit) !important; }
.text-success { color: var(--ok) !important; }
.text-warning { color: var(--warn) !important; }
.table-light { --bs-table-bg: var(--surface-2); }
.table-danger { --bs-table-bg: var(--crit-wash); --bs-table-color: var(--crit); }

/* =============================================================== login */
.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
  background:
    radial-gradient(1100px 520px at 10% -10%, #ede9fe 0%, transparent 60%),
    radial-gradient(900px 480px at 96% 110%, #dbe7fe 0%, transparent 58%),
    var(--plane);
}
.auth-card {
  width: 100%;
  max-width: 410px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-3);
  padding: 2.1rem 2rem 1.8rem;
}
.auth-mark {
  width: 56px;
  height: 56px;
  margin: 0 auto 1rem;
  border-radius: var(--r-lg);
  display: grid;
  place-items: center;
  font-size: 1.7rem;
  color: #fff;
  background: linear-gradient(145deg, #8b5cf6, #6d28d9);
  box-shadow: 0 10px 24px -6px rgba(109, 40, 217, .55);
}
.auth-card h1 { font-size: 1.22rem; font-weight: 750; letter-spacing: -0.025em; margin: 0; }
.auth-card .sub { font-size: .88rem; color: var(--ink-muted); margin: .25rem 0 0; }
.auth-foot { margin-top: 1.2rem; padding-top: 1rem; border-top: 1px solid var(--line); font-size: .82rem; color: var(--ink-muted); text-align: center; }

/* =============================================================== print */
.print-doc { max-width: 860px; margin: 0 auto; background: #fff; padding: 2rem; }

@media print {
  .erp-sidebar, .erp-topbar, .no-print, .scrim { display: none !important; }
  .erp-content { padding: 0; }
  body { background: #fff; font-size: 10.5pt; }
  .erp-card { border: 1px solid #ccc; box-shadow: none; break-inside: avoid; margin-bottom: .8rem; }
  /* Headline cards print as plain bordered boxes - saves ink and stays legible. */
  .erp-stat, .banner {
    background: #fff !important;
    color: #000 !important;
    border: 1px solid #ccc;
    box-shadow: none;
    break-inside: avoid;
  }
  .erp-stat::after, .banner::after { display: none; }
  .erp-stat .label, .erp-stat .hint, .banner p { color: #333 !important; }
  .erp-stat .value, .banner h2 { color: #000 !important; }
  .print-doc { max-width: none; padding: 0; }
  a[href]:after { content: ""; }
  .table-view { display: block !important; }
  .table-view > summary { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}
