/* Resource Global portal: brand layer over Bootstrap 5 (colours and type from resourceglobal.net). */
:root {
  --rg-navy: #000f55;
  --rg-deep: #000a23;
  --rg-blue: #0275d7;
  --rg-sky: #59b3f5;
  --rg-tint: #ebf9ff;
  --rg-bg: #f4f6fb;
  --rg-line: #e3e7ef;
  --rg-muted: #5f6b80;
  --rg-ok: #11845b;
  --rg-warn: #b45309;

  --bs-body-font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --bs-body-color: #1b1f2a;
  --bs-body-bg: var(--rg-bg);
  --bs-primary: var(--rg-navy);
  --bs-primary-rgb: 0, 15, 85;
  --bs-link-color: var(--rg-blue);
  --bs-link-color-rgb: 2, 117, 215;
  --bs-link-hover-color: var(--rg-navy);
  --bs-border-color: var(--rg-line);
  --bs-border-radius: .5rem;
}

body { min-height: 100vh; display: flex; flex-direction: column; font-feature-settings: "tnum" 1; }
main { flex: 1 0 auto; }

/* ---------- Header and navigation */
.rg-header { background: var(--rg-deep); color: #fff; }
.rg-header .navbar { padding-top: .9rem; padding-bottom: .9rem; }
.rg-header .navbar-brand img { height: 18px; display: block; }
.rg-header .brand-sub { font-size: .7rem; letter-spacing: .14em; text-transform: uppercase; color: var(--rg-sky); margin-top: .35rem; }
.rg-header .nav-link { color: rgba(255,255,255,.78); font-weight: 500; font-size: .92rem; padding: .5rem .85rem !important; border-radius: .4rem; }
.rg-header .nav-link:hover, .rg-header .nav-link:focus { color: #fff; background: rgba(255,255,255,.07); }
.rg-header .nav-link.active { color: #fff; background: rgba(2,117,215,.35); }
.rg-header .navbar-toggler { border-color: rgba(255,255,255,.3); }
.rg-header .navbar-toggler-icon { filter: invert(1); }
.rg-header .dropdown-menu { border-color: var(--rg-line); }
.rg-user { font-size: .85rem; color: rgba(255,255,255,.85); }

/* ---------- Page headings: RG "eyebrow + bold" pattern */
.rg-page-head { padding: 2rem 0 1.25rem; }
.eyebrow { display: block; text-transform: uppercase; letter-spacing: .14em; font-size: .75rem; font-weight: 400; color: var(--rg-blue); margin-bottom: .25rem; }
.rg-title { font-weight: 700; text-transform: uppercase; letter-spacing: .02em; color: var(--rg-navy); font-size: 1.6rem; margin: 0; }
.rg-lead { color: var(--rg-muted); max-width: 60rem; margin-top: .5rem; }
.section { font-size: 1rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--rg-navy); margin: 0 0 1rem; }

/* ---------- Cards, tiles, tables */
.card { border-color: var(--rg-line); box-shadow: 0 1px 2px rgba(0,10,35,.04); }
.card-body { padding: 1.25rem 1.4rem; }
.kpi { height: 100%; }
.kpi .label { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--rg-muted); }
.kpi .value { font-size: 1.9rem; font-weight: 700; color: var(--rg-navy); line-height: 1.15; margin-top: .25rem; }
.kpi .note { font-size: .8rem; color: var(--rg-muted); }
.kpi.green { border-left: 4px solid #1f9d6b; }
.kpi.green .value { color: #0d6b47; }
.table { --bs-table-bg: transparent; font-size: .9rem; }
.table thead th { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--rg-muted); font-weight: 600; border-bottom-width: 1px; white-space: nowrap; }
.table-hover tbody tr:hover { --bs-table-hover-bg: var(--rg-tint); }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.table tfoot td { font-weight: 700; border-top: 2px solid var(--rg-navy); }
.badge-soft { background: var(--rg-tint); color: var(--rg-navy); font-weight: 600; }
.text-muted-rg { color: var(--rg-muted) !important; }

/* ---------- Buttons and forms */
.btn { font-weight: 600; border-radius: .4rem; }
.btn-primary { --bs-btn-bg: var(--rg-navy); --bs-btn-border-color: var(--rg-navy); --bs-btn-hover-bg: #001a8c; --bs-btn-hover-border-color: #001a8c; --bs-btn-active-bg: var(--rg-deep); }
.btn-secondary { --bs-btn-bg: var(--rg-blue); --bs-btn-border-color: var(--rg-blue); --bs-btn-hover-bg: #015fae; --bs-btn-hover-border-color: #015fae; --bs-btn-color: #fff; }
.btn-outline-primary { --bs-btn-color: var(--rg-navy); --bs-btn-border-color: var(--rg-navy); --bs-btn-hover-bg: var(--rg-navy); --bs-btn-hover-border-color: var(--rg-navy); }
.form-label { font-weight: 600; font-size: .85rem; color: var(--rg-navy); }
.form-control:focus, .form-select:focus { border-color: var(--rg-blue); box-shadow: 0 0 0 .2rem rgba(2,117,215,.2); }
.field-validation-error, .validation-summary-errors { color: #b42318; font-size: .85rem; }
.validation-summary-valid { display: none; }

/* ---------- Filter bar */
.rg-filters { background: #fff; border: 1px solid var(--rg-line); border-radius: .6rem; padding: .9rem 1rem; margin-bottom: 1.5rem; }
.rg-filters .form-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; margin-bottom: .2rem; }
.rg-filters .form-control, .rg-filters .form-select { font-size: .88rem; }

/* ---------- Charts and bars */
.chart-box { position: relative; height: 280px; }
.chart-box.tall { height: 360px; }
.bar-list .row-item { margin-bottom: .65rem; }
.bar-list .bar { height: 8px; background: var(--rg-tint); border-radius: 4px; overflow: hidden; margin-top: .25rem; }
.bar-list .bar > span { display: block; height: 100%; background: var(--rg-blue); border-radius: 4px; }
.progress { height: .9rem; background: var(--rg-tint); }
.progress-bar { background: #1f9d6b; }

/* ---------- Map */
#rg-map { height: calc(100vh - 290px); min-height: 480px; border-radius: .6rem; border: 1px solid var(--rg-line); background: #dfe6ef; }
.map-popup { padding: .75rem .9rem; min-width: 260px; max-width: 340px; font-family: var(--bs-body-font-family); }
.map-popup h6 { font-weight: 700; color: var(--rg-navy); margin: 0 0 .15rem; }
.map-popup table { width: 100%; font-size: .8rem; margin-top: .5rem; }
.map-popup td { padding: .15rem .25rem; border-top: 1px solid var(--rg-line); }
.legend-ramp { height: 10px; border-radius: 5px; background: linear-gradient(90deg, rgba(89,179,245,.2), #59b3f5, #0275d7, #000f55, #ff8a00); }

/* ---------- Sign-in pages */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-brand { background: radial-gradient(circle at 20% 20%, #0b2a8a 0, var(--rg-navy) 35%, var(--rg-deep) 100%); color: #fff; padding: 3.5rem; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-brand img.word { height: 26px; }
.auth-brand .strap { font-size: 1.05rem; color: rgba(255,255,255,.85); margin-top: .75rem; }
.auth-brand h1 { font-weight: 700; text-transform: uppercase; font-size: 2.1rem; line-height: 1.15; max-width: 28rem; }
.auth-brand .mark { position: absolute; right: 48px; top: 50%; transform: translateY(-50%); width: 240px; height: 240px; opacity: .07; pointer-events: none; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 2rem; background: #fff; }
.auth-form .inner { width: 100%; max-width: 400px; }
.auth-form h2 { font-weight: 700; color: var(--rg-navy); text-transform: uppercase; font-size: 1.35rem; }
.qr { width: 200px; height: 200px; border: 1px solid var(--rg-line); border-radius: .5rem; padding: .5rem; background: #fff; }
.code-list { columns: 2; font-family: ui-monospace, Consolas, monospace; font-size: 1rem; }
@media (max-width: 900px) { .auth-wrap { grid-template-columns: 1fr; } .auth-brand { padding: 2rem; min-height: auto; } .auth-brand h1 { font-size: 1.5rem; } }

/* ---------- Footer */
.rg-footer { background: var(--rg-deep); color: rgba(255,255,255,.65); font-size: .8rem; padding: 1.5rem 0; margin-top: 3rem; }
.rg-footer img { height: 12px; opacity: .9; }
.rg-footer a { color: rgba(255,255,255,.8); }

/* ---------- Forecast and savings */
.status { display: inline-block; font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding: .2rem .5rem; border-radius: 999px; white-space: nowrap; }
.status-ahead { background: #e3f5ec; color: var(--rg-ok); }
.status-ontrack { background: var(--rg-tint); color: var(--rg-navy); }
.status-behind { background: #fdecea; color: #b42318; }
.status-noforecast { background: #eef1f6; color: var(--rg-muted); }
.kpi.ahead { border-left: 4px solid var(--rg-ok); }
.kpi.behind { border-left: 4px solid #b42318; }
.kpi.ontrack { border-left: 4px solid var(--rg-blue); }
/* Forecast matrix: franchisees down, months across. */
.forecast-matrix th:first-child { position: sticky; left: 0; background: #fff; z-index: 1; min-width: 12rem; font-weight: 600; }
.forecast-matrix td.cell { min-width: 6.5rem; line-height: 1.2; border-left: 2px solid #fff; }
.forecast-matrix .fc { font-weight: 600; }
.forecast-matrix .act { font-size: .75rem; opacity: .85; }
.forecast-matrix td.future { color: var(--rg-muted); }
.forecast-matrix tr.total th, .forecast-matrix tr.total td { border-top: 2px solid var(--rg-navy); }
.forecast-matrix td.cell:last-child { border-left: 2px solid var(--rg-navy); }

.num.pos { color: var(--rg-ok); }
.num.neg { color: #b42318; }

/* ---------- Admin */
.admin-nav .nav-link { color: var(--rg-navy); font-weight: 600; font-size: .9rem; }
.admin-nav .nav-link.active { background: var(--rg-navy); color: #fff; }
details.inline-edit summary { cursor: pointer; color: var(--rg-blue); font-size: .85rem; }
.invite-link { word-break: break-all; font-family: ui-monospace, Consolas, monospace; font-size: .8rem; background: var(--rg-tint); padding: .5rem; border-radius: .3rem; }

/* ---------- Products */
.approval-box { background: #fff8e6; border: 1px solid #f0d58a; border-radius: .4rem; padding: .75rem; max-width: 40rem; }
.matrix th:first-child, .matrix td:first-child { position: sticky; left: 0; background: #fff; min-width: 16rem; z-index: 1; }
