/* ─── App World shell — the OS-like chrome that contains every app ────────
   The shell is ONE web app (App World) that contains the others. Apps run
   as mounted iframes inside #app-stage, sandboxed from each other but
   sharing the same origin (and therefore the auth cookie). Switching apps
   is instant because each iframe stays mounted. Home + Catalogue are
   shell-level surfaces rendered into #shell-view (not iframes). */

#boot-splash {
  position: fixed; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px;
  background: var(--bg);
  z-index: 100;
}
.boot-logo { width: 72px; height: 72px; border-radius: 18px; opacity: .9; }
.boot-dot {
  width: 26px; height: 4px; background: var(--accent); border-radius: 2px;
  animation: boot-pulse 1s ease-in-out infinite;
}
@keyframes boot-pulse {
  0%, 100% { opacity: .25; transform: scaleX(.5); }
  50%      { opacity: 1;   transform: scaleX(1);  }
}

.shell-top {
  display: flex; align-items: center; gap: 24px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}
.shell-brand {
  /* <button> resets — without these the browser draws its default 1px
     border + grey fill around the logo + name. */
  appearance: none;
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  font: inherit;

  display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: var(--text-main);
  font-weight: 700; font-size: 14px;
}
.shell-brand-logo { width: 28px; height: 28px; border-radius: 6px; }
.shell-brand-name { letter-spacing: -.01em; }

.shell-nav { display: flex; gap: 4px; flex: 1; }
.shell-nav-link {
  /* Reset user-agent <button> styling so these read as nav links, not
     buttons. The earlier <a> version didn't need this; switching to
     <button data-go="…"> for the URL-container model surfaced it. */
  appearance: none;
  background: transparent;
  border: none;
  cursor: pointer;
  font: inherit;

  padding: 7px 12px; border-radius: 6px;
  font-size: 13px; font-weight: 500; color: var(--text-sub);
  text-decoration: none;
}
.shell-nav-link:hover { color: var(--text-main); background: var(--bg-input); }
.shell-nav-link.active { color: var(--text-main); background: var(--bg-elevated); }

.shell-right { display: flex; align-items: center; gap: 12px; }
.shell-user  { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-sub); }
.shell-user img { width: 24px; height: 24px; border-radius: 50%; }

#shell-view {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px;
}
/* Body content (inside #app-body) fades in on every view change. The frame
   itself stays put across sub-state changes within the same app, so swapping
   the Mod 'Airlines' tab for 'Activity' doesn't re-flash the chrome. */
.app-body { animation: app-body-in .18s ease-out; }
.app-body-home { animation: app-body-in .22s ease-out; }
@keyframes app-body-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0);   }
}

/* ─── App frame — the chrome that makes a route feel like an app ───────────
   Sits between the shell top-bar and the view's own content. Owns the
   brand-coloured accent rail, app icon, name + subtitle, optional server
   chip, and the "← Apps" back-to-launcher action. */

.app-frame {
  position: relative;
  background: linear-gradient(180deg, var(--ac-bg, transparent) 0%, transparent 100%);
  border: 1px solid var(--border-mid);
  border-radius: 14px;
  margin-bottom: 24px;
  overflow: hidden;
  animation: app-frame-in .26s cubic-bezier(.2,.7,.2,1);
}
.app-frame-rail {
  /* Top-edge accent rail — picks up the app's brand colour, same pattern
     as the launcher tile. Reads as "this is THAT app." */
  height: 3px;
  background: var(--ac, var(--text-dim));
}
.app-frame-inner {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 18px;
  padding: 22px 26px;
}
.app-frame-icon {
  width: 56px; height: 56px;
  border-radius: 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-mid);
  display: flex; align-items: center; justify-content: center;
  font-size: 30px;
  box-shadow: 0 4px 14px rgba(0,0,0,.25);
}
.app-frame-server {
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .12em;
  color: var(--ac, var(--text-sub));
  margin-bottom: 4px;
}
.app-frame-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.01em;
  margin: 0;
}
.app-frame-subtitle {
  font-size: 13px;
  color: var(--text-sub);
  margin: 4px 0 0;
}
.app-frame-back {
  appearance: none;
  background: var(--bg-input);
  border: 1px solid var(--border-mid);
  color: var(--text-sub);
  cursor: pointer;
  font: inherit;
  font-size: 12px; font-weight: 600;
  padding: 7px 14px;
  border-radius: 999px;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background .12s, color .12s, border-color .12s, transform .12s;
}
.app-frame-back:hover {
  background: var(--bg-elevated);
  color: var(--text-main);
  border-color: var(--ac, var(--border-mid));
  transform: translateX(-2px);
}
.app-frame-back-glyph { font-size: 14px; line-height: 1; }

/* "App opening" animation — the frame slides up and the icon does a brief
   pop. Feels like a window animating in, not a page swapping content. */
@keyframes app-frame-in {
  0%   { opacity: 0; transform: translateY(10px) scale(.985); }
  60%  { opacity: 1; }
  100% { opacity: 1; transform: translateY(0)    scale(1);     }
}
.app-frame-icon {
  animation: app-icon-pop .42s cubic-bezier(.2,.9,.2,1.1);
  transform-origin: center;
}
@keyframes app-icon-pop {
  0%   { transform: scale(.7); opacity: 0; }
  60%  { transform: scale(1.06); opacity: 1; }
  100% { transform: scale(1);    opacity: 1; }
}

/* (No special top-bar treatment when inside an app — the app-frame chrome
   already communicates that you're inside something, and dimming the
   Apps link would be a distracting flicker on every navigation.) */

@media (max-width: 700px) {
  .app-frame-inner { grid-template-columns: auto 1fr; }
  .app-frame-back  { grid-column: 1 / -1; justify-self: start; }
}

/* Section divider — used between rows of tiles, server chips, etc. */
.shell-section { margin-bottom: 28px; }
.shell-section-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-dim); margin-bottom: 10px;
}

.server-chip-row {
  display: flex; gap: 8px; flex-wrap: wrap;
  margin-bottom: 22px;
}
.server-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 11px; color: var(--text-sub);
}
.server-chip-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.server-chip-mod { font-weight: 700; color: var(--accent); }

/* ─── Tabs (inside SPA views) ──────────────────────────────────────────────
   Real <button> elements, not anchors — stops user-agent link styling from
   bleeding through (underline / visited-purple) and makes the active-state
   contract explicit. */
.tabs {
  display: flex; gap: 4px;
  border-bottom: 1px solid var(--border-mid);
  margin-bottom: 20px;
  padding-bottom: 0;
}
.tab {
  appearance: none;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 10px 16px;
  margin-bottom: -1px;             /* overlap the .tabs border */
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-sub);
  cursor: pointer;
  text-decoration: none;            /* belt + braces for any stray <a> */
  border-radius: 6px 6px 0 0;
  transition: color .12s, background .12s, border-color .12s;
}
.tab:hover {
  color: var(--text-main);
  background: var(--bg-input);
}
.tab.active {
  color: var(--text-main);
  border-bottom-color: var(--chelsea);
}
.tab:focus-visible {
  outline: 2px solid var(--chelsea);
  outline-offset: 2px;
}

/* ─── Data tables (admin + moderator views) ────────────────────────────────
   Both /admin and /mod render long tabular listings — users, airlines, audit
   entries. Shared styles keep them visually consistent. */

.filter-row {
  display: flex; gap: 10px; flex-wrap: wrap;
}
.filter-row input, .filter-row select {
  width: auto;
  min-width: 180px;
}

.card table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.card thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-dim);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}
.card tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.card tbody tr:last-child td { border-bottom: 0; }
.card tbody tr:hover { background: rgba(255,255,255,.02); }
.td-sub { color: var(--text-sub); }

.empty {
  padding: 36px 20px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
}

/* Button variants used by admin/mod tables — danger (destructive),
   ghost (subtle nav action), small. */
.btn-danger { background: rgba(239,68,68,.12); border-color: rgba(239,68,68,.35); color: #f87171; }
.btn-danger:hover { background: rgba(239,68,68,.22); }
.btn-ghost  { background: transparent; border-color: var(--border); color: var(--text-sub); }
.btn-ghost:hover { background: var(--bg-input); color: var(--text-main); }
.btn-sm     { padding: 5px 10px; font-size: 12px; }

/* Inline status pills — green/amber/red/blue for risk/verification/status,
   matching the badge palette across admin and mod views. */
.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
  border: 1px solid transparent;
  white-space: nowrap;
}
.pill-green { background: rgba(16,185,129,.10); border-color: rgba(16,185,129,.30); color: #34d399; }
.pill-amber { background: rgba(245,158,11,.10); border-color: rgba(245,158,11,.30); color: #fbbf24; }
.pill-red   { background: rgba(239,68,68,.10);  border-color: rgba(239,68,68,.30);  color: #f87171; }
.pill-blue  { background: rgba(14,165,233,.10); border-color: rgba(14,165,233,.30); color: #38bdf8; }

/* ─── App switcher (top-bar dock) ───────────────────────────────────────────
   A row of chips between the nav links and the user pill. Each chip is one
   "running" app — click to bring to front; × to quit. Mirrors how iOS's
   recent-apps row and macOS's dock surface background processes. */

.app-switcher {
  display: flex;
  gap: 6px;
  align-items: center;
  flex: 1;
  justify-content: flex-end;
  padding-right: 12px;
  overflow-x: auto;
  scrollbar-width: none;
}
.app-switcher::-webkit-scrollbar { display: none; }

.switcher-chip {
  display: inline-flex;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border-mid);
  border-radius: 999px;
  overflow: hidden;
  transition: border-color .12s, background .12s, transform .12s;
}
.switcher-chip.active {
  border-color: var(--ac, var(--accent));
  background: var(--bg-elevated);
  box-shadow: 0 0 0 1px var(--ac, var(--accent)) inset;
}
.switcher-chip:hover { transform: translateY(-1px); }

.switcher-chip-main {
  appearance: none;
  background: transparent;
  border: none;
  color: var(--text-main);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 4px 6px 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.switcher-chip-icon { font-size: 14px; line-height: 1; }
.switcher-chip-name { letter-spacing: -.01em; }

.switcher-chip-close {
  appearance: none;
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  width: 22px; height: 100%;
  padding: 0 8px 0 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color .12s, background .12s;
}
.switcher-chip-close:hover { color: var(--red); background: rgba(239,68,68,.10); }

/* ─── App stage (the iframe deck) ───────────────────────────────────────────
   #app-stage is hidden when a shell-surface (Home/Catalogue) is active.
   Each child iframe is absolutely-positioned to fill the stage; only the
   one with .active is visible (display:block). The others remain mounted
   so their state is preserved when switched away. */

.app-stage {
  position: relative;
  min-height: calc(100vh - 64px);   /* shell-top is ~58px tall */
  background: var(--bg);
}

.app-iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
  display: none;                    /* hidden by default */
  animation: app-iframe-in .22s cubic-bezier(.2,.7,.2,1);
}
.app-iframe.active { display: block; }

@keyframes app-iframe-in {
  from { opacity: 0; transform: scale(.985); }
  to   { opacity: 1; transform: scale(1);     }
}

/* ─── Home screen (iOS Springboard style) ───────────────────────────────────
   Welcome hero + grid of draggable tiles. Last tile is a "+ More apps"
   shortcut into the Catalogue. */

.home-hero {
  text-align: center;
  margin-bottom: 26px;
}
.home-greet-eyebrow {
  font-size: 11px; font-weight: 700; letter-spacing: .18em; text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 8px;
}
.home-greet-title {
  font-size: 26px; font-weight: 700; letter-spacing: -.01em;
  margin: 0 0 14px;
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 16px;
}
.home-empty {
  grid-column: 1 / -1;
  padding: 60px 20px;
  text-align: center;
}

.home-tile {
  appearance: none;
  background: var(--bg-elevated);
  border: 1px solid var(--border-mid);
  color: inherit;
  font: inherit;
  cursor: pointer;
  text-align: left;
  padding: 18px 18px 16px;
  border-radius: 18px;
  box-shadow: 0 6px 18px rgba(0,0,0,.25), 0 1px 0 rgba(255,255,255,.02) inset;
  position: relative;
  overflow: hidden;
  transition: transform .15s, border-color .15s, background .15s, box-shadow .15s;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 130px;
}
.home-tile::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--ac, var(--text-dim));
  opacity: .85;
}
.home-tile:hover {
  transform: translateY(-2px);
  border-color: var(--ac, var(--border-mid));
  background: var(--ac-bg, var(--bg-elevated));
  box-shadow: 0 10px 28px rgba(0,0,0,.35), 0 0 0 1px var(--ac, transparent) inset;
}
.home-tile.dragging {
  opacity: .55;
  transform: scale(.97) rotate(-1deg);
  cursor: grabbing;
  border-color: var(--ac, var(--accent));
}

.home-tile-icon  { font-size: 28px; line-height: 1; }
.home-tile-title { font-size: 16px; font-weight: 700; color: var(--text-main); letter-spacing: -.01em; }
.home-tile-sub   { font-size: 12px; color: #b6c0cc; line-height: 1.4; flex: 1; }
.home-tile-tag   {
  font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-sub);
}

.home-tile-add {
  border-style: dashed;
  border-color: var(--border-mid);
  background: transparent;
  align-items: center; justify-content: center;
  color: var(--text-sub);
}
.home-tile-add::before { display: none; }
.home-tile-add:hover { border-color: var(--accent); color: var(--accent); }
.home-tile-add-glyph { font-size: 30px; line-height: 1; }
.home-tile-add-label { font-size: 13px; font-weight: 600; }

/* ─── Catalogue (App Store / Play Store equivalent) ─────────────────────────
   Grouped cards — one section per server, Universal first. Each card has
   an open-app target + an "Add to / Remove from Home" toggle. */

.cat-hero { margin-bottom: 26px; }
.cat-hero-eyebrow {
  font-size: 11px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 6px;
}
.cat-hero-title { font-size: 26px; font-weight: 700; margin: 0 0 6px; letter-spacing: -.01em; }
.cat-hero-sub   { font-size: 13px; color: var(--text-sub); margin: 0; max-width: 640px; }

.cat-group { margin-bottom: 28px; }
.cat-group-title {
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .12em;
  color: var(--text-sub);
  margin: 0 0 12px;
  display: flex; align-items: center; gap: 8px;
}
.cat-group-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.cat-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-mid);
  border-radius: 14px;
  padding: 0;
  display: flex; flex-direction: column;
  overflow: hidden;
  position: relative;
}
.cat-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--ac, var(--text-dim));
  opacity: .85;
}
.cat-card-open {
  appearance: none;
  background: transparent;
  border: 0;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  padding: 18px 18px 12px;
  display: flex; flex-direction: column; gap: 6px;
}
.cat-card-open:hover { background: var(--ac-bg, transparent); }
.cat-card-icon { font-size: 28px; line-height: 1; }
.cat-card-name { font-size: 15px; font-weight: 700; color: var(--text-main); }
.cat-card-sub  { font-size: 12px; color: var(--text-sub); line-height: 1.4; }

.cat-card-toggle {
  appearance: none;
  background: transparent;
  border: 0;
  border-top: 1px solid var(--border);
  color: var(--text-sub);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 10px 16px;
  cursor: pointer;
  text-align: left;
  transition: background .12s, color .12s;
}
.cat-card-toggle:hover  { background: var(--bg-input); color: var(--text-main); }
.cat-card-toggle.on-home { color: var(--green); }

