/* Million Automations — shared design kit (the default look for any MA site).
 *
 * Drop-in (3 lines) for a new MA site or dashboard:
 *   <link rel="stylesheet" href="https://demo.millionautomations.com/ma-kit.css">
 *   <script src="https://demo.millionautomations.com/nodebg.js"></script>
 *   <script src="https://demo.millionautomations.com/track.js" data-prop="my-site" defer></script>
 * ...and set <html data-theme="light"> (light is the MA default; "dark" also supported).
 *
 * Provides: MA fonts (Space Grotesk headings + Inter body), the brand light-theme
 * token set, base typography, and a translucent .ma-panel card that reads well
 * over the constellation background. Page-specific components reference the vars.
 */
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600;700;800&display=swap');

:root,
:root[data-theme='light'] {
  --ma-bg: #eaf1fb;            /* cool near-white; nodebg paints its own light field over this */
  --ma-panel: rgba(255,255,255,0.80);
  --ma-panel-2: rgba(255,255,255,0.55);
  --ma-panel-solid: #ffffff;
  --ma-ink: #0c1b30;          /* deep navy — headings + numbers */
  --ma-ink-2: #33465f;        /* body */
  --ma-muted: #5a6b82;        /* labels (≥4.5:1 on white) */
  --ma-line: rgba(12,27,48,0.10);
  --ma-line-2: rgba(12,27,48,0.16);
  --ma-brand: #06b6d4;        /* MA cyan — fills, meters, nodes */
  --ma-brand-2: #7fe0f2;
  --ma-brand-strong: #0e7490; /* cyan text on white (contrast-safe) */
  --ma-brand-ink: #ffffff;    /* text on a brand fill */
  --ma-track: rgba(12,27,48,0.07);
  --ma-good: #059669;
  --ma-bad: #e11d48;
  --ma-shadow: 0 18px 40px -22px rgba(8,25,53,0.45);
  --ma-r: 14px;
  --ma-sans: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --ma-head: 'Space Grotesk', var(--ma-sans);
  color-scheme: light;
}

:root[data-theme='dark'] {
  --ma-bg: #050b18;
  --ma-panel: rgba(12,27,48,0.66);
  --ma-panel-2: rgba(255,255,255,0.05);
  --ma-panel-solid: #0c1b30;
  --ma-ink: #f2f7ff;
  --ma-ink-2: #c9d4e5;
  --ma-muted: #9fb0c8;
  --ma-line: rgba(255,255,255,0.12);
  --ma-line-2: rgba(255,255,255,0.18);
  --ma-brand: #22d3ee;
  --ma-brand-2: #7fe0f2;
  --ma-brand-strong: #67e8f9;
  --ma-brand-ink: #04222b;
  --ma-track: rgba(255,255,255,0.08);
  --ma-good: #34d399;
  --ma-bad: #fb7185;
  --ma-shadow: 0 22px 50px -18px rgba(0,0,0,0.7);
  color-scheme: dark;
}

.ma-base {
  margin: 0;
  font-family: var(--ma-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ma-ink-2);
  background: var(--ma-bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
.ma-base h1, .ma-base h2, .ma-base h3 {
  font-family: var(--ma-head);
  color: var(--ma-ink);
  text-wrap: balance;
}
.ma-panel {
  background: var(--ma-panel);
  border: 1px solid var(--ma-line);
  border-radius: var(--ma-r);
  backdrop-filter: blur(10px) saturate(1.15);
  -webkit-backdrop-filter: blur(10px) saturate(1.15);
  box-shadow: var(--ma-shadow);
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ===== ma-ui contract v1 — portal switcher =====
 * Pairs with /ma-ui.js MAUI.portalStrip(). Surfaces USE these classes, never DEFINE them:
 * each surface's own <style> loads after this file and would win at equal specificity. */
html{ --ma-accent: var(--ma-brand-strong); }   /* html (0,0,1) so a per-file :root override always wins */
.ma-portals,.ma-portals *{ box-sizing:border-box; }
.ma-portals{ margin:20px 0 10px; border:1px solid var(--ma-line); border-radius:var(--ma-r);
  background:var(--ma-panel); box-shadow:var(--ma-shadow);
  backdrop-filter:blur(10px) saturate(1.15); -webkit-backdrop-filter:blur(10px) saturate(1.15);
  font-family:var(--ma-sans); font-size:14px; }
.ma-portals>summary{ list-style:none; cursor:pointer; padding:0; }
.ma-portals>summary::-webkit-details-marker{ display:none; }
.ma-portals>summary::marker{ content:''; }
.ma-p-bar{ display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between;
  gap:6px 14px; padding:12px 14px; min-height:44px; border-radius:var(--ma-r); }
.ma-portals>summary:focus-visible .ma-p-bar{ outline:2px solid var(--ma-accent); outline-offset:-2px; }
.ma-p-here{ font-size:11px; letter-spacing:.06em; text-transform:uppercase; color:var(--ma-muted); }
.ma-p-here b{ font-size:12.5px; letter-spacing:0; text-transform:none; color:var(--ma-ink); font-weight:700; }
.ma-p-cta{ display:inline-flex; align-items:center; gap:7px; font-size:12.5px; font-weight:600;
  color:var(--ma-accent); white-space:nowrap; }
.ma-p-chev{ width:0; height:0; border-left:4.5px solid transparent; border-right:4.5px solid transparent;
  border-top:5px solid currentColor; transition:transform .18s ease; }
.ma-portals[open] .ma-p-chev{ transform:rotate(180deg); }
.ma-p-grid{ display:flex; flex-wrap:wrap; gap:8px; padding:0 14px 4px; }
.ma-p-grid a,.ma-p-self{ display:inline-flex; align-items:center; gap:6px; min-height:38px;
  border:1px solid var(--ma-line); border-radius:10px; padding:8px 12px; font-size:12.5px;
  background:var(--ma-panel-solid); color:var(--ma-ink-2); text-decoration:none; white-space:nowrap; }
.ma-p-grid a:hover{ border-color:var(--ma-accent); color:var(--ma-ink); }
.ma-p-grid a:focus-visible{ outline:2px solid var(--ma-accent); outline-offset:2px; }
.ma-p-grid a i{ font-style:normal; color:var(--ma-muted); }
.ma-p-self{ border-color:var(--ma-accent); color:var(--ma-accent); background:var(--ma-panel-2); cursor:default; }
.ma-p-self i{ font-style:normal; font-size:10.5px; letter-spacing:.05em; text-transform:uppercase; opacity:.8; }
.ma-p-note{ margin:0; padding:8px 14px 12px; font-size:11px; color:var(--ma-muted); }
.ma-p-jump{ font:600 12px/1 var(--ma-sans); cursor:pointer; padding:7px 11px; border-radius:9px;
  border:1px solid var(--ma-line-2); background:var(--ma-panel-solid); color:var(--ma-accent); }
.ma-p-jump:hover{ border-color:var(--ma-accent); }
.ma-p-jump:focus-visible{ outline:2px solid var(--ma-accent); outline-offset:2px; }
@media (max-width:430px){
  .ma-p-bar{ padding:11px 12px; } .ma-p-grid{ padding:0 12px 4px; }
  .ma-p-grid a,.ma-p-self{ width:100%; white-space:normal; }
}

/* ===== ma-ui contract v1 — detail modal =====
 * Singleton native <dialog> built by /ma-ui.js at body level (top layer, so it is immune to the
 * backdrop-filter containing-block and z-index contention inside each surface's cards).
 * Every selector is class-qualified so it outranks the per-file bare-element rules
 * (table/th/td/button/label/input) that load after this file. */
html.ma-modal-open{ overflow:hidden; }
dialog.ma-m{ padding:0; border:0; background:transparent; margin:auto; overflow:visible;
  width:min(560px,calc(100vw - 20px)); max-width:none; max-height:none; }
dialog.ma-m.wide{ width:min(760px,calc(100vw - 20px)); }
dialog.ma-m::backdrop{ background:rgba(8,14,24,.55); backdrop-filter:blur(3px); -webkit-backdrop-filter:blur(3px); }
dialog.ma-m .ma-m-card{ display:flex; flex-direction:column; overflow:hidden;
  max-height:88vh; max-height:88svh;   /* svh second so old engines keep the vh fallback */
  background:var(--ma-panel-solid); color:var(--ma-ink-2); font-family:var(--ma-sans); font-size:14px;
  line-height:1.5; text-align:left; border:1px solid var(--ma-line); border-radius:var(--ma-r);
  box-shadow:0 26px 64px -20px rgba(8,25,53,.55); animation:ma-pop .2s ease; }
dialog.ma-m .ma-m-card:focus{ outline:none; }
@keyframes ma-pop{ from{ transform:translateY(10px); opacity:0 } }
@media (prefers-reduced-motion:reduce){ dialog.ma-m .ma-m-card{ animation:none } }
dialog.ma-m .ma-m-head{ flex:none; display:flex; align-items:flex-start; gap:10px; padding:13px 15px;
  border-bottom:1px solid var(--ma-line); }
dialog.ma-m .ma-m-titles{ flex:1 1 auto; min-width:0; }
dialog.ma-m .ma-m-title{ margin:0; font-family:var(--ma-head); font-size:15.5px; font-weight:700; color:var(--ma-ink); }
dialog.ma-m .ma-m-sub{ margin:2px 0 0; font-size:11.5px; color:var(--ma-muted); }
dialog.ma-m .ma-m-back,dialog.ma-m .ma-m-x{ flex:none; cursor:pointer; background:var(--ma-panel-solid);
  border:1px solid var(--ma-line); border-radius:9px; color:var(--ma-muted); font:inherit; }
dialog.ma-m .ma-m-back{ padding:5px 9px; font-size:12px; }
dialog.ma-m .ma-m-x{ width:32px; height:32px; padding:0; font-size:19px; line-height:1; }
dialog.ma-m .ma-m-back:hover,dialog.ma-m .ma-m-x:hover{ color:var(--ma-ink); border-color:var(--ma-accent); }
dialog.ma-m .ma-m-back:focus-visible,dialog.ma-m .ma-m-x:focus-visible{ outline:2px solid var(--ma-accent); outline-offset:2px; }
dialog.ma-m .ma-m-body{ flex:1 1 auto; min-height:0; padding:14px 15px; overflow-y:auto;
  overscroll-behavior:contain; -webkit-overflow-scrolling:touch; }
dialog.ma-m .ma-m-foot{ flex:none; display:flex; flex-wrap:wrap; align-items:center; gap:8px 12px;
  padding:10px 15px; border-top:1px solid var(--ma-line); }
dialog.ma-m .ma-m-note{ flex:1 1 180px; margin:0; font-size:10.5px; color:var(--ma-muted); }
dialog.ma-m .ma-m-status{ order:3; flex:1 1 100%; margin:0; font-size:11.5px; font-weight:600; color:var(--ma-good); }
dialog.ma-m .ma-m-status:empty{ display:none; }
dialog.ma-m .ma-m-acts{ display:flex; gap:8px; flex-wrap:wrap; }
.ma-m-body .ma-m-h{ margin:16px 0 7px; font-family:var(--ma-head); font-size:12px; font-weight:700;
  letter-spacing:.06em; text-transform:uppercase; color:var(--ma-muted); }
.ma-m-body .ma-m-h:first-child{ margin-top:0; }
.ma-m-body .ma-kv{ margin:0; border:1px solid var(--ma-line); border-radius:10px; overflow:hidden; }
.ma-m-body .ma-kv-r{ display:flex; gap:12px; justify-content:space-between; padding:8px 11px; font-size:13px; }
.ma-m-body .ma-kv-r:nth-child(odd){ background:var(--ma-panel-2); }
.ma-m-body .ma-kv dt{ color:var(--ma-muted); min-width:0; }
.ma-m-body .ma-kv dd{ margin:0; font-weight:700; color:var(--ma-ink); text-align:right; font-variant-numeric:tabular-nums; }
.ma-m-body .ma-kv-x{ display:block; font-style:normal; font-weight:400; font-size:11px; color:var(--ma-muted); }
.ma-m-body .ma-scroll{ overflow-x:auto; -webkit-overflow-scrolling:touch; }
.ma-m-body .ma-scroll:focus-visible{ outline:2px solid var(--ma-accent); outline-offset:2px; }
.ma-m-body .ma-tbl{ width:100%; border-collapse:collapse; font-size:12.5px; }
.ma-m-body .ma-tbl th,.ma-m-body .ma-tbl td{ text-align:left; padding:7px 9px;
  border-bottom:1px solid var(--ma-line); white-space:nowrap; }
.ma-m-body .ma-tbl thead th{ font-size:10.5px; letter-spacing:.05em; text-transform:uppercase; color:var(--ma-muted); }
.ma-m-body .ma-tbl td:not(:first-child),.ma-m-body .ma-tbl th:not(:first-child){ text-align:right; font-variant-numeric:tabular-nums; }
.ma-m-body .ma-tbl tfoot th{ border-bottom:0; border-top:1px solid var(--ma-line-2); color:var(--ma-ink); }
.ma-m-body .ma-bars{ display:grid; gap:10px; }
.ma-m-body .ma-bar-t{ display:flex; justify-content:space-between; gap:10px; font-size:12.5px; }
.ma-m-body .ma-bar-t b{ color:var(--ma-ink); font-variant-numeric:tabular-nums; }
.ma-m-body .ma-bar-tr{ height:7px; margin-top:4px; border-radius:99px; background:var(--ma-track); overflow:hidden; }
.ma-m-body .ma-bar-tr i{ display:block; height:100%; background:var(--ma-brand); }
.ma-m-body .ma-bar-s{ margin-top:3px; font-size:11px; color:var(--ma-muted); }
.ma-m-body .ma-note{ margin:12px 0 0; padding:9px 11px; border:1px solid var(--ma-line);
  border-left:3px solid var(--ma-accent); border-radius:8px; background:var(--ma-panel-2); font-size:12px; }
.ma-m-body .ma-note-warn{ border-left-color:var(--ma-bad); }
.ma-m-body .ma-note-good{ border-left-color:var(--ma-good); }
.ma-m-body .ma-kv+.ma-kv,.ma-m-body .ma-scroll+*,.ma-m-body .ma-bars+*{ margin-top:12px; }
.ma-btn{ cursor:pointer; font:600 13px/1 var(--ma-sans); padding:10px 14px; border-radius:9px;
  border:1px solid var(--ma-line-2); background:var(--ma-panel-solid); color:var(--ma-ink); }
.ma-btn:hover{ border-color:var(--ma-accent); }
.ma-btn:focus-visible{ outline:2px solid var(--ma-accent); outline-offset:2px; }
.ma-btn-primary{ background:var(--ma-accent); border-color:var(--ma-accent); color:#fff; }
.ma-btn:disabled{ opacity:.45; cursor:not-allowed; }
.ma-toast{ position:fixed; left:50%; bottom:24px; transform:translateX(-50%) translateY(12px);
  background:#12253d; color:#e8edf4; border:1px solid var(--ma-brand); padding:10px 16px; border-radius:10px;
  font-size:13px; opacity:0; pointer-events:none; transition:opacity .3s,transform .3s; z-index:2147483000;
  max-width:calc(100vw - 32px); text-align:center; }
.ma-toast.show{ opacity:1; transform:translateX(-50%); }
