/* Cric11 Pulse light design system — brand navy/red, accessible contrast and shared UI tokens. */

:root {
  /* color — brand */
  --color-primary-30: #f26472;
  --color-primary-40: #e21c28;
  --color-primary-70: #7f1719;
  --color-primary-80: #5a1210;
  --color-primary-transparent-20: #e21c2833;
  --color-brand-navy: #032143;
  --color-brand-red: #e1191c;
  /* Navy accent scale for fills, links and active states. */
  --color-secondary-40: #93aecf;
  --color-secondary-50: #16406e;
  --color-secondary-60: #0b2f57;
  --color-secondary-70: #07223f;
  --color-active: #16406e;
  --color-khakhi-50: #cb8e40;
  --color-yellow-50: #f99e0d;
  --color-green-50: #b2c51e;
  /* color — greyscale */
  --gs-90: #191919; --gs-60: #666667; --gs-35: #989898; --gs-30: #b2b3b3;
  --gs-20: #cccbcb; --gs-10: #e6e6e5; --gs-5: #f3f3f3; --gs-2: #f2f2f2; --gs-0: #fff;
  /* type */
  --font-primary: 'Ubuntu', 'Ubuntu Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-secondary: 'Barlow', system-ui, sans-serif;
  --font-mono-ui: 'Roboto', system-ui, sans-serif;
  --font-display: 'Anton', Impact, sans-serif;
  --font-script: 'Pacifico', cursive;
  /* type scale (px observed) */
  --fs-12: .75rem; --fs-14: .875rem; --fs-16: 1rem; --fs-18: 1.125rem; --fs-20: 1.25rem;
  --fs-22: 1.375rem; --fs-24: 1.5rem; --fs-28: 1.75rem; --fs-32: 2rem; --fs-36: 2.25rem;
  --fs-40: 2.5rem; --fs-48: 3rem; --fs-56: 3.5rem;
  /* radii */
  --r-4: 4px; --r-6: 6px; --r-8: 8px; --r-12: 12px; --r-14: 14px; --r-20: 20px; --r-50: 50px;
  /* shadows */
  --sh-1: 0 1px 3px #0000001f, 0 1px 2px #0000003d;
  --sh-2: 0 3px 6px #00000029;
  --sh-3: 0 4px 12px #0000001a;
  --sh-4: 0 8px 24px #0000001f;
  --sh-up: 0 -4px 20px #00000026;
  /* motion */
  --dur-exit: .15s; --dur-enter: .21s; --dur-move: .4s;
  /* layout */
  --container: 1200px;
  --header-h: 68px;
  --button-radius: 8px;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font-primary); font-size: var(--fs-16); line-height: 1.55;
  color: var(--gs-90); background: var(--gs-0);
}
img, svg, video { max-width: 100%; display: block; }
a { color: inherit; }
h1, h2, h3, h4 { line-height: 1.18; margin: 0 0 .5em; font-weight: 700; letter-spacing: -.01em; }
p { margin: 0 0 1em; }
ul { margin: 0; padding: 0; list-style: none; }
button { font: inherit; cursor: pointer; }
.container { width: min(100% - 48px, var(--container)); margin-inline: auto; }
.skip-link { position: absolute; left: -9999px; top: 0; background: var(--color-primary-40); color: #fff; padding: 8px 14px; border-radius: 0 0 var(--r-8) 0; z-index: 200; }
.skip-link:focus { left: 0; }
:focus-visible { outline: 2px solid var(--color-secondary-50); outline-offset: 2px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: var(--button-radius);
  padding: 12px 22px; font-size: var(--fs-16); font-weight: 700; text-decoration: none;
  transition: background var(--dur-exit), color var(--dur-exit), transform var(--dur-exit), box-shadow var(--dur-exit), border-color var(--dur-exit);
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--color-primary-40); color: #fff; box-shadow: var(--sh-2); }
.btn-primary:hover { background: var(--color-primary-70); }
.btn-primary:disabled { background: var(--gs-20); color: var(--gs-60); box-shadow: none; cursor: not-allowed; }
.btn-outline, .btn-ghost {
  border-color: var(--line-strong); color: var(--text-strong); background: var(--surface);
}
.btn-outline:hover, .btn-ghost:hover {
  background: var(--surface-2); border-color: var(--color-secondary-50); color: var(--link-hover);
}
.btn-sm { padding: 8px 16px; font-size: var(--fs-14); }
.btn-lg { padding: 15px 30px; font-size: var(--fs-18); border-radius: var(--r-12); }

/* ---------- header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 100; height: var(--header-h);
  transition: background var(--dur-enter), box-shadow var(--dur-enter);
}
.site-header { background: #fff; box-shadow: 0 1px 0 var(--gs-10); }
.site-header.is-stuck { box-shadow: var(--sh-2); }
.header-inner { display: flex; align-items: center; justify-content: space-between; height: var(--header-h); gap: 20px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-logo { width: 44px; height: 44px; object-fit: contain; border-radius: 10px; background: #fff; padding: 3px; box-shadow: var(--sh-1); }
.brand-name { font-weight: 800; font-size: var(--fs-18); letter-spacing: .01em; }
.main-nav .nav-list { display: flex; align-items: center; gap: 4px; }
.nav-link {
  display: inline-flex; align-items: center; gap: 6px; padding: 9px 13px; border: 0; background: none;
  border-radius: var(--r-8); font-size: var(--fs-15, .9375rem); font-weight: 500; text-decoration: none; color: var(--gs-90);
  transition: background var(--dur-exit), color var(--dur-exit);
}
.nav-link:hover { background: #00000008; color: var(--color-primary-40); }
.nav-link.is-active { color: var(--color-primary-40); font-weight: 700; }
.has-drop { position: relative; }
.chev { transition: transform var(--dur-exit); }
.has-drop.open .chev { transform: rotate(180deg); }
.drop-menu {
  position: absolute; top: calc(100% + 6px); left: 0; min-width: 220px; background: #fff; border-radius: var(--r-12);
  box-shadow: var(--sh-4); padding: 8px; opacity: 0; visibility: hidden; transform: translateY(-6px);
  transition: opacity var(--dur-enter), transform var(--dur-enter), visibility var(--dur-enter);
}
.has-drop.open .drop-menu { opacity: 1; visibility: visible; transform: none; }
.drop-menu a { display: block; padding: 9px 12px; border-radius: var(--r-8); text-decoration: none; font-size: var(--fs-14); color: var(--gs-90); }
.drop-menu a:hover { background: var(--gs-5); color: var(--color-primary-40); }
.nav-cta-li { margin-left: 8px; }
.nav-burger { display: none; flex-direction: column; gap: 5px; background: none; border: 0; padding: 10px; }
.nav-burger span { width: 22px; height: 2px; background: currentColor; border-radius: 2px; transition: transform var(--dur-enter), opacity var(--dur-enter); }

@media (max-width: 960px) {
  .nav-burger { display: flex; }
  .main-nav {
    position: fixed; inset: var(--header-h) 0 auto 0; background: #fff; box-shadow: var(--sh-4);
    max-height: calc(100dvh - var(--header-h)); overflow: auto;
    transform: translateY(-8px); opacity: 0; visibility: hidden; transition: all var(--dur-enter);
  }
  body.nav-open .main-nav { transform: none; opacity: 1; visibility: visible; }
  .main-nav .nav-list { flex-direction: column; align-items: stretch; padding: 12px 16px 20px; gap: 2px; }
  .nav-link { width: 100%; justify-content: flex-start; color: var(--gs-90); }
  .drop-menu { position: static; box-shadow: none; opacity: 1; visibility: visible; transform: none; display: none; background: var(--gs-5); margin: 4px 0 6px; }
  .has-drop.open .drop-menu { display: block; }
  .nav-cta-li { margin: 10px 0 0; }
  .nav-cta-li .btn { width: 100%; }
}

/* ---------- footer ---------- */
.site-footer { background: var(--surface); color: var(--text); border-top: 1px solid var(--line); margin-top: 0; }
.footer-grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1.2fr; gap: 40px; padding: 48px 0 36px; }
.footer-logo { width: 64px; height: 64px; object-fit: contain; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 5px; margin-bottom: 14px; }
.footer-brand p { font-size: var(--fs-14); color: var(--muted); max-width: 36ch; }
.footer-quicklinks { display: flex; flex-wrap: wrap; gap: 10px 16px; margin-top: 14px; }
.footer-quicklinks a { color: var(--link); font-size: var(--fs-14); font-weight: 600; text-decoration: none; }
.footer-quicklinks a:hover { color: var(--link-hover); text-decoration: underline; }
.footer-col h3 { font-size: var(--fs-14); text-transform: uppercase; letter-spacing: .09em; color: var(--text-strong); margin-bottom: 14px; }
.footer-col ul li + li { margin-top: 9px; }
.footer-col a { text-decoration: none; font-size: var(--fs-14); color: var(--muted); transition: color var(--dur-exit); }
.footer-col a:hover { color: var(--link-hover); }
.footer-cta p { font-size: var(--fs-14); color: var(--muted); }
.footer-cta .footer-secondary-cta { margin: 12px 0 0; }
.footer-base { border-top: 1px solid var(--line); }
.footer-base-inner { display: flex; justify-content: space-between; gap: 16px; padding: 16px 0; font-size: var(--fs-12); color: var(--muted); flex-wrap: wrap; }
@media (max-width: 900px) { .footer-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .footer-grid { grid-template-columns: 1fr; gap: 26px; padding: 38px 0 28px; } }

/* ---------- reveal-on-scroll ---------- */
.reveal { opacity: 0; transform: translateY(26px); transition: opacity .6s ease, transform .6s ease; }
.reveal.is-in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  html { scroll-behavior: auto; }
}

/* ---- Native app shell (Capacitor Android/iOS) ---------------------------
   .is-native is added by assets/js/native.js when the page runs inside the
   app. Keep web behaviour untouched: these rules only apply there. */
html.is-native { -webkit-tap-highlight-color: transparent; }
html.is-native body { overscroll-behavior-y: none; }
html.is-native .bottom-nav {
  padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px));
  height: calc(60px + env(safe-area-inset-bottom, 0px));
}
html.is-native .bottom-nav ~ * { scroll-margin-bottom: env(safe-area-inset-bottom, 0px); }
html.is-native .install-bar { display: none !important; }

/* ==========================================================================
   Light appearance tokens
   --------------------------------------------------------------------------
   Components use these tokens for consistent public-page surfaces and controls.
   ========================================================================== */
:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --bg-elevated: #ffffff;
  --surface: #ffffff;
  --surface-2: #f2f4f7;
  --surface-3: #e9edf2;
  --text: #101820;
  --text-strong: #032143;
  --muted: #5a6b7b;
  --muted-2: #7b8894;
  --line: #dfe4ea;
  --line-strong: #c8d0d9;
  --link: #0b2f57;
  --link-hover: #e1191c;
  --brand: var(--color-brand-navy);
  --brand-ink: #ffffff;
  --accent: #16406e;
  --accent-soft: #eaeff6;
  --danger: #b3151a;
  --danger-soft: #fdecec;
  --success: #14663f;
  --success-soft: #e8f5ee;
  --warning: #8a5a06;
  --warning-soft: #fdf3e2;
  --info: #0b2f57;
  --info-soft: #eaeff6;
  --focus: #16406e;
  --focus-ring: #16406e40;
  --shadow-sm: 0 1px 2px #0321430f;
  --shadow-md: 0 4px 14px #0321431a;
  --shadow-lg: 0 12px 32px #03214326;
  --overlay: #032143a6;
}

/* ==========================================================================
   Light surface application
   --------------------------------------------------------------------------
   Public and admin surfaces remain in the light appearance.
   ========================================================================== */

html { background: var(--bg); }
body { background: var(--bg); color: var(--text); }

/* Headings, paragraphs and links inherit the theme's ink */
h1, h2, h3, h4 { color: var(--text-strong); }
a { color: var(--link); }
a:hover { color: var(--link-hover); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

/* shared surfaces */
.panel, .card-box, .chart-card, .form-card, .m-card, .lf-card, .card, .kpi {
  background: var(--surface);
  border-color: var(--line);
  color: var(--text);
}
.panel header, .card-box h3 { border-color: var(--line); }

/* tables */
table { border-color: var(--line); }
thead th, .sc-table thead th { background: var(--surface-2); color: var(--text-strong); border-color: var(--line); }
tbody tr:hover > * { background: var(--surface-2); }
tbody td { border-color: var(--line); }
tr.total td, .sc-table tr.total td { background: var(--surface-3); color: var(--text-strong); }

/* forms */
.field label, label { color: var(--text); }
.field input, .field select, .field textarea, .field textarea,
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="search"], input[type="date"], input[type="tel"], select, textarea {
  background: var(--surface);
  border-color: var(--line-strong);
  color: var(--text);
}
.field input:focus, .field select:focus, .field textarea:focus,
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 3px var(--focus-ring);
}
::placeholder { color: var(--muted-2); opacity: 1; }
input:disabled, select:disabled, textarea:disabled, .btn:disabled, .is-disabled {
  background: var(--surface-3);
  color: var(--muted-2);
  border-color: var(--line);
  cursor: not-allowed;
  opacity: 1;
}

/* status surfaces — colour is never the only signal, each carries its own ink */
.alert, .flash { border-radius: var(--r-8); border: 1px solid var(--line); }
.alert.ok, .alert.success, .flash.ok, .form-ok {
  background: var(--success-soft); border-color: #1c8a542e; color: var(--success);
}
.alert.bad, .alert.error, .flash.bad, .alert.danger {
  background: var(--danger-soft); border-color: #b3151a2e; color: var(--danger);
}
.alert.warn, .flash.warn { background: var(--warning-soft); border-color: #8a5a062e; color: var(--warning); }
.alert.info, .flash.info { background: var(--info-soft); border-color: #0b2f572e; color: var(--info); }
.alert.bad::before, .alert.ok::before { font-weight: 800; }
.error, .field .error, [aria-invalid="true"] { color: var(--danger); }
[aria-invalid="true"] { border-color: var(--danger) !important; }

/* dialog / overlay / menus */
.menu, .drop-menu, [role="menu"], dialog, .modal {
  background: var(--surface);
  color: var(--text);
  border-color: var(--line);
  box-shadow: var(--shadow-lg);
}
.overlay, .modal-backdrop, .lightbox { background: var(--overlay); }

/* users who ask the OS for less motion still get a usable page */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* segmented controls keep a legible active chip */
.seg { background: var(--surface); border-color: var(--line); color: var(--muted); }
.seg:hover { border-color: var(--line-strong); color: var(--text); }
.seg.on, .seg.on:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 700;
}
