/* ============================================================
   Funnl — Design System
   Bold Gen-Z SaaS: electric violet + lime on warm paper.
   Space Grotesk display / Inter body. Light + dark.
   Icons: Bootstrap Icons only (no emoji).
   ============================================================ */

:root {
  /* Brand */
  --violet:        #6C4CF1;
  --violet-600:    #5A3DE0;
  --violet-700:    #4A2FC4;
  --lime:          #C6F432;
  --lime-ink:      #1B2400;   /* readable text on lime */
  --coral:         #FF5C49;

  /* Surfaces (light) */
  --bg:            #F4F3EE;   /* warm paper */
  --surface:       #FFFFFF;
  --surface-2:     #FAFAF7;
  --ink:           #15151B;   /* primary text */
  --ink-soft:      #5A5A66;   /* secondary text */
  --ink-faint:     #8A8A95;
  --border:        #E6E5DD;
  --border-strong: #D6D5CB;

  /* Semantic */
  --success:       #14A05A;
  --warning:       #E8930C;
  --danger:        #E23B53;
  --info:          #2F8FE8;
  --success-bg:    #E3F6EC;
  --warning-bg:    #FCF1DC;
  --danger-bg:     #FBE4E8;
  --info-bg:       #E2F0FC;

  /* Shape + motion */
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;
  --pill: 999px;
  --shadow-sm: 0 1px 2px rgba(20,20,30,.06);
  --shadow-md: 0 6px 20px rgba(20,20,30,.08);
  --shadow-lg: 0 18px 50px rgba(20,20,30,.12);
  --ring: 0 0 0 4px rgba(108,76,241,.22);
  --t-fast: 140ms;
  --t-base: 220ms;
  --ease: cubic-bezier(.22,.61,.36,1);

  /* Layout */
  --sidebar-w: 264px;
  --topbar-h: 68px;

  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;
}

[data-theme="dark"] {
  --bg:            #0D0D12;
  --surface:       #16161E;
  --surface-2:     #1D1D27;
  --ink:           #F2F2F5;
  --ink-soft:      #ADADBA;
  --ink-faint:     #7C7C8A;
  --border:        #262631;
  --border-strong: #34343F;
  --success-bg:    #102A1D;
  --warning-bg:    #2C2310;
  --danger-bg:     #2C1219;
  --info-bg:       #11212F;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow-md: 0 6px 20px rgba(0,0,0,.45);
  --shadow-lg: 0 18px 50px rgba(0,0,0,.55);
  --ring: 0 0 0 4px rgba(108,76,241,.35);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  transition: background var(--t-base) var(--ease), color var(--t-base) var(--ease);
}

h1, h2, h3, h4, h5, .display {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin: 0 0 .4em;
}

a { color: var(--violet); text-decoration: none; }
a:hover { color: var(--violet-600); }

.text-soft  { color: var(--ink-soft); }
.text-faint { color: var(--ink-faint); }
.mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

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

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  font-family: var(--font-display); font-weight: 600; font-size: .95rem;
  min-height: 46px; padding: 0 1.15rem; border-radius: var(--r-md);
  border: 1.5px solid transparent; cursor: pointer; line-height: 1;
  transition: transform var(--t-fast) var(--ease), background var(--t-fast) var(--ease),
              box-shadow var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn i { font-size: 1.05em; }

.btn-primary { background: var(--violet); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--violet-600); color: #fff; box-shadow: var(--shadow-md); }

.btn-lime { background: var(--lime); color: var(--lime-ink); }
.btn-lime:hover { filter: brightness(1.04); color: var(--lime-ink); }

.btn-ghost { background: transparent; color: var(--ink); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }

.btn-block { width: 100%; }
.btn[disabled], .btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

/* ---------- Cards ---------- */
.card-f {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.4rem;
}
.card-f.hoverable { transition: transform var(--t-base) var(--ease), box-shadow var(--t-base) var(--ease); }
.card-f.hoverable:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }

/* KPI stat card */
.stat {
  display: flex; flex-direction: column; gap: .35rem;
}
.stat .label { font-size: .8rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.stat .value { font-family: var(--font-display); font-size: 2rem; font-weight: 700; letter-spacing: -.03em; }
.stat .delta { font-size: .82rem; font-weight: 600; display: inline-flex; align-items: center; gap: .25rem; }
.delta.up { color: var(--success); } .delta.down { color: var(--danger); }

/* ---------- Badges / pills ---------- */
.pill {
  display: inline-flex; align-items: center; gap: .35rem;
  font-size: .76rem; font-weight: 600; padding: .28rem .65rem; border-radius: var(--pill);
  background: var(--surface-2); color: var(--ink-soft); border: 1px solid var(--border);
}
.pill.violet { background: rgba(108,76,241,.12); color: var(--violet); border-color: transparent; }
.pill.lime   { background: rgba(198,244,50,.25); color: var(--lime-ink); border-color: transparent; }
.pill.success{ background: var(--success-bg); color: var(--success); border-color: transparent; }
.pill.warning{ background: var(--warning-bg); color: var(--warning); border-color: transparent; }
.pill.danger { background: var(--danger-bg); color: var(--danger); border-color: transparent; }
[data-theme="dark"] .pill.lime { color: var(--lime); }

/* ---------- Forms ---------- */
.field { margin-bottom: 1.05rem; }
.field label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .4rem; color: var(--ink); }
.field .hint { font-size: .8rem; color: var(--ink-faint); margin-top: .35rem; }
.input, .select, .textarea {
  width: 100%; min-height: 48px; padding: .7rem .9rem;
  font-family: var(--font-body); font-size: 1rem; color: var(--ink);
  background: var(--surface); border: 1.5px solid var(--border-strong);
  border-radius: var(--r-md); transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.textarea { min-height: 110px; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--ink-faint); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--violet); box-shadow: var(--ring); }
.field.has-error .input, .field.has-error .select, .field.has-error .textarea { border-color: var(--danger); }
.field .error { color: var(--danger); font-size: .82rem; margin-top: .35rem; }

/* ---------- Alerts (flash) ---------- */
.alert-f {
  display: flex; gap: .65rem; align-items: flex-start;
  padding: .8rem 1rem; border-radius: var(--r-md); font-size: .92rem; margin-bottom: 1rem;
  border: 1px solid transparent;
}
.alert-f i { font-size: 1.1rem; margin-top: .05rem; }
.alert-f.success { background: var(--success-bg); color: var(--success); }
.alert-f.error   { background: var(--danger-bg);  color: var(--danger); }
.alert-f.info    { background: var(--info-bg);    color: var(--info); }

/* ============================================================
   App shell: sidebar + topbar + content
   ============================================================ */
.app { display: flex; min-height: 100dvh; }

.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 1.1rem .85rem;
  position: sticky; top: 0; height: 100dvh;
}
.brand { display: flex; align-items: center; gap: .6rem; padding: .4rem .5rem 1.1rem; }
.brand .logo {
  width: 38px; height: 38px; border-radius: 11px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--violet), var(--coral));
  display: grid; place-items: center; color: #fff; font-size: 1.2rem;
}
.brand .name { font-family: var(--font-display); font-weight: 700; font-size: 1.25rem; letter-spacing: -.03em; }

.nav-f { display: flex; flex-direction: column; gap: .15rem; flex: 1; }
.nav-f a {
  display: flex; align-items: center; gap: .7rem;
  padding: .68rem .7rem; border-radius: var(--r-md);
  color: var(--ink-soft); font-weight: 500; font-size: .95rem;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.nav-f a i { font-size: 1.2rem; width: 1.3rem; text-align: center; }
.nav-f a:hover { background: var(--surface-2); color: var(--ink); }
.nav-f a.active { background: var(--violet); color: #fff; box-shadow: var(--shadow-sm); }
.nav-f .nav-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-faint); font-weight: 700; padding: .9rem .7rem .3rem; }

.sidebar .user-chip {
  display: flex; align-items: center; gap: .6rem; padding: .6rem; border-radius: var(--r-md);
  border: 1px solid var(--border); margin-top: .6rem;
}
.user-chip .avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  background: var(--lime); color: var(--lime-ink); display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 700; font-size: .9rem;
}
.user-chip .meta { min-width: 0; }
.user-chip .meta .n { font-weight: 600; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip .meta .e { font-size: .78rem; color: var(--ink-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--topbar-h); flex-shrink: 0;
  display: flex; align-items: center; gap: 1rem;
  padding: 0 1.4rem; border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 20;
}
.topbar .page-title { font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; margin: 0; }
.topbar .spacer { flex: 1; }
.icon-btn {
  width: 44px; height: 44px; border-radius: var(--r-md); border: 1px solid var(--border);
  background: var(--surface); color: var(--ink-soft); display: grid; place-items: center;
  cursor: pointer; font-size: 1.2rem; transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }

.content { padding: 1.6rem 1.4rem 3rem; max-width: 1280px; width: 100%; }

.menu-toggle { display: none; }

/* Empty state */
.empty {
  text-align: center; padding: 3rem 1.5rem;
  border: 1.5px dashed var(--border-strong); border-radius: var(--r-lg); background: var(--surface-2);
}
.empty .ico { font-size: 2.4rem; color: var(--violet); margin-bottom: .6rem; }

/* Skeleton loader */
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 37%, var(--surface-2) 63%);
  background-size: 400% 100%; animation: sk 1.4s ease infinite; border-radius: var(--r-sm); }
@keyframes sk { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* ============================================================
   Auth screens (split layout)
   ============================================================ */
.auth-wrap { display: grid; grid-template-columns: 1fr 1fr; min-height: 100dvh; }
.auth-art {
  background: linear-gradient(150deg, var(--violet) 0%, var(--violet-700) 55%, #2A1A6E 100%);
  color: #fff; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between;
  position: relative; overflow: hidden;
}
.auth-art::after {
  content: ''; position: absolute; width: 360px; height: 360px; right: -90px; bottom: -90px;
  background: var(--lime); border-radius: 50%; opacity: .9; filter: blur(2px);
}
.auth-art .blob2 { position: absolute; width: 200px; height: 200px; left: -60px; top: 20%;
  background: var(--coral); border-radius: 50%; opacity: .6; }
.auth-art .ax-content { position: relative; z-index: 2; }
.auth-art .name { font-family: var(--font-display); font-weight: 700; font-size: 1.5rem; display: flex; gap: .6rem; align-items: center; }
.auth-art h2 { color: #fff; font-size: 2.4rem; line-height: 1.1; max-width: 14ch; }
.auth-art .pts { position: relative; z-index: 2; display: flex; flex-direction: column; gap: .8rem; margin-top: 1.5rem; }
.auth-art .pts div { display: flex; gap: .6rem; align-items: center; font-weight: 500; }
.auth-art .pts i { background: rgba(255,255,255,.18); width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; }

.auth-form { display: flex; align-items: center; justify-content: center; padding: 2rem; background: var(--bg); }
.auth-card { width: 100%; max-width: 410px; }
.auth-card .eyebrow { color: var(--violet); font-weight: 700; font-size: .82rem; letter-spacing: .05em; text-transform: uppercase; }
.auth-card h1 { font-size: 2rem; margin: .3rem 0 .4rem; }
.auth-switch { margin-top: 1.3rem; font-size: .92rem; color: var(--ink-soft); text-align: center; }

@media (max-width: 860px) {
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-art { display: none; }
}

/* ============================================================
   Responsive shell
   ============================================================ */
@media (max-width: 900px) {
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 60; transform: translateX(-100%);
    transition: transform var(--t-base) var(--ease); box-shadow: var(--shadow-lg);
  }
  .app.nav-open .sidebar { transform: translateX(0); }
  .menu-toggle { display: grid; }
  .scrim {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 50;
  }
  .app.nav-open .scrim { display: block; }
}

/* Utility spacing helpers used in views */
.grid-cards { display: grid; gap: 1rem; }
@media (min-width: 640px) { .cols-2 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 980px) { .cols-3 { grid-template-columns: repeat(3, 1fr); } .cols-4 { grid-template-columns: repeat(4, 1fr); } }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.mt-2 { margin-top: .5rem; } .mt-4 { margin-top: 1rem; } .mb-0 { margin-bottom: 0; }
