/* FlashScaler portal — Material tokens (orange + white) and the app shell.
   Controls keep their own shadow-DOM styles and read the tokens below. */

:root {
  --primary: #f97316;        /* orange 500 — overridden at runtime from [brand].color */
  /* hover + tint shades derive from --primary, so a brand color change cascades */
  --primary-700: color-mix(in srgb, var(--primary) 85%, black);
  --primary-tint: color-mix(in srgb, var(--primary) 12%, white);
  --accent: #fb923c;
  --on-primary: #ffffff;

  --bg: #faf9f7;
  --surface: #ffffff;
  --surface-2: #f6f4f1;
  --elevated: #ffffff;
  --on-surface: #241c14;
  --muted: #6b5f54;
  --faint: #a89b8e;
  --line: #efe9e2;
  --line-2: #e2d9cf;
  --hover: #fff7f0;
  --ink: #7c2d12;            /* orange 900 for emphasis */
  --on-ink: #ffffff;

  --green: #16a34a;  --green-tint: #e7f7ee;
  --red: #dc2626;    --red-tint: #fde8e8;
  --amber: #d97706;  --amber-tint: #fdf0dd;
  --grey: #5b5b6b;   --grey-tint: #eeeef3;

  --shadow: 0 1px 3px rgba(20,20,40,.10), 0 1px 2px rgba(20,20,40,.06);
  --shadow-lg: 0 12px 32px rgba(20,20,40,.18);

  --radius: 10px;
  --radius-sm: 6px;
  --nav-w: 248px;
  --topbar-h: 56px;
  --scrollbar-size: 6px;
  --scrollbar-thumb: rgba(120,120,140,.45);
  --scrollbar-thumb-hover: rgba(120,120,140,.75);

  --font: "Inter", Roboto, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-family: var(--font);
  color: var(--on-surface);
  background: var(--bg);
}

* { box-sizing: border-box; }
* { scrollbar-width: thin; scrollbar-color: var(--scrollbar-thumb) transparent; }
::-webkit-scrollbar { width: var(--scrollbar-size); height: var(--scrollbar-size); }
::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-thumb-hover); }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--primary); }

/* ── shell ─────────────────────────────────────────────────────────────── */
.app { display: flex; min-height: 100vh; min-height: 100dvh; }
/* author `display:flex` beats the UA [hidden] rule — restore hidden so the app shell
   never flashes before boot() decides auth (same fix as .signin[hidden]). */
.app[hidden] { display: none; }

.nav {
  width: var(--nav-w); flex: 0 0 var(--nav-w);
  background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; height: 100dvh;
}
.nav__brand {
  height: var(--topbar-h); display: flex; align-items: center; gap: 8px;
  padding: 0 20px; font-weight: 600; font-size: 17px;
  color: var(--on-primary); background: var(--primary);
}
.nav__logo { font-size: 16px; }
.nav__list { display: flex; flex-direction: column; padding: 8px 0; overflow-y: auto; flex: 1; }
.nav__link {
  display: flex; align-items: center; gap: 10px; min-height: 46px; padding: 0 20px;
  color: var(--on-surface); text-decoration: none; font-size: 14px; font-weight: 500;
  border-left: 3px solid transparent;
}
.nav__link:hover { background: var(--hover); }
.nav__link[aria-current="page"] { color: var(--primary-700); background: var(--primary-tint); border-left-color: var(--primary); }
.nav__foot { padding: 14px 20px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--muted); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--topbar-h); display: flex; align-items: center; gap: 10px;
  padding: 0 16px; background: var(--primary); color: var(--on-primary);
  box-shadow: var(--shadow); position: sticky; top: 0; z-index: 10;
}
.topbar__title { margin: 0; font-size: 19px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar__spacer { flex: 1; }
.topbar__badge { font-size: 11px; font-weight: 700; letter-spacing: .08em; background: rgba(255,255,255,.2); padding: 3px 8px; border-radius: 999px; }
.topbar__menu { display: none; width: 44px; height: 44px; border: 0; border-radius: 50%; background: transparent; color: inherit; cursor: pointer; }
.topbar__menu:hover { background: rgba(255,255,255,.15); }

.view { flex: 1; padding: 24px; }

/* ── building blocks ──────────────────────────────────────────────────── */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.page { display: flex; flex-direction: column; gap: 18px; height: 100%; min-height: 0; }
.page__head { display: flex; align-items: center; gap: 12px; }
.page__head h2 { margin: 0; font-size: 20px; font-weight: 600; }
.page__head .muted { color: var(--muted); font-size: 14px; }
.page__spacer { flex: 1; }
.btn { height: 42px; padding: 0 18px; border: 0; border-radius: var(--radius-sm); background: var(--primary); color: var(--on-primary); font: inherit; font-weight: 600; cursor: pointer; box-shadow: var(--shadow); display: inline-flex; align-items: center; gap: 8px; }
.btn:hover { background: var(--primary-700); }
.btn--ghost { background: var(--surface); color: var(--on-surface); border: 1px solid var(--line-2); box-shadow: none; }
.btn--ghost:hover { background: var(--hover); }
.btn:disabled { opacity: .55; cursor: default; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.field > label { font-weight: 500; }
.input { height: 42px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: var(--radius-sm); font: inherit; color: var(--on-surface); background: var(--surface); }
.input:focus { outline: 2px solid var(--primary); outline-offset: -1px; }

.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; }
.pill--ready { background: var(--green-tint); color: var(--green); }
.pill--work  { background: var(--amber-tint); color: var(--amber); }
.pill--fail  { background: var(--red-tint); color: var(--red); }
.pill--draft { background: var(--grey-tint); color: var(--grey); }
.pill .spin { width: 11px; height: 11px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.table-wrap { flex: 1; min-height: 320px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.table-wrap fl-datatable { flex: 1 1 0; min-height: 0; margin: 0; --dt-height: auto; }

/* ── toasts ───────────────────────────────────────────────────────────── */
.toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 50; width: min(92vw, 440px); }
.toast { background: #2b2b3c; color: #fff; padding: 12px 16px; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); font-size: 14px; }
.toast--error { background: var(--red); }

.nav-scrim { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 30; }

/* ── responsive ───────────────────────────────────────────────────────── */
@media (max-width: 1024px) and (orientation: portrait), (max-width: 900px) {
  .topbar__menu { display: inline-flex; align-items: center; justify-content: center; }
  .nav { position: fixed; left: 0; top: 0; bottom: 0; z-index: 40; transform: translateX(-100%); transition: transform .2s ease; }
  .app.nav-open .nav { transform: translateX(0); box-shadow: var(--shadow-lg); }
}
@media (max-width: 600px) { .view { padding: 16px 12px; } .topbar__title { font-size: 17px; } }

/* ── sign-in screen ───────────────────────────────────────────────────────── */
.signin[hidden] { display: none; }
.signin { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center;
  padding: 24px; background: radial-gradient(1200px 600px at 50% -10%, var(--primary-tint), var(--bg)); }
.signin__card { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 32px 28px; text-align: center; }
.signin__brand { font-size: 22px; font-weight: 700; color: var(--on-surface); display: inline-flex; align-items: center; gap: 8px; }
.signin__logo { color: var(--primary); }
.signin__sub { margin-top: 6px; font-size: 14px; color: var(--muted); }
.signin__providers { display: flex; flex-direction: column; gap: 10px; margin-top: 24px; }
.prov { display: flex; align-items: center; gap: 12px; width: 100%; height: 48px; padding: 0 16px;
  border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: var(--surface);
  color: var(--on-surface); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  transition: background .12s, border-color .12s, box-shadow .12s; }
.prov:hover { background: var(--hover); border-color: var(--muted); box-shadow: var(--shadow); }
.prov__icon { width: 20px; height: 20px; flex: none; object-fit: contain; }
.prov span { flex: 1; text-align: center; margin-left: -20px; }
.signin__legal { margin-top: 18px; font-size: 12px; color: var(--faint); }
.signin__dev { margin-top: 14px; border: 0; background: none; color: var(--primary-700);
  font: inherit; font-size: 12.5px; text-decoration: underline; cursor: pointer; }

.nav__signout { margin-top: 8px; border: 0; background: none; padding: 0; color: var(--primary-700);
  font: inherit; font-size: 12px; text-decoration: underline; cursor: pointer; }
