/* BoundLink Customer Control Plane (console.boundlink.app)
   Locked visual baseline v0.10 + Mobile Navigation Shell v0.1 + Cookbook v2 motion */
:root {
  color-scheme: light;
  --bg: #f7f8fa;
  --surface: #ffffff;
  --sub: #f1f3f6;
  --hover: #fafbfc;
  --text: #14171c;
  --muted: #555d68;
  --dim: #7b8490;
  --border: #dfe3e8;
  --strong: #c9cfd7;
  --accent: #5b5ce2;
  --accent-strong: #4a4bc8;
  --accent-bg: #ededff;
  --ok: #1d7a49;
  --ok-bg: #e7f4ec;
  --warn: #9a6700;
  --warn-bg: #fff8e8;
  --bad: #b42318;
  --bad-bg: #fdecea;
  --rail: 248px;
  --max: 1120px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Consolas, monospace;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1013;
  --surface: #15181d;
  --sub: #1b1f25;
  --hover: #1a1e24;
  --text: #f4f6f8;
  --muted: #b7bec8;
  --dim: #858e9b;
  --border: #282e36;
  --strong: #39414c;
  --accent: #8c8df0;
  --accent-strong: #a7a8ff;
  --accent-bg: #262645;
  --ok: #69c18d;
  --ok-bg: #16281e;
  --warn: #e0ae49;
  --warn-bg: #302818;
  --bad: #f08078;
  --bad-bg: #33191a;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
code, pre { font-family: var(--mono); font-size: 13px; }

/* Brand mark light/dark swap */
.logo-dark { display: none; }
[data-theme="dark"] .logo-light { display: none; }
[data-theme="dark"] .logo-dark { display: block; }

/* Global Ops Banner */
.bl-banner { padding: 10px 20px; border-bottom: 1px solid var(--border); background: var(--accent-bg); color: var(--text); font-size: 13px; display: flex; justify-content: center; gap: 10px; align-items: center; }
.bl-banner.warn { background: var(--warn-bg); border-bottom-color: var(--warn); }

/* Auth Gate (Better Auth Email OTP) */
.auth-gate { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 28px; display: grid; gap: 14px; animation: fadeIn .22s var(--ease); }
.auth-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; }
.auth-card h1 { margin: 4px 0 0; font-size: 24px; line-height: 1.15; letter-spacing: -.02em; }
.auth-card p { margin: 0; color: var(--muted); }
.auth-field { display: grid; gap: 6px; }
.auth-field label { font-size: 12.5px; font-weight: 600; }
.auth-field input { height: 42px; padding: 0 12px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); }
.auth-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.auth-foot { display: flex; justify-content: space-between; align-items: center; padding-top: 10px; border-top: 1px solid var(--border); font-size: 12px; color: var(--dim); }

/* Buttons */
.btn { height: 38px; padding: 0 14px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: background .14s var(--ease), border-color .14s var(--ease), transform .14s var(--ease); }
.btn:hover { background: var(--hover); border-color: var(--strong); }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #ffffff; }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
[data-theme="dark"] .btn-primary { color: #0e1013; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.icon-btn { width: 36px; height: 36px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text); display: grid; place-items: center; cursor: pointer; transition: border-color .14s var(--ease), background .14s var(--ease); }
.icon-btn:hover { border-color: var(--strong); background: var(--hover); }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* App Shell (Locked v0.10: 248px desktop sidebar, 76px tablet rail, Mobile Shell v0.1) */
.shell { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); min-height: 100dvh; }
.sidebar { position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; padding: 20px 14px 16px; border-right: 1px solid var(--border); background: var(--surface); }
.brand-row { height: 36px; display: flex; align-items: center; gap: 10px; padding: 0 8px; font-weight: 700; font-size: 15px; letter-spacing: -.01em; margin-bottom: 16px; }
.brand-row img { width: 26px; height: 22px; object-fit: contain; flex: none; }
.nav-list { display: grid; gap: 2px; }
.nav-item { height: 40px; padding: 0 10px; border-radius: 6px; border: 0; background: transparent; color: var(--muted); display: flex; align-items: center; gap: 12px; font-weight: 500; cursor: pointer; text-align: left; transition: background .14s var(--ease), color .14s var(--ease); }
.nav-item:hover { background: var(--sub); color: var(--text); }
.nav-item[aria-current="page"] { background: var(--accent-bg); color: var(--accent-strong); font-weight: 600; }
.nav-item svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

.sidebar-foot { margin-top: auto; display: grid; gap: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.usage-meter { padding: 10px; border-radius: 8px; background: var(--sub); display: grid; gap: 6px; font-size: 12px; }
.usage-meter-top { display: flex; justify-content: space-between; color: var(--muted); font-weight: 500; }
.usage-bar { height: 5px; border-radius: 99px; background: var(--border); overflow: hidden; }
.usage-bar i { display: block; height: 100%; width: 0%; background: var(--accent); transition: width .35s var(--ease); }
.user-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 6px; font-size: 12px; }
.user-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }

/* Mobile Header + Bottom Tabs (Hidden >= 768px) */
.bl-mobile-shell, .mobile-nav { display: none; }

/* Main column */
.main-col { min-width: 0; display: flex; flex-direction: column; }
.desk-header { height: 56px; padding: 0 32px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; z-index: 10; }
.env-badge { font-size: 11.5px; font-weight: 600; color: var(--muted); padding: 3px 9px; border-radius: 99px; border: 1px solid var(--border); background: var(--sub); }
.header-utils { display: flex; align-items: center; gap: 8px; } /* Fixed order: Notifications -> Theme */

.content { width: min(var(--max), 100%); margin: 0 auto; padding: 48px 32px 72px; }
.page { display: none; }
.page.is-active { display: block; animation: fadeIn .18s var(--ease); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head h1 { margin: 0 0 6px; font-size: 38px; line-height: 1.08; letter-spacing: -.025em; font-weight: 650; }
.page-head p { margin: 0; color: var(--muted); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 20px; margin-bottom: 16px; }
.card h2 { margin: 0 0 6px; font-size: 18px; line-height: 1.3; font-weight: 600; }
.card p { margin: 0 0 12px; color: var(--muted); }
.state-banner { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; padding: 14px 16px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); margin-bottom: 18px; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 99px; background: var(--sub); color: var(--muted); }
.chip i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }

/* Command box with animated Copy -> Check */
.cmd-box { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-radius: 8px; background: var(--sub); border: 1px solid var(--border); overflow-x: auto; margin: 10px 0; }
.cmd-box code { white-space: nowrap; }
.copy-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.copy-btn .c-chk { display: none; stroke: var(--ok); }
.copy-btn.copied .c-box { display: none; }
.copy-btn.copied .c-chk { display: block; }

.auth-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.auth-cell { padding: 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); }
.auth-cell small { display: block; font-size: 11px; color: var(--dim); text-transform: uppercase; letter-spacing: .05em; }
.auth-cell b { display: block; margin-top: 4px; font-size: 14px; }

/* Smooth EvidenceDisclosure */
.disc { border: 1px solid var(--border); border-radius: 8px; background: var(--bg); overflow: hidden; margin-top: 12px; }
.disc-btn { width: 100%; padding: 11px 14px; border: 0; background: none; display: flex; justify-content: space-between; align-items: center; font-weight: 600; font-size: 13px; cursor: pointer; text-align: left; }
.disc-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; transition: transform .22s var(--ease); }
.disc.open .disc-btn svg { transform: rotate(180deg); }
.disc-body { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .22s var(--ease); }
.disc.open .disc-body { grid-template-rows: 1fr; }
.disc-body > div { overflow: hidden; }
.disc-inner { padding: 0 14px 12px; font-family: var(--mono); font-size: 12px; color: var(--muted); white-space: pre-wrap; }

/* Mobile Drawer (<dialog>) */
.bl-drawer { padding: 0; margin: 0; border: 0; border-right: 1px solid var(--border); width: min(86vw, 340px); max-width: 340px; height: 100dvh; max-height: 100dvh; background: var(--surface); color: var(--text); }
.bl-drawer::backdrop { background: rgba(0, 0, 0, .55); }
.bl-drawer[open] { display: flex; flex-direction: column; animation: slideIn .22s ease-out; }
@keyframes slideIn { from { transform: translateX(-100%); } to { transform: none; } }
.bl-drawer-head { padding: 16px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.bl-menu-row { min-height: 48px; padding: 0 16px; border: 0; border-bottom: 1px solid var(--border); background: none; color: var(--text); display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; font-weight: 500; cursor: pointer; }
.bl-drawer-foot { margin-top: auto; padding: 12px 16px max(12px, env(safe-area-inset-bottom)); border-top: 1px solid var(--border); display: flex; justify-content: space-between; gap: 8px; }

/* Tablet (768px - 1179px): 76px icon-only rail */
@media (max-width: 1179px) and (min-width: 768px) {
  :root { --rail: 76px; }
  .sidebar { padding: 20px 10px 16px; align-items: center; }
  .brand-row span, .nav-item span, .usage-meter, .user-email { display: none; }
  .nav-item { justify-content: center; width: 44px; padding: 0; }
  .auth-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Mobile (< 768px): Mobile Navigation Shell v0.1 */
@media (max-width: 767px) {
  .shell { display: block; }
  .sidebar, .desk-header { display: none; }
  .bl-mobile-shell { display: grid; grid-template-columns: 48px minmax(0, 1fr) 48px; align-items: center; min-height: 58px; padding: 5px 12px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 11; }
  .bl-avatar { width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; font-weight: 700; font-size: 12px; cursor: pointer; }
  .bl-mobile-title { text-align: center; font-weight: 650; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .content { padding: 24px 16px 84px; }
  .page-head h1 { font-size: 28px; line-height: 1.12; }
  .auth-grid { grid-template-columns: 1fr 1fr; }
  .mobile-nav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 12; min-height: 52px; padding-bottom: env(safe-area-inset-bottom); background: var(--surface); border-top: 1px solid var(--border); }
  .mobile-nav button { flex: 1; border: 0; background: none; color: var(--dim); font-size: 11px; font-weight: 600; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; cursor: pointer; }
  .mobile-nav button[aria-current="page"] { color: var(--accent); }
  .mobile-nav svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; }
}

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