/* ============================================================================
   Moxo Ops Portal — component styles. All values reference tokens.css.
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body.app   { display: flex; }
body.auth  { display: flex; align-items: center; justify-content: center; padding: 24px; }

a { color: inherit; }
h1, h2, h3, h4 { letter-spacing: var(--tracking-tight); }

/* ── Sidebar ─────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--shell);
  min-height: 100vh;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
/* The Moxo gradient as the brand signature on the shell's inner edge —
   the same green→blue→indigo that tops the login card and dashboard hero. */
.sidebar::after {
  content: ""; position: absolute; top: 0; right: 0; bottom: 0; width: 3px;
  background: var(--brand-gradient);
}
.sidebar-logo { padding: 22px 20px 18px; border-bottom: 1px solid var(--shell-line); }
.sidebar-logo img { height: 22px; width: auto; display: block; }
.sidebar-logo .brand-sub {
  font-size: 10px; color: var(--shell-ink-dim); margin-top: 8px;
  letter-spacing: .12em; text-transform: uppercase; font-weight: 600;
}
nav { padding: 16px 12px; flex: 1; }
.nav-section {
  font-size: 10px; font-weight: 600; color: var(--shell-ink-dim);
  letter-spacing: .08em; text-transform: uppercase; padding: 12px 8px 6px;
}
/* Respect the [hidden] attribute even on elements with an explicit display
   (e.g. .nav-link uses display:flex, which would otherwise override the UA
   [hidden]{display:none} and leak admin-only nav to non-admins). */
[hidden] { display: none !important; }

.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--radius-input);
  font-size: 14px; font-weight: 500; color: var(--shell-ink);
  text-decoration: none; margin-bottom: 2px;
  transition: background .12s, color .12s;
}
.nav-link:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav-link.active { background: var(--shell-active-bg); color: var(--shell-ink-active); }
.nav-link svg { width: 16px; height: 16px; flex-shrink: 0; opacity: .85; }
.sidebar-footer { padding: 16px 20px; border-top: 1px solid var(--shell-line); }
.sidebar-footer .user-email {
  font-size: 12px; color: rgba(255, 255, 255, .55);
  margin-bottom: 10px; word-break: break-all;
}
.logout-btn {
  background: none; border: 1px solid rgba(255, 255, 255, .15);
  color: rgba(255, 255, 255, .5); border-radius: var(--radius-input);
  padding: 7px 12px; font-size: 12px; cursor: pointer;
  width: 100%; text-align: left; transition: all .12s; font-family: inherit;
}
.logout-btn:hover { border-color: rgba(255, 255, 255, .3); color: rgba(255, 255, 255, .8); }

/* ── Main column ─────────────────────────────────────────────────────── */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 16px 32px; display: flex; align-items: center; justify-content: space-between;
}
.topbar h1 { font-size: 19px; font-weight: 700; letter-spacing: -.01em; }
.content { padding: 32px; flex: 1; }

/* ── Cards ───────────────────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card);
  padding: 24px; margin-bottom: 20px; box-shadow: var(--shadow-card);
}
.card.flush { padding: 0; overflow: hidden; }
.card-header {
  display: flex; align-items: center; justify-content: space-between;
}
.card.flush .card-header { padding: 18px 24px; border-bottom: 1px solid var(--border-soft); }
.card:not(.flush) .card-header { margin-bottom: 16px; }
.card-title { font-size: 14px; font-weight: 700; color: var(--ink); }
.card-desc { font-size: 13px; color: var(--ink-muted); margin-top: 3px; }

/* ── Stat grid (dashboard) ───────────────────────────────────────────── */
.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px; margin-bottom: 20px;
}
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card);
  padding: 20px 22px; box-shadow: var(--shadow-card);
}
.stat-label { font-size: 11px; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px; display: flex; align-items: center; gap: 7px; }
.stat-label::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--brand-indigo); flex-shrink: 0; }
.stat.accent-blue  .stat-label::before { background: var(--brand-blue); }
.stat.accent-green .stat-label::before { background: var(--brand-green); }
.stat-value { font-size: 26px; font-weight: 700; color: var(--ink); letter-spacing: -.01em; }
.stat-sub { font-size: 12px; color: var(--ink-faint); margin-top: 3px; }

/* ── Quick actions (dashboard) ───────────────────────────────────────── */
.quick-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.action-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card);
  padding: 22px; box-shadow: var(--shadow-card);
  text-decoration: none; color: inherit; display: block;
  transition: box-shadow .18s, transform .18s, border-color .18s;
}
.action-card:hover { box-shadow: var(--shadow-pop); transform: translateY(-2px); border-color: #D8D5CF; }
.action-icon { width: 40px; height: 40px; border-radius: var(--radius-input); display: flex; align-items: center; justify-content: center; margin-bottom: 12px; }
.action-icon.indigo { background: var(--brand-indigo-soft); color: var(--brand-indigo); }
.action-icon.blue   { background: #E3F2FF; color: #1E7BC4; }
.action-icon.green  { background: #E8F7E3; color: #3F8F2E; }
.action-title { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.action-desc { font-size: 13px; color: var(--ink-muted); }

/* ── Welcome hero — carries the login card's language: light surface, the
      Moxo gradient hairline along the top. The page's one signature moment. ── */
.welcome-banner {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 30px 32px; margin-bottom: 22px;
  box-shadow: var(--shadow-card);
}
.welcome-banner::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 4px;
  background: var(--brand-gradient);
}
.welcome-banner h2 { font-size: 23px; font-weight: 700; color: var(--ink); margin-bottom: 5px; letter-spacing: -.01em; }
.welcome-banner p { font-size: 14px; color: var(--ink-muted); }

/* ── Badges ──────────────────────────────────────────────────────────── */
.badge { display: inline-flex; padding: 3px 9px; border-radius: var(--radius-pill); font-size: 11px; font-weight: 600; }
.badge-indigo { background: var(--brand-indigo-soft); color: var(--brand-indigo); }
.badge-green  { background: var(--ok-bg); color: var(--ok-ink); }
.badge-gray   { background: var(--border-soft); color: var(--ink-muted); }

/* ── Buttons (pill — Moxo) ───────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  padding: 9px 18px; border-radius: var(--radius-pill);
  font-size: 13px; font-weight: 600; cursor: pointer; border: none;
  font-family: inherit; text-decoration: none; transition: all .15s;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-sm { padding: 6px 14px; font-size: 12px; }
.btn-block { width: 100%; padding: 12px; font-size: 15px; }
.btn-primary { background: var(--brand-indigo); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-indigo-hover); }
.btn-ghost { background: var(--surface-sunk); color: var(--ink); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--border-soft); }
.btn-danger { background: var(--danger-bg); color: var(--danger-ink); border: 1px solid var(--danger-border); }
.btn-danger:hover { background: #FEE2E2; }

/* ── Releases page ───────────────────────────────────────────────────── */
.release-row { border-bottom: 1px solid var(--border-soft); }
.release-row:last-child { border-bottom: none; }
.release-header { padding: 16px 24px; display: flex; align-items: center; gap: 16px; cursor: pointer; transition: background .1s; }
.release-header:hover { background: var(--surface-sunk); }
.release-version { font-size: 15px; font-weight: 700; color: var(--ink); min-width: 90px; }
.release-date { font-size: 13px; color: var(--ink-faint); flex: 1; }
.release-notes { font-size: 13px; color: var(--ink-muted); }
.release-files { padding: 0 24px 16px; display: none; }
.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; padding-top: 12px; }
.file-item { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; background: var(--surface-sunk); border-radius: var(--radius-input); border: 1px solid var(--border); }
.file-info .file-name { font-size: 13px; font-weight: 600; color: var(--ink); }
.file-info .file-size { font-size: 11px; color: var(--ink-faint); margin-top: 2px; }
.chevron { transition: transform .2s; }
.release-header.open .chevron { transform: rotate(180deg); }
.empty { text-align: center; padding: 40px; color: var(--ink-faint); font-size: 14px; }

/* ── Credentials page ────────────────────────────────────────────────── */
.info-box { background: var(--info-bg); border: 1px solid var(--info-border); border-radius: var(--radius-input); padding: 12px 14px; font-size: 13px; color: var(--info-ink); margin-bottom: 20px; line-height: 1.5; }
.token-reveal { background: var(--ok-bg); border: 1px solid var(--ok-border); border-radius: var(--radius-card); padding: 20px; margin-top: 16px; }
.token-reveal h3 { font-size: 14px; font-weight: 700; color: var(--ok-ink); margin-bottom: 8px; }
.token-reveal p { font-size: 12px; color: #15803D; margin-bottom: 12px; }
.token-box { display: flex; align-items: center; gap: 8px; }
.token-value { flex: 1; font-family: var(--font-mono); font-size: 12px; background: #fff; border: 1px solid var(--ok-border); border-radius: 6px; padding: 10px 12px; color: var(--ok-ink); word-break: break-all; overflow-wrap: anywhere; }
.warn-box { background: var(--warn-bg); border: 1px solid var(--warn-border); border-radius: var(--radius-input); padding: 12px 14px; font-size: 13px; color: var(--warn-ink); margin-top: 12px; line-height: 1.5; }
.warn-box strong { display: block; margin-bottom: 4px; }
.instructions { background: var(--surface-sunk); border-radius: var(--radius-input); padding: 14px; margin-top: 12px; font-size: 13px; }
.instructions h4 { font-weight: 600; margin-bottom: 8px; color: var(--ink); }
code.block { font-family: var(--font-mono); background: var(--shell); color: #A5F3FC; padding: 8px 12px; border-radius: 6px; display: block; margin-top: 4px; font-size: 12px; overflow-x: auto; white-space: pre; }
code.inline { font-weight: 600; }

/* ── Admin / Users page ──────────────────────────────────────────────── */
.invite-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.invite-form input, .invite-form select {
  padding: 10px 12px; border: 1.5px solid var(--border); border-radius: var(--radius-input);
  font-size: 14px; font-family: inherit; color: var(--ink); background: var(--surface); outline: none;
  transition: border-color .15s;
}
.invite-form input { flex: 1; min-width: 180px; }
.invite-form input:focus, .invite-form select:focus { border-color: var(--brand-indigo); }
.invite-form select { flex: 0 0 auto; min-width: 110px; cursor: pointer; }
.invite-form .btn { flex: 0 0 auto; }
table.users { width: 100%; border-collapse: collapse; }
table.users th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-faint); padding: 12px 16px; border-bottom: 1px solid var(--border-soft); font-weight: 600; }
table.users td { padding: 12px 16px; font-size: 13px; border-bottom: 1px solid var(--border-soft); color: var(--ink); vertical-align: middle; }
table.users tr:last-child td { border-bottom: none; }
.u-email { font-weight: 600; }
.u-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.badge-warn { background: var(--warn-bg); color: var(--warn-ink); }
.btn-xs { padding: 4px 10px; font-size: 11px; }
@media (max-width: 640px) { table.users th:nth-child(4), table.users td:nth-child(4) { display: none; } }

/* ── Login card (centered, branded gradient accent) ──────────────────── */
.card-auth {
  position: relative; overflow: hidden;
  background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-pop);
  padding: 48px 40px 36px; width: 100%; max-width: 420px;
}
/* Moxo gradient hairline along the top — our own touch, not a clone. */
.card-auth::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 4px;
  background: var(--brand-gradient);
}
.auth-logo { margin-bottom: 24px; text-align: center; }
.auth-logo img { height: 30px; width: auto; display: inline-block; }
.auth-logo .logo-sub { font-size: 10px; color: var(--ink-faint); font-weight: 600; letter-spacing: .14em; text-transform: uppercase; margin-top: 10px; }
.card-auth h1 { font-size: 25px; font-weight: 700; color: var(--ink); margin-bottom: 8px; text-align: center; letter-spacing: var(--tracking-tight); }
.subtitle { font-size: 14px; color: var(--ink-muted); margin-bottom: 28px; text-align: center; line-height: 1.5; }

/* Outlined floating-label field — label rests in the box, lifts into the
   border on focus / when filled (Atlas-style pattern, Moxo execution). */
.field { position: relative; margin-bottom: 16px; }
.field input {
  width: 100%; padding: 16px 14px;
  border: 1.5px solid var(--border); border-radius: var(--radius-input);
  font-size: 15px; color: var(--ink); font-family: inherit; background: var(--surface);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.field input:focus { border-color: var(--brand-indigo); box-shadow: 0 0 0 3px var(--brand-indigo-soft); }
.field label {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  margin: 0; padding: 0 5px; pointer-events: none; background: var(--surface);
  color: var(--ink-muted); font-size: 15px; font-weight: 400;
  transition: top .14s ease, font-size .14s ease, color .14s ease;
}
.field input:focus + label,
.field input:not(:placeholder-shown) + label { top: 0; font-size: 12px; font-weight: 500; }
.field input:focus + label { color: var(--brand-indigo); }
.otp-hint { font-size: 12px; color: var(--ink-muted); margin: -4px 0 16px; text-align: center; }
.auth-footer { text-align: center; font-size: 13px; color: var(--ink-muted); margin-top: 22px; }
.auth-footer a { color: var(--brand-indigo); font-weight: 600; text-decoration: none; }
.error { background: var(--danger-bg); border: 1px solid var(--danger-border); color: var(--danger-ink); border-radius: var(--radius-input); padding: 10px 14px; font-size: 13px; margin-bottom: 16px; display: none; }
.back-link { display: block; text-align: center; font-size: 13px; color: var(--ink-muted); margin-top: 16px; cursor: pointer; text-decoration: underline; }
#otp-section { display: none; }

/* ── Toast & spinner ─────────────────────────────────────────────────── */
.toast { position: fixed; bottom: 24px; right: 24px; background: var(--shell); color: #fff; padding: 12px 18px; border-radius: var(--radius-card); font-size: 13px; font-weight: 500; box-shadow: var(--shadow-pop); opacity: 0; transform: translateY(8px); transition: all .2s; pointer-events: none; z-index: 999; }
.toast.show { opacity: 1; transform: none; }
.toast.error { background: var(--danger-ink); }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid rgba(255, 255, 255, .4); border-top-color: #fff; border-radius: 50%; animation: spin .6s linear infinite; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .content { padding: 20px 16px; }
  .topbar { padding: 14px 16px; }
}

/* ── Customers admin: id sublabel, member panel, chips ───────────────────── */
.cust-id { font-size: 12px; color: var(--muted, #8a8a8a); margin-top: 2px; }
.member-row > td { background: var(--bg, #f6f5f3); padding: 0 !important; }
.member-panel { padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; }
.member-add { display: flex; gap: 8px; }
.member-add input { flex: 1; min-width: 0; padding: 8px 12px; border: 1px solid var(--border, #e2e2e2);
  border-radius: 8px; font: inherit; background: #fff; }
.member-list { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 12px;
  background: #fff; border: 1px solid var(--border, #e2e2e2); border-radius: 999px; font-size: 13px; }
.chip button { border: none; background: none; cursor: pointer; font-size: 16px; line-height: 1;
  color: var(--muted, #8a8a8a); padding: 0 4px; border-radius: 50%; }
.chip button:hover { color: #c0392b; }
.empty-inline { color: var(--muted, #8a8a8a); font-size: 13px; }

/* ── Releases catalog: customer banner + direct-access box ────────────────── */
.cust-banner { display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 18px; margin-bottom: 16px; background: #fff; border: 1px solid var(--border, #e2e2e2);
  border-radius: 12px; }
.cust-banner-name { font-size: 18px; font-weight: 700; color: var(--text, #1f1f1f); }
.cust-banner-sub { font-size: 13px; color: var(--muted, #8a8a8a); margin-top: 2px; }
.cust-banner-lines { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.direct-box { padding: 14px 16px; }
.direct-box code { background: var(--bg, #f6f5f3); border: 1px solid var(--border, #e2e2e2);
  border-radius: 6px; padding: 3px 8px; font-size: 13px; }

/* Release tagging form (Customers page) — wraps multiple inputs */
.release-add { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.release-add input { flex: 1 1 200px; min-width: 0; padding: 8px 12px;
  border: 1px solid var(--border, #e2e2e2); border-radius: 8px; font: inherit; background: #fff; }
.chip em { font-style: italic; font-size: 11px; }
