/* Shared "app shell" for Admin & Member Portal — deep purple dashboard look.
   Loaded after common.css; does not affect the /live overlay. */
:root {
  --ap-bg: #0e0a1c;
  --ap-panel: #18122b;
  --ap-panel-2: #201838;
  --ap-panel-3: #2a2046;
  --ap-line: #30264a;
  --ap-line-2: #3f3360;
  --ap-text: #f3eefc;
  --ap-muted: #a99ec4;
  --ap-gold: #f5b942;
  --ap-gold-2: #ffd77a;
  --ap-gold-ink: #2b1a00;
  --ap-purple: #7c4dff;
  --ap-purple-2: #a17bff;
  --ap-green: #2fd68c;
  --ap-red: #ff4d6d;
  --ap-blue: #5aa9f2;
}

body.app {
  color: var(--ap-text);
  background:
    radial-gradient(900px 520px at 12% -12%, rgba(124, 77, 255, 0.20), transparent 60%),
    radial-gradient(760px 480px at 105% 0%, rgba(245, 185, 66, 0.08), transparent 60%),
    linear-gradient(180deg, #110b22 0%, #120c24 45%, #0c0817 100%);
}
body.app .muted, body.app small { color: var(--ap-muted); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(14, 10, 28, 0.82);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--ap-line);
}
.tb-inner { max-width: 1320px; margin: 0 auto; padding: 10px 20px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.tb-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.tb-logo { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; font-size: 18px; background: linear-gradient(135deg, var(--ap-gold-2), var(--ap-gold)); color: var(--ap-gold-ink); box-shadow: 0 4px 14px rgba(245, 185, 66, 0.3); flex: 0 0 auto; }
.tb-name { font-weight: 800; font-size: 1.02rem; white-space: nowrap; }
.credit-pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 12px; border-radius: 999px; font-size: 0.8rem; font-weight: 600; color: var(--ap-gold-2); background: rgba(245, 185, 66, 0.08); border: 1px solid rgba(245, 185, 66, 0.5); white-space: nowrap; }
.tb-spacer { flex: 1 1 auto; }
.tb-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tb-nav { display: flex; gap: 4px; background: var(--ap-panel); border: 1px solid var(--ap-line); border-radius: 12px; padding: 3px; }
.tb-tab { appearance: none; border: 0; background: none; color: var(--ap-muted); font: inherit; font-size: 0.88rem; padding: 6px 12px; border-radius: 9px; cursor: pointer; white-space: nowrap; }
.tb-tab.active { background: var(--ap-panel-3); color: var(--ap-text); font-weight: 700; }
@media (max-width: 860px) {
  .credit-pill { display: none; }
  .tb-nav { order: 10; width: 100%; justify-content: space-between; }
  .tb-tab { flex: 1; }
}

.sync-pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: 0.76rem; border: 1px solid var(--ap-line-2); color: var(--ap-muted); white-space: nowrap; }
.sync-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ap-muted); }
.sync-pill.ok { color: #9ff0cc; border-color: rgba(47, 214, 140, 0.35); background: rgba(47, 214, 140, 0.07); }
.sync-pill.ok::before { background: var(--ap-green); box-shadow: 0 0 6px var(--ap-green); }
.sync-pill.busy::before { background: var(--ap-gold); }
.sync-pill.bad { color: #ffb3c0; border-color: rgba(255, 77, 109, 0.4); }
.sync-pill.bad::before { background: var(--ap-red); }

/* ---------- page ---------- */
.page { max-width: 1320px; margin: 0 auto; padding: 18px 20px 28px; }
.section-kicker { font-size: 0.72rem; font-weight: 800; letter-spacing: 0.18em; color: var(--ap-gold); text-transform: uppercase; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 4px 0 14px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 1.3rem; }
.ghost-pill { font-size: 0.76rem; color: var(--ap-muted); border: 1px solid var(--ap-line-2); border-radius: 8px; padding: 2px 10px; white-space: nowrap; }

/* ---------- panels ---------- */
body.app .card, .panel { background: linear-gradient(180deg, var(--ap-panel), #150f27); border: 1px solid var(--ap-line); border-radius: 16px; box-shadow: none; }
.panel { padding: 16px 18px; }

/* ---------- stats row ---------- */
.stats4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
@media (max-width: 1080px) { .stats4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .stats4 { gap: 8px; } }
.stat { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 16px; background: linear-gradient(180deg, var(--ap-panel), #150f27); border: 1px solid var(--ap-line); min-width: 0; }
.stat.gold { border-color: rgba(245, 185, 66, 0.55); box-shadow: inset 0 0 0 1px rgba(245, 185, 66, 0.12); }
.stat-icon { width: 42px; height: 42px; flex: 0 0 auto; border-radius: 12px; display: grid; place-items: center; font-size: 19px; background: var(--ap-panel-3); border: 1px solid var(--ap-line-2); }
.stat-body { min-width: 0; display: flex; flex-direction: column; line-height: 1.6; }
.stat-label { font-size: 0.8rem; color: var(--ap-muted); }
.stat-value { font-size: 1.55rem; font-weight: 800; line-height: 1.6; }
.stat.gold .stat-value { color: var(--ap-gold-2); }
.stat-value.live { color: var(--ap-red); }
.stat-sub { font-size: 0.76rem; color: var(--ap-muted); display: flex; gap: 6px; flex-wrap: wrap; }
.mini { padding: 0 8px; border-radius: 999px; font-size: 0.72rem; border: 1px solid var(--ap-line-2); }
.mini.ok { color: #9ff0cc; border-color: rgba(47, 214, 140, 0.35); }
.mini.bad { color: #ffb3c0; border-color: rgba(255, 77, 109, 0.35); }
.mini.warn { color: #ffd591; border-color: rgba(245, 165, 36, 0.4); }
@media (max-width: 520px) {
  .stat { padding: 12px; gap: 10px; }
  .stat:not(.pcard) .stat-icon { display: none; }
  .stat-label { font-size: 0.74rem; line-height: 1.6; }
  .stat-value { font-size: 1.25rem; }
  .stat-sub { font-size: 0.7rem; }
}

/* ---------- pills ---------- */
.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pill { appearance: none; font: inherit; font-size: 0.84rem; color: var(--ap-text); background: var(--ap-panel-2); border: 1px solid var(--ap-line-2); border-radius: 999px; padding: 4px 13px; cursor: pointer; line-height: 1.7; white-space: nowrap; }
.pill b { color: var(--ap-muted); font-weight: 600; margin-left: 3px; }
.pill:hover { border-color: #57487e; }
.pill.active { background: linear-gradient(135deg, var(--ap-gold-2), var(--ap-gold)); color: var(--ap-gold-ink); border-color: transparent; font-weight: 700; }
.pill.active b { color: rgba(43, 26, 0, 0.75); }

/* ---------- buttons ---------- */
body.app .btn { background: var(--ap-panel-2); border-color: var(--ap-line-2); color: var(--ap-text); }
body.app .btn:hover { border-color: #5d4d88; }
body.app .btn.primary { background: linear-gradient(135deg, var(--ap-gold-2), var(--ap-gold)); color: var(--ap-gold-ink); border-color: transparent; box-shadow: 0 4px 14px rgba(245, 185, 66, 0.22); }
body.app .btn.purple { background: linear-gradient(135deg, var(--ap-purple-2), var(--ap-purple)); border-color: transparent; color: #fff; font-weight: 700; }
body.app .btn.outline-gold { background: transparent; border-color: rgba(245, 185, 66, 0.7); color: var(--ap-gold-2); font-weight: 700; }
body.app .btn.danger { background: rgba(255, 77, 109, 0.12); border-color: rgba(255, 77, 109, 0.45); color: #ffb3c0; }
body.app .btn.ok { background: rgba(47, 214, 140, 0.1); border-color: rgba(47, 214, 140, 0.4); color: #a6f0cf; }
body.app .btn.icon { padding: 6px 9px; }

/* ---------- search ---------- */
.search-wrap { position: relative; display: flex; align-items: center; min-width: 0; }
.search-wrap .search-icon { position: absolute; left: 12px; opacity: 0.6; pointer-events: none; font-size: 0.9rem; }
.search-wrap input { padding-left: 36px; background: var(--ap-bg); border-color: var(--ap-line-2); }

/* ---------- inputs on app pages ---------- */
body.app input[type=text], body.app input[type=password], body.app input[type=number], body.app input[type=search],
body.app input[type=datetime-local], body.app select, body.app textarea { background: var(--ap-bg); border-color: var(--ap-line-2); }
body.app input:focus, body.app select:focus, body.app textarea:focus { border-color: var(--ap-gold); box-shadow: 0 0 0 3px rgba(245, 185, 66, 0.16); }

/* ---------- toggle (inline) ---------- */
.toggle { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 0.82rem; color: var(--ap-muted); margin: 0; }
.toggle input { appearance: none; width: 40px; height: 22px; border-radius: 22px; background: var(--ap-line-2); position: relative; cursor: pointer; transition: background 0.2s; margin: 0; flex: 0 0 auto; }
.toggle input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform 0.2s; }
.toggle input:checked { background: var(--ap-green); }
.toggle input:checked::after { transform: translateX(18px); }
.toggle.on { color: #9ff0cc; }

/* ---------- modal tabs ---------- */
body.app .modal-box { background: var(--ap-panel); border-color: var(--ap-line-2); }
body.app .modal-head, body.app .modal-foot { background: var(--ap-panel); border-color: var(--ap-line); }
.mtabs { display: flex; gap: 4px; background: var(--ap-bg); border: 1px solid var(--ap-line); border-radius: 12px; padding: 3px; margin-bottom: 14px; overflow-x: auto; }
.mtab { appearance: none; border: 0; background: none; color: var(--ap-muted); font: inherit; font-size: 0.86rem; padding: 6px 12px; border-radius: 9px; cursor: pointer; white-space: nowrap; flex: 1 0 auto; }
.mtab.active { background: var(--ap-panel-3); color: var(--ap-text); font-weight: 700; }

/* ---------- dropdown ---------- */
.dropdown { position: relative; }
.dropdown-menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 60; min-width: 210px; background: var(--ap-panel-2); border: 1px solid var(--ap-line-2); border-radius: 12px; padding: 6px; box-shadow: 0 14px 34px rgba(0, 0, 0, 0.45); }
.dropdown-menu button { display: flex; width: 100%; gap: 8px; align-items: center; text-align: left; background: none; border: 0; color: var(--ap-text); font: inherit; font-size: 0.9rem; padding: 7px 10px; border-radius: 8px; cursor: pointer; }
.dropdown-menu button:hover { background: var(--ap-panel-3); }

/* ---------- progress ---------- */
.bar { height: 6px; border-radius: 6px; background: var(--ap-line); overflow: hidden; }
.bar > i { display: block; height: 100%; width: var(--p, 0%); border-radius: inherit; background: linear-gradient(90deg, var(--ap-purple), var(--ap-gold)); transition: width 0.4s ease; }
.bar.warn > i { background: linear-gradient(90deg, #f5a524, #ff7a45); }
.bar.bad > i { background: var(--ap-red); }

body.app .site-footer { border-top: 1px solid var(--ap-line); margin-top: 10px; }
body.app .toast { background: var(--ap-panel-2); border-color: var(--ap-line-2); }
