/* ACE Staff Portal — design system
   Palette sampled from brand_assets/ace-logo.webp. Do not substitute. */

:root {
  /* Brand — straight off the ACE logo gradient */
  --navy-900: #0d1630;
  --navy-850: #101c42;
  --navy-800: #122a68;
  --navy-700: #1b3d92;   /* primary */
  --navy-600: #2d499c;
  --navy-500: #4e5ea8;
  --navy-400: #6d83bc;
  --navy-300: #91a7c9;
  --navy-200: #babedf;
  --navy-100: #d9dced;
  --navy-50:  #eef1f9;

  /* Functional accents, derived to sit beside the navy without fighting it */
  --amber-600: #b8650a;
  --amber-500: #d97d0d;
  --amber-100: #fdf1dd;
  --red-600:   #a82a22;
  --red-500:   #c2342b;
  --red-100:   #fbe7e5;
  --green-600: #156139;
  --green-500: #1b7a4b;
  --green-100: #e2f3ea;

  /* Surfaces: base → elevated → floating */
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-sunken: #f0f3fa;
  --border: #dfe3ee;
  --border-strong: #c8cfe2;

  --text: #131a2e;
  --text-2: #4a5673;
  --text-3: #79839d;
  --text-inv: #ffffff;

  --shadow-sm: 0 1px 2px rgba(13, 22, 48, .05), 0 2px 8px rgba(27, 61, 146, .05);
  --shadow-md: 0 2px 4px rgba(13, 22, 48, .05), 0 8px 20px rgba(27, 61, 146, .08);
  --shadow-lg: 0 8px 24px rgba(13, 22, 48, .10), 0 24px 56px rgba(27, 61, 146, .14);
  --shadow-inset: inset 0 1px 0 rgba(255, 255, 255, .6);

  /* 4px base scale */
  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px;
  --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px;

  --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --r-xl: 20px;

  --ease: cubic-bezier(.22, 1, .36, 1);
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);

  --sidebar-w: 248px;
}

* { box-sizing: border-box; }

/* Any explicit `display` beats the hidden attribute's UA default, so the
   attribute has to win outright — several panels here are grid/flex. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: Sora, Inter, sans-serif;
  letter-spacing: -.03em;
  line-height: 1.15;
  margin: 0;
  font-weight: 600;
}

h1 { font-size: 30px; }
h2 { font-size: 21px; }
h3 { font-size: 16px; letter-spacing: -.02em; }

p { margin: 0; }

a { color: var(--navy-700); }

.mono {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-variant-numeric: tabular-nums;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

:focus-visible {
  outline: 2px solid var(--navy-600);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* ------------------------------------------------------------------ login */

.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: var(--s5);
  position: relative;
  isolation: isolate;
  background:
    radial-gradient(900px 620px at 12% -8%, rgba(45, 73, 156, .55), transparent 62%),
    radial-gradient(760px 540px at 92% 6%, rgba(109, 131, 188, .40), transparent 58%),
    radial-gradient(1100px 800px at 50% 115%, rgba(18, 42, 104, .70), transparent 64%),
    linear-gradient(168deg, var(--navy-850) 0%, var(--navy-900) 58%, #080f22 100%);
}

/* Fine grain keeps the large gradient field from banding. */
.login::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  opacity: .16;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.login-card {
  width: min(430px, 100%);
  background: var(--surface);
  border-radius: var(--r-xl);
  padding: var(--s7) var(--s6) var(--s6);
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.login-logo {
  width: 168px;
  height: auto;
  margin: 0 auto var(--s5);
  display: block;
}

.login-card h1 { font-size: 23px; margin-bottom: var(--s2); }

.login-sub {
  color: var(--text-3);
  font-size: 14px;
  margin-bottom: var(--s6);
}

.login-form { display: grid; gap: var(--s4); text-align: left; }

.login-foot {
  margin-top: var(--s5);
  font-size: 12.5px;
  color: var(--text-3);
  line-height: 1.6;
}

.login-links {
  margin-top: var(--s4);
  padding-top: var(--s4);
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2) var(--s4);
  justify-content: center;
  font-size: 13px;
}

.login-links:empty { display: none; }

.link-btn {
  font: inherit;
  font-size: 13px;
  background: none;
  border: 0;
  padding: 2px 4px;
  color: var(--navy-700);
  font-weight: 550;
  cursor: pointer;
  border-radius: var(--r-sm);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  transition: color .16s var(--ease);
}

.link-btn:hover { color: var(--navy-800); }

/* ------------------------------------------------------------------ forms */

.field { display: grid; gap: var(--s2); }

label.lbl, .lbl {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-3);
}

input[type=text], input[type=email], input[type=password], input[type=search], select, textarea {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--neo-bg);
  border: 0;
  border-radius: var(--r-md);
  padding: 11px 13px;
  box-shadow: var(--neo-inset);
  transition: box-shadow .18s var(--ease);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  box-shadow: var(--neo-inset), 0 0 0 3px rgba(45, 73, 156, .22);
}

/* The sign-in screen sits on its own dark gradient, not the app's blue
   surface — its fields keep the original crisp white-card look rather
   than sinking into a background they're not actually sitting on. */
#login input[type=text], #login input[type=email], #login input[type=password] {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  box-shadow: none;
}
#login input:hover { border-color: var(--navy-400); }
#login input:focus {
  border-color: var(--navy-600);
  box-shadow: 0 0 0 3px rgba(45, 73, 156, .16);
}

textarea { resize: vertical; min-height: 128px; line-height: 1.65; }

input::placeholder, textarea::placeholder { color: var(--text-3); }

/* --------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  font: inherit;
  font-weight: 550;
  padding: 11px 18px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: transform .16s var(--ease-spring), box-shadow .18s var(--ease),
              background-color .18s var(--ease), border-color .18s var(--ease), opacity .18s var(--ease);
}

.btn:active:not(:disabled) { transform: translateY(1px) scale(.985); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(180deg, var(--navy-600), var(--navy-700));
  color: var(--text-inv);
  box-shadow: var(--neo-raised), var(--shadow-inset);
}
.btn-primary:hover:not(:disabled) {
  background: linear-gradient(180deg, var(--navy-700), var(--navy-800));
  box-shadow: var(--neo-raised-lg), var(--shadow-inset);
}
.btn-primary:active:not(:disabled) { box-shadow: var(--neo-inset-sm); }

.btn-secondary {
  background: var(--neo-bg);
  color: var(--navy-700);
  border-color: transparent;
  box-shadow: var(--neo-raised);
}
.btn-secondary:hover:not(:disabled) { box-shadow: var(--neo-raised-lg); }
.btn-secondary:active:not(:disabled) { box-shadow: var(--neo-inset-sm); }

.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--navy-50); color: var(--navy-700); }

.btn-danger {
  background: linear-gradient(180deg, var(--red-500), var(--red-600));
  color: var(--text-inv);
  box-shadow: var(--shadow-sm), var(--shadow-inset);
}
.btn-danger:hover:not(:disabled) { background: linear-gradient(180deg, var(--red-600), #8f231c); box-shadow: var(--shadow-md); }

.btn-block { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: 13px; }

/* ---------------------------------------------------------------- layout */

.app { display: none; min-height: 100dvh; }
.app.is-ready { display: grid; grid-template-columns: var(--sidebar-w) 1fr; }

.sidebar {
  background: linear-gradient(176deg, var(--navy-850), var(--navy-900));
  color: var(--navy-200);
  padding: var(--s5) var(--s3);
  display: flex;
  flex-direction: column;
  gap: var(--s5);
  position: sticky;
  top: 0;
  height: 100dvh;
}

.sidebar-brand {
  display: grid;
  justify-items: center;
  gap: var(--s2);
  padding: var(--s2) var(--s2) 0;
}

/* Full width so the "Aviation Career Enrichment, Inc." strapline stays legible. */
.sidebar-brand img {
  width: 100%;
  max-width: 190px;
  height: auto;
  border-radius: var(--r-md);
  background: #fff;
  padding: 9px 11px;
  display: block;
}

.sidebar-brand span {
  font-family: Sora, sans-serif;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--navy-300);
}

.nav { display: grid; gap: 2px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: 10px var(--s3);
  border-radius: var(--r-md);
  color: var(--navy-200);
  background: transparent;
  border: 0;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  width: 100%;
  cursor: pointer;
  transition: background-color .18s var(--ease), color .18s var(--ease), transform .16s var(--ease-spring);
}

.nav-item svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.nav-item:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav-item:active { transform: translateX(1px); }

.nav-item.is-active {
  background: linear-gradient(180deg, var(--navy-700), var(--navy-800));
  color: #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .28);
}
.nav-item.is-active svg { opacity: 1; }

.nav-badge {
  margin-left: auto;
  background: var(--red-500);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  padding: 3px 6px;
  border-radius: 999px;
  min-width: 18px;
  text-align: center;
}

.sidebar-foot { margin-top: auto; display: grid; gap: var(--s3); }

.user-chip {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s3);
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, .06);
}

.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(145deg, var(--navy-500), var(--navy-700));
  color: #fff;
  font-weight: 650;
  font-size: 13px;
  flex: none;
}

.user-chip b { color: #fff; font-size: 13.5px; font-weight: 600; display: block; line-height: 1.3; }
.user-chip span { font-size: 11.5px; color: var(--navy-300); display: block; }

.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

.main { min-width: 0; padding: var(--s6) var(--s6) var(--s8); background: var(--neo-bg); }
.main-inner { max-width: 1120px; margin: 0 auto; }

.page-head { margin-bottom: var(--s6); }
.page-head p { color: var(--text-2); margin-top: var(--s2); max-width: 70ch; }

.view { display: none; }
.view.is-active { display: block; animation: rise .32s var(--ease) both; }

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* ------------------------------------------------- neumorphic home surface

   Soft-UI depth comes from a matched background plus paired light/dark
   shadows. Hover states crossfade a second shadow layer with opacity rather
   than animating box-shadow, which keeps the work on the compositor.        */

/* Tokens live globally, not scoped to .view-neo: .main (full width, not
   capped at the 1120px content column) needs them too, to paint true
   full-bleed on wide windows instead of stopping at the content column like
   the first version did. */
:root {
  --neo-bg: #ccd8f6;
  --neo-light: rgba(255, 255, 255, .85);
  --neo-dark: rgba(55, 78, 156, .40);
  --neo-raised: -6px -6px 14px var(--neo-light), 7px 7px 18px var(--neo-dark);
  --neo-raised-lg: -9px -9px 20px var(--neo-light), 11px 11px 28px var(--neo-dark);
  --neo-inset: inset -4px -4px 10px var(--neo-light), inset 5px 5px 12px var(--neo-dark);
  /* Scaled down for compact controls (chips, toggles) — the full-size pair
     reads as too heavy on anything much smaller than a card. */
  --neo-raised-sm: -2px -2px 5px var(--neo-light), 3px 3px 7px var(--neo-dark);
  --neo-inset-sm: inset -2px -2px 5px var(--neo-light), inset 2px 2px 5px var(--neo-dark);
  /* A hairline that reads on the blue surface — the old near-white/navy-50
     borders were tuned for white cards and look muddy here. */
  --neo-divider: rgba(255, 255, 255, .55);
}

/* Every page sits on the same neumorphic blue surface — not just Home.
   Lives on .main (full width beside the sidebar), not on an individual
   view, since a view inside the 1120px-capped .main-inner can never paint
   past that column's edges. */
.main { background: var(--neo-bg); }

.view-neo {
  position: relative;
  isolation: isolate;
}

.neo-card {
  background: var(--neo-bg);
  border-radius: var(--r-xl);
  box-shadow: var(--neo-raised);
  border: 0;
  position: relative;
}

/* The elevated shadow lives on a pseudo-element so hover is an opacity fade. */
.neo-tile {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  padding: var(--s5);
  border-radius: var(--r-xl);
  background: var(--neo-bg);
  box-shadow: var(--neo-raised);
  text-decoration: none;
  color: inherit;
  position: relative;
  isolation: isolate;
  transition: transform .34s var(--ease-spring);
  will-change: transform;
}

.neo-tile::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: var(--neo-raised-lg);
  opacity: 0;
  transition: opacity .3s var(--ease);
  z-index: -1;
}

.neo-tile:hover { transform: translateY(-4px); }
.neo-tile:hover::after { opacity: 1; }
.neo-tile:active { transform: translateY(-1px) scale(.99); }
.neo-tile:focus-visible { outline: 2px solid var(--navy-600); outline-offset: 4px; }

.neo-tile b {
  font-family: Sora, sans-serif;
  font-size: 15px;
  letter-spacing: -.02em;
  color: var(--text);
}

.neo-tile span {
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.neo-icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--neo-bg);
  box-shadow: var(--neo-inset);
  color: var(--navy-700);
  margin-bottom: var(--s2);
}

.neo-icon svg { width: 20px; height: 20px; }

.neo-stat { padding: var(--s5); }

.neo-stat b {
  font-family: Sora, sans-serif;
  font-size: 34px;
  letter-spacing: -.045em;
  line-height: 1.02;
  display: block;
  background: linear-gradient(145deg, var(--navy-600), var(--navy-800));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.neo-stat.is-text b { font-size: 19px; letter-spacing: -.02em; line-height: 1.3; }
.neo-stat span { color: var(--text-2); font-size: 13px; font-weight: 500; }
.neo-stat .muted { color: var(--text-3); }

.view-neo .page-head p { color: var(--text-2); }

.neo-section-head { margin-bottom: var(--s4); }
.neo-section-head h2 { color: var(--text); }
.neo-section-head p { color: var(--text-3); font-size: 13.5px; margin-top: var(--s1); }

@media (max-width: 860px) {
}

/* A cursor-tracking trail is decoration; drop it when motion is unwelcome.
   JS also checks this before ever spawning a particle. */
@media (prefers-reduced-motion: reduce) {
  .cursor-trail-canvas { display: none; }
  .neo-tile:hover { transform: none; }
}

/* ----------------------------------------------------------------- cards */

.card {
  background: var(--neo-bg);
  border: 0;
  border-radius: var(--r-xl);
  box-shadow: var(--neo-raised);
  padding: var(--s5);
}

.card + .card { margin-top: var(--s4); }

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s4);
  margin-bottom: var(--s4);
  flex-wrap: wrap;
}

.card-head p { color: var(--text-3); font-size: 13.5px; }

.grid { display: grid; gap: var(--s4); }
.grid-stats { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid-tiles { grid-template-columns: repeat(auto-fill, minmax(236px, 1fr)); }
.grid-docs  { grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }

.stat { padding: var(--s5); }
.stat b {
  font-family: Sora, sans-serif;
  font-size: 32px;
  letter-spacing: -.04em;
  display: block;
  line-height: 1.05;
  color: var(--navy-700);
}

/* Text values (a role name, say) would dwarf the numbers at display size. */
.stat.is-text b { font-size: 19px; letter-spacing: -.02em; line-height: 1.3; }

.stat span { color: var(--text-3); font-size: 13px; }

/* Quick-link tiles */
.tile {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  padding: var(--s5);
  background: var(--neo-bg);
  border: 0;
  border-radius: var(--r-xl);
  box-shadow: var(--neo-raised);
  text-decoration: none;
  color: inherit;
  position: relative;
  isolation: isolate;
  overflow: hidden;
  transition: transform .2s var(--ease-spring);
}

.tile::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: var(--neo-raised-lg);
  opacity: 0;
  transition: opacity .2s var(--ease);
  z-index: -1;
}

.tile::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, var(--navy-700), var(--navy-400));
  opacity: 0;
  transition: opacity .2s var(--ease);
  z-index: 1;
}

.tile:hover { transform: translateY(-3px); }
.tile:hover::after { opacity: 1; }
.tile:hover::before { opacity: 1; }
.tile:active { transform: translateY(-1px); }

.tile-icon {
  width: 38px; height: 38px;
  border-radius: var(--r-md);
  display: grid; place-items: center;
  background: var(--neo-bg);
  box-shadow: var(--neo-inset-sm);
  color: var(--navy-700);
  margin-bottom: var(--s2);
}
.tile-icon svg { width: 19px; height: 19px; }

.tile b { font-family: Sora, sans-serif; font-size: 15px; letter-spacing: -.02em; }

/* Clamped so a long description cannot stretch its whole grid row. */
.tile span {
  color: var(--text-3);
  font-size: 13px;
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------------------------------------------------------------- badges */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .02em;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--navy-50);
  color: var(--navy-700);
  border: 1px solid var(--navy-100);
  white-space: nowrap;
}

.badge-green { background: var(--green-100); color: var(--green-600); border-color: #c3e4d2; }
.badge-amber { background: var(--amber-100); color: var(--amber-600); border-color: #f4ddb8; }
.badge-red   { background: var(--red-100);   color: var(--red-600);   border-color: #f2cac6; }
.badge-gray  { background: var(--surface-sunken); color: var(--text-3); border-color: var(--border); }

/* ----------------------------------------------------------------- chips */

.chips { display: flex; flex-wrap: wrap; gap: var(--s2); }

.chip {
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 13px;
  border-radius: 999px;
  border: 0;
  background: var(--neo-bg);
  color: var(--text-2);
  cursor: pointer;
  box-shadow: var(--neo-inset-sm);
  transition: color .16s var(--ease), box-shadow .16s var(--ease), transform .16s var(--ease-spring);
}

.chip:hover { color: var(--navy-700); }
.chip:active { transform: scale(.96); }

.chip.is-on {
  background: linear-gradient(180deg, var(--navy-600), var(--navy-700));
  color: #fff;
  box-shadow: var(--neo-raised-sm);
}

.filter-group { padding: var(--s4) 0; border-top: 1px solid var(--neo-divider); }

/* ---------------------------------------------------------- people search */

.people-results { margin-top: var(--s2); max-height: 220px; overflow-y: auto; }
.people-results:empty { display: none; }

.people-result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--s3);
  width: 100%;
  padding: 9px 12px;
  background: var(--neo-bg);
  border: 0;
  border-radius: var(--r-md);
  box-shadow: var(--neo-inset-sm);
  margin-top: var(--s2);
  cursor: pointer;
  font: inherit;
  text-align: left;
  color: var(--text);
  transition: box-shadow .15s var(--ease);
}

.people-result-row:hover { box-shadow: var(--neo-raised-sm); }
.people-result-row b { font-weight: 600; font-size: 13.5px; }
.people-result-row span { color: var(--text-3); font-size: 12px; white-space: nowrap; }

.chip-picked { display: inline-flex; align-items: center; gap: 6px; }
.chip-picked button {
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  color: inherit;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  opacity: .7;
}
.chip-picked button:hover { opacity: 1; }
.filter-group:first-of-type { border-top: 0; padding-top: 0; }
.filter-group > .lbl { display: block; margin-bottom: var(--s3); }

/* ---------------------------------------------------------------- toggle */

.toggle {
  display: flex;
  align-items: flex-start;
  gap: var(--s3);
  padding: var(--s3);
  border: 0;
  border-radius: var(--r-md);
  cursor: pointer;
  background: var(--neo-bg);
  box-shadow: var(--neo-inset-sm);
  transition: box-shadow .16s var(--ease);
}

.toggle:hover { box-shadow: var(--neo-raised-sm); }
.toggle input { margin: 3px 0 0; accent-color: var(--navy-700); width: 16px; height: 16px; flex: none; }
.toggle b { font-size: 14px; font-weight: 550; display: block; }
.toggle span { font-size: 12.5px; color: var(--text-3); display: block; line-height: 1.5; }

/* ---------------------------------------------------------------- tables */

.table-wrap {
  border: 0;
  border-radius: var(--r-xl);
  overflow: auto;
  background: var(--neo-bg);
  box-shadow: var(--neo-raised);
  max-height: 440px;
}

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }

th {
  position: sticky;
  top: 0;
  background: var(--neo-bg);
  box-shadow: inset 0 -2px 4px -2px var(--neo-dark);
  text-align: left;
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 10px var(--s4);
  white-space: nowrap;
}

td { padding: 10px var(--s4); border-bottom: 1px solid var(--neo-divider); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: rgba(255, 255, 255, .25); }

/* ----------------------------------------------------------- cursor trail */

/* Covers the viewport on every authenticated page. pointer-events:none means
   it never intercepts a click — clicks pass straight through to whatever's
   beneath. Sits above ordinary content (z-index 40) but below the modal
   backdrop (50) and toasts (80), so a dialog is never dimmed by sparkle. */
.cursor-trail-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 40;
}

/* ----------------------------------------------------------------- modal */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(13, 22, 48, .55);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  padding: var(--s5);
  z-index: 50;
  animation: fade .2s var(--ease) both;
}

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--neo-bg);
  border-radius: var(--r-xl);
  box-shadow: var(--neo-raised-lg), 0 24px 56px rgba(13, 22, 48, .35);
  width: min(560px, 100%);
  max-height: 86dvh;
  overflow: auto;
  padding: var(--s6);
  animation: pop .3s var(--ease-spring) both;
}

@keyframes pop {
  from { opacity: 0; transform: translateY(14px) scale(.97); }
  to   { opacity: 1; transform: none; }
}

.modal h2 { margin-bottom: var(--s3); }
.modal-actions { display: flex; gap: var(--s3); justify-content: flex-end; margin-top: var(--s5); flex-wrap: wrap; }

/* ----------------------------------------------------------------- alerts */

.alert {
  display: flex;
  gap: var(--s3);
  padding: var(--s4);
  border-radius: var(--r-md);
  font-size: 13.5px;
  line-height: 1.6;
  border: 1px solid;
  align-items: flex-start;
}

.alert svg { width: 18px; height: 18px; flex: none; margin-top: 2px; }
.alert-info   { background: var(--navy-50);   border-color: var(--navy-100);  color: var(--navy-800); }
.alert-amber  { background: var(--amber-100); border-color: #f4ddb8;          color: var(--amber-600); }
.alert-red    { background: var(--red-100);   border-color: #f2cac6;          color: var(--red-600); }
.alert-green  { background: var(--green-100); border-color: #c3e4d2;          color: var(--green-600); }
.alert b { font-weight: 650; }

/* ---------------------------------------------------------------- compose */

.compose { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: var(--s4); align-items: start; }

.segment-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--s4);
  margin-top: var(--s3);
  font-size: 12.5px;
  color: var(--text-3);
  flex-wrap: wrap;
}

.meter { height: 5px; border-radius: 999px; background: var(--navy-100); overflow: hidden; flex: 1; min-width: 120px; }
.meter i { display: block; height: 100%; background: linear-gradient(90deg, var(--navy-600), var(--navy-400)); transform-origin: left; transition: transform .3s var(--ease); }
.meter.is-warn i { background: linear-gradient(90deg, var(--amber-500), #e8a548); }

.tag-row { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s3); }

.tag-btn {
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: var(--r-sm);
  border: 1px dashed var(--border-strong);
  background: var(--surface-sunken);
  color: var(--text-2);
  cursor: pointer;
  font-family: 'JetBrains Mono', monospace;
  transition: border-color .16s var(--ease), color .16s var(--ease), transform .16s var(--ease-spring);
}

.tag-btn:hover { border-color: var(--navy-600); color: var(--navy-700); }
.tag-btn:active { transform: scale(.95); }

.phone-preview {
  background: linear-gradient(170deg, var(--navy-850), var(--navy-900));
  border-radius: var(--r-xl);
  padding: var(--s5) var(--s4);
  box-shadow: var(--shadow-md);
  /* Stays in view while you scroll the three compose steps. */
  position: sticky;
  top: var(--s5);
}

.phone-preview .lbl { color: var(--navy-300); margin-bottom: var(--s3); display: block; }

.bubble {
  background: #fff;
  color: var(--text);
  border-radius: 16px 16px 16px 4px;
  padding: 11px 14px;
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .3);
  min-height: 46px;
}

.bubble.is-empty { color: var(--text-3); font-style: italic; }

.phone-meta { color: var(--navy-300); font-size: 11.5px; margin-top: var(--s3); display: flex; justify-content: space-between; gap: var(--s3); }

/* ------------------------------------------------------------------ inbox */

.inbox-shell {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: var(--s4);
  align-items: start;
  height: calc(100dvh - 220px);
  min-height: 460px;
}

.inbox-threads {
  background: var(--neo-bg);
  border: 0;
  border-radius: var(--r-xl);
  box-shadow: var(--neo-raised);
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.inbox-threads-head { padding: var(--s3); border-bottom: 1px solid var(--neo-divider); }
.inbox-threads-head input { font-size: 13.5px; }

#thread-list { overflow-y: auto; flex: 1; }

.thread-row {
  display: flex;
  align-items: flex-start;
  gap: var(--s3);
  width: 100%;
  padding: var(--s3) var(--s4);
  border: 0;
  border-bottom: 1px solid var(--neo-divider);
  background: transparent;
  text-align: left;
  cursor: pointer;
  font: inherit;
  transition: background-color .15s var(--ease);
}

.thread-row:hover { background: rgba(255, 255, 255, .3); }
.thread-row.is-active { background: rgba(255, 255, 255, .4); box-shadow: inset 3px 0 0 var(--navy-700); }

.thread-row .avatar { width: 32px; height: 32px; font-size: 12px; margin-top: 1px; }

.thread-row-body { min-width: 0; flex: 1; }
.thread-row-top { display: flex; justify-content: space-between; gap: var(--s2); align-items: baseline; }
.thread-row-name { font-weight: 600; font-size: 13.5px; }
.thread-row-time { font-size: 11px; color: var(--text-3); white-space: nowrap; flex: none; }
.thread-row-preview {
  font-size: 12.5px;
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 2px;
}
.thread-row.has-unread .thread-row-preview { color: var(--text); font-weight: 550; }

.thread-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--navy-700);
  flex: none;
  margin-top: 5px;
}

.inbox-panel {
  background: var(--neo-bg);
  border: 0;
  border-radius: var(--r-xl);
  box-shadow: var(--neo-raised);
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.inbox-panel-head {
  padding: var(--s4) var(--s5);
  border-bottom: 1px solid var(--neo-divider);
  display: flex;
  align-items: center;
  gap: var(--s3);
}

.inbox-panel-head b { font-family: Sora, sans-serif; font-size: 15px; }
.inbox-panel-head span { color: var(--text-3); font-size: 12.5px; }

.inbox-thread {
  flex: 1;
  overflow-y: auto;
  padding: var(--s5);
  display: flex;
  flex-direction: column;
  gap: var(--s3);
}

/* Reuses the dark .bubble look from the compose preview for inbound text,
   and mirrors it light-on-navy for outbound so the two read like a chat. */
.msg-row { display: flex; max-width: 72%; }
.msg-row.is-in { align-self: flex-start; }
.msg-row.is-out { align-self: flex-end; }

.msg-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg-row.is-in .msg-bubble {
  background: var(--neo-bg);
  box-shadow: var(--neo-inset-sm);
  color: var(--text);
  border-radius: 16px 16px 16px 4px;
}

.msg-row.is-out .msg-bubble {
  background: linear-gradient(170deg, var(--navy-600), var(--navy-800));
  color: #fff;
  border-radius: 16px 16px 4px 16px;
}

.msg-row.is-out.is-failed .msg-bubble { background: linear-gradient(170deg, var(--red-500), var(--red-600)); }

.msg-meta { font-size: 10.5px; color: var(--text-3); margin-top: 3px; padding: 0 2px; }
.msg-row.is-out .msg-meta { text-align: right; }

.inbox-reply {
  border-top: 1px solid var(--border);
  padding: var(--s4);
  display: flex;
  gap: var(--s3);
  align-items: flex-end;
}

.inbox-reply textarea {
  flex: 1;
  min-height: 44px;
  max-height: 140px;
  resize: vertical;
}

@media (max-width: 860px) {
  .inbox-shell { grid-template-columns: 1fr; height: auto; }
  .inbox-threads { height: 280px; }
  .inbox-panel { height: 520px; }
}

/* --------------------------------------------------------------- loading */

.skeleton {
  background: linear-gradient(90deg, var(--surface-sunken) 25%, #e7ebf5 50%, var(--surface-sunken) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
  border-radius: var(--r-md);
  height: 92px;
}

@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.spinner {
  width: 15px; height: 15px;
  border: 2px solid rgba(255, 255, 255, .35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

.btn-secondary .spinner { border-color: var(--navy-100); border-top-color: var(--navy-700); }

@keyframes spin { to { transform: rotate(360deg); } }

.empty {
  text-align: center;
  padding: var(--s7) var(--s5);
  color: var(--text-3);
}
.empty b { display: block; color: var(--text-2); font-family: Sora, sans-serif; margin-bottom: var(--s2); font-size: 15px; }

/* ----------------------------------------------------------------- toast */

.toasts {
  position: fixed;
  bottom: var(--s5);
  right: var(--s5);
  display: grid;
  gap: var(--s2);
  z-index: 80;
  max-width: min(420px, calc(100vw - 32px));
}

.toast {
  background: var(--navy-900);
  color: #fff;
  padding: 13px var(--s4);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  font-size: 13.5px;
  line-height: 1.55;
  animation: slide-in .3s var(--ease-spring) both;
}

.toast.is-error { background: var(--red-600); }
.toast.is-success { background: var(--green-600); }

@keyframes slide-in {
  from { opacity: 0; transform: translateX(18px); }
  to   { opacity: 1; transform: none; }
}

/* -------------------------------------------------------------- utilities */

.row { display: flex; gap: var(--s3); align-items: center; flex-wrap: wrap; }
.row-end { justify-content: flex-end; }
.between { display: flex; gap: var(--s4); align-items: center; justify-content: space-between; flex-wrap: wrap; }
.stack { display: grid; gap: var(--s4); }
.stack-sm { display: grid; gap: var(--s2); }
.muted { color: var(--text-3); font-size: 13px; }
.mt3 { margin-top: var(--s3); }
.mt4 { margin-top: var(--s4); }
.mt5 { margin-top: var(--s5); }
.nowrap { white-space: nowrap; }

/* ------------------------------------------------------------ responsive */

@media (max-width: 1040px) {
  .compose { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .app.is-ready { grid-template-columns: 1fr; }

  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--s3);
    padding: var(--s3) var(--s4);
  }

  /* Horizontal bar on small screens: logo shrinks, strapline drops. */
  .sidebar-brand { padding: 0; }
  .sidebar-brand img { max-width: 104px; padding: 5px 7px; }
  .sidebar-brand span { display: none; }
  .nav { grid-auto-flow: column; gap: var(--s1); overflow-x: auto; flex: 1; }
  .nav-item { padding: 8px 11px; font-size: 13px; }
  .nav-item span { display: none; }
  .sidebar-foot { margin: 0; }
  .user-chip { padding: var(--s2); background: transparent; }
  .user-chip div { display: none; }

  .main { padding: var(--s5) var(--s4) var(--s7); }
  h1 { font-size: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
