/* ============================================================================
   FutureBridge Agents — App design system (auth + dashboard)
   Light "outreach infrastructure console" theme: warm-cream surface, white
   cards, soft shadows, and a dark brand rail. Carries the marketing site's
   palette (cream #f3f0e8, ink #0c0c0d, accent #ff6a3d) into the product.
   Shared by signup/login and every dashboard module.
   ========================================================================== */

:root {
  --app-bg: #f3f0e8;
  --app-bg-2: #ffffff;
  --panel: #fffdf8;
  --panel-2: #f7f4ec;
  --panel-3: #eeeadf;
  --ink: #0c0c0d;
  --ink-dim: #45433d;
  --muted: #6f6c63;
  --faint: #a5a196;
  --line: rgba(12, 12, 13, 0.08);
  --line-strong: rgba(12, 12, 13, 0.16);
  --accent: #ff6a3d;
  --accent-soft: rgba(255, 106, 61, 0.12);
  --accent-2: #e04f22;
  --good: #178a4c;
  --good-soft: rgba(23, 138, 76, 0.11);
  --warn: #96700c;
  --warn-soft: rgba(196, 150, 21, 0.14);
  --bad: #cf3f3f;
  --bad-soft: rgba(207, 63, 63, 0.1);
  --info: #2e6fce;
  --info-soft: rgba(46, 111, 206, 0.1);

  /* Dark rail palette (sidebar + rail-scoped components) */
  --rail-bg: #101014;
  --rail-ink: #f2efe6;
  --rail-ink-dim: #c9c5b8;
  --rail-muted: #8f8b7f;
  --rail-line: rgba(242, 239, 230, 0.09);

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;

  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-serif: "Instrument Serif", "Times New Roman", Georgia, serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --sidebar-w: 232px;
  --topbar-h: 58px;
  --shadow: 0 10px 30px rgba(12, 12, 13, 0.08);
  --shadow-sm: 0 2px 10px rgba(12, 12, 13, 0.05);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body.app {
  font-family: var(--font-sans);
  background: var(--app-bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

body.app::before {
  /* faint infrastructure grid on the cream surface */
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    linear-gradient(rgba(12, 12, 13, 0.028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(12, 12, 13, 0.028) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse 90% 70% at 50% 0%, #000 0%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 90% 70% at 50% 0%, #000 0%, transparent 75%);
}

img, svg { display: block; max-width: 100%; }
[hidden] { display: none !important; }
a { color: inherit; text-decoration: none; }
em { font-family: var(--font-serif); font-style: italic; font-weight: 400; }

.mono { font-family: var(--font-mono); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ── Brand wordmark ──────────────────────────────────────────────────────── */
.brand { display: inline-flex; align-items: baseline; gap: 2px; font-weight: 700; letter-spacing: 0.2px; font-size: 16px; color: inherit; }
.brand small { font-weight: 600; color: var(--accent); font-size: inherit; }
.brand-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); align-self: center; margin-left: 6px; box-shadow: 0 0 8px rgba(255, 106, 61, 0.7); }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 600 14px/1 var(--font-sans);
  padding: 11px 18px; border-radius: 10px; border: 1px solid transparent;
  cursor: pointer; transition: all 0.15s ease; white-space: nowrap;
  text-decoration: none;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover:not(:disabled) { background: #f25a2c; box-shadow: 0 6px 18px rgba(255, 106, 61, 0.35); }
.btn--ghost { background: var(--app-bg-2); color: var(--ink); border-color: var(--line-strong); }
.btn--ghost:hover:not(:disabled) { border-color: var(--accent); color: var(--accent-2); }
.btn--dark { background: var(--panel-2); color: var(--ink); border-color: var(--line); }
.btn--dark:hover:not(:disabled) { background: var(--panel-3); }
.btn--danger { background: var(--bad-soft); color: var(--bad); border-color: rgba(207, 63, 63, 0.3); }
.btn--sm { padding: 7px 12px; font-size: 13px; border-radius: 8px; }
.btn--lg { padding: 14px 24px; font-size: 15px; }
.btn--full { width: 100%; }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; margin: 0 0 16px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--ink-dim); letter-spacing: 0.3px; }
.field .hint { font-size: 12px; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; font: 400 14.5px/1.4 var(--font-sans); color: var(--ink);
  background: var(--app-bg-2); border: 1px solid var(--line-strong);
  border-radius: 10px; padding: 11px 13px; outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 106, 61, 0.16);
}
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.textarea { min-height: 110px; resize: vertical; font-family: var(--font-sans); }
.textarea--mono, .input--mono { font-family: var(--font-mono); font-size: 13px; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%236f6c63' fill='none' stroke-width='1.5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 13px center; padding-right: 34px; }
.form-error { color: var(--bad); background: var(--bad-soft); border: 1px solid rgba(207, 63, 63, 0.25); border-radius: 10px; padding: 10px 13px; font-size: 13.5px; margin: 0 0 16px; display: none; }
.form-error.show { display: block; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* Switch */
.switch { position: relative; display: inline-block; width: 38px; height: 22px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch i { position: absolute; inset: 0; background: var(--panel-3); border: 1px solid var(--line-strong); border-radius: 999px; transition: 0.15s; cursor: pointer; }
.switch i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(12, 12, 13, 0.25); transition: 0.15s; }
.switch input:checked + i { background: var(--accent); border-color: var(--accent); }
.switch input:checked + i::after { transform: translateX(16px); }

/* ── Cards / panels ──────────────────────────────────────────────────────── */
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 22px; position: relative; box-shadow: var(--shadow-sm);
}
.card--pad-lg { padding: 30px; }
.card__title { margin: 0 0 4px; font-size: 16px; font-weight: 650; }
.card__sub { margin: 0 0 16px; font-size: 13.5px; color: var(--muted); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }

/* Stat tiles */
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-sm); }
.stat__label { font: 600 11px/1.3 var(--font-sans); text-transform: uppercase; letter-spacing: 0.9px; color: var(--muted); margin-bottom: 10px; display: flex; align-items: center; gap: 6px; }
.stat__num { font-size: 26px; font-weight: 700; letter-spacing: -0.5px; line-height: 1.1; }
.stat__sub { font-size: 12px; color: var(--muted); margin-top: 6px; }
.stat__delta { font-size: 12px; font-weight: 600; }
.stat__delta.up { color: var(--good); }
.stat__delta.down { color: var(--bad); }

/* ── Badges / status ─────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 6px; font: 600 11px/1.3 var(--font-sans);
  letter-spacing: 0.5px; text-transform: uppercase;
  padding: 5px 9px; border-radius: 999px; border: 1px solid var(--line-strong);
  color: var(--ink-dim); background: var(--app-bg-2);
}
.badge--good { color: var(--good); background: var(--good-soft); border-color: rgba(23, 138, 76, 0.3); }
.badge--warn { color: var(--warn); background: var(--warn-soft); border-color: rgba(150, 112, 12, 0.3); }
.badge--bad { color: var(--bad); background: var(--bad-soft); border-color: rgba(207, 63, 63, 0.3); }
.badge--accent { color: var(--accent-2); background: var(--accent-soft); border-color: rgba(255, 106, 61, 0.4); }
.badge--info { color: var(--info); background: var(--info-soft); border-color: rgba(46, 111, 206, 0.3); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.dot--pulse { animation: dotpulse 1.8s ease infinite; }
@keyframes dotpulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* ── Tables ──────────────────────────────────────────────────────────────── */
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 640px; }
.table th {
  text-align: left; font: 600 11px/1.3 var(--font-sans); text-transform: uppercase; letter-spacing: 0.8px;
  color: var(--muted); padding: 11px 14px; border-bottom: 1px solid var(--line); background: var(--panel-2);
}
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background 0.12s; }
.table tbody tr:hover { background: rgba(12, 12, 13, 0.025); }
.table .row-title { font-weight: 600; color: var(--ink); }
.table .row-sub { font-size: 12px; color: var(--muted); }

/* ── Progress / meters ───────────────────────────────────────────────────── */
.meter { height: 6px; border-radius: 999px; background: var(--panel-3); overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: 999px; background: var(--accent); transition: width 0.4s ease; }
.meter--good > i { background: var(--good); }
.meter--warn > i { background: var(--warn); }

/* ── Tabs ────────────────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line-strong); margin-bottom: 20px; }
.tab {
  background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted);
  font: 600 13.5px/1 var(--font-sans); padding: 10px 14px; cursor: pointer; transition: 0.15s;
}
.tab:hover { color: var(--ink-dim); }
.tab.active { color: var(--ink); border-bottom-color: var(--accent); }

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(24, 22, 17, 0.45); backdrop-filter: blur(4px);
  display: none; align-items: flex-start; justify-content: center; z-index: 200; padding: 6vh 20px 40px; overflow-y: auto;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 26px; width: 100%; max-width: 560px; box-shadow: var(--shadow); position: relative;
}
.modal--lg { max-width: 780px; }
.modal__close { position: absolute; top: 14px; right: 14px; background: none; border: 0; color: var(--muted); font-size: 20px; cursor: pointer; line-height: 1; padding: 6px; }
.modal__close:hover { color: var(--ink); }
.modal h3 { margin: 0 0 6px; font-size: 18px; }
.modal .modal__sub { margin: 0 0 18px; color: var(--muted); font-size: 13.5px; }

/* ── Toasts ──────────────────────────────────────────────────────────────── */
.toasts { position: fixed; bottom: 22px; right: 22px; z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--ink); border: 1px solid var(--ink); color: #f7f4ec;
  border-radius: 10px; padding: 11px 16px; font-size: 13.5px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 9px; animation: toastin 0.2s ease;
}
.toast--good { border-color: rgba(71, 209, 138, 0.6); }
.toast--bad { border-color: rgba(255, 93, 93, 0.6); }
@keyframes toastin { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ── Empty states ────────────────────────────────────────────────────────── */
.empty { text-align: center; padding: 48px 24px; border: 1px dashed var(--line-strong); border-radius: var(--radius-lg); background: var(--panel); }
.empty__icon { font-size: 26px; margin-bottom: 10px; opacity: 0.8; }
.empty h4 { margin: 0 0 6px; font-size: 15.5px; }
.empty p { margin: 0 0 16px; color: var(--muted); font-size: 13.5px; }

/* ── App shell: dark rail + light main ───────────────────────────────────── */
.shell { display: flex; min-height: 100vh; position: relative; z-index: 1; }

.sidebar {
  width: var(--sidebar-w); flex: none; background: var(--rail-bg);
  border-right: 1px solid var(--rail-line); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; padding: 18px 14px; gap: 4px;
  color: var(--rail-ink);
}
.sidebar .brand { padding: 4px 10px 18px; color: var(--rail-ink); }
.navlink {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 10px;
  color: var(--rail-ink-dim); font: 500 13.5px/1 var(--font-sans); cursor: pointer; border: 1px solid transparent;
  background: none; width: 100%; text-align: left; transition: 0.13s;
}
.navlink svg { width: 17px; height: 17px; flex: none; opacity: 0.85; }
.navlink:hover { color: var(--rail-ink); background: rgba(242, 239, 230, 0.06); }
.navlink.active { color: var(--rail-ink); background: rgba(242, 239, 230, 0.09); border-color: var(--rail-line); }
.navlink.active svg { color: var(--accent); opacity: 1; }
.navlink .lock { margin-left: auto; font-size: 11px; color: var(--rail-muted); }
.nav-section { font: 600 10.5px/1.3 var(--font-sans); text-transform: uppercase; letter-spacing: 1.2px; color: var(--rail-muted); padding: 16px 12px 7px; }
.sidebar__foot { margin-top: auto; padding: 12px 10px 4px; border-top: 1px solid var(--rail-line); font-size: 12px; color: var(--rail-muted); }
/* Badges rendered inside the dark rail keep readable tints */
.sidebar .badge { background: transparent; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--topbar-h); flex: none; display: flex; align-items: center; gap: 14px;
  padding: 0 26px; border-bottom: 1px solid var(--line); background: rgba(255, 253, 248, 0.85);
  position: sticky; top: 0; z-index: 50; backdrop-filter: blur(8px);
}
.topbar__title { font-size: 15px; font-weight: 650; }
.topbar__right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-2);
  display: inline-flex; align-items: center; justify-content: center; font: 700 12.5px/1 var(--font-sans);
  border: 1px solid rgba(255, 106, 61, 0.35); cursor: pointer;
}
.content { padding: 28px; max-width: 1240px; width: 100%; margin: 0 auto; }
.content h2.page-title { margin: 0 0 4px; font-size: 22px; letter-spacing: -0.3px; }
.content .page-sub { margin: 0 0 24px; color: var(--muted); font-size: 14px; }

/* Grids */
.grid { display: grid; gap: 16px; }
.grid--2 { grid-template-columns: repeat(2, 1fr); }
.grid--3 { grid-template-columns: repeat(3, 1fr); }
.grid--4 { grid-template-columns: repeat(4, 1fr); }

/* ── Auth layout ─────────────────────────────────────────────────────────── */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 40px 20px; position: relative; z-index: 1; }
.auth-card { width: 100%; max-width: 440px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 34px; box-shadow: var(--shadow); }
.auth-card h1 { margin: 14px 0 6px; font-size: 24px; letter-spacing: -0.4px; }
.auth-card .auth-sub { margin: 0 0 24px; color: var(--muted); font-size: 14px; }
.auth-alt { margin-top: 18px; text-align: center; font-size: 13.5px; color: var(--muted); }
.auth-alt a, .link-accent { color: var(--accent-2); font-weight: 600; }
.auth-alt a:hover, .link-accent:hover { color: var(--accent); }

/* Plan cards */
.plans { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.plan-card {
  background: var(--panel); border: 1px solid var(--line-strong); border-radius: var(--radius-lg);
  padding: 24px; cursor: pointer; transition: 0.15s; position: relative; box-shadow: var(--shadow-sm);
}
.plan-card:hover { border-color: var(--accent); }
.plan-card.selected { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255, 106, 61, 0.18); }
.plan-card__flag { position: absolute; top: -11px; right: 16px; }
.plan-card h3 { margin: 0 0 2px; font-size: 17px; }
.plan-card .price { font-size: 30px; font-weight: 700; letter-spacing: -0.8px; margin: 8px 0 2px; }
.plan-card .price small { font-size: 13px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.plan-card ul { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 8px; font-size: 13.5px; color: var(--ink-dim); }
.plan-card ul li { display: flex; gap: 8px; align-items: flex-start; }
.plan-card ul li::before { content: "✓"; color: var(--good); font-weight: 700; flex: none; }

/* Upgrade / locked panel */
.locked-panel { text-align: center; padding: 56px 30px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: linear-gradient(180deg, var(--panel) 0%, var(--panel-2) 100%); box-shadow: var(--shadow-sm); }
.locked-panel .badge { margin-bottom: 14px; }
.locked-panel h3 { margin: 0 0 8px; font-size: 20px; }
.locked-panel p { margin: 0 auto 20px; color: var(--muted); max-width: 460px; font-size: 14px; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 1000px) {
  .grid--4 { grid-template-columns: repeat(2, 1fr); }
  .grid--3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 780px) {
  .sidebar { position: fixed; z-index: 150; transform: translateX(-100%); transition: transform 0.2s ease; box-shadow: var(--shadow); }
  .sidebar.open { transform: none; }
  .shell { display: block; }
  .content { padding: 20px 16px; }
  .grid--2, .plans, .form-row { grid-template-columns: 1fr; }
  .topbar { padding: 0 16px; }
  .menu-btn { display: inline-flex !important; }
}
.menu-btn { display: none; background: var(--app-bg-2); border: 1px solid var(--line-strong); border-radius: 8px; color: var(--ink); padding: 7px 10px; cursor: pointer; }
@media (max-width: 560px) {
  .grid--4, .grid--3 { grid-template-columns: 1fr; }
  .auth-card { padding: 26px 20px; }
}
