/* =========================================================================
   MRC Style — the shared look for Moore Race Chassis apps.
   Reference app: MRC Nexus. Used by: MRC Nexus, The Tree (see README).

   1. Tokens   — colors, fonts, radii, shadows (light + dark)
   2. Base     — page defaults that every app wants
   3. Pieces   — mrc-* classes: header, badge, headings, cards, tiles,
                 buttons, pills, chips, date blocks, notices

   Theme: set data-theme="light" | "dark" on <html> (see theme.js).
   With no data-theme, it follows the device's light/dark setting.
   Token names match The Tree's and Nexus's, so either app can load this
   file without renaming anything.
   ========================================================================= */

/* ---------- 1. Tokens ---------- */
:root {
  /* Brand */
  --brand: #D10A0A;          /* MRC red: badges, slashes, the header underline */
  --red: #D10A0A;
  --red-bright: #FF2A2A;     /* red on the dark header (names, highlights) */
  --brand-text: #D10A0A;     /* red text on page backgrounds; brighter in dark mode */
  --font-display: 'Barlow Condensed', 'Arial Narrow', sans-serif;  /* headings: 800, italic, uppercase */
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Dark racing header (same in light and dark mode) */
  --hero: #0E0F11; --hero-2: #17191C; --hero-text: #FFFFFF; --hero-muted: #A9AEB6;

  /* Surfaces and text */
  --bg: #EEF0F2; --surface: #FFFFFF; --surface-2: #F2F3F5; --surface-3: #F7F8FA; --hover: #F7F8FA;
  --line: #ECEDEF; --line-2: #DADCE0;
  --text: #111111; --text-2: #3C4043; --muted: #5F6368; --faint: #BDC1C6; --media: #E8EAED;
  --btn: #111111; --btn-text: #FFFFFF;
  --bar: #111111; --bar-2: #262626;
  --scrim: rgba(17,17,17,0.32);

  /* Status */
  --ok-bg: #E7F5EE; --ok-text: #0B6B43;
  --warn-bg: #FFF1CC; --warn-text: #6B4200;
  --danger-bg: #FDECEC; --danger-text: #A51515; --danger-line: #F3B4B4;
  --info-bg: #F3F7FE; --info-line: #BFD3F6;
  --red-text: #C81E1E; --amber-text: #B35500; --blue-text: #1F6FD1;
  --ink-tile: #111111; --lift: 0%;

  /* Kinds of thing (schedule dots, tags, chart series) */
  --kind-out: #C26A00;    /* PTO / out */
  --kind-pay: #0E8A4F;    /* payday / money in */
  --kind-hol: #D10A0A;    /* holiday / closed */
  --kind-drop: #1F6FD1;   /* drop-off / pick-up / delivery */
  --kind-appt: #7C3AED;   /* appointment */
  --kind-other: #7A8089;

  /* App tile colors (one per app; keep them consistent across apps) */
  --app-estimator: #1B5E8F; --app-tree: #D10A0A; --app-jobs: #B35500;
  --app-calls: #0F7C86; --app-portal: #7C3AED; --app-buildbook: #2E7D32;

  /* Shape */
  --radius: 14px; --radius-sm: 10px; --radius-pill: 999px;
  --shadow: 0 1px 3px rgba(17,17,17,0.08);
  --shadow-hover: 0 10px 28px rgba(18,19,21,.14);
  --shadow-pop: 0 10px 30px rgba(17,17,17,0.18), 0 0 0 1px rgba(17,17,17,0.06);

  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0F1113; --surface: #1A1D21; --surface-2: #262A2F; --surface-3: #20242A; --hover: #22262B;
  --line: #2B2F35; --line-2: #3A3F46;
  --text: #F1F3F5; --text-2: #C8CCD2; --muted: #A2A7AE; --faint: #5E646C; --media: #2B2F35;
  --btn: #F1F3F5; --btn-text: #111111;
  --bar: #08090A; --bar-2: #1E2125;
  --scrim: rgba(0,0,0,0.6);
  --hero: #060708; --hero-2: #101215;
  --ok-bg: #12301F; --ok-text: #7FD9A6;
  --warn-bg: #3B2F12; --warn-text: #F7C870;
  --danger-bg: #3A1618; --danger-text: #FF9A9A; --danger-line: #6B2A2D;
  --info-bg: #15243A; --info-line: #2D4C7C;
  --red-text: #FF7A7A; --amber-text: #F5B25C; --blue-text: #7FB0FF;
  --ink-tile: #3A3F46; --lift: 38%; --brand-text: #FF3B3B;
  --kind-out: #F0A040; --kind-pay: #44C98A; --kind-hol: #FF5A5A; --kind-drop: #6EA8FF; --kind-appt: #B08CFF; --kind-other: #9AA0A8;
  --shadow: 0 1px 3px rgba(0,0,0,0.5); --shadow-hover: 0 10px 28px rgba(0,0,0,.6);
  --shadow-pop: 0 10px 30px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.06);
  color-scheme: dark;
}

/* No data-theme set: follow the device. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #0F1113; --surface: #1A1D21; --surface-2: #262A2F; --surface-3: #20242A; --hover: #22262B;
    --line: #2B2F35; --line-2: #3A3F46;
    --text: #F1F3F5; --text-2: #C8CCD2; --muted: #A2A7AE; --faint: #5E646C; --media: #2B2F35;
    --btn: #F1F3F5; --btn-text: #111111; --bar: #08090A; --bar-2: #1E2125; --scrim: rgba(0,0,0,0.6);
    --hero: #060708; --hero-2: #101215;
    --ok-bg: #12301F; --ok-text: #7FD9A6; --warn-bg: #3B2F12; --warn-text: #F7C870;
    --danger-bg: #3A1618; --danger-text: #FF9A9A; --danger-line: #6B2A2D; --info-bg: #15243A; --info-line: #2D4C7C;
    --red-text: #FF7A7A; --amber-text: #F5B25C; --blue-text: #7FB0FF; --ink-tile: #3A3F46; --lift: 38%; --brand-text: #FF3B3B;
    --kind-out: #F0A040; --kind-pay: #44C98A; --kind-hol: #FF5A5A; --kind-drop: #6EA8FF; --kind-appt: #B08CFF; --kind-other: #9AA0A8;
    --shadow: 0 1px 3px rgba(0,0,0,0.5); --shadow-hover: 0 10px 28px rgba(0,0,0,.6);
    --shadow-pop: 0 10px 30px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.06);
    color-scheme: dark;
  }
}

/* ---------- 2. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 500 14px/1.45 var(--font-body); -webkit-font-smoothing: antialiased; }
:focus-visible { outline: 3px solid var(--text); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* ---------- 3. Pieces ---------- */

/* Display type: condensed, heavy, italic, uppercase. */
.mrc-display { font-family: var(--font-display); font-weight: 800; font-style: italic; text-transform: uppercase; letter-spacing: .01em; line-height: .95; }

/* The racing header: dark, fine diagonal stripes, red underline, faint red slashes at the right.
   Put .mrc-hero on the <header>; content goes in .mrc-hero__inner (max width, padding). */
.mrc-hero {
  position: relative; overflow: hidden; color: var(--hero-text);
  background:
    repeating-linear-gradient(-55deg, rgba(255,255,255,.028) 0 2px, transparent 2px 14px),
    radial-gradient(120% 140% at 100% 0%, #24272C 0%, transparent 55%),
    linear-gradient(180deg, var(--hero-2), var(--hero));
  border-bottom: 4px solid var(--brand);
}
.mrc-hero::after {
  content: ""; position: absolute; right: -60px; bottom: -4px; width: 340px; height: 100%; pointer-events: none;
  background: linear-gradient(90deg, transparent 0 22%, rgba(209,10,10,.16) 22% 30%, transparent 30% 40%, rgba(209,10,10,.1) 40% 46%, transparent 46%);
  transform: skewX(-28deg);
}
.mrc-hero--slim::after { display: none; }   /* for a thin top bar */
.mrc-hero__inner { position: relative; z-index: 1; max-width: 1240px; margin: 0 auto; padding: 16px 20px; }
.mrc-hero h1 { margin: 0; font-family: var(--font-display); font-weight: 800; font-style: italic; text-transform: uppercase; font-size: clamp(34px, 6vw, 52px); line-height: .95; }
.mrc-hero h1 em { font-style: inherit; color: var(--red-bright); }
.mrc-hero__sub { margin-top: 10px; font-weight: 600; color: var(--hero-muted); }

/* Logo + app badge, e.g. [MOORE RACE CHASSIS] [NEXUS] */
.mrc-brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; min-width: 0; }
.mrc-brand img { height: 48px; width: auto; display: block; }
.mrc-badge {
  display: inline-block; padding: 2px 10px 2px 12px; background: var(--brand); color: #fff;
  font-family: var(--font-display); font-weight: 800; font-style: italic; font-size: 20px; letter-spacing: .06em; text-transform: uppercase;
  clip-path: polygon(8px 0, 100% 0, calc(100% - 8px) 100%, 0 100%); white-space: nowrap;
}
@media (max-width: 640px) { .mrc-brand img { height: 28px; } .mrc-badge { font-size: 16px; } }

/* Buttons and links that sit on the dark header */
.mrc-hero-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-width: 44px; height: 44px; padding: 0 10px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--hero-text); font: 600 14px var(--font-body); text-decoration: none; cursor: pointer; white-space: nowrap; }
.mrc-hero-btn:hover { background: rgba(255,255,255,.1); }

/* Avatar circle with initial */
.mrc-avatar { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--c, #111); color: #fff; font-weight: 800; font-size: 14px; flex: none; }
.mrc-hero .mrc-avatar { box-shadow: 0 0 0 2px rgba(255,255,255,.55); }

/* Section heading with the red slash:  ▰ APPS                     note */
.mrc-section { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; }
.mrc-section::before { content: ""; width: 22px; height: 14px; background: var(--brand); clip-path: polygon(6px 0, 100% 0, calc(100% - 6px) 100%, 0 100%); flex: none; }
.mrc-section h2, .mrc-section h3 { margin: 0; font-family: var(--font-display); font-weight: 800; font-style: italic; font-size: 22px; letter-spacing: .06em; text-transform: uppercase; }
.mrc-section > small { margin-left: auto; font-size: 12px; font-weight: 600; color: var(--muted); }

/* Card */
.mrc-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.mrc-card > h2 { margin: 0 0 4px; font-size: 18px; font-weight: 800; }

/* App tile: set --c to the app's color (e.g. style="--c:var(--app-tree)").
   Use <a class="mrc-tile"> for a live app, <div class="mrc-tile is-off"> for one that isn't. */
.mrc-tile {
  --c: var(--kind-other);
  position: relative; display: flex; flex-direction: column; gap: 14px; padding: 20px 20px 18px; min-height: 168px; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  text-decoration: none; color: var(--text); transition: box-shadow .18s, transform .18s, border-color .18s;
}
.mrc-tile::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--c); }
.mrc-tile::after { content: ""; position: absolute; right: -30px; top: -30px; width: 120px; height: 120px; border-radius: 50%; background: var(--c); opacity: .07; transition: opacity .18s, transform .18s; }
a.mrc-tile:hover { box-shadow: var(--shadow-hover); transform: translateY(-3px); border-color: transparent; }
a.mrc-tile:hover::after { opacity: .13; transform: scale(1.15); }
.mrc-tile__icon { position: relative; z-index: 1; display: grid; place-items: center; width: 50px; height: 50px; border-radius: 14px; background: var(--c); color: #fff; box-shadow: 0 6px 14px -6px var(--c); }
.mrc-tile__name { font-family: var(--font-display); font-weight: 800; font-size: 27px; line-height: 1; text-transform: uppercase; }
.mrc-tile__sub { margin-top: 6px; font-size: 13px; color: var(--muted); }
.mrc-tile__foot { margin-top: auto; display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; color: var(--text-2); }
a.mrc-tile:hover .mrc-tile__foot { color: var(--c); }
.mrc-tile.is-off { background: transparent; box-shadow: none; border: 1.5px dashed var(--line-2); }
.mrc-tile.is-off::before, .mrc-tile.is-off::after { display: none; }
.mrc-tile.is-off .mrc-tile__icon { filter: grayscale(1); opacity: .5; box-shadow: none; }
.mrc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }

/* Buttons */
.mrc-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 20px; border: 0; border-radius: var(--radius-sm); background: var(--btn); color: var(--btn-text); font: 800 14px var(--font-body); text-decoration: none; cursor: pointer; }
.mrc-btn--brand { background: var(--brand); color: #fff; }
.mrc-btn--ghost { background: var(--surface); color: var(--text); border: 1px solid var(--line-2); font-weight: 700; min-height: 40px; padding: 0 14px; }
.mrc-btn:disabled { opacity: .55; cursor: default; }

/* Form fields */
.mrc-input { height: 44px; width: 100%; padding: 0 12px; border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font: inherit; }
textarea.mrc-input { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; }
.mrc-label { display: block; margin-bottom: 4px; font-size: 12px; font-weight: 600; color: var(--muted); }

/* Status pills */
.mrc-pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: var(--radius-pill); font-size: 12px; font-weight: 700; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.mrc-pill--ok { background: var(--ok-bg); color: var(--ok-text); }
.mrc-pill--warn { background: var(--warn-bg); color: var(--warn-text); }
.mrc-pill--bad { background: var(--danger-bg); color: var(--danger-text); }
.mrc-pill--brand { background: var(--brand); color: #fff; }

/* Chip with a colored dot (works on light pages and on the dark header) */
.mrc-chip { display: inline-flex; align-items: center; gap: 8px; min-height: 30px; padding: 4px 12px; border-radius: var(--radius-pill); background: var(--surface-2); border: 1px solid var(--line); font-size: 13px; font-weight: 600; }
.mrc-hero .mrc-chip { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.12); color: var(--hero-text); }
.mrc-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--k, var(--kind-other)); }

/* Calendar date block:  [NOV]
                          [ 5 ]   add .is-today for the red version */
.mrc-cal { flex: none; align-self: flex-start; width: 50px; text-align: center; border: 1px solid var(--line-2); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.mrc-cal__mo { padding: 2px 0; font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; background: var(--surface-2); color: var(--muted); }
.mrc-cal__day { padding: 1px 0 2px; font-family: var(--font-display); font-weight: 800; font-size: 24px; line-height: 1.15; }
.mrc-cal.is-today { border-color: var(--brand); }
.mrc-cal.is-today .mrc-cal__mo { background: var(--brand); color: #fff; }

/* Notice / announcement row with a red icon square */
.mrc-notice { display: flex; gap: 14px; align-items: flex-start; padding: 16px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.mrc-notice__icon { display: grid; place-items: center; flex: none; width: 38px; height: 38px; border-radius: 10px; background: var(--brand); color: #fff; }
.mrc-notice__meta { margin-top: 4px; font-size: 12px; color: var(--muted); }

/* Toast */
.mrc-toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); padding: 12px 18px; border-radius: 12px; font-weight: 700; box-shadow: var(--shadow-pop); background: var(--text); color: var(--bg); z-index: 1000; }
.mrc-toast--ok { background: var(--ok-bg); color: var(--ok-text); }
.mrc-toast--bad { background: var(--danger-bg); color: var(--danger-text); }

/* Page container */
.mrc-page { max-width: 1240px; margin: 0 auto; padding: 24px 20px 56px; }
@media (max-width: 640px) { .mrc-page { padding: 18px 16px 44px; } .mrc-hero__inner { padding: 12px 16px; } }
