/* =====================================================================
   FINALYTI R&D PIPELINE — Gen-Z Design System
   Space Grotesk (display) + Inter (body) + JetBrains Mono (data)
   Dark-first, vibrant accents, glassmorphism touches, big radii
   ===================================================================== */

/* ---------- Tokens ---------- */
:root {
  /* surfaces (dark theme default) */
  --bg:          #0a0a0f;
  --bg-grad-1:   #120c24;
  --bg-grad-2:   #0a0a0f;
  --surface:     #14141f;
  --surface-2:   #1c1c2b;
  --surface-3:   #25253a;
  --border:      rgba(255,255,255,.08);
  --border-2:    rgba(255,255,255,.14);

  /* text */
  --text:        #f3f3fb;
  --text-dim:    #a2a2c0;
  --text-mute:   #6b6b8a;

  /* brand */
  --violet:      #8b5cf6;
  --violet-2:    #6366f1;
  --lime:        #bef264;
  --lime-ink:    #1a2e05;
  --coral:       #fb6f92;
  --cyan:        #22d3ee;
  --amber:       #fbbf24;
  --slate:       #94a3b8;

  /* semantic */
  --success:     #34d399;
  --warning:     #fbbf24;
  --danger:      #fb7185;

  /* gradients */
  --grad-brand:  linear-gradient(135deg, #8b5cf6 0%, #6366f1 55%, #22d3ee 120%);
  --grad-lime:   linear-gradient(135deg, #bef264 0%, #84cc16 100%);
  --grad-coral:  linear-gradient(135deg, #fb6f92 0%, #f43f5e 100%);
  --grad-glow:   radial-gradient(120% 120% at 0% 0%, rgba(139,92,246,.20), transparent 60%);

  /* shape + motion */
  --r-sm: 10px; --r-md: 16px; --r-lg: 22px; --r-xl: 28px; --r-pill: 999px;
  --sh-1: 0 1px 2px rgba(0,0,0,.4);
  --sh-2: 0 8px 24px rgba(0,0,0,.35);
  --sh-glow: 0 8px 40px rgba(139,92,246,.30);
  --ease: cubic-bezier(.22,.61,.36,1);
}

/* light theme */
[data-theme="light"] {
  --bg:        #f4f4fb;
  --bg-grad-1: #ece9ff;
  --bg-grad-2: #f4f4fb;
  --surface:   #ffffff;
  --surface-2: #f7f7fc;
  --surface-3: #eeeef6;
  --border:    rgba(17,17,40,.09);
  --border-2:  rgba(17,17,40,.16);
  --text:      #15152b;
  --text-dim:  #4a4a68;
  --text-mute: #8585a3;
  --lime-ink:  #2a4006;
  --sh-2:      0 8px 24px rgba(40,30,90,.10);
  --sh-glow:   0 8px 40px rgba(139,92,246,.18);
}

/* ---------- Reset ---------- */
*,*::before,*::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background:
    var(--grad-glow),
    linear-gradient(180deg, var(--bg-grad-1), var(--bg-grad-2) 480px);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}
h1,h2,h3,h4 { font-family: 'Space Grotesk', sans-serif; font-weight: 700; letter-spacing: -.02em; margin: 0; line-height: 1.1; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
.mono { font-family: 'JetBrains Mono', monospace; font-variant-numeric: tabular-nums; }
::selection { background: var(--violet); color: #fff; }

/* scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-2); }

/* ---------- Layout shell ---------- */
.app { display: grid; grid-template-columns: 268px 1fr; min-height: 100dvh; }

.sidebar {
  position: sticky; top: 0; align-self: start; height: 100dvh;
  display: flex; flex-direction: column; gap: 6px;
  padding: 22px 16px;
  background: linear-gradient(180deg, var(--surface) , var(--surface-2));
  border-right: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 6px 10px 18px; }
.brand-logo {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: var(--grad-brand); box-shadow: var(--sh-glow); color: #fff; font-size: 20px; flex-shrink: 0;
}
.brand-name { font-family: 'Space Grotesk'; font-weight: 700; font-size: 17px; letter-spacing: -.02em; }
.brand-sub  { font-size: 11px; color: var(--text-mute); letter-spacing: .12em; text-transform: uppercase; }

.nav-label { font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--text-mute); padding: 16px 12px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: var(--r-sm);
  color: var(--text-dim); font-weight: 500; font-size: 14px;
  transition: background .2s var(--ease), color .2s var(--ease), transform .12s var(--ease);
}
.nav-item i { font-size: 18px; }
.nav-item:hover { background: var(--surface-3); color: var(--text); }
.nav-item.active {
  color: #fff; background: var(--grad-brand); box-shadow: var(--sh-glow);
}
.sidebar-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-sm); }
.user-avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--grad-coral); display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 14px; flex-shrink: 0; }

/* ---------- Main / topbar ---------- */
.main { min-width: 0; padding: 26px 30px 60px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 26px; flex-wrap: wrap; }
.page-title { font-size: 28px; }
.page-sub { color: var(--text-dim); font-size: 14px; margin-top: 4px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.icon-btn {
  width: 42px; height: 42px; border-radius: var(--r-sm); border: 1px solid var(--border);
  background: var(--surface); color: var(--text-dim); display: grid; place-items: center; font-size: 18px;
  transition: all .18s var(--ease);
}
.icon-btn:hover { color: var(--text); border-color: var(--border-2); transform: translateY(-1px); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  padding: 11px 18px; border-radius: var(--r-pill); border: 1px solid transparent;
  font-weight: 600; font-size: 14px; min-height: 44px;
  transition: transform .12s var(--ease), box-shadow .18s var(--ease), background .18s var(--ease);
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn i { font-size: 17px; }
.btn-primary { background: var(--grad-brand); color: #fff; box-shadow: var(--sh-glow); }
.btn-primary:hover { box-shadow: 0 10px 50px rgba(139,92,246,.45); transform: translateY(-1px); }
.btn-lime { background: var(--grad-lime); color: var(--lime-ink); }
.btn-lime:hover { transform: translateY(-1px); }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--border-2); }
.btn-danger { background: transparent; color: var(--danger); border-color: rgba(251,113,133,.4); }
.btn-danger:hover { background: rgba(251,113,133,.12); }
.btn-sm { padding: 7px 13px; min-height: 36px; font-size: 13px; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 22px; box-shadow: var(--sh-2);
}
.card-glass {
  background: linear-gradient(160deg, rgba(255,255,255,.04), rgba(255,255,255,.01));
  backdrop-filter: blur(8px);
}

/* ---------- Stat tiles ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 26px; }
.stat {
  position: relative; overflow: hidden; padding: 20px 22px; border-radius: var(--r-lg);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--sh-2);
}
.stat::after {
  content: ''; position: absolute; inset: -40% -40% auto auto; width: 140px; height: 140px;
  background: var(--accent-fill, var(--grad-brand)); filter: blur(40px); opacity: .25;
}
.stat-ico { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; font-size: 19px; color: #fff; margin-bottom: 14px; }
.stat-val { font-family: 'Space Grotesk'; font-size: 30px; font-weight: 700; letter-spacing: -.03em; }
.stat-label { color: var(--text-dim); font-size: 13px; margin-top: 2px; }

/* accent fills */
.fill-violet { background: var(--grad-brand); }   .ic-violet { background: var(--grad-brand); }
.fill-lime   { background: var(--grad-lime); }     .ic-lime   { background: var(--grad-lime); color: var(--lime-ink)!important; }
.fill-coral  { background: var(--grad-coral); }    .ic-coral  { background: var(--grad-coral); }
.fill-cyan   { background: linear-gradient(135deg,#22d3ee,#0ea5e9); } .ic-cyan { background: linear-gradient(135deg,#22d3ee,#0ea5e9); }
.fill-amber  { background: linear-gradient(135deg,#fbbf24,#f59e0b); } .ic-amber{ background: linear-gradient(135deg,#fbbf24,#f59e0b); }

/* ---------- Badges / pills ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: var(--r-pill);
  font-size: 12px; font-weight: 600; line-height: 1.4; white-space: nowrap;
}
.badge i { font-size: 13px; }
.b-slate  { background: rgba(148,163,184,.16); color: #b8c2d4; }
.b-cyan   { background: rgba(34,211,238,.15);  color: #5fe3f5; }
.b-lime   { background: rgba(190,242,100,.16); color: #c8f57a; }
.b-coral  { background: rgba(251,111,146,.16); color: #fda4bb; }
.b-amber  { background: rgba(251,191,36,.16);  color: #fcd34d; }
.b-violet { background: rgba(139,92,246,.18);  color: #c4b5fd; }
[data-theme="light"] .b-slate { color:#475569 } [data-theme="light"] .b-cyan{color:#0e7490}
[data-theme="light"] .b-lime{color:#3f6212} [data-theme="light"] .b-coral{color:#be123c}
[data-theme="light"] .b-amber{color:#a16207} [data-theme="light"] .b-violet{color:#6d28d9}

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.d-slate{background:var(--slate)} .d-cyan{background:var(--cyan)} .d-lime{background:var(--lime)}
.d-coral{background:var(--coral)} .d-amber{background:var(--amber)} .d-violet{background:var(--violet)}

/* ---------- Progress ---------- */
.bar { height: 9px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 999px; background: var(--grad-brand); transition: width .5s var(--ease); }
.bar.lime > span { background: var(--grad-lime); }

.ring { --p: 0; width: 96px; height: 96px; border-radius: 50%;
  background: conic-gradient(var(--violet) calc(var(--p)*1%), var(--surface-3) 0);
  display: grid; place-items: center; position: relative;
}
.ring::before { content:''; position:absolute; inset:9px; border-radius:50%; background: var(--surface); }
.ring b { position: relative; font-family:'Space Grotesk'; font-size: 22px; }

/* ---------- Project grid ---------- */
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px,1fr)); gap: 18px; }
.proj-card { display: flex; flex-direction: column; gap: 14px; transition: transform .15s var(--ease), border-color .2s var(--ease); }
.proj-card:hover { transform: translateY(-3px); border-color: var(--border-2); }
.proj-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.proj-code { font-size: 11.5px; color: var(--text-mute); letter-spacing: .08em; }
.proj-name { font-size: 18px; margin-top: 2px; }
.proj-meta { display: flex; gap: 14px; flex-wrap: wrap; color: var(--text-dim); font-size: 12.5px; }
.proj-meta span { display: inline-flex; align-items: center; gap: 5px; }

/* ---------- Stage rail ---------- */
.stage-rail { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 22px; }
.stage-pill {
  flex: 1 0 auto; min-width: 150px; padding: 14px 16px; border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--border); position: relative; overflow: hidden;
  transition: border-color .2s var(--ease), transform .12s var(--ease);
}
.stage-pill:hover { border-color: var(--border-2); transform: translateY(-2px); }
.stage-pill.is-current { border-color: transparent; box-shadow: var(--sh-glow); }
.stage-pill.is-current::before { content:''; position:absolute; inset:0; background: var(--grad-brand); opacity:.14; }
.stage-pill .sp-no { font-family:'Space Grotesk'; font-size: 12px; color: var(--text-mute); }
.stage-pill .sp-name { font-weight: 600; font-size: 13.5px; margin: 4px 0 10px; position: relative; }
.stage-pill .sp-pct  { font-family:'Space Grotesk'; font-size: 20px; font-weight: 700; }

/* ---------- Activity board ---------- */
.stage-block { margin-bottom: 16px; border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; background: var(--surface); }
.stage-head {
  display: flex; align-items: center; gap: 14px; padding: 16px 20px; cursor: pointer;
  background: var(--surface-2); user-select: none;
}
.stage-head:hover { background: var(--surface-3); }
.stage-num { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-family:'Space Grotesk'; font-weight: 700; color:#fff; flex-shrink: 0; }
.stage-head h3 { font-size: 16px; }
.stage-head .meta { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.stage-head .chev { transition: transform .25s var(--ease); font-size: 20px; color: var(--text-dim); }
.stage-block.collapsed .chev { transform: rotate(-90deg); }
.stage-block.collapsed .stage-body { display: none; }
.stage-body { padding: 8px 10px 12px; }

.cat-label { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--text-mute); padding: 14px 12px 8px; font-weight: 600; }

.act {
  display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: var(--r-md);
  transition: background .15s var(--ease);
}
.act:hover { background: var(--surface-2); }
.act + .act { border-top: 1px solid var(--border); }
.act.done .act-name { color: var(--text-mute); text-decoration: line-through; }

.check {
  width: 26px; height: 26px; border-radius: 9px; border: 2px solid var(--border-2);
  display: grid; place-items: center; flex-shrink: 0; color: transparent; font-size: 15px;
  transition: all .18s var(--ease); background: transparent;
}
.check:hover { border-color: var(--violet); }
.check.on { background: var(--grad-lime); border-color: transparent; color: var(--lime-ink); }
.check.blocked { background: var(--grad-coral); border-color: transparent; color: #fff; }
.check.in_progress { border-color: var(--cyan); color: var(--cyan); }

.act-name { flex: 1; min-width: 0; font-weight: 500; font-size: 14.5px; }
.act-side { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.status-select {
  appearance: none; background: var(--surface-3); border: 1px solid var(--border); color: var(--text-dim);
  padding: 6px 30px 6px 12px; border-radius: var(--r-pill); font-size: 12.5px; font-weight: 600;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23888' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center;
}
.assignee-select { max-width: 168px; min-width: 124px; }
.assignee-select option[value=""] { color: var(--text-mute); }

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--text-dim); margin-bottom: 7px; }
.input, .select, .textarea {
  width: 100%; padding: 12px 14px; min-height: 46px; border-radius: var(--r-md);
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text); font-size: 14.5px;
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease);
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--violet); box-shadow: 0 0 0 3px rgba(139,92,246,.22);
}
.textarea { min-height: 96px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ---------- Auth ---------- */
.auth-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 410px; }
.auth-logo { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; background: var(--grad-brand); box-shadow: var(--sh-glow); color:#fff; font-size: 28px; margin: 0 auto 18px; }

/* ---------- Misc ---------- */
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.muted { color: var(--text-dim); }
.empty { text-align: center; padding: 60px 20px; color: var(--text-dim); }
.empty i { font-size: 46px; opacity: .4; display: block; margin-bottom: 14px; }
.divider { height: 1px; background: var(--border); margin: 18px 0; }
.tag-input { display:flex; gap:8px; align-items:center; flex-wrap: wrap; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(120%);
  background: var(--surface-3); color: var(--text); border:1px solid var(--border-2);
  padding: 13px 20px; border-radius: var(--r-pill); box-shadow: var(--sh-2); font-weight: 600; font-size: 14px;
  z-index: 1000; transition: transform .35s var(--ease); display:flex; align-items:center; gap:10px;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.ok { border-color: rgba(190,242,100,.5); }

/* ---------- Mobile ---------- */
.menu-toggle { display: none; }
@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; z-index: 90; width: 268px; left: 0; top: 0;
    transform: translateX(-100%); transition: transform .3s var(--ease);
  }
  .sidebar.open { transform: translateX(0); }
  .menu-toggle { display: grid; }
  .scrim { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 80; opacity:0; pointer-events:none; transition: opacity .3s; }
  .scrim.show { opacity: 1; pointer-events: auto; }
  .stat-grid { grid-template-columns: repeat(2,1fr); }
  .form-row { grid-template-columns: 1fr; }
  .main { padding: 20px 18px 50px; }
}
@media (max-width: 560px) {
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .page-title { font-size: 23px; }
  .act-side .assignee { display:none; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
