/* Business Office: the one shared stylesheet (Phase 0 shell, 2026-11-05).
   Trimmed from CC-Amazon_PO_Compliance app/static/app.css (its --mg- tokens are the
   Martin Group design-system palette): tokens, base, shell, sign-in/errors, card,
   button and empty state. Page-specific CSS goes in /static/css/<page>.css via
   {% block page_css %}, not here. */


/* ---------- Tokens ---------- */
:root {
  /* Brand + accent */
  --mg-teal: #17A38C;
  --mg-teal-hover: #128A76;
  --mg-teal-deep: #0E7C6B;
  --mg-teal-tint: #E2F3EF;
  --mg-teal-tint-border: #B9E0D7;
  --link: #0E7C6B;
  --link-hover: #0A5C50;

  /* Chrome (rail) */
  --mg-ink: #232B2A;
  --mg-ink-hover: #2E3836;
  --mg-ink-divider: #3A4442;
  --mg-ink-text: #B9C2BF;
  --mg-ink-text-strong: #E8ECEA;
  --mg-ink-muted: #7E8A86;
  /* Status tones legible ON the ink (table heads, sparkline dot); the Inventory
     dashboard's --sc-red-dark / --sc-amber-dark / --sc-green-dark, so the two sites match. */
  --mg-red-on-ink: #F5A9A2;
  --mg-amber-on-ink: #F9C784;
  --mg-green-on-ink: #8FD3B6;

  /* Surfaces */
  --mg-page: #F4F5F4;
  --mg-card: #FFFFFF;
  --mg-strip: #FAFBFA;
  --mg-table-head: #F1F3F2;
  --mg-zebra: #F7F8F8;
  --mg-row-hover: #F6FAF9;

  /* Borders */
  --mg-border: #DDE1DF;
  --mg-border-control: #C9CFCC;
  --mg-border-row: #EEF0EF;

  /* Text (faint and zero are never text) */
  --mg-text: #222927;
  --mg-text-2: #5A6461;
  --mg-text-muted: #6B7370;

  /* Status */
  --mg-red: #C0392B;
  --mg-red-tint: #FBEAE7;
  --mg-red-border: #E5C4BE;
  --mg-amber: #A8720A;           /* never text under 14px */
  --mg-amber-text: #8A6D1F;
  --mg-amber-tint: #FBF3D9;
  --mg-amber-border: #E8D89A;
  --mg-green: #1E6B34;
  --mg-green-tint: #E3F3E4;
  --mg-green-border: #B5DDB9;
  --mg-neutral: #4A5350;
  --mg-neutral-tint: #ECEEED;

  /* Type */
  --text-2xs: 10px;  --text-xs: 11px;  --text-sm: 12px;  --text-base: 13px;
  --text-md: 14px;   --text-lg: 16px;  --text-xl: 19px;  --text-3xl: 28px;
  --tracking-label: 0.5px;
  --tracking-caps: 1px;
  --tracking-wide: 2px;
  --font-mono: Consolas, "SF Mono", "Courier New", monospace;

  /* Space, radii, rows, effects (design system) */
  --space-1: 4px;  --space-2: 6px;  --space-3: 8px;  --space-4: 10px;  --space-5: 12px;
  --space-6: 14px; --space-7: 16px; --space-9: 24px; --space-10: 32px;
  --radius-sm: 3px; --radius: 4px; --radius-md: 6px; --radius-pill: 999px;
  --shadow-card: 0 2px 10px rgba(0, 0, 0, 0.06);
  --row-h: 34px;
  --row-h-compact: 32px;
  --sidebar-w: 216px;

  /* New in this app (extend the system; purpose noted) */
  --font-app: Arial, Helvetica, sans-serif; /* Arial first: the dev box's Helvetica Neue is oblique */
  --topbar-h: 40px;
  --control-h: 32px;
  --control-h-touch: 44px;
  --pill-h: 20px;
  --edge-w: 3px;
  --indent-child: 16px;
  --spark-w: 120px;
  --spark-h: 28px;
}

/* ---------- Base ---------- */
html { box-sizing: border-box; -webkit-text-size-adjust: 100%; } *, *::before, *::after { box-sizing: inherit; }
body { margin: 0; background: var(--mg-page); color: var(--mg-text); font: 13px/1.5 var(--font-app); }
a { color: var(--link); } a:hover { color: var(--link-hover); }
h1, h2, h3 { line-height: 1.3; }
img { max-width: 100%; }
.num, td.n, th.n { font-variant-numeric: tabular-nums; text-align: right; }
.zero { color: var(--mg-text-muted); font-weight: 400; }
.mono { font-family: var(--font-mono); font-size: 12px; }
.micro { font-size: var(--text-2xs); font-weight: 700; letter-spacing: var(--tracking-label); text-transform: uppercase; color: var(--mg-text-muted); white-space: nowrap; }
.note { margin: 0; font-size: 12px; color: var(--mg-text-2); line-height: 1.5; text-wrap: pretty; }
.muted { color: var(--mg-text-muted); }
.nowrap { white-space: nowrap; }
.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; }
:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--mg-teal-tint), 0 0 0 3px var(--mg-teal); }
.inline-form { display: inline; margin: 0; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

/* ---------- 1. Shell ---------- */
.shell { display: flex; min-height: 100vh; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.page { width: 100%; max-width: 1264px; padding: 24px 32px 48px; display: flex; flex-direction: column; gap: 24px; min-width: 0; }
.banners { padding: 12px 32px 0; display: flex; flex-direction: column; gap: 8px; max-width: 1264px; }
.banners:empty { display: none; }

/* Rail: sticky at full viewport height so the identity foot stays bottom-left (D46). */
.rail { width: var(--sidebar-w); flex: none; background: var(--mg-ink); }
.rail-inner { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; overflow-y: auto; }
.rail-brand { background: #FFFFFF; padding: 14px 16px 10px; border-bottom: 3px solid var(--mg-teal); display: flex; flex-direction: column; gap: 6px; text-decoration: none; }
.rail-brand img { width: 150px; height: auto; display: block; }
.rail-caption { font-size: 10px; letter-spacing: var(--tracking-wide); text-transform: uppercase; color: var(--mg-text-muted); }
.rail-nav { display: flex; flex-direction: column; padding: 12px 0; }
.rail-link { min-height: 40px; padding: 0 16px 0 17px; border-left: 3px solid transparent; display: flex; align-items: center; gap: 8px; color: var(--mg-ink-text); font-size: 14px; text-decoration: none; white-space: nowrap; }
.rail-link:hover { background: var(--mg-ink-hover); color: #FFFFFF; }
.rail-link[aria-current="page"] { border-left-color: var(--mg-teal); background: var(--mg-ink-hover); color: #FFFFFF; font-weight: 700; }
.rail-count { margin-left: auto; min-width: 22px; height: 18px; padding: 0 6px; border-radius: var(--radius-pill); background: var(--mg-ink-divider); color: var(--mg-ink-text-strong); font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; font-variant-numeric: tabular-nums; }
.rail-link[aria-current="page"] .rail-count { background: var(--mg-ink-text-strong); color: var(--mg-ink); }

/* Identity foot: name, email (one line, ellipsis + title=), sign out. */
.identity { margin-top: auto; border-top: 1px solid var(--mg-ink-divider); padding: 14px 16px 14px 20px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.identity-name { font-size: 13px; font-weight: 700; color: #FFFFFF; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.identity-email { font-size: 11px; color: var(--mg-ink-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.signout { margin: 8px 0 0; }
.signout button { background: none; border: 0; padding: 0; font: inherit; font-size: 12px; color: var(--mg-ink-text-strong); text-decoration: underline; cursor: pointer; }
.signout button:hover { color: #FFFFFF; }
/* Visible sign-out in the rail foot and the phone menu (red-team 2026-10-25). */

/* Band (<= 900) + in-flow menu: replace the rail at narrow widths. */
.band { display: none; height: 56px; background: #FFFFFF; border-bottom: 3px solid var(--mg-teal); padding: 0 12px 0 4px; align-items: center; gap: 4px; position: sticky; top: 0; z-index: 3; }
.band-brand { display: flex; flex-direction: column; gap: 2px; text-decoration: none; }
.band img { width: 110px; height: auto; display: block; }
.band-caption { font-size: 9px; letter-spacing: var(--tracking-wide); text-transform: uppercase; color: var(--mg-text-muted); }
.hamburger { width: 44px; height: 44px; border: 0; border-radius: var(--radius); background: none; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 4px; cursor: pointer; flex: none; }
.hamburger span { width: 18px; height: 2px; background: var(--mg-text); }
.band-count { margin-left: auto; font-size: 12px; color: var(--mg-text-2); white-space: nowrap; }
.mmenu { display: none; background: #FFFFFF; border-bottom: 1px solid var(--mg-border); padding: 4px 0; flex-direction: column; }
.mmenu.open { display: flex; }
.mmenu a { min-height: 44px; padding: 0 16px; display: flex; align-items: center; gap: 8px; font-size: 16px; color: var(--mg-text); text-decoration: none; }
.mmenu a[aria-current="page"] { padding-left: 13px; border-left: 3px solid var(--mg-teal); background: var(--mg-teal-tint); font-weight: 700; }
.mmenu .mcount { margin-left: auto; min-width: 26px; height: 22px; padding: 0 8px; border-radius: var(--radius-pill); background: var(--mg-neutral-tint); color: var(--mg-neutral); font-size: 13px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.mmenu-foot { border-top: 1px solid var(--mg-border-row); margin-top: 4px; padding: 12px 16px 8px; display: flex; flex-direction: column; gap: 4px; font-size: 14px; min-width: 0; }
.mmenu-foot .who { font-weight: 700; }
.mmenu-foot .mail { color: var(--mg-text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mmenu-foot .note { font-size: 13px; }
.mmenu-foot form { margin: 8px 0 0; }

/* Top bar: title, month picker + state marker, scope, freshness. */
.topbar { min-height: var(--topbar-h); background: #FFFFFF; border-bottom: 1px solid var(--mg-border); padding: 6px 32px; display: flex; align-items: center; gap: 16px; position: sticky; top: 0; z-index: 2; flex-wrap: wrap; }
.topbar h1 { margin: 0; font-size: var(--text-xl); font-weight: 700; white-space: nowrap; }
.topbar .crumb { font-size: 13px; white-space: nowrap; } .topbar .crumb-sep { color: var(--mg-text-muted); }
.topbar-mid { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 16px; font-size: 12px; color: var(--mg-text-2); }

.scope { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: var(--radius-sm); background: var(--mg-table-head); color: var(--mg-text); font-size: 12px; white-space: nowrap; max-width: 360px; overflow: hidden; text-overflow: ellipsis; }
.scope b { font-weight: 700; }
.scope-strip { background: var(--mg-strip); border: 1px solid var(--mg-border); border-radius: var(--radius); padding: 8px 14px; display: flex; gap: 6px 18px; flex-wrap: wrap; align-items: center; font-size: 12px; }

.fresh { display: flex; align-items: center; gap: 6px; white-space: nowrap; font-size: 12px; color: var(--mg-text-2); }
.fresh::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--mg-green); flex: none; }
.fresh.stale { color: var(--mg-amber-text); font-weight: 700; } .fresh.stale::before { background: var(--mg-amber); }
.fresh.failed { color: var(--mg-red); font-weight: 700; } .fresh.failed::before { background: var(--mg-red); }
.fresh.none::before { background: none; border: 1px solid var(--mg-text-muted); }

/* Banners: failed, partial, stale, month state (in that order). */
.banner { display: flex; align-items: flex-start; gap: 12px; padding: 10px 14px; border: 1px solid; border-radius: var(--radius); font-size: 13px; line-height: 1.45; }
.banner-text { flex: 1; min-width: 0; }
.banner.red { border-color: var(--mg-red-border); background: var(--mg-red-tint); } .banner.red b { color: var(--mg-red); }
.banner.amber { border-color: var(--mg-amber-border); background: var(--mg-amber-tint); } .banner.amber b { color: var(--mg-amber-text); }
.banner.month { border-color: var(--mg-border); background: var(--mg-strip); align-items: center; }
.banner-dismiss { flex: none; background: none; border: 0; padding: 0; font: inherit; font-size: 12px; color: var(--link); text-decoration: underline; cursor: pointer; }

/* ---------- 2. Sign-in, no access, errors ---------- */
.center-page { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.signin { width: 100%; max-width: 400px; background: #FFFFFF; border: 1px solid var(--mg-border); border-radius: var(--radius-md); box-shadow: var(--shadow-card); padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.signin-brand { display: flex; flex-direction: column; gap: 6px; padding-bottom: 12px; border-bottom: 3px solid var(--mg-teal); }
.signin-brand img { width: 140px; height: auto; display: block; }
.signin-brand span { font-size: 10px; letter-spacing: var(--tracking-wide); text-transform: uppercase; color: var(--mg-text-muted); }
.signin h1 { margin: 0; font-size: var(--text-xl); line-height: 1.3; }
.signin p { margin: 0; }
.signin .help { font-size: 12px; color: var(--mg-text-2); line-height: 1.5; }
.signin .who { font-size: 12px; color: var(--mg-text-2); overflow-wrap: anywhere; }
.signin form { margin: 0; display: flex; flex-direction: column; }
.gbtn { display: flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 14px; border-radius: var(--radius); font: 700 15px var(--font-app); text-align: center; text-decoration: none; background: var(--mg-teal); border: 1px solid var(--mg-teal); color: #FFFFFF; cursor: pointer; overflow-wrap: anywhere; }
.gbtn:hover { background: var(--mg-teal-hover); color: #FFFFFF; }
.gbtn.secondary { background: #FFFFFF; border-color: var(--mg-border-control); color: var(--mg-text); }
.gbtn.secondary:hover { background: var(--mg-row-hover); color: var(--mg-text); }
.gbtn[aria-disabled="true"] { background: var(--mg-zebra); border-color: var(--mg-border); color: var(--mg-text-muted); pointer-events: none; }
.alert { margin: 0; padding: 10px 12px; border: 1px solid; border-radius: var(--radius); font-size: 13px; line-height: 1.45; }
.alert.red { border-color: var(--mg-red-border); background: var(--mg-red-tint); } .alert.red b { color: var(--mg-red); }
.alert.amber { border-color: var(--mg-amber-border); background: var(--mg-amber-tint); } .alert.amber b { color: var(--mg-amber-text); }
.alert.green { border-color: var(--mg-green-border); background: var(--mg-green-tint); } .alert.green b { color: var(--mg-green); }
.alert.grey { border-color: var(--mg-border); background: var(--mg-strip); }

.errcard { width: 100%; max-width: 520px; margin: 40px auto 0; background: #FFFFFF; border: 1px solid var(--mg-border); border-radius: var(--radius); padding: 28px; display: flex; flex-direction: column; gap: 10px; }
.errcard .errtitle { margin: 0; font-size: var(--text-xl); font-weight: 700; color: var(--mg-text); }
.errcard p { margin: 0; color: var(--mg-text-2); }
.errcard a.go { font-weight: 700; }

/* ---------- 3. Primitives (card, button, empty state) ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: var(--control-h); padding: 0 12px; border-radius: var(--radius); border: 1px solid var(--mg-border-control); background: #FFFFFF; color: var(--mg-text); font: 700 13px var(--font-app); text-decoration: none; white-space: nowrap; cursor: pointer; }
.btn:hover { background: var(--mg-row-hover); color: var(--mg-text); }
.btn.primary { background: var(--mg-teal); border-color: var(--mg-teal); color: #FFFFFF; } .btn.primary:hover { background: var(--mg-teal-hover); }
.btn[disabled], .btn[aria-disabled="true"] { background: var(--mg-zebra); border-color: var(--mg-border); color: var(--mg-text-muted); cursor: not-allowed; pointer-events: none; }
.card { background: #FFFFFF; border: 1px solid var(--mg-border); border-radius: var(--radius-md); display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; gap: 8px 12px; padding: 12px 16px; flex-wrap: wrap; background: var(--mg-ink); color: #FFFFFF; }
.card-head h2 { margin: 0; font-size: 17px; font-weight: 700; line-height: 1.2; color: #FFFFFF; }
.card-head .sub, .card-head .card-sub { font-size: 12px; color: var(--mg-ink-text); }
.card-head .count { min-width: 22px; height: 20px; padding: 0 6px; border-radius: var(--radius-pill); background: var(--mg-ink-divider); color: var(--mg-ink-text-strong); font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; font-variant-numeric: tabular-nums; }
.card-head .right { margin-left: auto; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.card-head a:not(.btn) { color: var(--mg-teal-tint-border); font-weight: 600; text-decoration: none; }
.card-head a:not(.btn):hover { color: #FFFFFF; text-decoration: underline; }
.card-head .store { color: #FFFFFF; }
.card-head .disclose { color: var(--mg-teal-tint-border); font-weight: 600; }
.card-head .disclose:hover { color: #FFFFFF; }
.card-head :focus-visible, .card-head .disclose:focus-visible { outline: 2px solid var(--mg-teal-tint-border); outline-offset: 2px; box-shadow: none; }
.card-head + .tablewrap { border-top: 0; }
.card-body { padding: 0 16px 16px; }
.card-head + .card-body { padding-top: 14px; }
.card-foot { padding: 12px 16px; border-top: 1px solid var(--mg-border-row); }
.empty { padding: 28px 24px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.empty b { font-size: 15px; } .empty span { font-size: 13px; color: var(--mg-text-2); line-height: 1.5; }

/* ---------- Business Office additions (2026-11-05) ---------- */
.rail-empty { padding: 10px 16px 0 20px; font-size: 12px; line-height: 1.45; color: var(--mg-ink-muted); }
.modlist, .storelist { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.storelist { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 6px 16px; font-size: 13px; }
.card-body .empty { padding: 4px 0 0; }
.storelist .code { display: inline-block; min-width: 52px; font-family: var(--font-mono); font-size: 12px; color: var(--mg-text-2); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .rail { display: none; }
  .band { display: flex; }
  .hamburger { display: flex; }
  .page { padding: 16px; gap: 16px; }
  .banners { padding: 12px 16px 0; }
  .topbar { position: static; flex-wrap: wrap; padding: 12px 16px; gap: 10px; }
  .topbar h1 { white-space: normal; }
  .topbar-right { margin-left: 0; width: 100%; justify-content: space-between; flex-wrap: wrap; gap: 8px 16px; }
  .scope { max-width: 100%; }
}
@media (max-width: 640px) {
  body { font-size: 16px; }
  .topbar h1 { font-size: 20px; }
  .topbar-right { font-size: 13px; }
  .banner { font-size: 15px; }
  .btn { min-height: var(--control-h-touch); font-size: 16px; padding: 0 16px; }
  .card-head { padding: 12px 14px; } .card-head h2 { font-size: 16px; }
  .card-head .sub, .card-head .card-sub { font-size: 13px; }
  .note { font-size: 14px; }
  .empty b { font-size: 16px; } .empty span { font-size: 15px; }
  .signin { padding: 20px; }
  .signin .help, .signin .who { font-size: 14px; }
  .errcard { margin-top: 16px; padding: 20px; }
  :root { --text-2xs: 12px; --text-xs: 12px; }
}
